3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-2007 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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 PERSONAL="(objectClass=inetOrgPerson)"
21 FAILURE="additional info:"
23 if test $TRANSLUCENT = translucentno ; then
24 echo "Translucent Proxy overlay not available, test skipped"
28 if test $AC_ldap = ldapno ; then
29 echo "Translucent Proxy overlay requires back-ldap backend, test skipped"
34 mkdir -p $TESTDIR $DBDIR1
36 $SLAPPASSWD -g -n >$CONFIGPWF
37 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
39 if test $MONITORDB != no ; then
45 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTREMOTECONF > $CONF1
46 echo "Running slapadd to build remote slapd database..."
47 $SLAPADD -f $CONF1 -l $LDIFTRANSLUCENTCONFIG
49 if test $RC != 0 ; then
50 echo "slapadd failed ($RC)!"
54 echo "Starting remote slapd on TCP/IP port $PORT1..."
55 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
57 if test $WAIT != 0 ; then
66 for i in 0 1 2 3 4 5; do
67 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
68 'objectclass=*' > /dev/null 2>&1
70 if test $RC = 0 ; then
73 echo "Waiting 5 seconds for remote slapd to start..."
77 if test $RC != 0 ; then
78 echo "ldapsearch failed ($RC)!"
79 test $KILLSERVERS != no && kill -HUP $KILLPIDS
86 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF > $CONF2
88 echo "Starting local slapd on TCP/IP port $PORT2..."
89 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
91 if test $WAIT != 0 ; then
96 KILLPIDS="$LOCALPID $REMOTEPID"
100 for i in 0 1 2 3 4 5; do
101 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
102 'objectclass=*' > /dev/null 2>&1
104 if test $RC = 0 ; then
107 echo "Waiting 5 seconds for local slapd to start..."
111 if test $RC != 0 ; then
112 echo "ldapsearch failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
117 echo "Testing slapd Translucent Proxy operations..."
119 echo "Testing search: no remote data defined..."
121 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" >$SEARCHOUT 2>&1
124 if test $RC != 0 ; then
125 echo "ldapsearch failed ($RC)!"
126 test $KILLSERVERS != no && kill -HUP $KILLPIDS
130 if test -s $SEARCHOUT; then
131 echo "ldapsearch should have returned no records!"
132 test $KILLSERVERS != no && kill -HUP $KILLPIDS
136 echo "Populating remote database..."
138 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI1 \
139 -w $PASSWD < $LDIFTRANSLUCENTDATA > $NOWHERE 2>&1
142 if test $RC != 0 ; then
143 echo "ldapadd failed ($RC)!"
144 test $KILLSERVERS != no && kill -HUP $KILLPIDS
148 echo "Testing search: remote database via local slapd..."
150 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
153 if test $RC != 0 ; then
154 echo "ldapsearch failed ($RC)!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
160 . $LDIFFILTER < $LDIFTRANSLUCENTDATA > $LDIFFLT
161 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
163 if test $? != 0 ; then
164 echo "Comparison failed -- corruption from remote to local!"
165 test $KILLSERVERS != no && kill -HUP $KILLPIDS
169 echo "Testing add: prohibited local record..."
171 $LDAPADD -D "$TRANSLUCENTDN" -H $URI2 \
172 -w $TRANSLUCENTPASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
175 if test $RC != 50 ; then
176 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
177 grep "$FAILURE" $TESTOUT
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
182 echo "Testing add: valid local record, no_glue..."
184 $LDAPADD -v -v -v -D "$TRANSLUCENTROOT" -H $URI2 \
185 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
188 if test $RC != 32 ; then
189 echo "ldapadd failed ($RC), expected NO SUCH OBJECT!"
190 grep "$FAILURE" $TESTOUT
191 test $KILLSERVERS != no && kill -HUP $KILLPIDS
195 echo "Testing modrdn: valid local record, no_glue..."
197 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
198 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
201 if test $RC != 32 ; then
202 echo "ldapmodrdn failed ($RC), expected NO SUCH OBJECT!"
203 grep "$FAILURE" $TESTOUT
204 test $KILLSERVERS != no && kill -HUP $KILLPIDS
208 echo "Dynamically configuring local slapd without translucent_no_glue..."
210 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
211 dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
213 replace: olcTranslucentNoGlue
214 olcTranslucentNoGlue: FALSE
217 if test $RC != 0 ; then
218 echo "ldapmodify of dynamic config failed ($RC)"
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 echo "Testing add: valid local record..."
225 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI2 \
226 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
229 if test $RC != 0 ; then
230 echo "ldapadd failed ($RC)!"
231 grep "$FAILURE" $TESTOUT
232 test $KILLSERVERS != no && kill -HUP $KILLPIDS
236 echo "Testing search: data merging..."
238 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
241 if test $RC != 0 ; then
242 echo "ldapsearch failed ($RC)!"
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
247 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
248 $CMP $SEARCHFLT $LDIFTRANSLUCENTMERGED > $CMPOUT
250 if test $? != 0 ; then
251 echo "Comparison failed -- local data failed to merge with remote!"
252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
256 echo "Testing compare: valid local..."
258 $LDAPCOMPARE -z -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
259 "uid=danger,ou=users,o=translucent" "carLicense:LIVID"
262 if test $RC != 6 ; then
263 echo "ldapcompare failed ($RC), expected TRUE!"
264 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 echo "Testing compare: valid remote..."
270 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
271 "uid=binder,o=translucent" "businessCategory:binder-test-user"
274 if test $RC != 6 ; then
275 echo "ldapcompare failed ($RC), expected TRUE!"
276 test $KILLSERVERS != no && kill -HUP $KILLPIDS
280 echo "Testing compare: bogus local..."
282 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
283 "uid=danger,ou=users,o=translucent" "businessCategory:invalid-test-value"
286 if test $RC != 5 ; then
287 echo "ldapcompare failed ($RC), expected FALSE!"
288 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 echo "Testing compare: bogus remote..."
294 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
295 "uid=binder,o=translucent" "businessCategory:invalid-test-value"
298 if test $RC != 5 ; then
299 echo "ldapcompare failed ($RC), expected FALSE!"
300 test $KILLSERVERS != no && kill -HUP $KILLPIDS
304 echo "Testing modify: nonexistent record..."
306 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
307 $TESTOUT 2>&1 << EOF_MOD
309 dn: uid=bogus,ou=users,o=translucent
316 if test $RC != 32 ; then
317 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
318 grep "$FAILURE" $TESTOUT
319 test $KILLSERVERS != no && kill -HUP $KILLPIDS
323 echo "Testing modify: valid local record, nonexistent attribute..."
325 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
326 $TESTOUT 2>&1 << EOF_MOD1
328 dn: uid=danger,ou=users,o=translucent
335 if test $RC != 0 ; then
336 echo "ldapmodify failed ($RC)!"
337 grep "$FAILURE" $TESTOUT
338 test $KILLSERVERS != no && kill -HUP $KILLPIDS
342 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" > $SEARCHOUT 2>&1
345 if test $RC != 0 ; then
346 echo "ldapsearch failed ($RC)!"
347 test $KILLSERVERS != no && kill -HUP $KILLPIDS
351 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
352 if test "$ATTR" != "roomNumber: 9N-21" ; then
353 echo "modification failed!"
354 test $KILLSERVERS != no && kill -HUP $KILLPIDS
358 echo "Testing search: specific nonexistent remote attribute..."
360 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" roomNumber > $SEARCHOUT 2>&1
363 if test $RC != 0 ; then
364 echo "ldapsearch failed ($RC)!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
369 echo "Testing modify: nonexistent local record, nonexistent attribute..."
371 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
372 $TESTOUT 2>&1 << EOF_MOD2
374 dn: uid=fred,ou=users,o=translucent
381 if test $RC != 0 ; then
382 echo "ldapmodify failed ($RC)!"
383 grep "$FAILURE" $TESTOUT
384 test $KILLSERVERS != no && kill -HUP $KILLPIDS
388 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
391 if test $RC != 0 ; then
392 echo "ldapsearch failed ($RC)!"
393 test $KILLSERVERS != no && kill -HUP $KILLPIDS
397 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
398 if test "$ATTR" != "roomNumber: 31J-2112" ; then
399 echo "modification failed!"
400 test $KILLSERVERS != no && kill -HUP $KILLPIDS
404 echo "Testing modify: valid remote record, nonexistent attribute..."
406 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
407 $TESTOUT 2>&1 << EOF_MOD9
409 dn: uid=fred,ou=users,o=translucent
411 delete: preferredLanguage
415 if test $RC != 16 ; then
416 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
417 grep "$FAILURE" $TESTOUT
418 test $KILLSERVERS != no && kill -HUP $KILLPIDS
422 echo "Testing delete: valid local record, nonexistent attribute..."
424 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
425 $TESTOUT 2>&1 << EOF_MOD4
427 dn: uid=fred,ou=users,o=translucent
433 if test $RC != 0 ; then
434 echo "ldapmodify failed ($RC)!"
435 grep "$FAILURE" $TESTOUT
436 test $KILLSERVERS != no && kill -HUP $KILLPIDS
440 echo "Testing modrdn: prohibited local record..."
442 $LDAPMODRDN -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
443 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
446 if test $RC != 50 ; then
447 echo "ldapmodrdn failed ($RC), expected INSUFFICIENT ACCESS!"
448 grep "$FAILURE" $TESTOUT
449 test $KILLSERVERS != no && kill -HUP $KILLPIDS
453 echo "Testing modrdn: valid local record..."
455 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
456 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
459 if test $RC != 0 ; then
460 echo "ldapmodrdn failed ($RC)!"
461 grep "$FAILURE" $TESTOUT
462 test $KILLSERVERS != no && kill -HUP $KILLPIDS
466 echo "Testing delete: prohibited local record..."
468 $LDAPMODIFY -v -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
469 $TESTOUT 2>&1 << EOF_DEL2
471 dn: uid=someguy,ou=users,o=translucent
476 if test $RC != 50 ; then
477 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
478 grep "$FAILURE" $TESTOUT
479 test $KILLSERVERS != no && kill -HUP $KILLPIDS
483 echo "Testing delete: valid local record..."
485 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
486 $TESTOUT 2>&1 << EOF_DEL3
488 dn: uid=someguy,ou=users,o=translucent
493 if test $RC != 0 ; then
494 echo "ldapmodify failed ($RC)!"
495 grep "$FAILURE" $TESTOUT
496 test $KILLSERVERS != no && kill -HUP $KILLPIDS
500 echo "Testing delete: valid remote record..."
502 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
503 $TESTOUT 2>&1 << EOF_DEL8
505 dn: uid=fred,ou=users,o=translucent
510 if test $RC != 32 ; then
511 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
512 grep "$FAILURE" $TESTOUT
513 test $KILLSERVERS != no && kill -HUP $KILLPIDS
517 echo "Testing delete: nonexistent local record, nonexistent attribute..."
519 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
520 $TESTOUT 2>&1 << EOF_DEL1
522 dn: uid=fred,ou=users,o=translucent
528 if test $RC != 0 ; then
529 echo "ldapmodify failed ($RC)!"
530 grep "$FAILURE" $TESTOUT
531 test $KILLSERVERS != no && kill -HUP $KILLPIDS
535 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
538 if test $RC != 0 ; then
539 echo "ldapsearch failed ($RC)!"
540 test $KILLSERVERS != no && kill -HUP $KILLPIDS
544 echo "Testing delete: valid local record, nonexistent attribute..."
546 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
547 $TESTOUT 2>&1 << EOF_MOD8
549 dn: uid=danger,ou=users,o=translucent
551 delete: preferredLanguage
555 if test $RC != 16 ; then
556 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
557 grep "$FAILURE" $TESTOUT
558 test $KILLSERVERS != no && kill -HUP $KILLPIDS
562 echo "Testing delete: valid local record, remote attribute..."
564 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
565 $TESTOUT 2>&1 << EOF_MOD8
567 dn: uid=danger,ou=users,o=translucent
573 if test $RC != 0 ; then
574 echo "ldapmodify failed ($RC)"
575 grep "$FAILURE" $TESTOUT
576 test $KILLSERVERS != no && kill -HUP $KILLPIDS
580 echo "Testing modify: valid remote record, combination add-modify-delete..."
582 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
583 $TESTOUT 2>&1 << EOF_MOD6
585 dn: uid=fred,ou=users,o=translucent
589 add: preferredLanguage
590 preferredLanguage: ISO8859-1
592 replace: employeeType
593 employeeType: consultant
597 if test $RC != 0 ; then
598 echo "ldapmodify failed ($RC)!"
599 grep "$FAILURE" $TESTOUT
600 test $KILLSERVERS != no && kill -HUP $KILLPIDS
604 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
607 if test $RC != 0 ; then
608 echo "ldapsearch failed ($RC)!"
609 test $KILLSERVERS != no && kill -HUP $KILLPIDS
613 ATTR=`grep employeeType $SEARCHOUT` > $NOWHERE 2>&1
614 if test "$ATTR" != "employeeType: consultant" ; then
615 echo "modification failed!"
616 test $KILLSERVERS != no && kill -HUP $KILLPIDS
620 ATTR=`grep preferredLanguage $SEARCHOUT` > $NOWHERE 2>&1
621 if test "$ATTR" != "preferredLanguage: ISO8859-1" ; then
622 echo "modification failed!"
623 test $KILLSERVERS != no && kill -HUP $KILLPIDS
627 echo "Dynamically configuring local slapd with translucent_no_glue and translucent_strict..."
629 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
630 dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
632 replace: olcTranslucentNoGlue
633 olcTranslucentNoGlue: TRUE
635 replace: olcTranslucentStrict
636 olcTranslucentStrict: TRUE
639 if test $RC != 0 ; then
640 echo "ldapmodify of dynamic config failed ($RC)"
641 test $KILLSERVERS != no && kill -HUP $KILLPIDS
645 echo "Testing strict mode delete: nonexistent local attribute..."
647 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
648 $TESTOUT 2>&1 << EOF_MOD5
650 dn: uid=example,ou=users,o=translucent
652 delete: preferredLanguage
656 if test $RC != 19 ; then
657 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
658 grep "$FAILURE" $TESTOUT
659 test $KILLSERVERS != no && kill -HUP $KILLPIDS
663 echo "Testing strict mode delete: nonexistent remote attribute..."
665 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
666 $TESTOUT 2>&1 << EOF_MOD3
668 dn: uid=danger,ou=users,o=translucent
674 if test $RC != 19 ; then
675 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
676 grep "$FAILURE" $TESTOUT
677 test $KILLSERVERS != no && kill -HUP $KILLPIDS
681 echo "Testing strict mode modify: combination add-modify-delete..."
683 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
684 $TESTOUT 2>&1 << EOF_MOD6
686 dn: uid=example,ou=users,o=translucent
690 add: preferredLanguage
691 preferredLanguage: ISO8859-1
693 replace: employeeType
694 employeeType: consultant
698 if test $RC != 19 ; then
699 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
700 grep "$FAILURE" $TESTOUT
701 test $KILLSERVERS != no && kill -HUP $KILLPIDS
705 echo "Testing invalid Bind request..."
706 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w Wrong"$TRANSLUCENTPASSWD" > \
709 if test $RC != 49 ; then
710 echo "ldapwhoami failed ($RC), expected INVALID CREDENTIALS!"
711 grep "$FAILURE" $TESTOUT
712 test $KILLSERVERS != no && kill -HUP $KILLPIDS
716 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w "$TRANSLUCENTPASSWD" > \
719 if test $RC != 0 ; then
720 echo "ldapwhoami failed ($RC), expected SUCCESS!"
721 grep "$FAILURE" $TESTOUT
722 test $KILLSERVERS != no && kill -HUP $KILLPIDS
726 test $KILLSERVERS != no && kill -HUP $KILLPIDS
728 echo ">>>>> Test succeeded"
730 test $KILLSERVERS != no && wait