2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ## Copyright 1998-2013 The OpenLDAP Foundation.
5 ## All rights reserved.
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted only as authorized by the OpenLDAP
11 ## A copy of this license is available in the file LICENSE in the
12 ## top-level directory of the distribution or, alternatively, at
13 ## <http://www.OpenLDAP.org/license.html>.
15 echo "running defines.sh"
16 . $SRCDIR/scripts/defines.sh
18 if test $DYNLIST = "dynlistno" ; then
19 echo "dynlist overlay not available, test skipped"
23 if test $BACKEND = ldif ; then
24 # dynlist+ldif fails because back-ldif lacks bi_op_compare()
25 echo "$BACKEND backend unsuitable for dynlist overlay, test skipped"
29 mkdir -p $TESTDIR $DBDIR1
31 $SLAPPASSWD -g -n >$CONFIGPWF
32 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
34 if test $MONITORDB != no ; then
40 echo "Running slapadd to build slapd database..."
41 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
42 $SLAPADD -f $ADDCONF -l $LDIFORDERED
44 if test $RC != 0 ; then
45 echo "slapadd failed ($RC)!"
49 . $CONFFILTER $BACKEND $MONITORDB < $DYNLISTCONF > $CONF1
51 echo "Starting slapd on TCP/IP port $PORT1..."
52 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
54 if test $WAIT != 0 ; then
62 echo "Testing slapd searching..."
63 for i in 0 1 2 3 4 5; do
64 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
65 '(objectclass=*)' > /dev/null 2>&1
67 if test $RC = 0 ; then
70 echo "Waiting 5 seconds for slapd to start..."
74 if test $RC != 0 ; then
75 echo "ldapsearch failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 cat /dev/null > $SEARCHOUT
82 LISTDN="ou=Dynamic Lists,$BASEDN"
83 echo "Adding a dynamic list..."
84 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
85 > $TESTOUT 2>&1 << EOMODS
87 objectClass: organizationalUnit
90 dn: cn=Dynamic List,$LISTDN
91 objectClass: groupOfURLs
93 memberURL: ldap:///ou=People,${BASEDN}?cn,mail?sub?(objectClass=person)
96 echo "Testing list search of all attrs..."
97 echo "# Testing list search of all attrs..." >> $SEARCHOUT
98 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
99 '(cn=Dynamic List)' '*' \
102 if test $RC != 0 ; then
103 echo "ldapsearch failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 echo "Testing list search of a listed attr..."
109 echo "# Testing list search of a listed attr..." >> $SEARCHOUT
110 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
111 '(cn=Dynamic List)' mail \
114 if test $RC != 0 ; then
115 echo "ldapsearch failed ($RC)!"
116 test $KILLSERVERS != no && kill -HUP $KILLPIDS
120 echo "Testing list search of a non-listed attr..."
121 echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT
122 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
123 '(cn=Dynamic List)' objectClass \
126 if test $RC != 0 ; then
127 echo "ldapsearch failed ($RC)!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
132 echo "Testing list search with (critical) manageDSAit..."
133 echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT
134 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \
135 '(cn=Dynamic List)' '*' \
138 if test $RC != 0 ; then
139 echo "ldapsearch failed ($RC)!"
140 test $KILLSERVERS != no && kill -HUP $KILLPIDS
144 echo "Testing list compare..."
145 echo "# Testing list compare..." >> $SEARCHOUT
146 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
147 "cn=Dynamic List,$LISTDN" "cn:Bjorn Jensen" \
152 echo "ldapcompare returned FALSE ($RC)!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 echo "ldapcompare returned TRUE ($RC)"
160 echo "ldapcompare returned success ($RC)!"
161 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 echo "ldapcompare failed ($RC)!"
166 test $KILLSERVERS != no && kill -HUP $KILLPIDS
170 echo "" >> $SEARCHOUT
172 echo "Testing list compare (should return FALSE)..."
173 echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
174 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
175 "cn=Dynamic List,$LISTDN" "cn:FALSE" \
180 echo "ldapcompare returned FALSE ($RC)"
183 echo "ldapcompare returned TRUE ($RC)!"
184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
188 echo "ldapcompare returned success ($RC)!"
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193 echo "ldapcompare failed ($RC)!"
194 test $KILLSERVERS != no && kill -HUP $KILLPIDS
198 echo "" >> $SEARCHOUT
200 echo "Testing list compare (should return UNDEFINED)..."
201 echo "# Testing list compare (should return UNDEFINED)..." >> $SEARCHOUT
202 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
203 "cn=Dynamic List,$LISTDN" "dc:UNDEFINED" \
208 echo "ldapcompare returned FALSE ($RC)!"
209 test $KILLSERVERS != no && kill -HUP $KILLPIDS
213 echo "ldapcompare returned TRUE ($RC)!"
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 echo "ldapcompare returned UNDEFINED ($RC)"
221 echo "ldapcompare returned success ($RC)!"
222 test $KILLSERVERS != no && kill -HUP $KILLPIDS
226 echo "ldapcompare failed ($RC)"
229 echo "" >> $SEARCHOUT
231 echo "Testing list compare with manageDSAit..."
232 echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT
233 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \
234 "cn=Dynamic List,$LISTDN" "cn:Bjorn Jensen" \
239 echo "ldapcompare returned FALSE ($RC)"
242 echo "ldapcompare returned TRUE ($RC)!"
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
247 echo "ldapcompare returned success ($RC)!"
248 test $KILLSERVERS != no && kill -HUP $KILLPIDS
252 echo "ldapcompare failed ($RC)!"
253 test $KILLSERVERS != no && kill -HUP $KILLPIDS
257 echo "" >> $SEARCHOUT
259 echo "Reconfiguring slapd..."
260 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
261 $TESTOUT 2>&1 << EOMODS
263 dn: olcOverlay={0}dynlist,olcDatabase={$DBIX}$BACKEND,cn=config
269 olcDLattrSet: groupOfURLs memberURL sn:cn mail
273 echo "==========================================================" >> $LOG1
275 echo "Testing attribute mapping"
277 echo "Testing list search of all (mapped) attrs..."
278 echo "# Testing list search of all (mapped) attrs..." >> $SEARCHOUT
279 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
280 '(cn=Dynamic List)' '*' \
283 if test $RC != 0 ; then
284 echo "ldapsearch failed ($RC)!"
285 test $KILLSERVERS != no && kill -HUP $KILLPIDS
289 echo "Testing list search of a (mapped) listed attr..."
290 echo "# Testing list search of a (mapped) listed attr..." >> $SEARCHOUT
291 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
292 '(cn=Dynamic List)' sn \
295 if test $RC != 0 ; then
296 echo "ldapsearch failed ($RC)!"
297 test $KILLSERVERS != no && kill -HUP $KILLPIDS
301 echo "Testing list search of a (n unmapped) listed attr..."
302 echo "# Testing list search of a (n unmapped) listed attr..." >> $SEARCHOUT
303 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
304 '(cn=Dynamic List)' mail \
307 if test $RC != 0 ; then
308 echo "ldapsearch failed ($RC)!"
309 test $KILLSERVERS != no && kill -HUP $KILLPIDS
313 echo "Testing list compare (mapped attrs) ..."
314 echo "# Testing list compare (mapped attrs) ..." >> $SEARCHOUT
315 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
316 "cn=Dynamic List,$LISTDN" "sn:Bjorn Jensen" \
321 echo "ldapcompare returned FALSE ($RC)!"
322 test $KILLSERVERS != no && kill -HUP $KILLPIDS
326 echo "ldapcompare returned TRUE ($RC)"
329 echo "ldapcompare returned success ($RC)!"
330 test $KILLSERVERS != no && kill -HUP $KILLPIDS
334 echo "ldapcompare failed ($RC)!"
335 test $KILLSERVERS != no && kill -HUP $KILLPIDS
339 echo "" >> $SEARCHOUT
341 echo "Testing list compare (mapped attrs; should return FALSE)..."
342 echo "# Testing list compare (mapped attrs; should return FALSE)..." >> $SEARCHOUT
343 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
344 "cn=Dynamic List,$LISTDN" "sn:FALSE" \
349 echo "ldapcompare returned FALSE ($RC)"
352 echo "ldapcompare returned TRUE ($RC)!"
353 test $KILLSERVERS != no && kill -HUP $KILLPIDS
357 echo "ldapcompare returned success ($RC)!"
358 test $KILLSERVERS != no && kill -HUP $KILLPIDS
362 echo "ldapcompare failed ($RC)!"
363 test $KILLSERVERS != no && kill -HUP $KILLPIDS
367 echo "" >> $SEARCHOUT
369 echo "Reconfiguring slapd..."
370 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
371 $TESTOUT 2>&1 << EOMODS
373 dn: olcOverlay={0}dynlist,olcDatabase={$DBIX}$BACKEND,cn=config
379 olcDLattrSet: groupOfURLs memberURL member
383 echo "==========================================================" >> $LOG1
385 echo "Adding a dynamic list..."
386 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
387 > $TESTOUT 2>&1 << EOMODS
388 dn: cn=Dynamic List of Members,$LISTDN
389 objectClass: groupOfURLs
390 cn: Dynamic List of Members
391 memberURL: ldap:///ou=People,${BASEDN}??sub?(objectClass=person)
394 echo "Testing list search of all attrs..."
395 echo "# Testing list search of all attrs..." >> $SEARCHOUT
396 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
397 '(cn=Dynamic List of Members)' '*' \
400 if test $RC != 0 ; then
401 echo "ldapsearch failed ($RC)!"
402 test $KILLSERVERS != no && kill -HUP $KILLPIDS
406 echo "Testing list search of a listed attr..."
407 echo "# Testing list search of a listed attr..." >> $SEARCHOUT
408 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
409 '(cn=Dynamic List of Members)' member \
412 if test $RC != 0 ; then
413 echo "ldapsearch failed ($RC)!"
414 test $KILLSERVERS != no && kill -HUP $KILLPIDS
418 echo "Testing list search of a non-listed attr..."
419 echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT
420 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
421 '(cn=Dynamic List of Members)' objectClass \
424 if test $RC != 0 ; then
425 echo "ldapsearch failed ($RC)!"
426 test $KILLSERVERS != no && kill -HUP $KILLPIDS
430 echo "Testing list search with (critical) manageDSAit..."
431 echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT
432 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \
433 '(&(cn=Dynamic List of Members)(objectClass=groupOfURLs))' '*' \
436 if test $RC != 0 ; then
437 echo "ldapsearch failed ($RC)!"
438 test $KILLSERVERS != no && kill -HUP $KILLPIDS
443 echo "Testing list compare..."
444 echo "# Testing list compare..." >> $SEARCHOUT
445 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
446 "cn=Dynamic List of Members,$LISTDN" "member:$CMPDN" \
451 echo "ldapcompare returned FALSE ($RC)!"
452 test $KILLSERVERS != no && kill -HUP $KILLPIDS
456 echo "ldapcompare returned TRUE ($RC)"
459 echo "ldapcompare returned success ($RC)!"
460 test $KILLSERVERS != no && kill -HUP $KILLPIDS
464 echo "ldapcompare failed ($RC)!"
465 test $KILLSERVERS != no && kill -HUP $KILLPIDS
469 echo "" >> $SEARCHOUT
471 echo "Testing list compare (should return FALSE)..."
472 echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
473 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
474 "cn=Dynamic List of Members,$LISTDN" "member:cn=Foo Bar" \
479 echo "ldapcompare returned FALSE ($RC)"
482 echo "ldapcompare returned TRUE ($RC)!"
483 test $KILLSERVERS != no && kill -HUP $KILLPIDS
487 echo "ldapcompare returned success ($RC)!"
488 test $KILLSERVERS != no && kill -HUP $KILLPIDS
492 echo "ldapcompare failed ($RC)!"
493 test $KILLSERVERS != no && kill -HUP $KILLPIDS
497 echo "" >> $SEARCHOUT
499 echo "Testing list compare with manageDSAit..."
500 echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT
501 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \
502 "cn=Dynamic List,$LISTDN" "member:$CMPDN" \
507 echo "ldapcompare returned FALSE ($RC)"
510 echo "ldapcompare returned TRUE ($RC)!"
511 test $KILLSERVERS != no && kill -HUP $KILLPIDS
515 echo "ldapcompare returned success ($RC)!"
516 test $KILLSERVERS != no && kill -HUP $KILLPIDS
520 echo "ldapcompare failed ($RC)!"
521 test $KILLSERVERS != no && kill -HUP $KILLPIDS
525 echo "" >> $SEARCHOUT
527 echo "==========================================================" >> $LOG1
529 echo "Testing dgIdentity..."
531 # Set ACL, require authentication to get list contents
532 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
533 $TESTOUT 2>&1 << EOMODS
535 dn: olcDatabase={$DBIX}$BACKEND,cn=config
538 olcAccess: to dn.base="cn=Dynamic List of Members,$LISTDN" by * read
539 olcAccess: to * by users read by * search
542 echo "Testing list search without dgIdentity..."
543 echo "# Testing list search without dgIdentity..." >> $SEARCHOUT
544 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
545 '(cn=Dynamic List of Members)' '*' \
548 if test $RC != 0 ; then
549 echo "ldapsearch failed ($RC)!"
550 test $KILLSERVERS != no && kill -HUP $KILLPIDS
554 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
555 > $TESTOUT 2>&1 << EOMODS
556 dn: cn=Dynamic List of Members,$LISTDN
559 objectClass: dgIdentityAux
565 echo "Testing list search with dgIdentity..."
566 echo "# Testing list search with dgIdentity..." >> $SEARCHOUT
567 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
568 '(cn=Dynamic List of Members)' '*' \
571 if test $RC != 0 ; then
572 echo "ldapsearch failed ($RC)!"
573 test $KILLSERVERS != no && kill -HUP $KILLPIDS
577 echo "Testing dgAuthz..."
579 CMPDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN"
580 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
581 > $TESTOUT 2>&1 << EOMODS
582 dn: cn=Dynamic List of Members,$LISTDN
588 echo "Testing list search with dgIdentity and dgAuthz anonymously..."
589 echo "# Testing list search with dgIdentity and dgAuthz anonymously..." >> $SEARCHOUT
590 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
591 '(cn=Dynamic List of Members)' '*' \
594 if test $RC != 0 ; then
595 echo "ldapsearch failed ($RC)!"
596 test $KILLSERVERS != no && kill -HUP $KILLPIDS
600 echo "Testing list search with dgIdentity and dgAuthz as the authorized identity..."
601 echo "# Testing list search with dgIdentity and dgAuthz as the authorized identity..." >> $SEARCHOUT
602 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
603 -D "$BABSDN" -w bjensen \
604 '(cn=Dynamic List of Members)' '*' \
607 if test $RC != 0 ; then
608 echo "ldapsearch failed ($RC)!"
609 test $KILLSERVERS != no && kill -HUP $KILLPIDS
613 test $KILLSERVERS != no && kill -HUP $KILLPIDS
617 echo "Filtering ldapsearch results..."
618 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
619 echo "Filtering original ldif used to create database..."
620 $LDIFFILTER < $LDIF > $LDIFFLT
621 echo "Comparing filter output..."
622 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
624 if test $? != 0 ; then
625 echo "Comparison failed"
629 echo ">>>>> Test succeeded"
631 test $KILLSERVERS != no && wait