]> git.sur5r.net Git - openldap/blob - tests/scripts/test034-translucent
0a1db94a2224edb7e344cff8ca83d56410329bb2
[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-2016 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 && test $RC,$BACKEND != 0,null ; 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 && test $RC,$BACKEND != 0,null ; 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 $LDIFFILTER < $LDIFTRANSLUCENTMERGED > $LDIFFLT
249 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
250
251 if test $? != 0 ; then
252         echo "Comparison failed -- local data failed to merge with remote!"
253         test $KILLSERVERS != no && kill -HUP $KILLPIDS
254         exit 1
255 fi
256
257 echo "Testing compare: valid local..."
258
259 $LDAPCOMPARE -z -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
260         "uid=danger,ou=users,o=translucent" "carLicense:LIVID"
261
262 RC=$?
263 if test $RC != 6 ; then
264         echo "ldapcompare failed ($RC), expected TRUE!"
265         test $KILLSERVERS != no && kill -HUP $KILLPIDS
266         exit 1
267 fi
268
269 echo "Testing compare: valid remote..."
270
271 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
272         "uid=binder,o=translucent" "businessCategory:binder-test-user"
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: bogus local..."
282
283 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
284         "uid=danger,ou=users,o=translucent" "businessCategory:invalid-test-value"
285
286 RC=$?
287 if test $RC != 5 ; then
288         echo "ldapcompare failed ($RC), expected FALSE!"
289         test $KILLSERVERS != no && kill -HUP $KILLPIDS
290         exit 1
291 fi
292
293 echo "Testing compare: bogus remote..."
294
295 $LDAPCOMPARE -z -x -H $URI2 -w $TRANSLUCENTPASSWD -D $TRANSLUCENTDN \
296         "uid=binder,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 modify: nonexistent record..."
306
307 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
308         $TESTOUT 2>&1 << EOF_MOD
309 version: 1
310 dn: uid=bogus,ou=users,o=translucent
311 changetype: modify
312 replace: roomNumber
313 roomNumber: 31J-2112
314 EOF_MOD
315
316 RC=$?
317 if test $RC != 32 ; then
318         echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
319         grep "$FAILURE" $TESTOUT
320         test $KILLSERVERS != no && kill -HUP $KILLPIDS
321         exit 1
322 fi
323
324 echo "Testing modify: valid local record, nonexistent attribute..."
325
326 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
327         $TESTOUT 2>&1 << EOF_MOD1
328 version: 1
329 dn: uid=danger,ou=users,o=translucent
330 changetype: modify
331 replace: roomNumber
332 roomNumber: 9N-21
333 EOF_MOD1
334
335 RC=$?
336 if test $RC != 0 ; then
337         echo "ldapmodify failed ($RC)!"
338         grep "$FAILURE" $TESTOUT
339         test $KILLSERVERS != no && kill -HUP $KILLPIDS
340         exit $RC
341 fi
342
343 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" > $SEARCHOUT 2>&1
344
345 RC=$?
346 if test $RC != 0 ; then
347         echo "ldapsearch failed ($RC)!"
348         test $KILLSERVERS != no && kill -HUP $KILLPIDS
349         exit $RC
350 fi
351
352 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
353 if test "$ATTR" != "roomNumber: 9N-21" ; then
354         echo "modification failed!"
355         test $KILLSERVERS != no && kill -HUP $KILLPIDS
356         exit 1
357 fi
358
359 echo "Testing search: specific nonexistent remote attribute..."
360
361 $LDAPSEARCH -H $URI2 -b "uid=danger,ou=users,o=translucent" roomNumber > $SEARCHOUT 2>&1
362
363 RC=$?
364 if test $RC != 0 ; then
365         echo "ldapsearch failed ($RC)!"
366         test $KILLSERVERS != no && kill -HUP $KILLPIDS
367         exit $RC
368 fi
369
370 echo "Testing modify: nonexistent local record, nonexistent attribute..."
371
372 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
373         $TESTOUT 2>&1 << EOF_MOD2
374 version: 1
375 dn: uid=fred,ou=users,o=translucent
376 changetype: modify
377 replace: roomNumber
378 roomNumber: 31J-2112
379 EOF_MOD2
380
381 RC=$?
382 if test $RC != 0 ; then
383         echo "ldapmodify failed ($RC)!"
384         grep "$FAILURE" $TESTOUT
385         test $KILLSERVERS != no && kill -HUP $KILLPIDS
386         exit $RC
387 fi
388
389 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
390
391 RC=$?
392 if test $RC != 0 ; then
393         echo "ldapsearch failed ($RC)!"
394         test $KILLSERVERS != no && kill -HUP $KILLPIDS
395         exit $RC
396 fi
397
398 ATTR=`grep roomNumber $SEARCHOUT` > $NOWHERE 2>&1
399 if test "$ATTR" != "roomNumber: 31J-2112" ; then
400         echo "modification failed!"
401         test $KILLSERVERS != no && kill -HUP $KILLPIDS
402         exit 1
403 fi
404
405 echo "Testing modify: valid remote record, nonexistent attribute..."
406
407 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
408         $TESTOUT 2>&1 << EOF_MOD9
409 version: 1
410 dn: uid=fred,ou=users,o=translucent
411 changetype: modify
412 delete: preferredLanguage
413 EOF_MOD9
414
415 RC=$?
416 if test $RC != 16 ; then
417         echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
418         grep "$FAILURE" $TESTOUT
419         test $KILLSERVERS != no && kill -HUP $KILLPIDS
420         exit 1
421 fi
422
423 echo "Testing delete: valid local record, nonexistent attribute..."
424
425 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
426         $TESTOUT 2>&1 << EOF_MOD4
427 version: 1
428 dn: uid=fred,ou=users,o=translucent
429 changetype: modify
430 delete: roomNumber
431 EOF_MOD4
432
433 RC=$?
434 if test $RC != 0 ; then
435         echo "ldapmodify failed ($RC)!"
436         grep "$FAILURE" $TESTOUT
437         test $KILLSERVERS != no && kill -HUP $KILLPIDS
438         exit $RC
439 fi
440
441 echo "Testing modrdn: prohibited local record..."
442
443 $LDAPMODRDN -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
444         $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
445
446 RC=$?
447 if test $RC != 50 ; then
448         echo "ldapmodrdn failed ($RC), expected INSUFFICIENT ACCESS!"
449         grep "$FAILURE" $TESTOUT
450         test $KILLSERVERS != no && kill -HUP $KILLPIDS
451         exit 1
452 fi
453
454 echo "Testing modrdn: valid local record..."
455
456 $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
457         $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
458
459 RC=$?
460 if test $RC != 0 ; then
461         echo "ldapmodrdn failed ($RC)!"
462         grep "$FAILURE" $TESTOUT
463         test $KILLSERVERS != no && kill -HUP $KILLPIDS
464         exit $RC
465 fi
466
467 echo "Testing delete: prohibited local record..."
468
469 $LDAPMODIFY -v -D "$TRANSLUCENTDN" -H $URI2 -w $TRANSLUCENTPASSWD > \
470         $TESTOUT 2>&1 << EOF_DEL2
471 version: 1
472 dn: uid=someguy,ou=users,o=translucent
473 changetype: delete
474 EOF_DEL2
475
476 RC=$?
477 if test $RC != 50 ; then
478         echo "ldapadd failed ($RC), expected INSUFFICIENT ACCESS!"
479         grep "$FAILURE" $TESTOUT
480         test $KILLSERVERS != no && kill -HUP $KILLPIDS
481         exit 1
482 fi
483
484 echo "Testing delete: valid local record..."
485
486 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
487         $TESTOUT 2>&1 << EOF_DEL3
488 version: 1
489 dn: uid=someguy,ou=users,o=translucent
490 changetype: delete
491 EOF_DEL3
492
493 RC=$?
494 if test $RC != 0 ; then
495         echo "ldapmodify failed ($RC)!"
496         grep "$FAILURE" $TESTOUT
497         test $KILLSERVERS != no && kill -HUP $KILLPIDS
498         exit $RC
499 fi
500
501 echo "Testing delete: valid remote record..."
502
503 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
504         $TESTOUT 2>&1 << EOF_DEL8
505 version: 1
506 dn: uid=fred,ou=users,o=translucent
507 changetype: delete
508 EOF_DEL8
509
510 RC=$?
511 if test $RC != 32 ; then
512         echo "ldapmodify failed ($RC), expected NO SUCH OBJECT!"
513         grep "$FAILURE" $TESTOUT
514         test $KILLSERVERS != no && kill -HUP $KILLPIDS
515         exit 1
516 fi
517
518 echo "Testing delete: nonexistent local record, nonexistent attribute..."
519
520 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
521         $TESTOUT 2>&1 << EOF_DEL1
522 version: 1
523 dn: uid=fred,ou=users,o=translucent
524 changetype: modify
525 delete: roomNumber
526 EOF_DEL1
527
528 RC=$?
529 if test $RC != 0 ; then
530         echo "ldapmodify failed ($RC)!"
531         grep "$FAILURE" $TESTOUT
532         test $KILLSERVERS != no && kill -HUP $KILLPIDS
533         exit $RC
534 fi
535
536 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
537
538 RC=$?
539 if test $RC != 0 ; then
540         echo "ldapsearch failed ($RC)!"
541         test $KILLSERVERS != no && kill -HUP $KILLPIDS
542         exit $RC
543 fi
544
545 echo "Testing delete: valid local record, nonexistent attribute..."
546
547 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
548         $TESTOUT 2>&1 << EOF_MOD8
549 version: 1
550 dn: uid=danger,ou=users,o=translucent
551 changetype: modify
552 delete: preferredLanguage
553 EOF_MOD8
554
555 RC=$?
556 if test $RC != 16 ; then
557         echo "ldapmodify failed ($RC), expected NO SUCH ATTRIBUTE!"
558         grep "$FAILURE" $TESTOUT
559         test $KILLSERVERS != no && kill -HUP $KILLPIDS
560         exit 1
561 fi
562
563 echo "Testing delete: valid local record, remote attribute..."
564
565 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
566         $TESTOUT 2>&1 << EOF_MOD8
567 version: 1
568 dn: uid=danger,ou=users,o=translucent
569 changetype: modify
570 delete: initials
571 EOF_MOD8
572
573 RC=$?
574 if test $RC != 0 ; then
575         echo "ldapmodify failed ($RC)"
576         grep "$FAILURE" $TESTOUT
577         test $KILLSERVERS != no && kill -HUP $KILLPIDS
578         exit 1
579 fi
580
581 echo "Testing modify: valid remote record, combination add-modify-delete..."
582
583 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
584         $TESTOUT 2>&1 << EOF_MOD6
585 version: 1
586 dn: uid=fred,ou=users,o=translucent
587 changetype: modify
588 delete: carLicense
589 -
590 add: preferredLanguage
591 preferredLanguage: ISO8859-1
592 -
593 replace: employeeType
594 employeeType: consultant
595 EOF_MOD6
596
597 RC=$?
598 if test $RC != 0 ; then
599         echo "ldapmodify failed ($RC)!"
600         grep "$FAILURE" $TESTOUT
601         test $KILLSERVERS != no && kill -HUP $KILLPIDS
602         exit $RC
603 fi
604
605 $LDAPSEARCH -H $URI2 -b "uid=fred,ou=users,o=translucent" > $SEARCHOUT 2>&1
606
607 RC=$?
608 if test $RC != 0 ; then
609         echo "ldapsearch failed ($RC)!"
610         test $KILLSERVERS != no && kill -HUP $KILLPIDS
611         exit $RC
612 fi
613
614 ATTR=`grep employeeType $SEARCHOUT` > $NOWHERE 2>&1
615 if test "$ATTR" != "employeeType: consultant" ; then
616         echo "modification failed!"
617         test $KILLSERVERS != no && kill -HUP $KILLPIDS
618         exit 1
619 fi
620
621 ATTR=`grep preferredLanguage $SEARCHOUT` > $NOWHERE 2>&1
622 if test "$ATTR" != "preferredLanguage: ISO8859-1" ; then
623         echo "modification failed!"
624         test $KILLSERVERS != no && kill -HUP $KILLPIDS
625         exit 1
626 fi
627
628 echo "Dynamically configuring local slapd with translucent_no_glue and translucent_strict..."
629
630 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
631 dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
632 changetype: modify
633 replace: olcTranslucentNoGlue
634 olcTranslucentNoGlue: TRUE
635 -
636 replace: olcTranslucentStrict
637 olcTranslucentStrict: TRUE
638 EOF
639 RC=$?
640 if test $RC != 0 ; then
641     echo "ldapmodify of dynamic config failed ($RC)"
642     test $KILLSERVERS != no && kill -HUP $KILLPIDS
643     exit 1
644 fi
645
646 echo "Testing strict mode delete: nonexistent local attribute..."
647
648 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
649         $TESTOUT 2>&1 << EOF_MOD5
650 version: 1
651 dn: uid=example,ou=users,o=translucent
652 changetype: modify
653 delete: preferredLanguage
654 EOF_MOD5
655
656 RC=$?
657 if test $RC != 19 ; then
658         echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
659         grep "$FAILURE" $TESTOUT
660         test $KILLSERVERS != no && kill -HUP $KILLPIDS
661         exit 1
662 fi
663
664 echo "Testing strict mode delete: nonexistent remote attribute..."
665
666 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
667         $TESTOUT 2>&1 << EOF_MOD3
668 version: 1
669 dn: uid=danger,ou=users,o=translucent
670 changetype: modify
671 delete: displayName
672 EOF_MOD3
673
674 RC=$?
675 if test $RC != 19 ; then
676         echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
677         grep "$FAILURE" $TESTOUT
678         test $KILLSERVERS != no && kill -HUP $KILLPIDS
679         exit 1
680 fi
681
682 echo "Testing strict mode modify: combination add-modify-delete..."
683
684 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
685         $TESTOUT 2>&1 << EOF_MOD6
686 version: 1
687 dn: uid=example,ou=users,o=translucent
688 changetype: modify
689 delete: carLicense
690 -
691 add: preferredLanguage
692 preferredLanguage: ISO8859-1
693 -
694 replace: employeeType
695 employeeType: consultant
696 EOF_MOD6
697
698 RC=$?
699 if test $RC != 19 ; then
700         echo "ldapmodify failed ($RC), expected CONSTRAINT VIOLATION!"
701         grep "$FAILURE" $TESTOUT
702         test $KILLSERVERS != no && kill -HUP $KILLPIDS
703         exit 1
704 fi
705
706 echo "Testing invalid Bind request..."
707 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w Wrong"$TRANSLUCENTPASSWD" > \
708         $TESTOUT 2>&1
709 RC=$?
710 if test $RC != 49 ; then
711         echo "ldapwhoami failed ($RC), expected INVALID CREDENTIALS!"
712         grep "$FAILURE" $TESTOUT
713         test $KILLSERVERS != no && kill -HUP $KILLPIDS
714         exit 1
715 fi
716
717 $LDAPWHOAMI -D "$TRANSLUCENTDN" -H $URI2 -w "$TRANSLUCENTPASSWD" > \
718         $TESTOUT 2>&1
719 RC=$?
720 if test $RC != 0 ; then
721         echo "ldapwhoami failed ($RC), expected SUCCESS!"
722         grep "$FAILURE" $TESTOUT
723         test $KILLSERVERS != no && kill -HUP $KILLPIDS
724         exit 1
725 fi
726
727 echo "Testing search: unconfigured local filter..."
728 $LDAPSEARCH -H $URI2 -b "o=translucent" "(employeeType=consultant)" > $SEARCHOUT 2>&1
729
730 ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1
731 if test -n "$ATTR" ; then
732         echo "got result $ATTR, should have been no result"
733         test $KILLSERVERS != no && kill -HUP $KILLPIDS
734         exit 1
735 fi
736
737 echo "Dynamically configuring local slapd with translucent_local..."
738
739 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
740 dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
741 changetype: modify
742 add: olcTranslucentLocal
743 olcTranslucentLocal: employeeType
744 EOF
745 RC=$?
746 if test $RC != 0 ; then
747     echo "ldapmodify of dynamic config failed ($RC)"
748     test $KILLSERVERS != no && kill -HUP $KILLPIDS
749     exit 1
750 fi
751
752 echo "Testing search: configured local filter..."
753 $LDAPSEARCH -H $URI2 -b "o=translucent" "(employeeType=consultant)" > $SEARCHOUT 2>&1
754
755 ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1
756 if test -z "$ATTR" ; then
757         echo "got no result, should have found entry"
758         test $KILLSERVERS != no && kill -HUP $KILLPIDS
759         exit 1
760 fi
761
762 echo "Testing search: unconfigured remote filter..."
763 $LDAPSEARCH -H $URI2 -b "o=translucent" "(|(employeeType=foo)(carlicense=right))" > $SEARCHOUT 2>&1
764
765 ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1
766 if test -n "$ATTR" ; then
767         echo "got result $ATTR, should have been no result"
768         test $KILLSERVERS != no && kill -HUP $KILLPIDS
769         exit 1
770 fi
771
772 echo "Dynamically configuring local slapd with translucent_remote..."
773
774 $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
775 dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
776 changetype: modify
777 add: olcTranslucentRemote
778 olcTranslucentRemote: carLicense
779 EOF
780 RC=$?
781 if test $RC != 0 ; then
782     echo "ldapmodify of dynamic config failed ($RC)"
783     test $KILLSERVERS != no && kill -HUP $KILLPIDS
784     exit 1
785 fi
786
787 echo "Testing search: configured remote filter..."
788 $LDAPSEARCH -H $URI2 -b "o=translucent" "(|(employeeType=foo)(carlicense=right))" > $SEARCHOUT 2>&1
789
790 ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1
791 if test -z "$ATTR" ; then
792         echo "got no result, should have found entry"
793         test $KILLSERVERS != no && kill -HUP $KILLPIDS
794         exit 1
795 fi
796
797 test $KILLSERVERS != no && kill -HUP $KILLPIDS
798
799 echo ">>>>> Test succeeded"
800
801 test $KILLSERVERS != no && wait
802
803 exit 0