3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-2006 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
20 PERSONAL="(objectClass=inetOrgPerson)"
22 FAILURE="additional info:"
24 if test $TRANSLUCENT = translucentno ; then
25 echo "Translucent Proxy overlay not available, test skipped"
29 if test $AC_ldap = ldapno ; then
30 echo "Translucent Proxy overlay requires back-ldap backend, test skipped"
35 mkdir -p $TESTDIR $DBDIR1
37 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTREMOTECONF > $CONF1
38 echo "Running slapadd to build remote slapd database..."
39 $SLAPADD -f $CONF1 -l $LDIFTRANSLUCENTCONFIG
41 if test $RC != 0 ; then
42 echo "slapadd failed ($RC)!"
46 echo "Starting remote slapd on TCP/IP port $PORT1..."
47 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
49 if test $WAIT != 0 ; then
58 for i in 0 1 2 3 4 5; do
59 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
60 'objectclass=*' > /dev/null 2>&1
62 if test $RC = 0 ; then
65 echo "Waiting 5 seconds for remote slapd to start..."
69 if test $RC != 0 ; then
70 echo "ldapsearch failed ($RC)!"
71 test $KILLSERVERS != no && kill -HUP $KILLPIDS
77 mkdir -p testrun/conf2
79 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF > $CONF2
81 echo "Starting local slapd on TCP/IP port $PORT2..."
82 $SLAPD -f $CONF2 -F testrun/conf2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
84 if test $WAIT != 0 ; then
89 KILLPIDS="$LOCALPID $REMOTEPID"
93 for i in 0 1 2 3 4 5; do
94 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
95 'objectclass=*' > /dev/null 2>&1
97 if test $RC = 0 ; then
100 echo "Waiting 5 seconds for local slapd to start..."
104 if test $RC != 0 ; then
105 echo "ldapsearch failed ($RC)!"
106 test $KILLSERVERS != no && kill -HUP $KILLPIDS
110 echo "Testing slapd Translucent Proxy operations..."
112 echo "Testing search: no remote data defined..."
114 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" >$SEARCHOUT 2>&1
117 if test $RC != 0 ; then
118 echo "ldapsearch failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 if test -s $SEARCHOUT; then
124 echo "ldapsearch should have returned no records!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
129 echo "Populating remote database..."
131 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI1 \
132 -w $PASSWD < $LDIFTRANSLUCENTDATA > $NOWHERE 2>&1
135 if test $RC != 0 ; then
136 echo "ldapadd failed ($RC)!"
137 test $KILLSERVERS != no && kill -HUP $KILLPIDS
141 echo "Testing search: remote database via local slapd..."
143 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
146 if test $RC != 0 ; then
147 echo "ldapsearch failed ($RC)!"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
153 . $LDIFFILTER < $LDIFTRANSLUCENTDATA > $LDIFFLT
154 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
156 if test $? != 0 ; then
157 echo "Comparison failed -- corruption from remote to local!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 echo "Testing add: prohibited local record..."
164 $LDAPADD -D "$TRANSLUCENTDN" -H $URI2 \
165 -w $TRANSLUCENTPASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
168 if test $RC != 50 ; then
169 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
170 grep "$FAILURE" $TESTOUT
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
175 echo "Testing add: valid local record, no_glue..."
177 $LDAPADD -v -v -v -D "$TRANSLUCENTROOT" -H $URI2 \
178 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
181 if test $RC != 32 ; then
182 echo "ldapadd failed ($RC), expected NO SUCH OBJECT!"
183 grep "$FAILURE" $TESTOUT
184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
188 echo "Testing modrdn: valid local record, no_glue..."
190 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
191 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
194 if test $RC != 32 ; then
195 echo "ldapmodrdn failed ($RC), expected NO SUCH OBJECT!"
196 grep "$FAILURE" $TESTOUT
197 test $KILLSERVERS != no && kill -HUP $KILLPIDS
201 echo "Dynamically configuring local slapd without translucent_no_glue..."
203 $LDAPMODIFY -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD <<EOF
204 dn: olcOverlay={0}translucent,olcDatabase={2}bdb,cn=config
206 replace: olcTranslucentNoGlue
207 olcTranslucentNoGlue: FALSE
210 if test $RC != 0 ; then
211 echo "ldapmodify of dynamic config failed ($RC)"
212 test $KILLSERVERS != no && kill -HUP $KILLPIDS
216 echo "Testing add: valid local record..."
218 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI2 \
219 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
222 if test $RC != 0 ; then
223 echo "ldapadd failed ($RC)!"
224 grep "$FAILURE" $TESTOUT
225 test $KILLSERVERS != no && kill -HUP $KILLPIDS
229 echo "Testing search: data merging..."
231 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
234 if test $RC != 0 ; then
235 echo "ldapsearch failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
241 $CMP $SEARCHFLT $LDIFTRANSLUCENTMERGED > $CMPOUT
243 if test $? != 0 ; then
244 echo "Comparison failed -- local data failed to merge with remote!"
245 test $KILLSERVERS != no && kill -HUP $KILLPIDS
249 echo "Testing compare: valid local..."
251 $LDAPCOMPARE -z -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
252 "uid=danger,ou=users,o=translucent" "carLicense:LIVID"
255 if test $RC != 6 ; then
256 echo "ldapcompare failed ($RC), expected TRUE!"
257 test $KILLSERVERS != no && kill -HUP $KILLPIDS
261 echo "Testing compare: valid remote..."
263 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
264 "uid=binder,o=translucent" "businessCategory:binder-test-user"
267 if test $RC != 6 ; then
268 echo "ldapcompare failed ($RC), expected TRUE!"
269 test $KILLSERVERS != no && kill -HUP $KILLPIDS
273 echo "Testing compare: bogus local..."
275 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
276 "uid=danger,ou=users,o=translucent" "businessCategory:invalid-test-value"
279 if test $RC != 5 ; then
280 echo "ldapcompare failed ($RC), expected FALSE!"
281 test $KILLSERVERS != no && kill -HUP $KILLPIDS
285 echo "Testing compare: bogus remote..."
287 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
288 "uid=binder,o=translucent" "businessCategory:invalid-test-value"
291 if test $RC != 5 ; then
292 echo "ldapcompare failed ($RC), expected FALSE!"
293 test $KILLSERVERS != no && kill -HUP $KILLPIDS
297 echo "Testing modify: nonexistent record..."
299 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
300 $TESTOUT 2>&1 << EOF_MOD
302 dn: uid=bogus,ou=users,o=translucent
309 if test $RC != 32 ; then
310 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
311 grep "$FAILURE" $TESTOUT
312 test $KILLSERVERS != no && kill -HUP $KILLPIDS
316 echo "Testing modify: valid local record, nonexistent attribute..."
318 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
319 $TESTOUT 2>&1 << EOF_MOD1
321 dn: uid=danger,ou=users,o=translucent
328 if test $RC != 0 ; then
329 echo "ldapmodify failed ($RC)!"
330 grep "$FAILURE" $TESTOUT
331 test $KILLSERVERS != no && kill -HUP $KILLPIDS
335 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" > $SEARCHOUT 2>&1
338 if test $RC != 0 ; then
339 echo "ldapsearch failed ($RC)!"
340 test $KILLSERVERS != no && kill -HUP $KILLPIDS
344 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
345 if test "$ATTR" != "roomNumber: 9N-21" ; then
346 echo "modification failed!"
347 test $KILLSERVERS != no && kill -HUP $KILLPIDS
351 echo "Testing search: specific nonexistent remote attribute..."
353 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" roomNumber > $SEARCHOUT 2>&1
356 if test $RC != 0 ; then
357 echo "ldapsearch failed ($RC)!"
358 test $KILLSERVERS != no && kill -HUP $KILLPIDS
362 echo "Testing modify: nonexistent local record, nonexistent attribute..."
364 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
365 $TESTOUT 2>&1 << EOF_MOD2
367 dn: uid=fred,ou=users,o=translucent
374 if test $RC != 0 ; then
375 echo "ldapmodify failed ($RC)!"
376 grep "$FAILURE" $TESTOUT
377 test $KILLSERVERS != no && kill -HUP $KILLPIDS
381 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
384 if test $RC != 0 ; then
385 echo "ldapsearch failed ($RC)!"
386 test $KILLSERVERS != no && kill -HUP $KILLPIDS
390 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
391 if test "$ATTR" != "roomNumber: 31J-2112" ; then
392 echo "modification failed!"
393 test $KILLSERVERS != no && kill -HUP $KILLPIDS
397 echo "Testing modify: valid remote record, nonexistent attribute..."
399 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
400 $TESTOUT 2>&1 << EOF_MOD9
402 dn: uid=fred,ou=users,o=translucent
404 delete: preferredLanguage
408 if test $RC != 16 ; then
409 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
410 grep "$FAILURE" $TESTOUT
411 test $KILLSERVERS != no && kill -HUP $KILLPIDS
415 echo "Testing delete: valid local record, nonexistent attribute..."
417 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
418 $TESTOUT 2>&1 << EOF_MOD4
420 dn: uid=fred,ou=users,o=translucent
426 if test $RC != 0 ; then
427 echo "ldapmodify failed ($RC)!"
428 grep "$FAILURE" $TESTOUT
429 test $KILLSERVERS != no && kill -HUP $KILLPIDS
433 echo "Testing modrdn: prohibited local record..."
435 $LDAPMODRDN -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
436 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
439 if test $RC != 50 ; then
440 echo "ldapmodrdn failed ($RC), expected INSUFFICIENT ACCESS!"
441 grep "$FAILURE" $TESTOUT
442 test $KILLSERVERS != no && kill -HUP $KILLPIDS
446 echo "Testing modrdn: valid local record..."
448 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
449 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
452 if test $RC != 0 ; then
453 echo "ldapmodrdn failed ($RC)!"
454 grep "$FAILURE" $TESTOUT
455 test $KILLSERVERS != no && kill -HUP $KILLPIDS
459 echo "Testing delete: prohibited local record..."
461 $LDAPMODIFY -v -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
462 $TESTOUT 2>&1 << EOF_DEL2
464 dn: uid=someguy,ou=users,o=translucent
469 if test $RC != 50 ; then
470 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
471 grep "$FAILURE" $TESTOUT
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
476 echo "Testing delete: valid local record..."
478 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
479 $TESTOUT 2>&1 << EOF_DEL3
481 dn: uid=someguy,ou=users,o=translucent
486 if test $RC != 0 ; then
487 echo "ldapmodify failed ($RC)!"
488 grep "$FAILURE" $TESTOUT
489 test $KILLSERVERS != no && kill -HUP $KILLPIDS
493 echo "Testing delete: valid remote record..."
495 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
496 $TESTOUT 2>&1 << EOF_DEL8
498 dn: uid=fred,ou=users,o=translucent
503 if test $RC != 32 ; then
504 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
505 grep "$FAILURE" $TESTOUT
506 test $KILLSERVERS != no && kill -HUP $KILLPIDS
510 echo "Testing delete: nonexistent local record, nonexistent attribute..."
512 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
513 $TESTOUT 2>&1 << EOF_DEL1
515 dn: uid=fred,ou=users,o=translucent
521 if test $RC != 0 ; then
522 echo "ldapmodify failed ($RC)!"
523 grep "$FAILURE" $TESTOUT
524 test $KILLSERVERS != no && kill -HUP $KILLPIDS
528 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
531 if test $RC != 0 ; then
532 echo "ldapsearch failed ($RC)!"
533 test $KILLSERVERS != no && kill -HUP $KILLPIDS
537 echo "Testing delete: valid local record, nonexistent attribute..."
539 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
540 $TESTOUT 2>&1 << EOF_MOD8
542 dn: uid=danger,ou=users,o=translucent
544 delete: preferredLanguage
548 if test $RC != 16 ; then
549 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
550 grep "$FAILURE" $TESTOUT
551 test $KILLSERVERS != no && kill -HUP $KILLPIDS
555 echo "Testing modify: valid remote record, combination add-modify-delete..."
557 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
558 $TESTOUT 2>&1 << EOF_MOD6
560 dn: uid=fred,ou=users,o=translucent
564 add: preferredLanguage
565 preferredLanguage: ISO8859-1
567 replace: employeeType
568 employeeType: consultant
572 if test $RC != 0 ; then
573 echo "ldapmodify failed ($RC)!"
574 grep "$FAILURE" $TESTOUT
575 test $KILLSERVERS != no && kill -HUP $KILLPIDS
579 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
582 if test $RC != 0 ; then
583 echo "ldapsearch failed ($RC)!"
584 test $KILLSERVERS != no && kill -HUP $KILLPIDS
588 ATTR=`grep employeeType $SEARCHOUT` > $NOWHERE 2>&1
589 if test "$ATTR" != "employeeType: consultant" ; then
590 echo "modification failed!"
591 test $KILLSERVERS != no && kill -HUP $KILLPIDS
595 ATTR=`grep preferredLanguage $SEARCHOUT` > $NOWHERE 2>&1
596 if test "$ATTR" != "preferredLanguage: ISO8859-1" ; then
597 echo "modification failed!"
598 test $KILLSERVERS != no && kill -HUP $KILLPIDS
602 echo "Dynamically configuring local slapd with translucent_no_glue and translucent_string..."
604 $LDAPMODIFY -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD <<EOF
605 dn: olcOverlay={0}translucent,olcDatabase={2}bdb,cn=config
607 replace: olcTranslucentNoGlue
608 olcTranslucentNoGlue: TRUE
610 replace: olcTranslucentStrict
611 olcTranslucentStrict: TRUE
614 if test $RC != 0 ; then
615 echo "ldapmodify of dynamic config failed ($RC)"
616 test $KILLSERVERS != no && kill -HUP $KILLPIDS
620 echo "Testing strict mode delete: nonexistent local attribute..."
622 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
623 $TESTOUT 2>&1 << EOF_MOD5
625 dn: uid=example,ou=users,o=translucent
627 delete: preferredLanguage
631 if test $RC != 19 ; then
632 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
633 grep "$FAILURE" $TESTOUT
634 test $KILLSERVERS != no && kill -HUP $KILLPIDS
638 echo "Testing strict mode delete: nonexistent remote attribute..."
640 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
641 $TESTOUT 2>&1 << EOF_MOD3
643 dn: uid=danger,ou=users,o=translucent
649 if test $RC != 19 ; then
650 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
651 grep "$FAILURE" $TESTOUT
652 test $KILLSERVERS != no && kill -HUP $KILLPIDS
656 echo "Testing strict mode modify: combination add-modify-delete..."
658 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
659 $TESTOUT 2>&1 << EOF_MOD6
661 dn: uid=example,ou=users,o=translucent
665 add: preferredLanguage
666 preferredLanguage: ISO8859-1
668 replace: employeeType
669 employeeType: consultant
673 if test $RC != 19 ; then
674 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
675 grep "$FAILURE" $TESTOUT
676 test $KILLSERVERS != no && kill -HUP $KILLPIDS
680 echo "Testing invalid Bind request..."
681 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w Wrong"$TRANSLUCENTPASSWD" > \
684 if test $RC != 49 ; then
685 echo "ldapwhoami failed ($RC), expected INVALID CREDENTIALS!"
686 grep "$FAILURE" $TESTOUT
687 test $KILLSERVERS != no && kill -HUP $KILLPIDS
691 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w "$TRANSLUCENTPASSWD" > \
694 if test $RC != 0 ; then
695 echo "ldapwhoami failed ($RC), expected SUCCESS!"
696 grep "$FAILURE" $TESTOUT
697 test $KILLSERVERS != no && kill -HUP $KILLPIDS
701 test $KILLSERVERS != no && kill -HUP $KILLPIDS
703 echo ">>>>> Test succeeded"
705 test $KILLSERVERS != no && wait