2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ## Copyright 1998-2008 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 mkdir -p $TESTDIR $DBDIR1
25 $SLAPPASSWD -g -n >$CONFIGPWF
26 echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
28 echo "Running slapadd to build slapd database..."
29 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
30 $SLAPADD -f $ADDCONF -l $LDIFORDERED
32 if test $RC != 0 ; then
33 echo "slapadd failed ($RC)!"
37 . $CONFFILTER $BACKEND $MONITORDB < $DYNLISTCONF > $CONF1
39 echo "Starting slapd on TCP/IP port $PORT1..."
40 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
42 if test $WAIT != 0 ; then
50 echo "Testing slapd searching..."
51 for i in 0 1 2 3 4 5; do
52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53 '(objectclass=*)' > /dev/null 2>&1
55 if test $RC = 0 ; then
58 echo "Waiting 5 seconds for slapd to start..."
62 if test $RC != 0 ; then
63 echo "ldapsearch failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 cat /dev/null > $SEARCHOUT
70 LISTDN="ou=Dynamic Lists,$BASEDN"
71 echo "Adding a dynamic list..."
72 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
73 > $TESTOUT 2>&1 << EOMODS
75 objectClass: organizationalUnit
78 dn: cn=Dynamic List,$LISTDN
79 objectClass: groupOfURLs
81 memberURL: ldap:///ou=People,${BASEDN}?cn,mail?sub?(objectClass=person)
84 echo "Testing list search of all attrs..."
85 echo "# Testing list search of all attrs..." >> $SEARCHOUT
86 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
87 '(cn=Dynamic List)' '*' \
90 if test $RC != 0 ; then
91 echo "ldapsearch failed ($RC)!"
92 test $KILLSERVERS != no && kill -HUP $KILLPIDS
96 echo "Testing list search of a listed attr..."
97 echo "# Testing list search of a listed attr..." >> $SEARCHOUT
98 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
99 '(cn=Dynamic List)' mail \
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 non-listed attr..."
109 echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT
110 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
111 '(cn=Dynamic List)' objectClass \
114 if test $RC != 0 ; then
115 echo "ldapsearch failed ($RC)!"
116 test $KILLSERVERS != no && kill -HUP $KILLPIDS
120 echo "Testing list search with (critical) manageDSAit..."
121 echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT
122 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \
123 '(cn=Dynamic List)' '*' \
126 if test $RC != 0 ; then
127 echo "ldapsearch failed ($RC)!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
132 echo "Testing list compare..."
133 echo "# Testing list compare..." >> $SEARCHOUT
134 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
135 "cn=Dynamic List,$LISTDN" "cn:Bjorn Jensen" \
140 echo "ldapcompare returned FALSE ($RC)!"
141 test $KILLSERVERS != no && kill -HUP $KILLPIDS
145 echo "ldapcompare returned TRUE ($RC)"
148 echo "ldapcompare returned success ($RC)!"
149 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 echo "ldapcompare failed ($RC)!"
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
158 echo "" >> $SEARCHOUT
160 echo "Testing list compare (should return FALSE)..."
161 echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
162 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
163 "cn=Dynamic List,$LISTDN" "cn:FALSE" \
168 echo "ldapcompare returned FALSE ($RC)"
171 echo "ldapcompare returned TRUE ($RC)!"
172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
176 echo "ldapcompare returned success ($RC)!"
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
181 echo "ldapcompare failed ($RC)!"
182 test $KILLSERVERS != no && kill -HUP $KILLPIDS
186 echo "" >> $SEARCHOUT
188 echo "Testing list compare (should return UNDEFINED)..."
189 echo "# Testing list compare (should return UNDEFINED)..." >> $SEARCHOUT
190 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
191 "cn=Dynamic List,$LISTDN" "dc:UNDEFINED" \
196 echo "ldapcompare returned FALSE ($RC)!"
197 test $KILLSERVERS != no && kill -HUP $KILLPIDS
201 echo "ldapcompare returned TRUE ($RC)!"
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
206 echo "ldapcompare returned UNDEFINED ($RC)"
209 echo "ldapcompare returned success ($RC)!"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 echo "ldapcompare failed ($RC)"
217 echo "" >> $SEARCHOUT
219 echo "Testing list compare with manageDSAit..."
220 echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT
221 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \
222 "cn=Dynamic List,$LISTDN" "cn:Bjorn Jensen" \
227 echo "ldapcompare returned FALSE ($RC)"
230 echo "ldapcompare returned TRUE ($RC)!"
231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
235 echo "ldapcompare returned success ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 echo "ldapcompare failed ($RC)!"
241 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 echo "" >> $SEARCHOUT
247 echo "Reconfiguring slapd..."
248 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
249 $TESTOUT 2>&1 << EOMODS
251 dn: olcOverlay={0}dynlist,olcDatabase={2}$BACKEND,cn=config
257 olcDLattrSet: groupOfURLs memberURL sn:cn mail
261 echo "==========================================================" >> $LOG1
263 echo "Testing attribute mapping"
265 echo "Testing list search of all (mapped) attrs..."
266 echo "# Testing list search of all (mapped) attrs..." >> $SEARCHOUT
267 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
268 '(cn=Dynamic List)' '*' \
271 if test $RC != 0 ; then
272 echo "ldapsearch failed ($RC)!"
273 test $KILLSERVERS != no && kill -HUP $KILLPIDS
277 echo "Testing list search of a (mapped) listed attr..."
278 echo "# Testing list search of a (mapped) listed attr..." >> $SEARCHOUT
279 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
280 '(cn=Dynamic List)' sn \
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 (n unmapped) listed attr..."
290 echo "# Testing list search of a (n unmapped) listed attr..." >> $SEARCHOUT
291 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
292 '(cn=Dynamic List)' mail \
295 if test $RC != 0 ; then
296 echo "ldapsearch failed ($RC)!"
297 test $KILLSERVERS != no && kill -HUP $KILLPIDS
301 echo "Testing list compare (mapped attrs) ..."
302 echo "# Testing list compare (mapped attrs) ..." >> $SEARCHOUT
303 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
304 "cn=Dynamic List,$LISTDN" "sn:Bjorn Jensen" \
309 echo "ldapcompare returned FALSE ($RC)!"
310 test $KILLSERVERS != no && kill -HUP $KILLPIDS
314 echo "ldapcompare returned TRUE ($RC)"
317 echo "ldapcompare returned success ($RC)!"
318 test $KILLSERVERS != no && kill -HUP $KILLPIDS
322 echo "ldapcompare failed ($RC)!"
323 test $KILLSERVERS != no && kill -HUP $KILLPIDS
327 echo "" >> $SEARCHOUT
329 echo "Testing list compare (mapped attrs; should return FALSE)..."
330 echo "# Testing list compare (mapped attrs; should return FALSE)..." >> $SEARCHOUT
331 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
332 "cn=Dynamic List,$LISTDN" "sn:FALSE" \
337 echo "ldapcompare returned FALSE ($RC)"
340 echo "ldapcompare returned TRUE ($RC)!"
341 test $KILLSERVERS != no && kill -HUP $KILLPIDS
345 echo "ldapcompare returned success ($RC)!"
346 test $KILLSERVERS != no && kill -HUP $KILLPIDS
350 echo "ldapcompare failed ($RC)!"
351 test $KILLSERVERS != no && kill -HUP $KILLPIDS
355 echo "" >> $SEARCHOUT
357 echo "Reconfiguring slapd..."
358 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
359 $TESTOUT 2>&1 << EOMODS
361 dn: olcOverlay={0}dynlist,olcDatabase={2}$BACKEND,cn=config
367 olcDLattrSet: groupOfURLs memberURL member
371 echo "==========================================================" >> $LOG1
373 echo "Adding a dynamic list..."
374 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
375 > $TESTOUT 2>&1 << EOMODS
376 dn: cn=Dynamic List of Members,$LISTDN
377 objectClass: groupOfURLs
378 cn: Dynamic List of Members
379 memberURL: ldap:///ou=People,${BASEDN}??sub?(objectClass=person)
382 echo "Testing list search of all attrs..."
383 echo "# Testing list search of all attrs..." >> $SEARCHOUT
384 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
385 '(cn=Dynamic List of Members)' '*' \
388 if test $RC != 0 ; then
389 echo "ldapsearch failed ($RC)!"
390 test $KILLSERVERS != no && kill -HUP $KILLPIDS
394 echo "Testing list search of a listed attr..."
395 echo "# Testing list search of a listed attr..." >> $SEARCHOUT
396 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
397 '(cn=Dynamic List of Members)' member \
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 non-listed attr..."
407 echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT
408 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
409 '(cn=Dynamic List of Members)' objectClass \
412 if test $RC != 0 ; then
413 echo "ldapsearch failed ($RC)!"
414 test $KILLSERVERS != no && kill -HUP $KILLPIDS
418 echo "Testing list search with (critical) manageDSAit..."
419 echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT
420 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \
421 '(&(cn=Dynamic List of Members)(objectClass=groupOfURLs))' '*' \
424 if test $RC != 0 ; then
425 echo "ldapsearch failed ($RC)!"
426 test $KILLSERVERS != no && kill -HUP $KILLPIDS
431 echo "Testing list compare..."
432 echo "# Testing list compare..." >> $SEARCHOUT
433 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
434 "cn=Dynamic List of Members,$LISTDN" "member:$CMPDN" \
439 echo "ldapcompare returned FALSE ($RC)!"
440 test $KILLSERVERS != no && kill -HUP $KILLPIDS
444 echo "ldapcompare returned TRUE ($RC)"
447 echo "ldapcompare returned success ($RC)!"
448 test $KILLSERVERS != no && kill -HUP $KILLPIDS
452 echo "ldapcompare failed ($RC)!"
453 test $KILLSERVERS != no && kill -HUP $KILLPIDS
457 echo "" >> $SEARCHOUT
459 echo "Testing list compare (should return FALSE)..."
460 echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
461 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
462 "cn=Dynamic List of Members,$LISTDN" "member:cn=Foo Bar" \
467 echo "ldapcompare returned FALSE ($RC)"
470 echo "ldapcompare returned TRUE ($RC)!"
471 test $KILLSERVERS != no && kill -HUP $KILLPIDS
475 echo "ldapcompare returned success ($RC)!"
476 test $KILLSERVERS != no && kill -HUP $KILLPIDS
480 echo "ldapcompare failed ($RC)!"
481 test $KILLSERVERS != no && kill -HUP $KILLPIDS
485 echo "" >> $SEARCHOUT
487 echo "Testing list compare with manageDSAit..."
488 echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT
489 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \
490 "cn=Dynamic List,$LISTDN" "member:$CMPDN" \
495 echo "ldapcompare returned FALSE ($RC)"
498 echo "ldapcompare returned TRUE ($RC)!"
499 test $KILLSERVERS != no && kill -HUP $KILLPIDS
503 echo "ldapcompare returned success ($RC)!"
504 test $KILLSERVERS != no && kill -HUP $KILLPIDS
508 echo "ldapcompare failed ($RC)!"
509 test $KILLSERVERS != no && kill -HUP $KILLPIDS
513 echo "" >> $SEARCHOUT
515 echo "==========================================================" >> $LOG1
517 echo "Testing dgIdentity..."
519 # Set ACL, require authentication to get list contents
520 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
521 $TESTOUT 2>&1 << EOMODS
523 dn: olcDatabase={2}$BACKEND,cn=config
526 olcAccess: to dn.base="cn=Dynamic List of Members,$LISTDN" by * read
527 olcAccess: to * by users read by * search
530 echo "Testing list search without dgIdentity..."
531 echo "# Testing list search without dgIdentity..." >> $SEARCHOUT
532 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
533 '(cn=Dynamic List of Members)' '*' \
536 if test $RC != 0 ; then
537 echo "ldapsearch failed ($RC)!"
538 test $KILLSERVERS != no && kill -HUP $KILLPIDS
542 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
543 > $TESTOUT 2>&1 << EOMODS
544 dn: cn=Dynamic List of Members,$LISTDN
547 objectClass: dgIdentityAux
553 echo "Testing list search with dgIdentity..."
554 echo "# Testing list search with dgIdentity..." >> $SEARCHOUT
555 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
556 '(cn=Dynamic List of Members)' '*' \
559 if test $RC != 0 ; then
560 echo "ldapsearch failed ($RC)!"
561 test $KILLSERVERS != no && kill -HUP $KILLPIDS
565 echo "Testing dgAuthz..."
567 CMPDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN"
568 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
569 > $TESTOUT 2>&1 << EOMODS
570 dn: cn=Dynamic List of Members,$LISTDN
576 echo "Testing list search with dgIdentity and dgAuthz anonymously..."
577 echo "# Testing list search with dgIdentity and dgAuthz anonymously..." >> $SEARCHOUT
578 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
579 '(cn=Dynamic List of Members)' '*' \
582 if test $RC != 0 ; then
583 echo "ldapsearch failed ($RC)!"
584 test $KILLSERVERS != no && kill -HUP $KILLPIDS
588 echo "Testing list search with dgIdentity and dgAuthz as the authorized identity..."
589 echo "# Testing list search with dgIdentity and dgAuthz as the authorized identity..." >> $SEARCHOUT
590 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
591 -D "$BABSDN" -w bjensen \
592 '(cn=Dynamic List of Members)' '*' \
595 if test $RC != 0 ; then
596 echo "ldapsearch failed ($RC)!"
597 test $KILLSERVERS != no && kill -HUP $KILLPIDS
601 test $KILLSERVERS != no && kill -HUP $KILLPIDS
605 echo "Filtering ldapsearch results..."
606 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
607 echo "Filtering original ldif used to create database..."
608 . $LDIFFILTER < $LDIF > $LDIFFLT
609 echo "Comparing filter output..."
610 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
612 if test $? != 0 ; then
613 echo "Comparison failed"
617 echo ">>>>> Test succeeded"
619 test $KILLSERVERS != no && wait