2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ## Copyright 1998-2007 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 member
260 echo "==========================================================" >> $LOG1
262 echo "Adding a dynamic list..."
263 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
264 > $TESTOUT 2>&1 << EOMODS
265 dn: cn=Dynamic List of Members,$LISTDN
266 objectClass: groupOfURLs
267 cn: Dynamic List of Members
268 memberURL: ldap:///ou=People,${BASEDN}??sub?(objectClass=person)
271 echo "Testing list search of all attrs..."
272 echo "# Testing list search of all attrs..." >> $SEARCHOUT
273 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
274 '(cn=Dynamic List of Members)' '*' \
277 if test $RC != 0 ; then
278 echo "ldapsearch failed ($RC)!"
279 test $KILLSERVERS != no && kill -HUP $KILLPIDS
283 echo "Testing list search of a listed attr..."
284 echo "# Testing list search of a listed attr..." >> $SEARCHOUT
285 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
286 '(cn=Dynamic List of Members)' member \
289 if test $RC != 0 ; then
290 echo "ldapsearch failed ($RC)!"
291 test $KILLSERVERS != no && kill -HUP $KILLPIDS
295 echo "Testing list search of a non-listed attr..."
296 echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT
297 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
298 '(cn=Dynamic List of Members)' objectClass \
301 if test $RC != 0 ; then
302 echo "ldapsearch failed ($RC)!"
303 test $KILLSERVERS != no && kill -HUP $KILLPIDS
307 echo "Testing list search with (critical) manageDSAit..."
308 echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT
309 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \
310 '(&(cn=Dynamic List of Members)(objectClass=groupOfURLs))' '*' \
313 if test $RC != 0 ; then
314 echo "ldapsearch failed ($RC)!"
315 test $KILLSERVERS != no && kill -HUP $KILLPIDS
319 CMPDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN"
320 echo "Testing list compare..."
321 echo "# Testing list compare..." >> $SEARCHOUT
322 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
323 "cn=Dynamic List of Members,$LISTDN" "member:$CMPDN" \
328 echo "ldapcompare returned FALSE ($RC)!"
329 test $KILLSERVERS != no && kill -HUP $KILLPIDS
333 echo "ldapcompare returned TRUE ($RC)"
336 echo "ldapcompare returned success ($RC)!"
337 test $KILLSERVERS != no && kill -HUP $KILLPIDS
341 echo "ldapcompare failed ($RC)!"
342 test $KILLSERVERS != no && kill -HUP $KILLPIDS
346 echo "" >> $SEARCHOUT
348 echo "Testing list compare (should return FALSE)..."
349 echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
350 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
351 "cn=Dynamic List of Members,$LISTDN" "member:cn=Foo Bar" \
356 echo "ldapcompare returned FALSE ($RC)"
359 echo "ldapcompare returned TRUE ($RC)!"
360 test $KILLSERVERS != no && kill -HUP $KILLPIDS
364 echo "ldapcompare returned success ($RC)!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
369 echo "ldapcompare failed ($RC)!"
370 test $KILLSERVERS != no && kill -HUP $KILLPIDS
374 echo "" >> $SEARCHOUT
376 echo "Testing list compare with manageDSAit..."
377 echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT
378 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \
379 "cn=Dynamic List,$LISTDN" "member:$CMPDN" \
384 echo "ldapcompare returned FALSE ($RC)"
387 echo "ldapcompare returned TRUE ($RC)!"
388 test $KILLSERVERS != no && kill -HUP $KILLPIDS
392 echo "ldapcompare returned success ($RC)!"
393 test $KILLSERVERS != no && kill -HUP $KILLPIDS
397 echo "ldapcompare failed ($RC)!"
398 test $KILLSERVERS != no && kill -HUP $KILLPIDS
402 echo "" >> $SEARCHOUT
404 echo "==========================================================" >> $LOG1
406 echo "Testing dgIdentity..."
408 # Set ACL, require authentication to get list contents
409 $LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
410 $TESTOUT 2>&1 << EOMODS
412 dn: olcDatabase={2}$BACKEND,cn=config
415 olcAccess: to dn.base="cn=Dynamic List of Members,$LISTDN" by * read
416 olcAccess: to * by users read by * search
419 echo "Testing list search without dgIdentity..."
420 echo "# Testing list search without dgIdentity..." >> $SEARCHOUT
421 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
422 '(cn=Dynamic List of Members)' '*' \
425 if test $RC != 0 ; then
426 echo "ldapsearch failed ($RC)!"
427 test $KILLSERVERS != no && kill -HUP $KILLPIDS
431 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
432 > $TESTOUT 2>&1 << EOMODS
433 dn: cn=Dynamic List of Members,$LISTDN
436 objectClass: dgIdentityAux
442 echo "Testing list search with dgIdentity..."
443 echo "# Testing list search with dgIdentity..." >> $SEARCHOUT
444 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
445 '(cn=Dynamic List of Members)' '*' \
448 if test $RC != 0 ; then
449 echo "ldapsearch failed ($RC)!"
450 test $KILLSERVERS != no && kill -HUP $KILLPIDS
454 test $KILLSERVERS != no && kill -HUP $KILLPIDS
458 echo "Filtering ldapsearch results..."
459 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
460 echo "Filtering original ldif used to create database..."
461 . $LDIFFILTER < $LDIF > $LDIFFLT
462 echo "Comparing filter output..."
463 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
465 if test $? != 0 ; then
466 echo "Comparison failed"
470 echo ">>>>> Test succeeded"
472 test $KILLSERVERS != no && wait