2 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ## Copyright 1998-2006 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 echo "Running slapadd to build slapd database..."
26 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
27 $SLAPADD -f $ADDCONF -l $LDIFORDERED
29 if test $RC != 0 ; then
30 echo "slapadd failed ($RC)!"
34 . $CONFFILTER $BACKEND $MONITORDB < $DYNLISTCONF > $CONF1
35 echo "dynlist-attrset groupOfURLs memberURL" >> $CONF1
37 echo "Running slapindex to index slapd database..."
40 if test $RC != 0 ; then
41 echo "warning: slapindex failed ($RC)"
42 echo " assuming no indexing support"
45 echo "Starting slapd on TCP/IP port $PORT1..."
46 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
48 if test $WAIT != 0 ; then
56 echo "Testing slapd searching..."
57 for i in 0 1 2 3 4 5; do
58 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
59 '(objectclass=*)' > /dev/null 2>&1
61 if test $RC = 0 ; then
64 echo "Waiting 5 seconds for slapd to start..."
68 if test $RC != 0 ; then
69 echo "ldapsearch failed ($RC)!"
70 test $KILLSERVERS != no && kill -HUP $KILLPIDS
74 cat /dev/null > $SEARCHOUT
76 LISTDN="ou=Dynamic Lists,$BASEDN"
77 echo "Adding a dynamic list..."
78 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
79 > $TESTOUT 2>&1 << EOMODS
81 objectClass: organizationalUnit
84 dn: cn=Dynamic List,$LISTDN
85 objectClass: groupOfURLs
87 memberURL: ldap:///ou=People,${BASEDN}?cn,mail?sub?(objectClass=person)
90 echo "Testing list search of all attrs..."
91 echo "# Testing list search of all attrs..." >> $SEARCHOUT
92 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
93 '(cn=Dynamic List)' '*' \
96 if test $RC != 0 ; then
97 echo "ldapsearch failed ($RC)!"
98 test $KILLSERVERS != no && kill -HUP $KILLPIDS
102 echo "Testing list search of a listed attr..."
103 echo "# Testing list search of a listed attr..." >> $SEARCHOUT
104 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
105 '(cn=Dynamic List)' mail \
108 if test $RC != 0 ; then
109 echo "ldapsearch failed ($RC)!"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 echo "Testing list search of a non-listed attr..."
115 echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT
116 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
117 '(cn=Dynamic List)' objectClass \
120 if test $RC != 0 ; then
121 echo "ldapsearch failed ($RC)!"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 echo "Testing list search with (critical) manageDSAit..."
127 echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT
128 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \
129 '(cn=Dynamic List)' '*' \
132 if test $RC != 0 ; then
133 echo "ldapsearch failed ($RC)!"
134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138 echo "Testing list compare..."
139 echo "# Testing list compare..." >> $SEARCHOUT
140 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
141 "cn=Dynamic List,$LISTDN" "cn:Bjorn Jensen" \
146 echo "ldapcompare returned FALSE ($RC)!"
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 echo "ldapcompare returned TRUE ($RC)"
154 echo "ldapcompare returned success ($RC)!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 echo "ldapcompare failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 echo "" >> $SEARCHOUT
166 echo "Testing list compare (should return FALSE)..."
167 echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
168 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
169 "cn=Dynamic List,$LISTDN" "cn:FALSE" \
174 echo "ldapcompare returned FALSE ($RC)"
177 echo "ldapcompare returned TRUE ($RC)!"
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
182 echo "ldapcompare returned success ($RC)!"
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
187 echo "ldapcompare failed ($RC)!"
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 echo "" >> $SEARCHOUT
194 echo "Testing list compare (should return UNDEFINED)..."
195 echo "# Testing list compare (should return UNDEFINED)..." >> $SEARCHOUT
196 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
197 "cn=Dynamic List,$LISTDN" "dc:UNDEFINED" \
202 echo "ldapcompare returned FALSE ($RC)!"
203 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207 echo "ldapcompare returned TRUE ($RC)!"
208 test $KILLSERVERS != no && kill -HUP $KILLPIDS
212 echo "ldapcompare returned UNDEFINED ($RC)"
215 echo "ldapcompare returned success ($RC)!"
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 echo "ldapcompare failed ($RC)"
223 echo "" >> $SEARCHOUT
225 echo "Testing list compare with manageDSAit..."
226 echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT
227 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \
228 "cn=Dynamic List,$LISTDN" "cn:Bjorn Jensen" \
233 echo "ldapcompare returned FALSE ($RC)"
236 echo "ldapcompare returned TRUE ($RC)!"
237 test $KILLSERVERS != no && kill -HUP $KILLPIDS
241 echo "ldapcompare returned success ($RC)!"
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 echo "ldapcompare failed ($RC)!"
247 test $KILLSERVERS != no && kill -HUP $KILLPIDS
251 echo "" >> $SEARCHOUT
253 echo "Stopping slapd..."
257 echo "Reconfiguring slapd..."
258 . $CONFFILTER $BACKEND $MONITORDB < $DYNLISTCONF > $CONF1
259 echo "dynlist-attrset groupOfURLs memberURL member" >> $CONF1
261 echo "==========================================================" >> $LOG1
263 echo "Starting slapd on TCP/IP port $PORT1..."
264 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
266 if test $WAIT != 0 ; then
274 echo "Testing slapd searching..."
275 for i in 0 1 2 3 4 5; do
276 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
277 '(objectclass=*)' > /dev/null 2>&1
279 if test $RC = 0 ; then
282 echo "Waiting 5 seconds for slapd to start..."
286 if test $RC != 0 ; then
287 echo "ldapsearch failed ($RC)!"
288 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 echo "Adding a dynamic list..."
293 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
294 > $TESTOUT 2>&1 << EOMODS
295 dn: cn=Dynamic List of Members,$LISTDN
296 objectClass: groupOfURLs
297 cn: Dynamic List of Members
298 memberURL: ldap:///ou=People,${BASEDN}??sub?(objectClass=person)
301 echo "Testing list search of all attrs..."
302 echo "# Testing list search of all attrs..." >> $SEARCHOUT
303 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
304 '(cn=Dynamic List of Members)' '*' \
307 if test $RC != 0 ; then
308 echo "ldapsearch failed ($RC)!"
309 test $KILLSERVERS != no && kill -HUP $KILLPIDS
313 echo "Testing list search of a listed attr..."
314 echo "# Testing list search of a listed attr..." >> $SEARCHOUT
315 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
316 '(cn=Dynamic List of Members)' member \
319 if test $RC != 0 ; then
320 echo "ldapsearch failed ($RC)!"
321 test $KILLSERVERS != no && kill -HUP $KILLPIDS
325 echo "Testing list search of a non-listed attr..."
326 echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT
327 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
328 '(cn=Dynamic List of Members)' objectClass \
331 if test $RC != 0 ; then
332 echo "ldapsearch failed ($RC)!"
333 test $KILLSERVERS != no && kill -HUP $KILLPIDS
337 echo "Testing list search with (critical) manageDSAit..."
338 echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT
339 $LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \
340 '(&(cn=Dynamic List of Members)(objectClass=groupOfURLs))' '*' \
343 if test $RC != 0 ; then
344 echo "ldapsearch failed ($RC)!"
345 test $KILLSERVERS != no && kill -HUP $KILLPIDS
349 CMPDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN"
350 echo "Testing list compare..."
351 echo "# Testing list compare..." >> $SEARCHOUT
352 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
353 "cn=Dynamic List of Members,$LISTDN" "member:$CMPDN" \
358 echo "ldapcompare returned FALSE ($RC)!"
359 test $KILLSERVERS != no && kill -HUP $KILLPIDS
363 echo "ldapcompare returned TRUE ($RC)"
366 echo "ldapcompare returned success ($RC)!"
367 test $KILLSERVERS != no && kill -HUP $KILLPIDS
371 echo "ldapcompare failed ($RC)!"
372 test $KILLSERVERS != no && kill -HUP $KILLPIDS
376 echo "" >> $SEARCHOUT
378 echo "Testing list compare (should return FALSE)..."
379 echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
380 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
381 "cn=Dynamic List of Members,$LISTDN" "member:cn=Foo Bar" \
386 echo "ldapcompare returned FALSE ($RC)"
389 echo "ldapcompare returned TRUE ($RC)!"
390 test $KILLSERVERS != no && kill -HUP $KILLPIDS
394 echo "ldapcompare returned success ($RC)!"
395 test $KILLSERVERS != no && kill -HUP $KILLPIDS
399 echo "ldapcompare failed ($RC)!"
400 test $KILLSERVERS != no && kill -HUP $KILLPIDS
404 echo "" >> $SEARCHOUT
406 echo "Testing list compare with manageDSAit..."
407 echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT
408 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \
409 "cn=Dynamic List,$LISTDN" "member:$CMPDN" \
414 echo "ldapcompare returned FALSE ($RC)"
417 echo "ldapcompare returned TRUE ($RC)!"
418 test $KILLSERVERS != no && kill -HUP $KILLPIDS
422 echo "ldapcompare returned success ($RC)!"
423 test $KILLSERVERS != no && kill -HUP $KILLPIDS
427 echo "ldapcompare failed ($RC)!"
428 test $KILLSERVERS != no && kill -HUP $KILLPIDS
432 echo "" >> $SEARCHOUT
434 test $KILLSERVERS != no && kill -HUP $KILLPIDS
438 echo "Filtering ldapsearch results..."
439 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
440 echo "Filtering original ldif used to create database..."
441 . $LDIFFILTER < $LDIF > $LDIFFLT
442 echo "Comparing filter output..."
443 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
445 if test $? != 0 ; then
446 echo "Comparison failed"
450 echo ">>>>> Test succeeded"
452 test $KILLSERVERS != no && wait