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
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 $BACKEND = ldbm ; then
29 echo "Translucent Proxy overlay not qualified for use with LDBM, test skipped"
33 if test $AC_ldap = ldapno ; then
34 echo "Translucent Proxy overlay requires back-ldap backend, test skipped"
39 mkdir -p $TESTDIR $DBDIR1
41 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTREMOTECONF > $CONF1
42 echo "Running slapadd to build remote slapd database..."
43 $SLAPADD -f $CONF1 -l $LDIFTRANSLUCENTCONFIG
45 if test $RC != 0 ; then
46 echo "slapadd failed ($RC)!"
50 echo "Starting remote slapd on TCP/IP port $PORT1..."
51 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
53 if test $WAIT != 0 ; then
62 for i in 0 1 2 3 4 5; do
63 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
64 'objectclass=*' > /dev/null 2>&1
66 if test $RC = 0 ; then
69 echo "Waiting 5 seconds for remote slapd to start..."
73 if test $RC != 0 ; then
74 echo "ldapsearch failed ($RC)!"
75 test $KILLSERVERS != no && kill -HUP $KILLPIDS
82 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF > $CONF2
84 echo "Starting local slapd on TCP/IP port $PORT2..."
85 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
87 if test $WAIT != 0 ; then
92 KILLPIDS="$LOCALPID $REMOTEPID"
96 for i in 0 1 2 3 4 5; do
97 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
98 'objectclass=*' > /dev/null 2>&1
100 if test $RC = 0 ; then
103 echo "Waiting 5 seconds for local slapd to start..."
107 if test $RC != 0 ; then
108 echo "ldapsearch failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 echo "Testing slapd Translucent Proxy operations..."
115 echo "Testing search: no remote data defined..."
117 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" >$SEARCHOUT 2>&1
120 if test $RC != 0 ; then
121 echo "ldapsearch failed ($RC)!"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 if test -s $SEARCHOUT; then
127 echo "ldapsearch should have returned no records!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
132 echo "Populating remote database..."
134 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI1 \
135 -w $PASSWD < $LDIFTRANSLUCENTDATA > $NOWHERE 2>&1
138 if test $RC != 0 ; then
139 echo "ldapadd failed ($RC)!"
140 test $KILLSERVERS != no && kill -HUP $KILLPIDS
144 echo "Testing search: remote database via local slapd..."
146 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
149 if test $RC != 0 ; then
150 echo "ldapsearch failed ($RC)!"
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
156 . $LDIFFILTER < $LDIFTRANSLUCENTDATA > $LDIFFLT
157 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
159 if test $? != 0 ; then
160 echo "Comparison failed -- corruption from remote to local!"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 echo "Testing add: prohibited local record..."
167 $LDAPADD -D "$TRANSLUCENTDN" -H $URI2 \
168 -w $TRANSLUCENTPASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
171 if test $RC != 50 ; then
172 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
173 grep "$FAILURE" $TESTOUT
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 echo "Testing add: valid local record, no_glue..."
180 $LDAPADD -v -v -v -D "$TRANSLUCENTROOT" -H $URI2 \
181 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
184 if test $RC != 32 ; then
185 echo "ldapadd failed ($RC), expected NO SUCH OBJECT!"
186 grep "$FAILURE" $TESTOUT
187 test $KILLSERVERS != no && kill -HUP $KILLPIDS
191 echo "Testing modrdn: valid local record, no_glue..."
193 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
194 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
197 if test $RC != 32 ; then
198 echo "ldapmodrdn failed ($RC), expected NO SUCH OBJECT!"
199 grep "$FAILURE" $TESTOUT
200 test $KILLSERVERS != no && kill -HUP $KILLPIDS
204 echo "Shutting down local slapd..."
208 echo "Configuring local slapd without translucent_no_glue..."
209 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF | \
210 grep -v translucent_no_glue > $CONF2
212 echo "Restarting local slapd on TCP/IP port $PORT2..."
213 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
215 if test $WAIT != 0 ; then
220 KILLPIDS="$REMOTEPID $PID"
224 for i in 0 1 2 3 4 5; do
225 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
226 'objectclass=*' > /dev/null 2>&1
228 if test $RC = 0 ; then
231 echo "Waiting 5 seconds for local slapd to start..."
235 if test $RC != 0 ; then
236 echo "ldapsearch failed ($RC)!"
237 test $KILLSERVERS != no && kill -HUP $KILLPIDS
241 echo "Testing add: valid local record..."
243 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI2 \
244 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
247 if test $RC != 0 ; then
248 echo "ldapadd failed ($RC)!"
249 grep "$FAILURE" $TESTOUT
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
254 echo "Testing search: data merging..."
256 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
259 if test $RC != 0 ; then
260 echo "ldapsearch failed ($RC)!"
261 test $KILLSERVERS != no && kill -HUP $KILLPIDS
265 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
266 $CMP $SEARCHFLT $LDIFTRANSLUCENTMERGED > $CMPOUT
268 if test $? != 0 ; then
269 echo "Comparison failed -- local data failed to merge with remote!"
270 test $KILLSERVERS != no && kill -HUP $KILLPIDS
274 echo "Testing compare: valid local..."
276 $LDAPCOMPARE -z -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
277 "uid=danger,ou=users,o=translucent" "carLicense:LIVID"
280 if test $RC != 6 ; then
281 echo "ldapcompare failed ($RC), expected TRUE!"
282 test $KILLSERVERS != no && kill -HUP $KILLPIDS
286 echo "Testing compare: valid remote..."
288 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
289 "uid=binder,o=translucent" "businessCategory:binder-test-user"
292 if test $RC != 6 ; then
293 echo "ldapcompare failed ($RC), expected TRUE!"
294 test $KILLSERVERS != no && kill -HUP $KILLPIDS
298 echo "Testing compare: bogus local..."
300 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
301 "uid=danger,ou=users,o=translucent" "businessCategory:invalid-test-value"
304 if test $RC != 5 ; then
305 echo "ldapcompare failed ($RC), expected FALSE!"
306 test $KILLSERVERS != no && kill -HUP $KILLPIDS
310 echo "Testing compare: bogus remote..."
312 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
313 "uid=binder,o=translucent" "businessCategory:invalid-test-value"
316 if test $RC != 5 ; then
317 echo "ldapcompare failed ($RC), expected FALSE!"
318 test $KILLSERVERS != no && kill -HUP $KILLPIDS
322 echo "Testing modify: nonexistent record..."
324 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
325 $TESTOUT 2>&1 << EOF_MOD
327 dn: uid=bogus,ou=users,o=translucent
334 if test $RC != 32 ; then
335 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
336 grep "$FAILURE" $TESTOUT
337 test $KILLSERVERS != no && kill -HUP $KILLPIDS
341 echo "Testing modify: valid local record, nonexistent attribute..."
343 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
344 $TESTOUT 2>&1 << EOF_MOD1
346 dn: uid=danger,ou=users,o=translucent
353 if test $RC != 0 ; then
354 echo "ldapmodify failed ($RC)!"
355 grep "$FAILURE" $TESTOUT
356 test $KILLSERVERS != no && kill -HUP $KILLPIDS
360 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" > $SEARCHOUT 2>&1
363 if test $RC != 0 ; then
364 echo "ldapsearch failed ($RC)!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
369 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
370 if test "$ATTR" != "roomNumber: 9N-21" ; then
371 echo "modification failed!"
372 test $KILLSERVERS != no && kill -HUP $KILLPIDS
376 echo "Testing search: specific nonexistent remote attribute..."
378 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" roomNumber > $SEARCHOUT 2>&1
381 if test $RC != 0 ; then
382 echo "ldapsearch failed ($RC)!"
383 test $KILLSERVERS != no && kill -HUP $KILLPIDS
387 echo "Testing modify: nonexistent local record, nonexistent attribute..."
389 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
390 $TESTOUT 2>&1 << EOF_MOD2
392 dn: uid=fred,ou=users,o=translucent
399 if test $RC != 0 ; then
400 echo "ldapmodify failed ($RC)!"
401 grep "$FAILURE" $TESTOUT
402 test $KILLSERVERS != no && kill -HUP $KILLPIDS
406 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
409 if test $RC != 0 ; then
410 echo "ldapsearch failed ($RC)!"
411 test $KILLSERVERS != no && kill -HUP $KILLPIDS
415 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
416 if test "$ATTR" != "roomNumber: 31J-2112" ; then
417 echo "modification failed!"
418 test $KILLSERVERS != no && kill -HUP $KILLPIDS
422 echo "Testing modify: valid remote record, nonexistent attribute..."
424 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
425 $TESTOUT 2>&1 << EOF_MOD9
427 dn: uid=fred,ou=users,o=translucent
429 delete: preferredLanguage
433 if test $RC != 16 ; then
434 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
435 grep "$FAILURE" $TESTOUT
436 test $KILLSERVERS != no && kill -HUP $KILLPIDS
440 echo "Testing delete: valid local record, nonexistent attribute..."
442 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
443 $TESTOUT 2>&1 << EOF_MOD4
445 dn: uid=fred,ou=users,o=translucent
451 if test $RC != 0 ; then
452 echo "ldapmodify failed ($RC)!"
453 grep "$FAILURE" $TESTOUT
454 test $KILLSERVERS != no && kill -HUP $KILLPIDS
458 echo "Testing modrdn: prohibited local record..."
460 $LDAPMODRDN -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
461 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
464 if test $RC != 50 ; then
465 echo "ldapmodrdn failed ($RC), expected INSUFFICIENT ACCESS!"
466 grep "$FAILURE" $TESTOUT
467 test $KILLSERVERS != no && kill -HUP $KILLPIDS
471 echo "Testing modrdn: valid local record..."
473 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
474 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
477 if test $RC != 0 ; then
478 echo "ldapmodrdn failed ($RC)!"
479 grep "$FAILURE" $TESTOUT
480 test $KILLSERVERS != no && kill -HUP $KILLPIDS
484 echo "Testing delete: prohibited local record..."
486 $LDAPMODIFY -v -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
487 $TESTOUT 2>&1 << EOF_DEL2
489 dn: uid=someguy,ou=users,o=translucent
494 if test $RC != 50 ; then
495 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
496 grep "$FAILURE" $TESTOUT
497 test $KILLSERVERS != no && kill -HUP $KILLPIDS
501 echo "Testing delete: valid local record..."
503 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
504 $TESTOUT 2>&1 << EOF_DEL3
506 dn: uid=someguy,ou=users,o=translucent
511 if test $RC != 0 ; then
512 echo "ldapmodify failed ($RC)!"
513 grep "$FAILURE" $TESTOUT
514 test $KILLSERVERS != no && kill -HUP $KILLPIDS
518 echo "Testing delete: valid remote record..."
520 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
521 $TESTOUT 2>&1 << EOF_DEL8
523 dn: uid=fred,ou=users,o=translucent
528 if test $RC != 32 ; then
529 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
530 grep "$FAILURE" $TESTOUT
531 test $KILLSERVERS != no && kill -HUP $KILLPIDS
535 echo "Testing delete: nonexistent local record, nonexistent attribute..."
537 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
538 $TESTOUT 2>&1 << EOF_DEL1
540 dn: uid=fred,ou=users,o=translucent
546 if test $RC != 0 ; then
547 echo "ldapmodify failed ($RC)!"
548 grep "$FAILURE" $TESTOUT
549 test $KILLSERVERS != no && kill -HUP $KILLPIDS
553 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
556 if test $RC != 0 ; then
557 echo "ldapsearch failed ($RC)!"
558 test $KILLSERVERS != no && kill -HUP $KILLPIDS
562 echo "Testing delete: valid local record, nonexistent attribute..."
564 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
565 $TESTOUT 2>&1 << EOF_MOD8
567 dn: uid=danger,ou=users,o=translucent
569 delete: preferredLanguage
573 if test $RC != 16 ; then
574 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
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 "Shutting down local slapd..."
631 echo "Configuring local slapd with translucent_strict..."
632 echo translucent_strict >> $CONF2
634 echo "Restarting slapd on TCP/IP port $PORT2..."
635 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
637 if test $WAIT != 0 ; then
642 KILLPIDS="$REMOTEPID $PID"
646 for i in 0 1 2 3 4 5; do
647 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
648 'objectclass=*' > /dev/null 2>&1
650 if test $RC = 0 ; then
653 echo "Waiting 5 seconds for local slapd to start..."
657 if test $RC != 0 ; then
658 echo "ldapsearch failed ($RC)!"
659 test $KILLSERVERS != no && kill -HUP $KILLPIDS
663 echo "Testing strict mode delete: nonexistent local attribute..."
665 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
666 $TESTOUT 2>&1 << EOF_MOD5
668 dn: uid=example,ou=users,o=translucent
670 delete: preferredLanguage
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 delete: nonexistent remote attribute..."
683 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
684 $TESTOUT 2>&1 << EOF_MOD3
686 dn: uid=danger,ou=users,o=translucent
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 strict mode modify: combination add-modify-delete..."
701 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
702 $TESTOUT 2>&1 << EOF_MOD6
704 dn: uid=example,ou=users,o=translucent
708 add: preferredLanguage
709 preferredLanguage: ISO8859-1
711 replace: employeeType
712 employeeType: consultant
716 if test $RC != 19 ; then
717 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
718 grep "$FAILURE" $TESTOUT
719 test $KILLSERVERS != no && kill -HUP $KILLPIDS
723 echo "Testing invalid Bind request..."
724 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w Wrong"$TRANSLUCENTPASSWD" > \
727 if test $RC != 49 ; then
728 echo "ldapwhoami failed ($RC), expected INVALID CREDENTIALS!"
729 grep "$FAILURE" $TESTOUT
730 test $KILLSERVERS != no && kill -HUP $KILLPIDS
734 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w "$TRANSLUCENTPASSWD" > \
737 if test $RC != 0 ; then
738 echo "ldapwhoami failed ($RC), expected SUCCESS!"
739 grep "$FAILURE" $TESTOUT
740 test $KILLSERVERS != no && kill -HUP $KILLPIDS
744 test $KILLSERVERS != no && kill -HUP $KILLPIDS
746 echo ">>>>> Test succeeded"
748 test $KILLSERVERS != no && wait