]> git.sur5r.net Git - openldap/blob - tests/scripts/test034-translucent
75ba8298687815faad611dfabbf335c736f79082
[openldap] / tests / scripts / test034-translucent
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 2004-2006 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 PERSONAL="(objectClass=inetOrgPerson)"
20 NOWHERE="/dev/null"
21 FAILURE="additional info:"
22
23 if test $TRANSLUCENT = translucentno ; then 
24         echo "Translucent Proxy overlay not available, test skipped"
25         exit 0
26 fi 
27
28 if test $AC_ldap = ldapno ; then
29         echo "Translucent Proxy overlay requires back-ldap backend, test skipped"
30         exit 0
31 fi
32
33 # configure backside
34 mkdir -p $TESTDIR $DBDIR1
35
36 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTREMOTECONF > $CONF1
37 echo "Running slapadd to build remote slapd database..."
38 $SLAPADD -f $CONF1 -l $LDIFTRANSLUCENTCONFIG
39 RC=$?
40 if test $RC != 0 ; then
41         echo "slapadd failed ($RC)!"
42         exit $RC
43 fi
44
45 echo "Starting remote slapd on TCP/IP port $PORT1..."
46 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
47 PID=$!
48 if test $WAIT != 0 ; then
49     echo PID $PID
50     read foo
51 fi
52 REMOTEPID="$PID"
53 KILLPIDS="$PID"
54
55 sleep 1
56
57 for i in 0 1 2 3 4 5; do
58         $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
59                 'objectclass=*' > /dev/null 2>&1
60         RC=$?
61         if test $RC = 0 ; then
62                 break
63         fi
64         echo "Waiting 5 seconds for remote slapd to start..."
65         sleep 5
66 done
67
68 if test $RC != 0 ; then
69         echo "ldapsearch failed ($RC)!"
70         test $KILLSERVERS != no && kill -HUP $KILLPIDS
71         exit $RC
72 fi
73
74 # configure frontside
75 mkdir -p $DBDIR2
76
77 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF > $CONF2
78
79 echo "Starting local slapd on TCP/IP port $PORT2..."
80 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
81 PID=$!
82 if test $WAIT != 0 ; then
83     echo PID $PID
84     read foo
85 fi
86 LOCALPID="$PID"
87 KILLPIDS="$LOCALPID $REMOTEPID"
88
89 sleep 1
90
91 for i in 0 1 2 3 4 5; do
92         $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
93                 'objectclass=*' > /dev/null 2>&1
94         RC=$?
95         if test $RC = 0 ; then
96                 break
97         fi
98         echo "Waiting 5 seconds for local slapd to start..."
99         sleep 5
100 done
101
102 if test $RC != 0 ; then
103         echo "ldapsearch failed ($RC)!"
104         test $KILLSERVERS != no && kill -HUP $KILLPIDS
105         exit $RC
106 fi
107
108 echo "Testing slapd Translucent Proxy operations..."
109
110 echo "Testing search: no remote data defined..."
111
112 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" >$SEARCHOUT 2>&1
113
114 RC=$?
115 if test $RC != 0 ; then
116         echo "ldapsearch failed ($RC)!"
117         test $KILLSERVERS != no && kill -HUP $KILLPIDS
118         exit $RC
119 fi
120
121 if test -s $SEARCHOUT; then
122         echo "ldapsearch should have returned no records!"
123         test $KILLSERVERS != no && kill -HUP $KILLPIDS
124         exit 1
125 fi
126
127 echo "Populating remote database..."
128
129 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI1 \
130         -w $PASSWD < $LDIFTRANSLUCENTDATA > $NOWHERE 2>&1
131
132 RC=$?
133 if test $RC != 0 ; then
134         echo "ldapadd failed ($RC)!"
135         test $KILLSERVERS != no && kill -HUP $KILLPIDS
136         exit $RC
137 fi
138
139 echo "Testing search: remote database via local slapd..."
140
141 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
142
143 RC=$?
144 if test $RC != 0 ; then
145         echo "ldapsearch failed ($RC)!"
146         test $KILLSERVERS != no && kill -HUP $KILLPIDS
147         exit $RC
148 fi
149
150 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
151 . $LDIFFILTER < $LDIFTRANSLUCENTDATA > $LDIFFLT
152 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
153
154 if test $? != 0 ; then
155         echo "Comparison failed -- corruption from remote to local!"
156         test $KILLSERVERS != no && kill -HUP $KILLPIDS
157         exit 1
158 fi
159
160 echo "Testing add: prohibited local record..."
161
162 $LDAPADD -D "$TRANSLUCENTDN" -H $URI2 \
163         -w $TRANSLUCENTPASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
164
165 RC=$?
166 if test $RC != 50 ; then
167         echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
168         grep "$FAILURE" $TESTOUT
169         test $KILLSERVERS != no && kill -HUP $KILLPIDS
170         exit 1
171 fi
172
173 echo "Testing add: valid local record, no_glue..."
174
175 $LDAPADD -v -v -v -D "$TRANSLUCENTROOT" -H $URI2 \
176         -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
177
178 RC=$?
179 if test $RC != 32 ; then
180         echo "ldapadd failed ($RC), expected NO SUCH OBJECT!"
181         grep "$FAILURE" $TESTOUT
182         test $KILLSERVERS != no && kill -HUP $KILLPIDS
183         exit 1
184 fi
185
186 echo "Testing modrdn: valid local record, no_glue..."
187
188 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
189         $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
190
191 RC=$?
192 if test $RC != 32 ; then
193         echo "ldapmodrdn failed ($RC), expected NO SUCH OBJECT!"
194         grep "$FAILURE" $TESTOUT
195         test $KILLSERVERS != no && kill -HUP $KILLPIDS
196         exit 1
197 fi
198
199 echo "Shutting down local slapd..."
200 kill -HUP $LOCALPID
201 wait $LOCALPID
202
203 echo "Configuring local slapd without translucent_no_glue..."
204 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF | \
205         grep -v translucent_no_glue > $CONF2
206
207 echo "Restarting local slapd on TCP/IP port $PORT2..."
208 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
209 PID=$!
210 if test $WAIT != 0 ; then
211     echo PID $PID
212     read foo
213 fi
214 LOCALPID="$PID"
215 KILLPIDS="$REMOTEPID $PID"
216
217 sleep 1
218
219 for i in 0 1 2 3 4 5; do
220         $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
221                 'objectclass=*' > /dev/null 2>&1
222         RC=$?
223         if test $RC = 0 ; then
224                 break
225         fi
226         echo "Waiting 5 seconds for local slapd to start..."
227         sleep 5
228 done
229
230 if test $RC != 0 ; then
231         echo "ldapsearch failed ($RC)!"
232         test $KILLSERVERS != no && kill -HUP $KILLPIDS
233         exit $RC
234 fi
235
236 echo "Testing add: valid local record..."
237
238 $LDAPADD -D "$TRANSLUCENTROOT" -H $URI2 \
239         -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
240
241 RC=$?
242 if test $RC != 0 ; then
243         echo "ldapadd failed ($RC)!"
244         grep "$FAILURE" $TESTOUT
245         test $KILLSERVERS != no && kill -HUP $KILLPIDS
246         exit $RC
247 fi
248
249 echo "Testing search: data merging..."
250
251 $LDAPSEARCH -H $URI2 -b "$TRANSLUCENTUSER" "$PERSONAL" > $SEARCHOUT 2>&1
252
253 RC=$?
254 if test $RC != 0 ; then
255         echo "ldapsearch failed ($RC)!"
256         test $KILLSERVERS != no && kill -HUP $KILLPIDS
257         exit $RC
258 fi
259
260 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
261 $CMP $SEARCHFLT $LDIFTRANSLUCENTMERGED > $CMPOUT
262
263 if test $? != 0 ; then
264         echo "Comparison failed -- local data failed to merge with remote!"
265         test $KILLSERVERS != no && kill -HUP $KILLPIDS
266         exit 1
267 fi
268
269 echo "Testing compare: valid local..."
270
271 $LDAPCOMPARE -z -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
272         "uid=danger,ou=users,o=translucent" "carLicense:LIVID"
273
274 RC=$?
275 if test $RC != 6 ; then
276         echo "ldapcompare failed ($RC), expected TRUE!"
277         test $KILLSERVERS != no && kill -HUP $KILLPIDS
278         exit 1
279 fi
280
281 echo "Testing compare: valid remote..."
282
283 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
284         "uid=binder,o=translucent" "businessCategory:binder-test-user"
285
286 RC=$?
287 if test $RC != 6 ; then
288         echo "ldapcompare failed ($RC), expected TRUE!"
289         test $KILLSERVERS != no && kill -HUP $KILLPIDS
290         exit 1
291 fi
292
293 echo "Testing compare: bogus local..."
294
295 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
296         "uid=danger,ou=users,o=translucent" "businessCategory:invalid-test-value"
297
298 RC=$?
299 if test $RC != 5 ; then
300         echo "ldapcompare failed ($RC), expected FALSE!"
301         test $KILLSERVERS != no && kill -HUP $KILLPIDS
302         exit 1
303 fi
304
305 echo "Testing compare: bogus remote..."
306
307 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
308         "uid=binder,o=translucent" "businessCategory:invalid-test-value"
309
310 RC=$?
311 if test $RC != 5 ; then
312         echo "ldapcompare failed ($RC), expected FALSE!"
313         test $KILLSERVERS != no && kill -HUP $KILLPIDS
314         exit 1
315 fi
316
317 echo "Testing modify: nonexistent record..."
318
319 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
320         $TESTOUT 2>&1 << EOF_MOD
321 version: 1
322 dn: uid=bogus,ou=users,o=translucent
323 changetype: modify
324 replace: roomNumber
325 roomNumber: 31J-2112
326 EOF_MOD
327
328 RC=$?
329 if test $RC != 32 ; then
330         echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
331         grep "$FAILURE" $TESTOUT
332         test $KILLSERVERS != no && kill -HUP $KILLPIDS
333         exit 1
334 fi
335
336 echo "Testing modify: valid local record, nonexistent attribute..."
337
338 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
339         $TESTOUT 2>&1 << EOF_MOD1
340 version: 1
341 dn: uid=danger,ou=users,o=translucent
342 changetype: modify
343 replace: roomNumber
344 roomNumber: 9N-21
345 EOF_MOD1
346
347 RC=$?
348 if test $RC != 0 ; then
349         echo "ldapmodify failed ($RC)!"
350         grep "$FAILURE" $TESTOUT
351         test $KILLSERVERS != no && kill -HUP $KILLPIDS
352         exit $RC
353 fi
354
355 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" > $SEARCHOUT 2>&1
356
357 RC=$?
358 if test $RC != 0 ; then
359         echo "ldapsearch failed ($RC)!"
360         test $KILLSERVERS != no && kill -HUP $KILLPIDS
361         exit $RC
362 fi
363
364 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
365 if test "$ATTR" != "roomNumber: 9N-21" ; then
366         echo "modification failed!"
367         test $KILLSERVERS != no && kill -HUP $KILLPIDS
368         exit 1
369 fi
370
371 echo "Testing search: specific nonexistent remote attribute..."
372
373 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" roomNumber > $SEARCHOUT 2>&1
374
375 RC=$?
376 if test $RC != 0 ; then
377         echo "ldapsearch failed ($RC)!"
378         test $KILLSERVERS != no && kill -HUP $KILLPIDS
379         exit $RC
380 fi
381
382 echo "Testing modify: nonexistent local record, nonexistent attribute..."
383
384 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
385         $TESTOUT 2>&1 << EOF_MOD2
386 version: 1
387 dn: uid=fred,ou=users,o=translucent
388 changetype: modify
389 replace: roomNumber
390 roomNumber: 31J-2112
391 EOF_MOD2
392
393 RC=$?
394 if test $RC != 0 ; then
395         echo "ldapmodify failed ($RC)!"
396         grep "$FAILURE" $TESTOUT
397         test $KILLSERVERS != no && kill -HUP $KILLPIDS
398         exit $RC
399 fi
400
401 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
402
403 RC=$?
404 if test $RC != 0 ; then
405         echo "ldapsearch failed ($RC)!"
406         test $KILLSERVERS != no && kill -HUP $KILLPIDS
407         exit $RC
408 fi
409
410 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
411 if test "$ATTR" != "roomNumber: 31J-2112" ; then
412         echo "modification failed!"
413         test $KILLSERVERS != no && kill -HUP $KILLPIDS
414         exit 1
415 fi
416
417 echo "Testing modify: valid remote record, nonexistent attribute..."
418
419 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
420         $TESTOUT 2>&1 << EOF_MOD9
421 version: 1
422 dn: uid=fred,ou=users,o=translucent
423 changetype: modify
424 delete: preferredLanguage
425 EOF_MOD9
426
427 RC=$?
428 if test $RC != 16 ; then
429         echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
430         grep "$FAILURE" $TESTOUT
431         test $KILLSERVERS != no && kill -HUP $KILLPIDS
432         exit 1
433 fi
434
435 echo "Testing delete: valid local record, nonexistent attribute..."
436
437 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
438         $TESTOUT 2>&1 << EOF_MOD4
439 version: 1
440 dn: uid=fred,ou=users,o=translucent
441 changetype: modify
442 delete: roomNumber
443 EOF_MOD4
444
445 RC=$?
446 if test $RC != 0 ; then
447         echo "ldapmodify failed ($RC)!"
448         grep "$FAILURE" $TESTOUT
449         test $KILLSERVERS != no && kill -HUP $KILLPIDS
450         exit $RC
451 fi
452
453 echo "Testing modrdn: prohibited local record..."
454
455 $LDAPMODRDN -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
456         $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
457
458 RC=$?
459 if test $RC != 50 ; then
460         echo "ldapmodrdn failed ($RC), expected INSUFFICIENT ACCESS!"
461         grep "$FAILURE" $TESTOUT
462         test $KILLSERVERS != no && kill -HUP $KILLPIDS
463         exit 1
464 fi
465
466 echo "Testing modrdn: valid local record..."
467
468 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
469         $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
470
471 RC=$?
472 if test $RC != 0 ; then
473         echo "ldapmodrdn failed ($RC)!"
474         grep "$FAILURE" $TESTOUT
475         test $KILLSERVERS != no && kill -HUP $KILLPIDS
476         exit $RC
477 fi
478
479 echo "Testing delete: prohibited local record..."
480
481 $LDAPMODIFY -v -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
482         $TESTOUT 2>&1 << EOF_DEL2
483 version: 1
484 dn: uid=someguy,ou=users,o=translucent
485 changetype: delete
486 EOF_DEL2
487
488 RC=$?
489 if test $RC != 50 ; then
490         echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
491         grep "$FAILURE" $TESTOUT
492         test $KILLSERVERS != no && kill -HUP $KILLPIDS
493         exit 1
494 fi
495
496 echo "Testing delete: valid local record..."
497
498 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
499         $TESTOUT 2>&1 << EOF_DEL3
500 version: 1
501 dn: uid=someguy,ou=users,o=translucent
502 changetype: delete
503 EOF_DEL3
504
505 RC=$?
506 if test $RC != 0 ; then
507         echo "ldapmodify failed ($RC)!"
508         grep "$FAILURE" $TESTOUT
509         test $KILLSERVERS != no && kill -HUP $KILLPIDS
510         exit $RC
511 fi
512
513 echo "Testing delete: valid remote record..."
514
515 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
516         $TESTOUT 2>&1 << EOF_DEL8
517 version: 1
518 dn: uid=fred,ou=users,o=translucent
519 changetype: delete
520 EOF_DEL8
521
522 RC=$?
523 if test $RC != 32 ; then
524         echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
525         grep "$FAILURE" $TESTOUT
526         test $KILLSERVERS != no && kill -HUP $KILLPIDS
527         exit 1
528 fi
529
530 echo "Testing delete: nonexistent local record, nonexistent attribute..."
531
532 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
533         $TESTOUT 2>&1 << EOF_DEL1
534 version: 1
535 dn: uid=fred,ou=users,o=translucent
536 changetype: modify
537 delete: roomNumber
538 EOF_DEL1
539
540 RC=$?
541 if test $RC != 0 ; then
542         echo "ldapmodify failed ($RC)!"
543         grep "$FAILURE" $TESTOUT
544         test $KILLSERVERS != no && kill -HUP $KILLPIDS
545         exit $RC
546 fi
547
548 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
549
550 RC=$?
551 if test $RC != 0 ; then
552         echo "ldapsearch failed ($RC)!"
553         test $KILLSERVERS != no && kill -HUP $KILLPIDS
554         exit $RC
555 fi
556
557 echo "Testing delete: valid local record, nonexistent attribute..."
558
559 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
560         $TESTOUT 2>&1 << EOF_MOD8
561 version: 1
562 dn: uid=danger,ou=users,o=translucent
563 changetype: modify
564 delete: preferredLanguage
565 EOF_MOD8
566
567 RC=$?
568 if test $RC != 16 ; then
569         echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
570         grep "$FAILURE" $TESTOUT
571         test $KILLSERVERS != no && kill -HUP $KILLPIDS
572         exit 1
573 fi
574
575 echo "Testing modify: valid remote record, combination add-modify-delete..."
576
577 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
578         $TESTOUT 2>&1 << EOF_MOD6
579 version: 1
580 dn: uid=fred,ou=users,o=translucent
581 changetype: modify
582 delete: carLicense
583 -
584 add: preferredLanguage
585 preferredLanguage: ISO8859-1
586 -
587 replace: employeeType
588 employeeType: consultant
589 EOF_MOD6
590
591 RC=$?
592 if test $RC != 0 ; then
593         echo "ldapmodify failed ($RC)!"
594         grep "$FAILURE" $TESTOUT
595         test $KILLSERVERS != no && kill -HUP $KILLPIDS
596         exit $RC
597 fi
598
599 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
600
601 RC=$?
602 if test $RC != 0 ; then
603         echo "ldapsearch failed ($RC)!"
604         test $KILLSERVERS != no && kill -HUP $KILLPIDS
605         exit $RC
606 fi
607
608 ATTR=`grep employeeType $SEARCHOUT` > $NOWHERE 2>&1
609 if test "$ATTR" != "employeeType: consultant" ; then
610         echo "modification failed!"
611         test $KILLSERVERS != no && kill -HUP $KILLPIDS
612         exit 1
613 fi
614
615 ATTR=`grep preferredLanguage $SEARCHOUT` > $NOWHERE 2>&1
616 if test "$ATTR" != "preferredLanguage: ISO8859-1" ; then
617         echo "modification failed!"
618         test $KILLSERVERS != no && kill -HUP $KILLPIDS
619         exit 1
620 fi
621
622 echo "Shutting down local slapd..."
623 kill -HUP $LOCALPID
624 wait $LOCALPID
625
626 echo "Configuring local slapd with translucent_strict..."
627 echo translucent_strict >> $CONF2
628
629 echo "Restarting slapd on TCP/IP port $PORT2..."
630 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING >> $LOG2 2>&1 &
631 PID=$!
632 if test $WAIT != 0 ; then
633     echo PID $PID
634     read foo
635 fi
636 LOCALPID="$PID"
637 KILLPIDS="$REMOTEPID $PID"
638
639 sleep 1
640
641 for i in 0 1 2 3 4 5; do
642         $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
643                 'objectclass=*' > /dev/null 2>&1
644         RC=$?
645         if test $RC = 0 ; then
646                 break
647         fi
648         echo "Waiting 5 seconds for local slapd to start..."
649         sleep 5
650 done
651
652 if test $RC != 0 ; then
653         echo "ldapsearch failed ($RC)!"
654         test $KILLSERVERS != no && kill -HUP $KILLPIDS
655         exit $RC
656 fi
657
658 echo "Testing strict mode delete: nonexistent local attribute..."
659
660 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
661         $TESTOUT 2>&1 << EOF_MOD5
662 version: 1
663 dn: uid=example,ou=users,o=translucent
664 changetype: modify
665 delete: preferredLanguage
666 EOF_MOD5
667
668 RC=$?
669 if test $RC != 19 ; then
670         echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
671         grep "$FAILURE" $TESTOUT
672         test $KILLSERVERS != no && kill -HUP $KILLPIDS
673         exit 1
674 fi
675
676 echo "Testing strict mode delete: nonexistent remote attribute..."
677
678 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
679         $TESTOUT 2>&1 << EOF_MOD3
680 version: 1
681 dn: uid=danger,ou=users,o=translucent
682 changetype: modify
683 delete: displayName
684 EOF_MOD3
685
686 RC=$?
687 if test $RC != 19 ; then
688         echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
689         grep "$FAILURE" $TESTOUT
690         test $KILLSERVERS != no && kill -HUP $KILLPIDS
691         exit 1
692 fi
693
694 echo "Testing strict mode modify: combination add-modify-delete..."
695
696 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
697         $TESTOUT 2>&1 << EOF_MOD6
698 version: 1
699 dn: uid=example,ou=users,o=translucent
700 changetype: modify
701 delete: carLicense
702 -
703 add: preferredLanguage
704 preferredLanguage: ISO8859-1
705 -
706 replace: employeeType
707 employeeType: consultant
708 EOF_MOD6
709
710 RC=$?
711 if test $RC != 19 ; then
712         echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
713         grep "$FAILURE" $TESTOUT
714         test $KILLSERVERS != no && kill -HUP $KILLPIDS
715         exit 1
716 fi
717
718 echo "Testing invalid Bind request..."
719 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w Wrong"$TRANSLUCENTPASSWD" > \
720         $TESTOUT 2>&1
721 RC=$?
722 if test $RC != 49 ; then
723         echo "ldapwhoami failed ($RC), expected INVALID CREDENTIALS!"
724         grep "$FAILURE" $TESTOUT
725         test $KILLSERVERS != no && kill -HUP $KILLPIDS
726         exit 1
727 fi
728
729 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w "$TRANSLUCENTPASSWD" > \
730         $TESTOUT 2>&1
731 RC=$?
732 if test $RC != 0 ; then
733         echo "ldapwhoami failed ($RC), expected SUCCESS!"
734         grep "$FAILURE" $TESTOUT
735         test $KILLSERVERS != no && kill -HUP $KILLPIDS
736         exit 1
737 fi
738
739 test $KILLSERVERS != no && kill -HUP $KILLPIDS
740
741 echo ">>>>> Test succeeded"
742
743 test $KILLSERVERS != no && wait
744
745 exit 0