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