Debian Codegraph @

tests/scripts/test020-proxycache

raw
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2024 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 PCACHETTL=${PCACHETTL-"1m"}
17 PCACHENTTL=${PCACHENTTL-"1m"}
18 PCACHESTTL=${PCACHESTTL-"1m"}
19 PCACHE_ENTRY_LIMIT=${PCACHE_ENTRY_LIMIT-"6"}
20 PCACHE_CCPERIOD=${PCACHE_CCPERIOD-"2"}
21 PCACHETTR=${PCACHETTR-"2"}
22 PCACHEBTTR=${PCACHEBTTR-"5"}
23
24 . $SRCDIR/scripts/defines.sh
25
26 if test $PROXYCACHE = pcacheno; then
27 echo "Proxy cache overlay not available, test skipped"
28 exit 0
29 fi
30
31 if test $BACKLDAP = "ldapno" ; then
32 echo "LDAP backend not available, test skipped"
33 exit 0
34 fi
35
36 if test $BACKEND = ldif ; then
37 # The (mail=example.com*) queries hit a sizelimit, so which
38 # entry is returned depends on the ordering in the backend.
39 echo "Test does not support $BACKEND backend, test skipped"
40 exit 0
41 fi
42
43 if test $BACKEND = wt ; then
44 echo "Test does not support $BACKEND backend, test skipped"
45 exit 0
46 fi
47
48 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
49
50 # Test proxy caching:
51 # - start provider
52 # - start proxy cache
53 # - populate provider
54 # - perform first set of searches at the proxy
55 # - verify cacheability
56 # - perform second set of searches at the proxy
57 # - verify answerability
58
59 echo "Starting provider slapd on TCP/IP port $PORT1..."
60 . $CONFFILTER < $CACHEPROVIDERCONF > $CONF1
61 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
62 PID=$!
63 if test $WAIT != 0 ; then
64 echo PID $PID
65 read foo
66 fi
67 KILLPIDS="$PID"
68
69 sleep 1
70
71 echo "Using ldapsearch to check that provider slapd is running..."
72 for i in 0 1 2 3 4 5; do
73 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
74 'objectclass=*' > /dev/null 2>&1
75 RC=$?
76 if test $RC = 0 ; then
77 break
78 fi
79 echo "Waiting 5 seconds for slapd to start..."
80 sleep 5
81 done
82
83 if test $RC != 0 ; then
84 echo "ldapsearch failed ($RC)!"
85 test $KILLSERVERS != no && kill -HUP $KILLPIDS
86 exit $RC
87 fi
88
89 echo "Using ldapadd to populate the provider directory..."
90 $LDAPADD -x -D "$MANAGERDN" -H $URI1 -w $PASSWD < \
91 $LDIFORDERED > /dev/null 2>&1
92 RC=$?
93 if test $RC != 0 ; then
94 echo "ldapadd failed ($RC)!"
95 test $KILLSERVERS != no && kill -HUP $KILLPIDS
96 exit $RC
97 fi
98
99 echo "Starting proxy cache on TCP/IP port $PORT2..."
100 . $CONFFILTER < $PROXYCACHECONF | sed \
101 -e "s/@TTL@/${PCACHETTL}/" \
102 -e "s/@NTTL@/${PCACHENTTL}/" \
103 -e "s/@STTL@/${PCACHENTTL}/" \
104 -e "s/@TTR@/${PCACHETTR}/" \
105 -e "s/@ENTRY_LIMIT@/${PCACHE_ENTRY_LIMIT}/" \
106 -e "s/@CCPERIOD@/${PCACHE_CCPERIOD}/" \
107 -e "s/@BTTR@/${PCACHEBTTR}/" \
108 > $CONF2
109
110 $SLAPD -f $CONF2 -h $URI2 -d $LVL -d pcache > $LOG2 2>&1 &
111 CACHEPID=$!
112 if test $WAIT != 0 ; then
113 echo CACHEPID $CACHEPID
114 read foo
115 fi
116 KILLPIDS="$KILLPIDS $CACHEPID"
117
118 sleep 1
119
120 echo "Using ldapsearch to check that proxy slapd is running..."
121 for i in 0 1 2 3 4 5; do
122 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
123 'objectclass=*' > /dev/null 2>&1
124 RC=$?
125 if test $RC = 0 ; then
126 break
127 fi
128 echo "Waiting 5 seconds for slapd to start..."
129 sleep 5
130 done
131
132 if test $RC != 0 ; then
133 echo "ldapsearch failed ($RC)!"
134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
135 exit $RC
136 fi
137
138 cat /dev/null > $SEARCHOUT
139
140 echo "Making queries on the proxy cache..."
141 CNT=0
142
143 CNT=`expr $CNT + 1`
144 FILTER="(sn=Jon)"
145 echo "Query $CNT: filter:$FILTER attrs:all (expect nothing)"
146 echo "# Query $CNT: filter:$FILTER attrs:all (expect nothing)" >> $SEARCHOUT
147 $LDAPSEARCH -x -S "" -b "$BASEDN" -H $URI2 \
148 "$FILTER" >> $SEARCHOUT 2>> $TESTOUT
149 RC=$?
150 if test $RC != 0 ; then
151 echo "ldapsearch failed ($RC)!"
152 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 exit $RC
154 fi
155
156 # ITS#4491, if debug messages are unavailable, we can't verify the tests.
157 grep "query template" $LOG2 > /dev/null
158 RC=$?
159 if test $RC != 0 ; then
160 echo "Debug messages unavailable, remaining test skipped..."
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
162 exit 0
163 fi
164
165 CNT=`expr $CNT + 1`
166 FILTER="(|(cn=*Jon*)(sn=Jon*))"
167 ATTRS="cn sn title uid"
168 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
169 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
170 $LDAPSEARCH -x -S "" -b "$BASEDN" -H $URI2 \
171 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
172 RC=$?
173 if test $RC != 0 ; then
174 echo "ldapsearch failed ($RC)!"
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
176 exit $RC
177 fi
178
179 CNT=`expr $CNT + 1`
180 FILTER="(sn=Smith*)"
181 ATTRS="cn sn uid"
182 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
183 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
184 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
185 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
186 RC=$?
187 if test $RC != 0 ; then
188 echo "ldapsearch failed ($RC)!"
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
190 exit $RC
191 fi
192
193 CNT=`expr $CNT + 1`
194 FILTER="(sn=Doe*)"
195 ATTRS="cn sn title uid"
196 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
197 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
198 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
199 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
200 RC=$?
201 if test $RC != 0 ; then
202 echo "ldapsearch failed ($RC)!"
203 test $KILLSERVERS != no && kill -HUP $KILLPIDS
204 exit $RC
205 fi
206
207 CNT=`expr $CNT + 1`
208 FILTER="(uid=johnd)"
209 ATTRS="mail postaladdress telephonenumber cn uid"
210 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
211 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
212 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
213 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
214 RC=$?
215 if test $RC != 0 ; then
216 echo "ldapsearch failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 exit $RC
219 fi
220
221 CNT=`expr $CNT + 1`
222 FILTER="(mail=*@mail.alumni.example.com)"
223 ATTRS="cn sn title uid"
224 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
225 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
226 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
227 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
228 RC=$?
229 if test $RC != 0 ; then
230 echo "ldapsearch failed ($RC)!"
231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 exit $RC
233 fi
234
235 CNT=`expr $CNT + 1`
236 FILTER="(mail=*)"
237 ATTRS="cn sn title uid"
238 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
239 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
240 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
241 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
242 RC=$?
243 if test $RC != 0 ; then
244 echo "ldapsearch failed ($RC)!"
245 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 exit $RC
247 fi
248
249 CNT=`expr $CNT + 1`
250 FILTER="(mail=*example.com)"
251 ATTRS="cn sn title uid"
252 USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
253 UPASSWD="bjorn"
254 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
255 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
256 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
257 -D "$USERDN" -w "$UPASSWD" \
258 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
259 RC=$?
260 case $RC in
261 0)
262 echo "ldapsearch should have failed!"
263 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 exit 1
265 ;;
266 4)
267 echo "ldapsearch failed ($RC)"
268 ;;
269 *)
270 echo "ldapsearch failed ($RC)!"
271 test $KILLSERVERS != no && kill -HUP $KILLPIDS
272 exit $RC
273 ;;
274 esac
275
276 CNT=`expr $CNT + 1`
277 FILTER="(uid=b*)"
278 ATTRS="mail"
279 USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
280 UPASSWD="bjorn"
281 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
282 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
283 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
284 -D "$USERDN" -w "$UPASSWD" \
285 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
286 RC=$?
287 case $RC in
288 0)
289 echo "ldapsearch should have failed!"
290 test $KILLSERVERS != no && kill -HUP $KILLPIDS
291 exit 1
292 ;;
293 4)
294 echo "ldapsearch failed ($RC)"
295 ;;
296 *)
297 echo "ldapsearch failed ($RC)!"
298 test $KILLSERVERS != no && kill -HUP $KILLPIDS
299 exit $RC
300 ;;
301 esac
302
303 CNT=`expr $CNT + 1`
304 FILTER="(|(cn=All Staff)(sn=All Staff))"
305 ATTRS="sn cn title uid undefinedAttr"
306 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
307 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
308 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
309 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
310 RC=$?
311 if test $RC != 0 ; then
312 echo "ldapsearch failed ($RC)!"
313 test $KILLSERVERS != no && kill -HUP $KILLPIDS
314 exit $RC
315 fi
316
317 FIRST=$CNT
318
319 # queries 2-6,8-10 are cacheable
320 CACHEABILITY=0111110111
321 grep CACHEABLE $LOG2 | awk '
322 /NOT CACHEABLE/{printf "Query %d not cacheable\n",NR}
323 /QUERY CACHEABLE/{printf "Query %d cacheable\n",NR}'
324 CACHED=`grep CACHEABLE $LOG2 | awk '
325 /NOT CACHEABLE/{printf "0"}
326 /QUERY CACHEABLE/{printf "1"}'`
327
328 if test "$CACHEABILITY" = "$CACHED" ; then
329 echo "Successfully verified cacheability"
330 else
331 echo "Error in verifying cacheability"
332 echo "$CACHED"
333 echo "$CACHEABILITY"
334 test $KILLSERVERS != no && kill -HUP $KILLPIDS
335 exit 1
336 fi
337
338 CNT=`expr $CNT + 1`
339 FILTER="(|(cn=*Jones)(sn=Jones))"
340 ATTRS="cn sn title uid"
341 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
342 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
343 $LDAPSEARCH -x -S "" -b "$BASEDN" -H $URI2 \
344 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
345 RC=$?
346 if test $RC != 0 ; then
347 echo "ldapsearch failed ($RC)!"
348 test $KILLSERVERS != no && kill -HUP $KILLPIDS
349 exit $RC
350 fi
351
352 CNT=`expr $CNT + 1`
353 FILTER="(sn=Smith)"
354 ATTRS="cn sn title uid"
355 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
356 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
357 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
358 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
359 RC=$?
360 if test $RC != 0 ; then
361 echo "ldapsearch failed ($RC)!"
362 test $KILLSERVERS != no && kill -HUP $KILLPIDS
363 exit $RC
364 fi
365
366 CNT=`expr $CNT + 1`
367 FILTER="(uid=bjorn)"
368 ATTRS="mail postaladdress telephonenumber cn uid"
369 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
370 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
371 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
372 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
373 RC=$?
374 if test $RC != 0 ; then
375 echo "ldapsearch failed ($RC)!"
376 test $KILLSERVERS != no && kill -HUP $KILLPIDS
377 exit $RC
378 fi
379
380 CNT=`expr $CNT + 1`
381 FILTER="([email protected])"
382 ATTRS="cn sn title uid"
383 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
384 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
385 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
386 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
387 RC=$?
388
389 if test $RC != 0 ; then
390 echo "ldapsearch failed ($RC)!"
391 test $KILLSERVERS != no && kill -HUP $KILLPIDS
392 exit $RC
393 fi
394
395 CNT=`expr $CNT + 1`
396 FILTER="(mail=*example.com)"
397 ATTRS="cn sn title uid"
398 USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
399 UPASSWD="bjorn"
400 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
401 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
402 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
403 -D "$USERDN" -w "$UPASSWD" \
404 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
405 RC=$?
406 case $RC in
407 0)
408 echo "ldapsearch should have failed!"
409 test $KILLSERVERS != no && kill -HUP $KILLPIDS
410 exit 1
411 ;;
412 4)
413 echo "ldapsearch failed ($RC)"
414 ;;
415 *)
416 echo "ldapsearch failed ($RC)!"
417 test $KILLSERVERS != no && kill -HUP $KILLPIDS
418 exit $RC
419 ;;
420 esac
421
422 CNT=`expr $CNT + 1`
423 FILTER="(uid=b*)"
424 ATTRS="mail"
425 USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
426 UPASSWD="bjorn"
427 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
428 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
429 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
430 -D "$USERDN" -w "$UPASSWD" \
431 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
432 RC=$?
433 case $RC in
434 0)
435 echo "ldapsearch should have failed!"
436 test $KILLSERVERS != no && kill -HUP $KILLPIDS
437 exit 1
438 ;;
439 4)
440 echo "ldapsearch failed ($RC)"
441 ;;
442 *)
443 echo "ldapsearch failed ($RC)!"
444 test $KILLSERVERS != no && kill -HUP $KILLPIDS
445 exit $RC
446 ;;
447 esac
448
449 CNT=`expr $CNT + 1`
450 FILTER="(|(cn=All Staff)(sn=All Staff))"
451 ATTRS="sn cn title uid undefinedAttr"
452 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
453 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
454 $LDAPSEARCH -S "" -b "$BASEDN" -H $URI2 \
455 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
456 RC=$?
457 if test $RC != 0 ; then
458 echo "ldapsearch failed ($RC)!"
459 test $KILLSERVERS != no && kill -HUP $KILLPIDS
460 exit $RC
461 fi
462
463 #queries 11-13,16-17 are answerable, 14-15 are not
464 #actually, 14 would be answerable, but since 8 made mail=*example.com
465 #not answerable because of sizelimit, queries contained in it are no longer
466 #answerable as well
467 ANSWERABILITY=1110011
468 grep ANSWERABLE $LOG2 | awk "BEGIN {FIRST=$FIRST}"'
469 /NOT ANSWERABLE/{if (NR > FIRST) printf "Query %d not answerable\n",NR}
470 /QUERY ANSWERABLE/{if (NR > FIRST) printf "Query %d answerable\n",NR}'
471 ANSWERED=`grep ANSWERABLE $LOG2 | awk "BEGIN {FIRST=$FIRST}"'
472 /NOT ANSWERABLE/{if (NR > FIRST) printf "0"}
473 /QUERY ANSWERABLE/{if (NR > FIRST) printf "1"}'`
474
475 if test "$ANSWERABILITY" = "$ANSWERED" ; then
476 echo "Successfully verified answerability"
477 else
478 echo "Error in verifying answerability"
479 test $KILLSERVERS != no && kill -HUP $KILLPIDS
480 exit 1
481 fi
482
483 echo "Filtering ldapsearch results..."
484 $LDIFFILTER -s ldif=a < $SEARCHOUT > $SEARCHFLT
485 echo "Filtering original ldif..."
486 $LDIFFILTER -s ldif=a < $PROXYCACHEOUT > $LDIFFLT
487 echo "Comparing filter output..."
488 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
489
490 if test $? != 0 ; then
491 echo "Comparison failed"
492 test $KILLSERVERS != no && kill -HUP $KILLPIDS
493 exit 1
494 fi
495
496 echo ""
497 echo "Testing cache refresh"
498
499 CNT=`expr $CNT + 1`
500 FILTER="(&(objectclass=person)(uid=dots))"
501 ATTRS="cn mail telephonenumber"
502 echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
503 echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
504 $LDAPSEARCH -x -S "" -b "$BASEDN" -H $URI2 \
505 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
506 RC=$?
507 if test $RC != 0 ; then
508 echo "ldapsearch failed ($RC)!"
509 test $KILLSERVERS != no && kill -HUP $KILLPIDS
510 exit $RC
511 fi
512
513 $LDAPMODIFY -x -D "$MANAGERDN" -H $URI1 -w $PASSWD <<EOF \
514 > /dev/null 2>&1
515 dn: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
516 changetype: modify
517 replace: mail
518 mail: [email protected]
519 -
520
521 EOF
522 RC=$?
523 if test $RC != 0 ; then
524 echo "ldapmodify failed ($RC)!"
525 test $KILLSERVERS != no && kill -HUP $KILLPIDS
526 exit $RC
527 fi
528
529 SLEEP=`expr $PCACHETTR + $PCACHE_CCPERIOD + 1`
530 echo "Waiting $SLEEP seconds for cache to refresh"
531
532 sleep $SLEEP
533
534 echo "Checking entry again"
535 $LDAPSEARCH -x -S "" -b "$BASEDN" -H $URI2 \
536 "$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
537 RC=$?
538 if test $RC != 0 ; then
539 echo "ldapsearch failed ($RC)!"
540 test $KILLSERVERS != no && kill -HUP $KILLPIDS
541 exit $RC
542 fi
543
544 grep "^mail: dots@admin" $SEARCHOUT > /dev/null
545 RC=$?
546 if test $RC != 0 ; then
547 echo "Refresh failed"
548 test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
549 exit 1
550 fi
551
552 echo ""
553 echo "Testing Bind caching"
554
555 CNT=`expr $CNT + 1`
556 USERDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com"
557 UPASSWD="jaj"
558 echo "Query $CNT: $USERDN"
559 echo "# Query $CNT: $USERDN" >> $SEARCHOUT
560 $LDAPSEARCH -S "" -b "" -s base -H $URI2 \
561 -D "$USERDN" -w "$UPASSWD" >> $SEARCHOUT 2>> $TESTOUT
562 RC=$?
563 if test $RC != 0 ; then
564 echo "ldapsearch failed ($RC)!"
565 test $KILLSERVERS != no && kill -HUP $KILLPIDS
566 exit $RC
567 fi
568
569 grep "CACHING BIND" $LOG2 > /dev/null
570 RC=$?
571 if test $RC != 0 ; then
572 echo "Refresh failed"
573 test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
574 exit 1
575 fi
576
577 CNT=`expr $CNT + 1`
578 USERDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com"
579 UPASSWD="jaj"
580 echo "Query $CNT: (Bind should be cached)"
581 echo "# Query $CNT: (Bind should be cached)" >> $SEARCHOUT
582 $LDAPSEARCH -S "" -b "" -s base -H $URI2 \
583 -D "$USERDN" -w "$UPASSWD" >> $SEARCHOUT 2>> $TESTOUT
584 RC=$?
585 if test $RC != 0 ; then
586 echo "ldapsearch failed ($RC)!"
587 test $KILLSERVERS != no && kill -HUP $KILLPIDS
588 exit $RC
589 fi
590
591 grep "CACHED BIND" $LOG2 > /dev/null
592 RC=$?
593 if test $RC != 0 ; then
594 echo "Refresh failed"
595 test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
596 exit 1
597 fi
598
599 echo ""
600 echo "Testing pwdModify"
601 $LDAPPASSWD -H $URI2 \
602 -D "$MANAGERDN" -w "$PASSWD" -s newpw "$USERDN" >> $TESTOUT 2>&1
603 RC=$?
604 if test $RC != 0 ; then
605 echo "ldappasswd failed ($RC)!"
606 test $KILLSERVERS != no && kill -HUP $KILLPIDS
607 exit $RC
608 fi
609
610 RC=`grep "CACH.* BIND" $LOG2 | wc -l`
611 if test $RC != 3 ; then
612 echo "ldappasswd didn't update the cache"
613 test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
614 exit 1
615 fi
616
617 CNT=`expr $CNT + 1`
618 USERDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com"
619 UPASSWD=newpw
620 echo "Query $CNT: (Bind should be cached)"
621 echo "# Query $CNT: (Bind should be cached)" >> $SEARCHOUT
622 $LDAPSEARCH -S "" -b "" -s base -H $URI2 \
623 -D "$USERDN" -w "$UPASSWD" >> $SEARCHOUT 2>> $TESTOUT
624 RC=$?
625 if test $RC != 0 ; then
626 echo "ldapsearch failed ($RC)!"
627 test $KILLSERVERS != no && kill -HUP $KILLPIDS
628 exit $RC
629 fi
630
631 RC=`grep "CACH.* BIND" $LOG2 | wc -l`
632 if test $RC != 4 ; then
633 echo "Bind wasn't answered from cache"
634 test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
635 exit 1
636 fi
637 test $KILLSERVERS != no && kill -HUP $KILLPIDS
638
639 echo ">>>>> Test succeeded"
640
641 test $KILLSERVERS != no && wait
642
643 exit 0