3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
19 . $SRCDIR/scripts/defines.sh
21 if test $PROXYCACHE = pcacheno; then
22 echo "Proxy cache overlay not available, test skipped"
26 if test $BACKLDAP = "ldapno" ; then
27 echo "LDAP backend not available, test skipped"
31 if test "x$LVL" = "x0" ; then
32 echo "test020 needs a minimal log level; setting to LDAP_DEBUG_NONE..."
36 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
42 # - perform first set of searches at the proxy
43 # - verify cacheability
44 # - perform second set of searches at the proxy
45 # - verify answerability
47 echo "Starting master slapd on TCP/IP port $PORT1..."
48 . $CONFFILTER < $CACHEMASTERCONF > $CONF1
49 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
51 if test $WAIT != 0 ; then
59 echo "Using ldapsearch to check that master slapd is running..."
60 for i in 0 1 2 3 4 5; do
61 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
62 'objectclass=*' > /dev/null 2>&1
64 if test $RC = 0 ; then
67 echo "Waiting 5 seconds for slapd to start..."
71 if test $RC != 0 ; then
72 echo "ldapsearch failed ($RC)!"
73 test $KILLSERVERS != no && kill -HUP $KILLPIDS
77 echo "Using ldapadd to populate the master directory..."
78 $LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
79 $LDIFORDERED > /dev/null 2>&1
81 if test $RC != 0 ; then
82 echo "ldapadd failed ($RC)!"
83 test $KILLSERVERS != no && kill -HUP $KILLPIDS
87 echo "Starting proxy cache on TCP/IP port $PORT2..."
88 . $CONFFILTER < $PROXYCACHECONF > $CONF2
89 $SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 &
91 if test $WAIT != 0 ; then
92 echo CACHEPID $CACHEPID
95 KILLPIDS="$KILLPIDS $CACHEPID"
99 echo "Using ldapsearch to check that proxy slapd is running..."
100 for i in 0 1 2 3 4 5; do
101 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
102 'objectclass=*' > /dev/null 2>&1
104 if test $RC = 0 ; then
107 echo "Waiting 5 seconds for slapd to start..."
111 if test $RC != 0 ; then
112 echo "ldapsearch failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
117 cat /dev/null > $SLAVEOUT
119 echo "Making queries on the proxy cache..."
120 echo "Query 1: filter:(sn=Jon) attrs: all"
121 echo "# Query 1: filter:(sn=Jon) attrs: all" >> $SLAVEOUT
122 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
123 'sn=Jon' >> $SLAVEOUT 2>&1
125 if test $RC != 0 ; then
126 echo "ldapsearch failed ($RC)!"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid"
132 echo "# Query 2: filter:(|(cn=*Jon*)(sn=Jon*)) attrs:cn sn title uid" >> $SLAVEOUT
133 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
134 '(|(cn=*Jon*)(sn=Jon*))' cn sn title uid >> $SLAVEOUT 2>&1
136 if test $RC != 0 ; then
137 echo "ldapsearch failed ($RC)!"
138 test $KILLSERVERS != no && kill -HUP $KILLPIDS
142 echo "Query 3: filter:(sn=Smith*) attrs:cn sn title uid"
143 echo "# Query 3: filter:(sn=Smith*) attrs:cn sn title uid" >> $SLAVEOUT
144 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
145 'sn=Smith*' cn sn title uid >> $SLAVEOUT 2>&1
147 if test $RC != 0 ; then
148 echo "ldapsearch failed ($RC)!"
149 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 echo "Query 4: filter:(sn=Doe*) attrs:cn sn title uid"
154 echo "# Query 4: filter:(sn=Doe*) attrs:cn sn title uid" >> $SLAVEOUT
155 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
156 'sn=Doe' cn sn title uid >> $SLAVEOUT 2>&1
158 if test $RC != 0 ; then
159 echo "ldapsearch failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 echo "Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
165 echo "# Query 5: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid" >> $SLAVEOUT
166 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
167 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
169 if test $RC != 0 ; then
170 echo "ldapsearch failed ($RC)!"
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
175 echo "Query 6: filter:(mail=*@mail.alumni.example.com) cn sn title uid"
176 echo "# Query 6: filter:(mail=*@mail.alumni.example.com) cn sn title uid" >> $SLAVEOUT
177 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
178 'mail=*@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
180 if test $RC != 0 ; then
181 echo "ldapsearch failed ($RC)!"
182 test $KILLSERVERS != no && kill -HUP $KILLPIDS
186 echo "Query 7: filter:(mail=*) cn sn title uid"
187 echo "# Query 7: filter:(mail=*) cn sn title uid" >> $SLAVEOUT
188 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
189 'mail=*' cn sn title uid >> $SLAVEOUT 2>&1
191 if test $RC != 0 ; then
192 echo "ldapsearch failed ($RC)!"
193 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 # queries 2-6 are cacheable
199 grep CACHEABLE $LOG2 | awk '{
201 printf "Query %d not cacheable\n",NR
203 printf "Query %d cacheable\n",NR
205 CACHED=`grep CACHEABLE $LOG2 | awk '{
212 if test "$CACHEABILITY" = "$CACHED" ; then
213 echo "Successfully verified cacheability"
215 echo "Error in verifying cacheability"
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 echo "Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid"
221 echo "# Query 8: filter:(|(cn=*Jones)(sn=Jones)) attrs:cn sn title uid" >> $SLAVEOUT
222 $LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
223 '(|(cn=*Jones)(sn=Jones))' cn sn title uid >> $SLAVEOUT 2>&1
225 if test $RC != 0 ; then
226 echo "ldapsearch failed ($RC)!"
227 test $KILLSERVERS != no && kill -HUP $KILLPIDS
231 echo "Query 9: filter:(sn=Smith) attrs:cn sn title uid"
232 echo "# Query 9: filter:(sn=Smith) attrs:cn sn title uid" >> $SLAVEOUT
233 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
234 'sn=Smith' cn sn title uid >> $SLAVEOUT 2>&1
236 if test $RC != 0 ; then
237 echo "ldapsearch failed ($RC)!"
238 test $KILLSERVERS != no && kill -HUP $KILLPIDS
242 echo "Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid"
243 echo "# Query 10: filter:(uid=bjorn) attrs:mail postaladdress telephonenumber cn uid" >> $SLAVEOUT
244 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
245 'uid=bjorn' mail postaladdress telephonenumber cn uid >> $SLAVEOUT 2>&1
247 if test $RC != 0 ; then
248 echo "ldapsearch failed ($RC)!"
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
253 echo "Query 11: filter:(mail=jaj@mail.alumni.example.com) cn sn title uid"
254 echo "# Query 11: filter:(mail=jaj@mail.alumni.example.com) cn sn title uid" >> $SLAVEOUT
255 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
256 'mail=jaj@mail.alumni.example.com' cn sn title uid >> $SLAVEOUT 2>&1
259 if test $RC != 0 ; then
260 echo "ldapsearch failed ($RC)!"
261 test $KILLSERVERS != no && kill -HUP $KILLPIDS
265 #queries 8-11 are answerable
267 grep ANSWERABLE $LOG2 | awk '{
270 printf "Query %d not answerable\n",NR
272 printf "Query %d answerable\n",NR
275 ANSWERED=`grep ANSWERABLE $LOG2 | awk '{
284 test $KILLSERVERS != no && kill -HUP $KILLPIDS
286 if test "$ANSWERABILITY" = "$ANSWERED" ; then
287 echo "Successfully verified answerability"
289 echo "Error in verifying answerability"
293 echo "Filtering ldapsearch results..."
294 . $LDIFFILTER < $SLAVEOUT > $SEARCHFLT
295 echo "Comparing filter output..."
296 $CMP $SEARCHFLT $PROXYCACHEOUT > $CMPOUT
298 if test $? != 0 ; then
299 echo "Comparison failed"
303 echo ">>>>> Test succeeded"