3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004 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, skipping"
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
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"
92 for i in 0 1 2 3 4 5; do
93 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
94 'objectclass=*' > /dev/null 2>&1
96 if test $RC = 0 ; then
99 echo "Waiting 5 seconds for local slapd to start..."
103 if test $RC != 0 ; then
104 echo "ldapsearch failed ($RC)!"
105 test $KILLSERVERS != no && kill -HUP $KILLPIDS
109 echo "Testing slapd Translucent Proxy operations..."
111 echo "Testing search: no remote data defined..."
113 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" >$SEARCHOUT 2>&1
116 if test $RC != 0 ; then
117 echo "ldapsearch failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
122 if test -s $SEARCHOUT; then
123 echo "ldapsearch should have returned no records!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 echo "Populating remote database..."
130 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI1 \
131 -w $PASSWD < $LDIFTRANSLUCENTDATA > $NOWHERE 2>&1
134 if test $RC != 0 ; then
135 echo "ldapadd failed ($RC)!"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 echo "Testing search: remote database via local slapd..."
142 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
145 if test $RC != 0 ; then
146 echo "ldapsearch failed ($RC)!"
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
152 . $LDIFFILTER < $LDIFTRANSLUCENTDATA > $LDIFFLT
153 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
155 if test $? != 0 ; then
156 echo "Comparison failed -- corruption from remote to local!"
157 test $KILLSERVERS != no && kill -HUP $KILLPIDS
161 echo "Testing add: prohibited local record..."
163 $LDAPADD -D "$TRANSLUCENTDN" -H $URI2 \
164 -w $TRANSLUCENTPASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
167 if test $RC != 50 ; then
168 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
169 grep "$FAILURE" $TESTOUT
170 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 echo "Testing add: valid local record, no_glue..."
176 $LDAPADD -v -v -v -D "$TRANSLUCENTROOT" -H $URI2 \
177 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
180 if test $RC != 32 ; then
181 echo "ldapadd failed ($RC), expected NO SUCH OBJECT!"
182 grep "$FAILURE" $TESTOUT
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
187 echo "Testing modrdn: valid local record, no_glue..."
189 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
190 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
193 if test $RC != 32 ; then
194 echo "ldapmodrdn failed ($RC), expected NO SUCH OBJECT!"
195 grep "$FAILURE" $TESTOUT
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
200 echo "Shutting down local slapd..."
204 echo "Configuring local slapd without translucent_no_glue..."
205 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF | \
206 grep -v translucent_no_glue > $CONF2
208 echo "Restarting local slapd on TCP/IP port $PORT2..."
209 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
211 if test $WAIT != 0 ; then
216 KILLPIDS="$REMOTEPID $PID"
218 for i in 0 1 2 3 4 5; do
219 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
220 'objectclass=*' > /dev/null 2>&1
222 if test $RC = 0 ; then
225 echo "Waiting 5 seconds for local slapd to start..."
229 if test $RC != 0 ; then
230 echo "ldapsearch failed ($RC)!"
231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
235 echo "Testing add: valid local record..."
237 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI2 \
238 -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
241 if test $RC != 0 ; then
242 echo "ldapadd failed ($RC)!"
243 grep "$FAILURE" $TESTOUT
244 test $KILLSERVERS != no && kill -HUP $KILLPIDS
248 echo "Testing search: data merging..."
250 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
253 if test $RC != 0 ; then
254 echo "ldapsearch failed ($RC)!"
255 test $KILLSERVERS != no && kill -HUP $KILLPIDS
259 $CMP $SEARCHOUT $LDIFTRANSLUCENTMERGED > $CMPOUT
261 if test $? != 0 ; then
262 echo "Comparison failed -- local data failed to merge with remote!"
263 test $KILLSERVERS != no && kill -HUP $KILLPIDS
267 echo "Testing compare: valid local..."
269 $LDAPCOMPARE -z -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
270 "uid=danger,ou=users,o=translucent" "carLicense:LIVID"
273 if test $RC != 6 ; then
274 echo "ldapcompare failed ($RC), expected TRUE!"
275 test $KILLSERVERS != no && kill -HUP $KILLPIDS
279 echo "Testing compare: valid remote..."
281 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
282 "uid=binder,o=translucent" "businessCategory:binder-test-user"
285 if test $RC != 6 ; then
286 echo "ldapcompare failed ($RC), expected TRUE!"
287 test $KILLSERVERS != no && kill -HUP $KILLPIDS
291 echo "Testing compare: bogus local..."
293 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
294 "uid=danger,ou=users,o=translucent" "businessCategory:invalid-test-value"
297 if test $RC != 5 ; then
298 echo "ldapcompare failed ($RC), expected FALSE!"
299 test $KILLSERVERS != no && kill -HUP $KILLPIDS
303 echo "Testing compare: bogus remote..."
305 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
306 "uid=binder,o=translucent" "businessCategory:invalid-test-value"
309 if test $RC != 5 ; then
310 echo "ldapcompare failed ($RC), expected FALSE!"
311 test $KILLSERVERS != no && kill -HUP $KILLPIDS
315 echo "Testing modify: nonexistent record..."
317 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
318 $TESTOUT 2>&1 << EOF_MOD
320 dn: uid=bogus,ou=users,o=translucent
327 if test $RC != 32 ; then
328 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
329 grep "$FAILURE" $TESTOUT
330 test $KILLSERVERS != no && kill -HUP $KILLPIDS
334 echo "Testing modify: valid local record, nonexistent attribute..."
336 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
337 $TESTOUT 2>&1 << EOF_MOD1
339 dn: uid=danger,ou=users,o=translucent
346 if test $RC != 0 ; then
347 echo "ldapmodify failed ($RC)!"
348 grep "$FAILURE" $TESTOUT
349 test $KILLSERVERS != no && kill -HUP $KILLPIDS
353 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" > $SEARCHOUT 2>&1
356 if test $RC != 0 ; then
357 echo "ldapsearch failed ($RC)!"
358 test $KILLSERVERS != no && kill -HUP $KILLPIDS
362 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
363 if test "$ATTR" != "roomNumber: 9N-21" ; then
364 echo "modification failed!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
369 echo "Testing search: specific nonexistent remote attribute..."
371 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" roomNumber > $SEARCHOUT 2>&1
374 if test $RC != 0 ; then
375 echo "ldapsearch failed ($RC)!"
376 test $KILLSERVERS != no && kill -HUP $KILLPIDS
380 echo "Testing modify: nonexistent local record, nonexistent attribute..."
382 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
383 $TESTOUT 2>&1 << EOF_MOD2
385 dn: uid=fred,ou=users,o=translucent
392 if test $RC != 0 ; then
393 echo "ldapmodify failed ($RC)!"
394 grep "$FAILURE" $TESTOUT
395 test $KILLSERVERS != no && kill -HUP $KILLPIDS
399 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
402 if test $RC != 0 ; then
403 echo "ldapsearch failed ($RC)!"
404 test $KILLSERVERS != no && kill -HUP $KILLPIDS
408 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
409 if test "$ATTR" != "roomNumber: 31J-2112" ; then
410 echo "modification failed!"
411 test $KILLSERVERS != no && kill -HUP $KILLPIDS
415 echo "Testing modify: valid remote record, nonexistent attribute..."
417 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
418 $TESTOUT 2>&1 << EOF_MOD9
420 dn: uid=fred,ou=users,o=translucent
422 delete: preferredLanguage
426 if test $RC != 16 ; then
427 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
428 grep "$FAILURE" $TESTOUT
429 test $KILLSERVERS != no && kill -HUP $KILLPIDS
433 echo "Testing delete: valid local record, nonexistent attribute..."
435 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
436 $TESTOUT 2>&1 << EOF_MOD4
438 dn: uid=fred,ou=users,o=translucent
444 if test $RC != 0 ; then
445 echo "ldapmodify failed ($RC)!"
446 grep "$FAILURE" $TESTOUT
447 test $KILLSERVERS != no && kill -HUP $KILLPIDS
451 echo "Testing modrdn: prohibited local record..."
453 $LDAPMODRDN -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
454 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
457 if test $RC != 50 ; then
458 echo "ldapmodrdn failed ($RC), expected INSUFFICIENT ACCESS!"
459 grep "$FAILURE" $TESTOUT
460 test $KILLSERVERS != no && kill -HUP $KILLPIDS
464 echo "Testing modrdn: valid local record..."
466 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
467 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
470 if test $RC != 0 ; then
471 echo "ldapmodrdn failed ($RC)!"
472 grep "$FAILURE" $TESTOUT
473 test $KILLSERVERS != no && kill -HUP $KILLPIDS
477 echo "Testing delete: prohibited local record..."
479 $LDAPMODIFY -v -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
480 $TESTOUT 2>&1 << EOF_DEL2
482 dn: uid=someguy,ou=users,o=translucent
487 if test $RC != 50 ; then
488 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
489 grep "$FAILURE" $TESTOUT
490 test $KILLSERVERS != no && kill -HUP $KILLPIDS
494 echo "Testing delete: valid local record..."
496 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
497 $TESTOUT 2>&1 << EOF_DEL3
499 dn: uid=someguy,ou=users,o=translucent
504 if test $RC != 0 ; then
505 echo "ldapmodify failed ($RC)!"
506 grep "$FAILURE" $TESTOUT
507 test $KILLSERVERS != no && kill -HUP $KILLPIDS
511 echo "Testing delete: valid remote record..."
513 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
514 $TESTOUT 2>&1 << EOF_DEL8
516 dn: uid=fred,ou=users,o=translucent
521 if test $RC != 32 ; then
522 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
523 grep "$FAILURE" $TESTOUT
524 test $KILLSERVERS != no && kill -HUP $KILLPIDS
528 echo "Testing delete: nonexistent local record, nonexistent attribute..."
530 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
531 $TESTOUT 2>&1 << EOF_DEL1
533 dn: uid=fred,ou=users,o=translucent
539 if test $RC != 0 ; then
540 echo "ldapmodify failed ($RC)!"
541 grep "$FAILURE" $TESTOUT
542 test $KILLSERVERS != no && kill -HUP $KILLPIDS
546 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
549 if test $RC != 0 ; then
550 echo "ldapsearch failed ($RC)!"
551 test $KILLSERVERS != no && kill -HUP $KILLPIDS
555 echo "Testing delete: valid local record, nonexistent attribute..."
557 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
558 $TESTOUT 2>&1 << EOF_MOD8
560 dn: uid=danger,ou=users,o=translucent
562 delete: preferredLanguage
566 if test $RC != 16 ; then
567 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
568 grep "$FAILURE" $TESTOUT
569 test $KILLSERVERS != no && kill -HUP $KILLPIDS
573 echo "Testing modify: valid remote record, combination add-modify-delete..."
575 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
576 $TESTOUT 2>&1 << EOF_MOD6
578 dn: uid=fred,ou=users,o=translucent
582 add: preferredLanguage
583 preferredLanguage: ISO8859-1
585 replace: employeeType
586 employeeType: consultant
590 if test $RC != 0 ; then
591 echo "ldapmodify failed ($RC)!"
592 grep "$FAILURE" $TESTOUT
593 test $KILLSERVERS != no && kill -HUP $KILLPIDS
597 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
600 if test $RC != 0 ; then
601 echo "ldapsearch failed ($RC)!"
602 test $KILLSERVERS != no && kill -HUP $KILLPIDS
606 ATTR=`grep employeeType $SEARCHOUT` > $NOWHERE 2>&1
607 if test "$ATTR" != "employeeType: consultant" ; then
608 echo "modification failed!"
609 test $KILLSERVERS != no && kill -HUP $KILLPIDS
613 ATTR=`grep preferredLanguage $SEARCHOUT` > $NOWHERE 2>&1
614 if test "$ATTR" != "preferredLanguage: ISO8859-1" ; then
615 echo "modification failed!"
616 test $KILLSERVERS != no && kill -HUP $KILLPIDS
620 echo "Shutting down local slapd..."
624 echo "Configuring local slapd with translucent_strict..."
625 echo translucent_strict >> $CONF2
627 echo "Restarting slapd on TCP/IP port $PORT2..."
628 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
630 if test $WAIT != 0 ; then
635 KILLPIDS="$REMOTEPID $PID"
637 for i in 0 1 2 3 4 5; do
638 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
639 'objectclass=*' > /dev/null 2>&1
641 if test $RC = 0 ; then
644 echo "Waiting 5 seconds for local slapd to start..."
648 if test $RC != 0 ; then
649 echo "ldapsearch failed ($RC)!"
650 test $KILLSERVERS != no && kill -HUP $KILLPIDS
654 echo "Testing strict mode delete: nonexistent local attribute..."
656 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
657 $TESTOUT 2>&1 << EOF_MOD5
659 dn: uid=example,ou=users,o=translucent
661 delete: preferredLanguage
665 if test $RC != 19 ; then
666 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
667 grep "$FAILURE" $TESTOUT
668 test $KILLSERVERS != no && kill -HUP $KILLPIDS
672 echo "Testing strict mode delete: nonexistent remote attribute..."
674 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
675 $TESTOUT 2>&1 << EOF_MOD3
677 dn: uid=danger,ou=users,o=translucent
683 if test $RC != 19 ; then
684 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
685 grep "$FAILURE" $TESTOUT
686 test $KILLSERVERS != no && kill -HUP $KILLPIDS
690 echo "Testing strict mode modify: combination add-modify-delete..."
692 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
693 $TESTOUT 2>&1 << EOF_MOD6
695 dn: uid=example,ou=users,o=translucent
699 add: preferredLanguage
700 preferredLanguage: ISO8859-1
702 replace: employeeType
703 employeeType: consultant
707 if test $RC != 19 ; then
708 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
709 grep "$FAILURE" $TESTOUT
710 test $KILLSERVERS != no && kill -HUP $KILLPIDS
714 test $KILLSERVERS != no && kill -HUP $KILLPIDS
716 echo ">>>>> Test succeeded"