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 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTREMOTECONF > $CONF1
40 echo "Running slapadd to build remote slapd database..."
41 $SLAPADD -f $CONF1 -l $LDIFTRANSLUCENTCONFIG
43 if test $RC != 0 ; then
44 echo "slapadd failed ($RC)!"
48 echo "Starting remote slapd on TCP/IP port $PORT1..."
49 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
51 if test $WAIT != 0 ; then
60 for i in 0 1 2 3 4 5; do
61 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
62 'objectclass=*' > /dev/null 2>&1
64 if test $RC = 0 ; then
67 echo "Waiting 5 seconds for remote slapd to start..."
71 if test $RC != 0 ; then
72 echo "ldapsearch failed ($RC)!"
73 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF > $CONF2
82 echo "Starting local slapd on TCP/IP port $PORT2..."
83 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
85 if test $WAIT != 0 ; then
90 KILLPIDS="$LOCALPID $REMOTEPID"
94 for i in 0 1 2 3 4 5; do
95 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
96 'objectclass=*' > /dev/null 2>&1
98 if test $RC = 0 ; then
101 echo "Waiting 5 seconds for local slapd to start..."
105 if test $RC != 0 ; then
106 echo "ldapsearch failed ($RC)!"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 echo "Testing slapd Translucent Proxy operations..."
113 echo "Testing search: no remote data defined..."
115 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" >$SEARCHOUT 2>&1
118 if test $RC != 0 ; then
119 echo "ldapsearch failed ($RC)!"
120 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124 if test -s $SEARCHOUT; then
125 echo "ldapsearch should have returned no records!"
126 test $KILLSERVERS != no && kill -HUP $KILLPIDS
130 echo "Populating remote database..."
132 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI1 \
133 -w $PASSWD < $LDIFTRANSLUCENTDATA > $NOWHERE 2>&1
136 if test $RC != 0 ; then
137 echo "ldapadd failed ($RC)!"
138 test $KILLSERVERS != no && kill -HUP $KILLPIDS
142 echo "Testing search: remote database via local slapd..."
144 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
147 if test $RC != 0 ; then
148 echo "ldapsearch failed ($RC)!"
149 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
154 . $LDIFFILTER < $LDIFTRANSLUCENTDATA > $LDIFFLT
155 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
157 if test $? != 0 ; then
158 echo "Comparison failed -- corruption from remote to local!"
159 test $KILLSERVERS != no && kill -HUP $KILLPIDS
163 echo "Testing add: prohibited local record..."
165 $LDAPADD -D "$TRANSLUCENTDN" -H $URI2 \
166 -w $TRANSLUCENTPASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
169 if test $RC != 50 ; then
170 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
171 grep "$FAILURE" $TESTOUT
172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
176 echo "Testing add: valid local record, no_glue..."
178 $LDAPADD -v -v -v -D "$TRANSLUCENTROOT" -H $URI2 \
179 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
182 if test $RC != 32 ; then
183 echo "ldapadd failed ($RC), expected NO SUCH OBJECT!"
184 grep "$FAILURE" $TESTOUT
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 echo "Testing modrdn: valid local record, no_glue..."
191 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
192 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
195 if test $RC != 32 ; then
196 echo "ldapmodrdn failed ($RC), expected NO SUCH OBJECT!"
197 grep "$FAILURE" $TESTOUT
198 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 echo "Dynamically configuring local slapd without translucent_no_glue..."
204 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
205 dn: olcOverlay={0}translucent,olcDatabase={2}$BACKEND,cn=config
207 replace: olcTranslucentNoGlue
208 olcTranslucentNoGlue: FALSE
211 if test $RC != 0 ; then
212 echo "ldapmodify of dynamic config failed ($RC)"
213 test $KILLSERVERS != no && kill -HUP $KILLPIDS
217 echo "Testing add: valid local record..."
219 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI2 \
220 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
223 if test $RC != 0 ; then
224 echo "ldapadd failed ($RC)!"
225 grep "$FAILURE" $TESTOUT
226 test $KILLSERVERS != no && kill -HUP $KILLPIDS
230 echo "Testing search: data merging..."
232 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
235 if test $RC != 0 ; then
236 echo "ldapsearch failed ($RC)!"
237 test $KILLSERVERS != no && kill -HUP $KILLPIDS
241 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
242 $CMP $SEARCHFLT $LDIFTRANSLUCENTMERGED > $CMPOUT
244 if test $? != 0 ; then
245 echo "Comparison failed -- local data failed to merge with remote!"
246 test $KILLSERVERS != no && kill -HUP $KILLPIDS
250 echo "Testing compare: valid local..."
252 $LDAPCOMPARE -z -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
253 "uid=danger,ou=users,o=translucent" "carLicense:LIVID"
256 if test $RC != 6 ; then
257 echo "ldapcompare failed ($RC), expected TRUE!"
258 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 echo "Testing compare: valid remote..."
264 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
265 "uid=binder,o=translucent" "businessCategory:binder-test-user"
268 if test $RC != 6 ; then
269 echo "ldapcompare failed ($RC), expected TRUE!"
270 test $KILLSERVERS != no && kill -HUP $KILLPIDS
274 echo "Testing compare: bogus local..."
276 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
277 "uid=danger,ou=users,o=translucent" "businessCategory:invalid-test-value"
280 if test $RC != 5 ; then
281 echo "ldapcompare failed ($RC), expected FALSE!"
282 test $KILLSERVERS != no && kill -HUP $KILLPIDS
286 echo "Testing compare: bogus remote..."
288 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
289 "uid=binder,o=translucent" "businessCategory:invalid-test-value"
292 if test $RC != 5 ; then
293 echo "ldapcompare failed ($RC), expected FALSE!"
294 test $KILLSERVERS != no && kill -HUP $KILLPIDS
298 echo "Testing modify: nonexistent record..."
300 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
301 $TESTOUT 2>&1 << EOF_MOD
303 dn: uid=bogus,ou=users,o=translucent
310 if test $RC != 32 ; then
311 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
312 grep "$FAILURE" $TESTOUT
313 test $KILLSERVERS != no && kill -HUP $KILLPIDS
317 echo "Testing modify: valid local record, nonexistent attribute..."
319 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
320 $TESTOUT 2>&1 << EOF_MOD1
322 dn: uid=danger,ou=users,o=translucent
329 if test $RC != 0 ; then
330 echo "ldapmodify failed ($RC)!"
331 grep "$FAILURE" $TESTOUT
332 test $KILLSERVERS != no && kill -HUP $KILLPIDS
336 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" > $SEARCHOUT 2>&1
339 if test $RC != 0 ; then
340 echo "ldapsearch failed ($RC)!"
341 test $KILLSERVERS != no && kill -HUP $KILLPIDS
345 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
346 if test "$ATTR" != "roomNumber: 9N-21" ; then
347 echo "modification failed!"
348 test $KILLSERVERS != no && kill -HUP $KILLPIDS
352 echo "Testing search: specific nonexistent remote attribute..."
354 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" roomNumber > $SEARCHOUT 2>&1
357 if test $RC != 0 ; then
358 echo "ldapsearch failed ($RC)!"
359 test $KILLSERVERS != no && kill -HUP $KILLPIDS
363 echo "Testing modify: nonexistent local record, nonexistent attribute..."
365 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
366 $TESTOUT 2>&1 << EOF_MOD2
368 dn: uid=fred,ou=users,o=translucent
375 if test $RC != 0 ; then
376 echo "ldapmodify failed ($RC)!"
377 grep "$FAILURE" $TESTOUT
378 test $KILLSERVERS != no && kill -HUP $KILLPIDS
382 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
385 if test $RC != 0 ; then
386 echo "ldapsearch failed ($RC)!"
387 test $KILLSERVERS != no && kill -HUP $KILLPIDS
391 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
392 if test "$ATTR" != "roomNumber: 31J-2112" ; then
393 echo "modification failed!"
394 test $KILLSERVERS != no && kill -HUP $KILLPIDS
398 echo "Testing modify: valid remote record, nonexistent attribute..."
400 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
401 $TESTOUT 2>&1 << EOF_MOD9
403 dn: uid=fred,ou=users,o=translucent
405 delete: preferredLanguage
409 if test $RC != 16 ; then
410 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
411 grep "$FAILURE" $TESTOUT
412 test $KILLSERVERS != no && kill -HUP $KILLPIDS
416 echo "Testing delete: valid local record, nonexistent attribute..."
418 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
419 $TESTOUT 2>&1 << EOF_MOD4
421 dn: uid=fred,ou=users,o=translucent
427 if test $RC != 0 ; then
428 echo "ldapmodify failed ($RC)!"
429 grep "$FAILURE" $TESTOUT
430 test $KILLSERVERS != no && kill -HUP $KILLPIDS
434 echo "Testing modrdn: prohibited local record..."
436 $LDAPMODRDN -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
437 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
440 if test $RC != 50 ; then
441 echo "ldapmodrdn failed ($RC), expected INSUFFICIENT ACCESS!"
442 grep "$FAILURE" $TESTOUT
443 test $KILLSERVERS != no && kill -HUP $KILLPIDS
447 echo "Testing modrdn: valid local record..."
449 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
450 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
453 if test $RC != 0 ; then
454 echo "ldapmodrdn failed ($RC)!"
455 grep "$FAILURE" $TESTOUT
456 test $KILLSERVERS != no && kill -HUP $KILLPIDS
460 echo "Testing delete: prohibited local record..."
462 $LDAPMODIFY -v -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
463 $TESTOUT 2>&1 << EOF_DEL2
465 dn: uid=someguy,ou=users,o=translucent
470 if test $RC != 50 ; then
471 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
472 grep "$FAILURE" $TESTOUT
473 test $KILLSERVERS != no && kill -HUP $KILLPIDS
477 echo "Testing delete: valid local record..."
479 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
480 $TESTOUT 2>&1 << EOF_DEL3
482 dn: uid=someguy,ou=users,o=translucent
487 if test $RC != 0 ; then
488 echo "ldapmodify failed ($RC)!"
489 grep "$FAILURE" $TESTOUT
490 test $KILLSERVERS != no && kill -HUP $KILLPIDS
494 echo "Testing delete: valid remote record..."
496 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
497 $TESTOUT 2>&1 << EOF_DEL8
499 dn: uid=fred,ou=users,o=translucent
504 if test $RC != 32 ; then
505 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
506 grep "$FAILURE" $TESTOUT
507 test $KILLSERVERS != no && kill -HUP $KILLPIDS
511 echo "Testing delete: nonexistent local record, nonexistent attribute..."
513 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
514 $TESTOUT 2>&1 << EOF_DEL1
516 dn: uid=fred,ou=users,o=translucent
522 if test $RC != 0 ; then
523 echo "ldapmodify failed ($RC)!"
524 grep "$FAILURE" $TESTOUT
525 test $KILLSERVERS != no && kill -HUP $KILLPIDS
529 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
532 if test $RC != 0 ; then
533 echo "ldapsearch failed ($RC)!"
534 test $KILLSERVERS != no && kill -HUP $KILLPIDS
538 echo "Testing delete: valid local record, nonexistent attribute..."
540 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
541 $TESTOUT 2>&1 << EOF_MOD8
543 dn: uid=danger,ou=users,o=translucent
545 delete: preferredLanguage
549 if test $RC != 16 ; then
550 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
551 grep "$FAILURE" $TESTOUT
552 test $KILLSERVERS != no && kill -HUP $KILLPIDS
556 echo "Testing delete: valid local record, remote attribute..."
558 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
559 $TESTOUT 2>&1 << EOF_MOD8
561 dn: uid=danger,ou=users,o=translucent
567 if test $RC != 0 ; then
568 echo "ldapmodify failed ($RC)"
569 grep "$FAILURE" $TESTOUT
570 test $KILLSERVERS != no && kill -HUP $KILLPIDS
574 echo "Testing modify: valid remote record, combination add-modify-delete..."
576 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
577 $TESTOUT 2>&1 << EOF_MOD6
579 dn: uid=fred,ou=users,o=translucent
583 add: preferredLanguage
584 preferredLanguage: ISO8859-1
586 replace: employeeType
587 employeeType: consultant
591 if test $RC != 0 ; then
592 echo "ldapmodify failed ($RC)!"
593 grep "$FAILURE" $TESTOUT
594 test $KILLSERVERS != no && kill -HUP $KILLPIDS
598 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
601 if test $RC != 0 ; then
602 echo "ldapsearch failed ($RC)!"
603 test $KILLSERVERS != no && kill -HUP $KILLPIDS
607 ATTR=`grep employeeType $SEARCHOUT` > $NOWHERE 2>&1
608 if test "$ATTR" != "employeeType: consultant" ; then
609 echo "modification failed!"
610 test $KILLSERVERS != no && kill -HUP $KILLPIDS
614 ATTR=`grep preferredLanguage $SEARCHOUT` > $NOWHERE 2>&1
615 if test "$ATTR" != "preferredLanguage: ISO8859-1" ; then
616 echo "modification failed!"
617 test $KILLSERVERS != no && kill -HUP $KILLPIDS
621 echo "Dynamically configuring local slapd with translucent_no_glue and translucent_strict..."
623 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
624 dn: olcOverlay={0}translucent,olcDatabase={2}$BACKEND,cn=config
626 replace: olcTranslucentNoGlue
627 olcTranslucentNoGlue: TRUE
629 replace: olcTranslucentStrict
630 olcTranslucentStrict: TRUE
633 if test $RC != 0 ; then
634 echo "ldapmodify of dynamic config failed ($RC)"
635 test $KILLSERVERS != no && kill -HUP $KILLPIDS
639 echo "Testing strict mode delete: nonexistent local attribute..."
641 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
642 $TESTOUT 2>&1 << EOF_MOD5
644 dn: uid=example,ou=users,o=translucent
646 delete: preferredLanguage
650 if test $RC != 19 ; then
651 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
652 grep "$FAILURE" $TESTOUT
653 test $KILLSERVERS != no && kill -HUP $KILLPIDS
657 echo "Testing strict mode delete: nonexistent remote attribute..."
659 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
660 $TESTOUT 2>&1 << EOF_MOD3
662 dn: uid=danger,ou=users,o=translucent
668 if test $RC != 19 ; then
669 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
670 grep "$FAILURE" $TESTOUT
671 test $KILLSERVERS != no && kill -HUP $KILLPIDS
675 echo "Testing strict mode modify: combination add-modify-delete..."
677 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
678 $TESTOUT 2>&1 << EOF_MOD6
680 dn: uid=example,ou=users,o=translucent
684 add: preferredLanguage
685 preferredLanguage: ISO8859-1
687 replace: employeeType
688 employeeType: consultant
692 if test $RC != 19 ; then
693 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
694 grep "$FAILURE" $TESTOUT
695 test $KILLSERVERS != no && kill -HUP $KILLPIDS
699 echo "Testing invalid Bind request..."
700 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w Wrong"$TRANSLUCENTPASSWD" > \
703 if test $RC != 49 ; then
704 echo "ldapwhoami failed ($RC), expected INVALID CREDENTIALS!"
705 grep "$FAILURE" $TESTOUT
706 test $KILLSERVERS != no && kill -HUP $KILLPIDS
710 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w "$TRANSLUCENTPASSWD" > \
713 if test $RC != 0 ; then
714 echo "ldapwhoami failed ($RC), expected SUCCESS!"
715 grep "$FAILURE" $TESTOUT
716 test $KILLSERVERS != no && kill -HUP $KILLPIDS
720 test $KILLSERVERS != no && kill -HUP $KILLPIDS
722 echo ">>>>> Test succeeded"
724 test $KILLSERVERS != no && wait