3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2005-2009 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $BACKEND = "ldif" ; then
20 echo "LDIF backend does not support acls, test skipped"
24 if test $DDS = ddsno; then
25 echo "Dynamic Directory Services overlay not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1
31 echo "Running slapadd to build slapd database..."
32 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
33 $SLAPADD -f $ADDCONF -l $LDIFORDERED
35 if test $RC != 0 ; then
36 echo "slapadd failed ($RC)!"
40 echo "Running slapindex to index slapd database..."
41 . $CONFFILTER $BACKEND $MONITORDB < $DDSCONF > $CONF1
44 if test $RC != 0 ; then
45 echo "warning: slapindex failed ($RC)"
46 echo " assuming no indexing support"
49 echo "Starting slapd on TCP/IP port $PORT1..."
50 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
52 if test $WAIT != 0 ; then
60 echo "Testing slapd searching..."
61 for i in 0 1 2 3 4 5; do
62 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
63 '(objectclass=*)' > /dev/null 2>&1
65 if test $RC = 0 ; then
68 echo "Waiting 5 seconds for slapd to start..."
72 if test $RC != 0 ; then
73 echo "ldapsearch failed ($RC)!"
74 test $KILLSERVERS != no && kill -HUP $KILLPIDS
78 cat /dev/null > $SEARCHOUT
80 echo "Creating a dynamic entry..."
81 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
82 >> $TESTOUT 2>&1 << EOMODS
83 dn: cn=Dynamic Object,dc=example,dc=com
84 objectClass: inetOrgPerson
85 objectClass: dynamicObject
90 if test $RC != 0 ; then
91 echo "ldapadd failed ($RC)!"
92 test $KILLSERVERS != no && kill -HUP $KILLPIDS
96 echo "Refreshing the newly created dynamic entry..."
97 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
98 "refresh" "cn=Dynamic Object,dc=example,dc=com" "120" \
101 if test $RC != 0 ; then
102 echo "ldapexop failed ($RC)!"
103 test $KILLSERVERS != no && kill -HUP $KILLPIDS
107 echo "Modifying the newly created dynamic entry..."
108 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
109 >> $TESTOUT 2>&1 << EOMODS
110 dn: cn=Dynamic Object,dc=example,dc=com
113 userPassword: dynamic
116 if test $RC != 0 ; then
117 echo "ldapadd failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
122 echo "Binding as the newly created dynamic entry..."
123 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
124 -D "cn=Dynamic Object,dc=example,dc=com" -w dynamic
126 if test $RC != 0 ; then
127 echo "ldapwhoami failed ($RC)!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
132 echo "Creating a dynamic entry subordinate to another..."
133 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
134 >> $TESTOUT 2>&1 << EOMODS
135 dn: cn=Subordinate Dynamic Object,cn=Dynamic Object,dc=example,dc=com
136 objectClass: inetOrgPerson
137 objectClass: dynamicObject
138 cn: Subordinate Dynamic Object
140 userPassword: dynamic
143 if test $RC != 0 ; then
144 echo "ldapadd failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 SEARCH=`expr $SEARCH + 1`
152 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
153 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
154 '(objectClass=dynamicObject)' '*' entryTtl \
157 if test $RC != 0 ; then
158 echo "ldapsearch failed ($RC)!"
159 test $KILLSERVERS != no && kill -HUP $KILLPIDS
163 echo "Creating a static entry subordinate to a dynamic one (should fail)..."
164 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
165 >> $TESTOUT 2>&1 << EOMODS
166 dn: cn=Subordinate Static Object,cn=Dynamic Object,dc=example,dc=com
167 objectClass: inetOrgPerson
168 cn: Subordinate Static Object
175 echo "ldapadd should have failed ($RC)!"
176 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 echo "ldapadd failed ($RC)"
183 echo "ldapadd failed ($RC)!"
184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 echo "Turning a static into a dynamic entry (should fail)..."
190 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
191 >> $TESTOUT 2>&1 << EOMODS
192 dn: ou=People,dc=example,dc=com
195 objectClass: dynamicObject
200 echo "ldapmodify should have failed ($RC)!"
201 test $KILLSERVERS != no && kill -HUP $KILLPIDS
205 echo "ldapmodify failed ($RC)"
208 echo "ldapmodify failed ($RC)!"
209 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 echo "Turning a dynamic into a static entry (should fail)..."
215 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
216 >> $TESTOUT 2>&1 << EOMODS
217 dn: cn=Dynamic Object,dc=example,dc=com
220 objectClass: dynamicObject
225 echo "ldapmodify should have failed ($RC)!"
226 test $KILLSERVERS != no && kill -HUP $KILLPIDS
230 echo "ldapmodify failed ($RC)"
233 echo "ldapmodify failed ($RC)!"
234 test $KILLSERVERS != no && kill -HUP $KILLPIDS
239 echo "Renaming a dynamic entry..."
240 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
241 >> $TESTOUT 2>&1 << EOMODS
242 dn: cn=Subordinate Dynamic Object,cn=Dynamic Object,dc=example,dc=com
244 newrdn: cn=Renamed Dynamic Object
248 if test $RC != 0 ; then
249 echo "ldapmodrdn failed ($RC)!"
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
254 SEARCH=`expr $SEARCH + 1`
255 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
256 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
257 '(objectClass=dynamicObject)' '*' entryTtl \
260 if test $RC != 0 ; then
261 echo "ldapsearch failed ($RC)!"
262 test $KILLSERVERS != no && kill -HUP $KILLPIDS
266 echo "Refreshing the initial dynamic entry to make it expire earlier than the subordinate..."
267 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
268 "refresh" "cn=Dynamic Object,dc=example,dc=com" "1" \
271 if test $RC != 0 ; then
272 echo "ldapexop failed ($RC)!"
273 test $KILLSERVERS != no && kill -HUP $KILLPIDS
278 echo "Waiting $SLEEP seconds to force a subordinate/superior expiration conflict..."
281 echo "Re-vitalizing the initial dynamic entry..."
282 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
283 "refresh" "cn=Dynamic Object,dc=example,dc=com" "120" \
286 if test $RC != 0 ; then
287 echo "ldapexop failed ($RC)!"
288 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 echo "Re-renaming the subordinate dynamic entry (new superior)..."
293 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
294 >> $TESTOUT 2>&1 << EOMODS
295 dn: cn=Renamed Dynamic Object,cn=Dynamic Object,dc=example,dc=com
297 newrdn: cn=Renamed Dynamic Object
299 newsuperior: dc=example,dc=com
302 if test $RC != 0 ; then
303 echo "ldapmodrdn failed ($RC)!"
304 test $KILLSERVERS != no && kill -HUP $KILLPIDS
308 SEARCH=`expr $SEARCH + 1`
309 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
310 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
311 '(objectClass=dynamicObject)' '*' entryTtl \
314 if test $RC != 0 ; then
315 echo "ldapsearch failed ($RC)!"
316 test $KILLSERVERS != no && kill -HUP $KILLPIDS
320 echo "Deleting a dynamic entry..."
321 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
322 >> $TESTOUT 2>&1 << EOMODS
323 dn: cn=Dynamic Object,dc=example,dc=com
327 if test $RC != 0 ; then
328 echo "ldapdelete failed ($RC)!"
329 test $KILLSERVERS != no && kill -HUP $KILLPIDS
333 SEARCH=`expr $SEARCH + 1`
334 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
335 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
336 '(objectClass=dynamicObject)' '*' entryTtl \
339 if test $RC != 0 ; then
340 echo "ldapsearch failed ($RC)!"
341 test $KILLSERVERS != no && kill -HUP $KILLPIDS
345 echo "Refreshing the remaining dynamic entry..."
346 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
347 "refresh" "cn=Renamed Dynamic Object,dc=example,dc=com" "1" \
350 if test $RC != 0 ; then
351 echo "ldapexop failed ($RC)!"
352 test $KILLSERVERS != no && kill -HUP $KILLPIDS
356 SEARCH=`expr $SEARCH + 1`
357 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
358 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
359 '(objectClass=dynamicObject)' '*' entryTtl \
362 if test $RC != 0 ; then
363 echo "ldapsearch failed ($RC)!"
364 test $KILLSERVERS != no && kill -HUP $KILLPIDS
369 echo "Waiting $SLEEP seconds for remaining entry to expire..."
372 SEARCH=`expr $SEARCH + 1`
373 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
374 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
375 '(objectClass=dynamicObject)' '*' entryTtl \
378 if test $RC != 0 ; then
379 echo "ldapsearch failed ($RC)!"
380 test $KILLSERVERS != no && kill -HUP $KILLPIDS
385 MEETINGDN="cn=Meeting,ou=Groups,dc=example,dc=com"
386 echo "Creating a meeting as $BJORNSDN..."
387 $LDAPMODIFY -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
388 >> $TESTOUT 2>&1 << EOMODS
391 objectClass: groupOfNames
392 objectClass: dynamicObject
402 if test $RC != 0 ; then
403 echo "ldapmodify failed ($RC)!"
404 test $KILLSERVERS != no && kill -HUP $KILLPIDS
408 echo "Refreshing the meeting as $BJORNSDN..."
409 $LDAPEXOP -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
410 "refresh" "$MEETINGDN" "120" \
413 if test $RC != 0 ; then
414 echo "ldapexop failed ($RC)!"
415 test $KILLSERVERS != no && kill -HUP $KILLPIDS
419 echo "Joining the meeting as $BABSDN..."
420 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
421 >> $TESTOUT 2>&1 << EOMODS
428 if test $RC != 0 ; then
429 echo "ldapmodify failed ($RC)!"
430 test $KILLSERVERS != no && kill -HUP $KILLPIDS
434 echo "Trying to add a member as $BABSDN (should fail)..."
435 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
436 >> $TESTOUT 2>&1 << EOMODS
445 echo "ldapmodify should have failed ($RC)!"
446 test $KILLSERVERS != no && kill -HUP $KILLPIDS
450 echo "ldapmodify failed ($RC)"
453 echo "ldapmodify failed ($RC)!"
454 test $KILLSERVERS != no && kill -HUP $KILLPIDS
459 echo "Refreshing the meeting as $BABSDN..."
460 $LDAPEXOP -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
461 "refresh" "$MEETINGDN" "180" \
464 if test $RC != 0 ; then
465 echo "ldapexop failed ($RC)!"
466 test $KILLSERVERS != no && kill -HUP $KILLPIDS
470 echo "Trying to refresh the meeting anonymously (should fail)..."
471 $LDAPEXOP -h $LOCALHOST -p $PORT1 \
472 "refresh" "$MEETINGDN" "240" \
475 if test $RC = 0 ; then
476 echo "ldapexop should have failed ($RC)!"
477 test $KILLSERVERS != no && kill -HUP $KILLPIDS
481 echo "Trying to delete the meeting as $BABSDN (should fail)..."
482 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
483 >> $TESTOUT 2>&1 << EOMODS
490 echo "ldapdelete should have failed ($RC)!"
491 test $KILLSERVERS != no && kill -HUP $KILLPIDS
495 echo "ldapdelete failed ($RC)"
498 echo "ldapdelete failed ($RC)!"
499 test $KILLSERVERS != no && kill -HUP $KILLPIDS
504 echo "Deleting the meeting as $BJORNSDN..."
505 $LDAPMODIFY -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
506 >> $TESTOUT 2>&1 << EOMODS
511 if test $RC != 0 ; then
512 echo "ldapdelete failed ($RC)!"
513 test $KILLSERVERS != no && kill -HUP $KILLPIDS
517 test $KILLSERVERS != no && kill -HUP $KILLPIDS
521 echo "Filtering ldapsearch results..."
522 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
523 echo "Filtering original ldif used to create database..."
524 . $LDIFFILTER < $LDIF > $LDIFFLT
525 echo "Comparing filter output..."
526 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
528 if test $? != 0 ; then
529 echo "Comparison failed"
533 echo ">>>>> Test succeeded"
535 test $KILLSERVERS != no && wait