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 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
260 $CMP $SEARCHFLT $LDIFTRANSLUCENTMERGED > $CMPOUT
262 if test $? != 0 ; then
263 echo "Comparison failed -- local data failed to merge with remote!"
264 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 echo "Testing compare: valid local..."
270 $LDAPCOMPARE -z -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
271 "uid=danger,ou=users,o=translucent" "carLicense:LIVID"
274 if test $RC != 6 ; then
275 echo "ldapcompare failed ($RC), expected TRUE!"
276 test $KILLSERVERS != no && kill -HUP $KILLPIDS
280 echo "Testing compare: valid remote..."
282 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
283 "uid=binder,o=translucent" "businessCategory:binder-test-user"
286 if test $RC != 6 ; then
287 echo "ldapcompare failed ($RC), expected TRUE!"
288 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 echo "Testing compare: bogus local..."
294 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
295 "uid=danger,ou=users,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 compare: bogus remote..."
306 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
307 "uid=binder,o=translucent" "businessCategory:invalid-test-value"
310 if test $RC != 5 ; then
311 echo "ldapcompare failed ($RC), expected FALSE!"
312 test $KILLSERVERS != no && kill -HUP $KILLPIDS
316 echo "Testing modify: nonexistent record..."
318 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
319 $TESTOUT 2>&1 << EOF_MOD
321 dn: uid=bogus,ou=users,o=translucent
328 if test $RC != 32 ; then
329 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
330 grep "$FAILURE" $TESTOUT
331 test $KILLSERVERS != no && kill -HUP $KILLPIDS
335 echo "Testing modify: valid local record, nonexistent attribute..."
337 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
338 $TESTOUT 2>&1 << EOF_MOD1
340 dn: uid=danger,ou=users,o=translucent
347 if test $RC != 0 ; then
348 echo "ldapmodify failed ($RC)!"
349 grep "$FAILURE" $TESTOUT
350 test $KILLSERVERS != no && kill -HUP $KILLPIDS
354 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" > $SEARCHOUT 2>&1
357 if test $RC != 0 ; then
358 echo "ldapsearch failed ($RC)!"
359 test $KILLSERVERS != no && kill -HUP $KILLPIDS
363 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
364 if test "$ATTR" != "roomNumber: 9N-21" ; then
365 echo "modification failed!"
366 test $KILLSERVERS != no && kill -HUP $KILLPIDS
370 echo "Testing search: specific nonexistent remote attribute..."
372 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" roomNumber > $SEARCHOUT 2>&1
375 if test $RC != 0 ; then
376 echo "ldapsearch failed ($RC)!"
377 test $KILLSERVERS != no && kill -HUP $KILLPIDS
381 echo "Testing modify: nonexistent local record, nonexistent attribute..."
383 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
384 $TESTOUT 2>&1 << EOF_MOD2
386 dn: uid=fred,ou=users,o=translucent
393 if test $RC != 0 ; then
394 echo "ldapmodify failed ($RC)!"
395 grep "$FAILURE" $TESTOUT
396 test $KILLSERVERS != no && kill -HUP $KILLPIDS
400 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
403 if test $RC != 0 ; then
404 echo "ldapsearch failed ($RC)!"
405 test $KILLSERVERS != no && kill -HUP $KILLPIDS
409 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
410 if test "$ATTR" != "roomNumber: 31J-2112" ; then
411 echo "modification failed!"
412 test $KILLSERVERS != no && kill -HUP $KILLPIDS
416 echo "Testing modify: valid remote record, nonexistent attribute..."
418 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
419 $TESTOUT 2>&1 << EOF_MOD9
421 dn: uid=fred,ou=users,o=translucent
423 delete: preferredLanguage
427 if test $RC != 16 ; then
428 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
429 grep "$FAILURE" $TESTOUT
430 test $KILLSERVERS != no && kill -HUP $KILLPIDS
434 echo "Testing delete: valid local record, nonexistent attribute..."
436 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
437 $TESTOUT 2>&1 << EOF_MOD4
439 dn: uid=fred,ou=users,o=translucent
445 if test $RC != 0 ; then
446 echo "ldapmodify failed ($RC)!"
447 grep "$FAILURE" $TESTOUT
448 test $KILLSERVERS != no && kill -HUP $KILLPIDS
452 echo "Testing modrdn: prohibited local record..."
454 $LDAPMODRDN -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
455 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
458 if test $RC != 50 ; then
459 echo "ldapmodrdn failed ($RC), expected INSUFFICIENT ACCESS!"
460 grep "$FAILURE" $TESTOUT
461 test $KILLSERVERS != no && kill -HUP $KILLPIDS
465 echo "Testing modrdn: valid local record..."
467 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
468 $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
471 if test $RC != 0 ; then
472 echo "ldapmodrdn failed ($RC)!"
473 grep "$FAILURE" $TESTOUT
474 test $KILLSERVERS != no && kill -HUP $KILLPIDS
478 echo "Testing delete: prohibited local record..."
480 $LDAPMODIFY -v -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
481 $TESTOUT 2>&1 << EOF_DEL2
483 dn: uid=someguy,ou=users,o=translucent
488 if test $RC != 50 ; then
489 echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
490 grep "$FAILURE" $TESTOUT
491 test $KILLSERVERS != no && kill -HUP $KILLPIDS
495 echo "Testing delete: valid local record..."
497 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
498 $TESTOUT 2>&1 << EOF_DEL3
500 dn: uid=someguy,ou=users,o=translucent
505 if test $RC != 0 ; then
506 echo "ldapmodify failed ($RC)!"
507 grep "$FAILURE" $TESTOUT
508 test $KILLSERVERS != no && kill -HUP $KILLPIDS
512 echo "Testing delete: valid remote record..."
514 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
515 $TESTOUT 2>&1 << EOF_DEL8
517 dn: uid=fred,ou=users,o=translucent
522 if test $RC != 32 ; then
523 echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
524 grep "$FAILURE" $TESTOUT
525 test $KILLSERVERS != no && kill -HUP $KILLPIDS
529 echo "Testing delete: nonexistent local record, nonexistent attribute..."
531 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
532 $TESTOUT 2>&1 << EOF_DEL1
534 dn: uid=fred,ou=users,o=translucent
540 if test $RC != 0 ; then
541 echo "ldapmodify failed ($RC)!"
542 grep "$FAILURE" $TESTOUT
543 test $KILLSERVERS != no && kill -HUP $KILLPIDS
547 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
550 if test $RC != 0 ; then
551 echo "ldapsearch failed ($RC)!"
552 test $KILLSERVERS != no && kill -HUP $KILLPIDS
556 echo "Testing delete: valid local record, nonexistent attribute..."
558 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
559 $TESTOUT 2>&1 << EOF_MOD8
561 dn: uid=danger,ou=users,o=translucent
563 delete: preferredLanguage
567 if test $RC != 16 ; then
568 echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
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 "Shutting down local slapd..."
625 echo "Configuring local slapd with translucent_strict..."
626 echo translucent_strict >> $CONF2
628 echo "Restarting slapd on TCP/IP port $PORT2..."
629 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
631 if test $WAIT != 0 ; then
636 KILLPIDS="$REMOTEPID $PID"
638 for i in 0 1 2 3 4 5; do
639 $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
640 'objectclass=*' > /dev/null 2>&1
642 if test $RC = 0 ; then
645 echo "Waiting 5 seconds for local slapd to start..."
649 if test $RC != 0 ; then
650 echo "ldapsearch failed ($RC)!"
651 test $KILLSERVERS != no && kill -HUP $KILLPIDS
655 echo "Testing strict mode delete: nonexistent local attribute..."
657 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
658 $TESTOUT 2>&1 << EOF_MOD5
660 dn: uid=example,ou=users,o=translucent
662 delete: preferredLanguage
666 if test $RC != 19 ; then
667 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
668 grep "$FAILURE" $TESTOUT
669 test $KILLSERVERS != no && kill -HUP $KILLPIDS
673 echo "Testing strict mode delete: nonexistent remote attribute..."
675 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
676 $TESTOUT 2>&1 << EOF_MOD3
678 dn: uid=danger,ou=users,o=translucent
684 if test $RC != 19 ; then
685 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
686 grep "$FAILURE" $TESTOUT
687 test $KILLSERVERS != no && kill -HUP $KILLPIDS
691 echo "Testing strict mode modify: combination add-modify-delete..."
693 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
694 $TESTOUT 2>&1 << EOF_MOD6
696 dn: uid=example,ou=users,o=translucent
700 add: preferredLanguage
701 preferredLanguage: ISO8859-1
703 replace: employeeType
704 employeeType: consultant
708 if test $RC != 19 ; then
709 echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
710 grep "$FAILURE" $TESTOUT
711 test $KILLSERVERS != no && kill -HUP $KILLPIDS
715 test $KILLSERVERS != no && kill -HUP $KILLPIDS
717 echo ">>>>> Test succeeded"