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