Debian Codegraph @

tests/scripts/test034-translucent

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