3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2005-2011 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 case $BACKEND in ldif | null)
20 # LDIF lacks ACL support, NULL cannot hold dynamic entries
21 echo "Test does not support $BACKEND backend, test skipped"
25 if test $DDS = ddsno; then
26 echo "Dynamic Directory Services overlay not available, test skipped"
30 mkdir -p $TESTDIR $DBDIR1
32 echo "Running slapadd to build slapd database..."
33 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
34 $SLAPADD -f $ADDCONF -l $LDIFORDERED
36 if test $RC != 0 ; then
37 echo "slapadd failed ($RC)!"
41 echo "Running slapindex to index slapd database..."
42 . $CONFFILTER $BACKEND $MONITORDB < $DDSCONF > $CONF1
45 if test $RC != 0 ; then
46 echo "warning: slapindex failed ($RC)"
47 echo " assuming no indexing support"
50 echo "Starting slapd on TCP/IP port $PORT1..."
51 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
53 if test $WAIT != 0 ; then
61 echo "Testing slapd searching..."
62 for i in 0 1 2 3 4 5; do
63 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
64 '(objectclass=*)' > /dev/null 2>&1
66 if test $RC = 0 ; then
69 echo "Waiting 5 seconds for slapd to start..."
73 if test $RC != 0 ; then
74 echo "ldapsearch failed ($RC)!"
75 test $KILLSERVERS != no && kill -HUP $KILLPIDS
79 cat /dev/null > $SEARCHOUT
81 echo "Creating a dynamic entry..."
82 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
83 >> $TESTOUT 2>&1 << EOMODS
84 dn: cn=Dynamic Object,dc=example,dc=com
85 objectClass: inetOrgPerson
86 objectClass: dynamicObject
91 if test $RC != 0 ; then
92 echo "ldapadd failed ($RC)!"
93 test $KILLSERVERS != no && kill -HUP $KILLPIDS
97 echo "Refreshing the newly created dynamic entry..."
98 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
99 "refresh" "cn=Dynamic Object,dc=example,dc=com" "120" \
102 if test $RC != 0 ; then
103 echo "ldapexop failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 echo "Modifying the newly created dynamic entry..."
109 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
110 >> $TESTOUT 2>&1 << EOMODS
111 dn: cn=Dynamic Object,dc=example,dc=com
114 userPassword: dynamic
117 if test $RC != 0 ; then
118 echo "ldapadd failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 echo "Binding as the newly created dynamic entry..."
124 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
125 -D "cn=Dynamic Object,dc=example,dc=com" -w dynamic
127 if test $RC != 0 ; then
128 echo "ldapwhoami failed ($RC)!"
129 test $KILLSERVERS != no && kill -HUP $KILLPIDS
133 echo "Creating a dynamic entry subordinate to another..."
134 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
135 >> $TESTOUT 2>&1 << EOMODS
136 dn: cn=Subordinate Dynamic Object,cn=Dynamic Object,dc=example,dc=com
137 objectClass: inetOrgPerson
138 objectClass: dynamicObject
139 cn: Subordinate Dynamic Object
141 userPassword: dynamic
144 if test $RC != 0 ; then
145 echo "ldapadd failed ($RC)!"
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 SEARCH=`expr $SEARCH + 1`
153 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
154 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
155 '(objectClass=dynamicObject)' '*' entryTtl \
158 if test $RC != 0 ; then
159 echo "ldapsearch failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 echo "Creating a static entry subordinate to a dynamic one (should fail)..."
165 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
166 >> $TESTOUT 2>&1 << EOMODS
167 dn: cn=Subordinate Static Object,cn=Dynamic Object,dc=example,dc=com
168 objectClass: inetOrgPerson
169 cn: Subordinate Static Object
176 echo "ldapadd should have failed ($RC)!"
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
181 echo "ldapadd failed ($RC)"
184 echo "ldapadd failed ($RC)!"
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
190 echo "Turning a static into a dynamic entry (should fail)..."
191 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
192 >> $TESTOUT 2>&1 << EOMODS
193 dn: ou=People,dc=example,dc=com
196 objectClass: dynamicObject
201 echo "ldapmodify should have failed ($RC)!"
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
206 echo "ldapmodify failed ($RC)"
209 echo "ldapmodify failed ($RC)!"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 echo "Turning a dynamic into a static entry (should fail)..."
216 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
217 >> $TESTOUT 2>&1 << EOMODS
218 dn: cn=Dynamic Object,dc=example,dc=com
221 objectClass: dynamicObject
226 echo "ldapmodify should have failed ($RC)!"
227 test $KILLSERVERS != no && kill -HUP $KILLPIDS
231 echo "ldapmodify failed ($RC)"
234 echo "ldapmodify failed ($RC)!"
235 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 echo "Renaming a dynamic entry..."
241 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
242 >> $TESTOUT 2>&1 << EOMODS
243 dn: cn=Subordinate Dynamic Object,cn=Dynamic Object,dc=example,dc=com
245 newrdn: cn=Renamed Dynamic Object
249 if test $RC != 0 ; then
250 echo "ldapmodrdn failed ($RC)!"
251 test $KILLSERVERS != no && kill -HUP $KILLPIDS
255 SEARCH=`expr $SEARCH + 1`
256 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
257 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
258 '(objectClass=dynamicObject)' '*' entryTtl \
261 if test $RC != 0 ; then
262 echo "ldapsearch failed ($RC)!"
263 test $KILLSERVERS != no && kill -HUP $KILLPIDS
267 echo "Refreshing the initial dynamic entry to make it expire earlier than the subordinate..."
268 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
269 "refresh" "cn=Dynamic Object,dc=example,dc=com" "1" \
272 if test $RC != 0 ; then
273 echo "ldapexop failed ($RC)!"
274 test $KILLSERVERS != no && kill -HUP $KILLPIDS
279 echo "Waiting $SLEEP seconds to force a subordinate/superior expiration conflict..."
282 echo "Re-vitalizing the initial dynamic entry..."
283 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
284 "refresh" "cn=Dynamic Object,dc=example,dc=com" "120" \
287 if test $RC != 0 ; then
288 echo "ldapexop failed ($RC)!"
289 test $KILLSERVERS != no && kill -HUP $KILLPIDS
293 echo "Re-renaming the subordinate dynamic entry (new superior)..."
294 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
295 >> $TESTOUT 2>&1 << EOMODS
296 dn: cn=Renamed Dynamic Object,cn=Dynamic Object,dc=example,dc=com
298 newrdn: cn=Renamed Dynamic Object
300 newsuperior: dc=example,dc=com
303 if test $RC != 0 ; then
304 echo "ldapmodrdn failed ($RC)!"
305 test $KILLSERVERS != no && kill -HUP $KILLPIDS
309 SEARCH=`expr $SEARCH + 1`
310 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
311 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
312 '(objectClass=dynamicObject)' '*' entryTtl \
315 if test $RC != 0 ; then
316 echo "ldapsearch failed ($RC)!"
317 test $KILLSERVERS != no && kill -HUP $KILLPIDS
321 echo "Deleting a dynamic entry..."
322 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
323 >> $TESTOUT 2>&1 << EOMODS
324 dn: cn=Dynamic Object,dc=example,dc=com
328 if test $RC != 0 ; then
329 echo "ldapdelete failed ($RC)!"
330 test $KILLSERVERS != no && kill -HUP $KILLPIDS
334 SEARCH=`expr $SEARCH + 1`
335 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
336 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
337 '(objectClass=dynamicObject)' '*' entryTtl \
340 if test $RC != 0 ; then
341 echo "ldapsearch failed ($RC)!"
342 test $KILLSERVERS != no && kill -HUP $KILLPIDS
346 echo "Refreshing the remaining dynamic entry..."
347 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
348 "refresh" "cn=Renamed Dynamic Object,dc=example,dc=com" "1" \
351 if test $RC != 0 ; then
352 echo "ldapexop failed ($RC)!"
353 test $KILLSERVERS != no && kill -HUP $KILLPIDS
357 SEARCH=`expr $SEARCH + 1`
358 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
359 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
360 '(objectClass=dynamicObject)' '*' entryTtl \
363 if test $RC != 0 ; then
364 echo "ldapsearch failed ($RC)!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
370 echo "Waiting $SLEEP seconds for remaining entry to expire..."
373 SEARCH=`expr $SEARCH + 1`
374 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
375 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
376 '(objectClass=dynamicObject)' '*' entryTtl \
379 if test $RC != 0 ; then
380 echo "ldapsearch failed ($RC)!"
381 test $KILLSERVERS != no && kill -HUP $KILLPIDS
386 MEETINGDN="cn=Meeting,ou=Groups,dc=example,dc=com"
387 echo "Creating a meeting as $BJORNSDN..."
388 $LDAPMODIFY -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
389 >> $TESTOUT 2>&1 << EOMODS
392 objectClass: groupOfNames
393 objectClass: dynamicObject
403 if test $RC != 0 ; then
404 echo "ldapmodify failed ($RC)!"
405 test $KILLSERVERS != no && kill -HUP $KILLPIDS
409 echo "Refreshing the meeting as $BJORNSDN..."
410 $LDAPEXOP -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
411 "refresh" "$MEETINGDN" "120" \
414 if test $RC != 0 ; then
415 echo "ldapexop failed ($RC)!"
416 test $KILLSERVERS != no && kill -HUP $KILLPIDS
420 echo "Joining the meeting as $BABSDN..."
421 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
422 >> $TESTOUT 2>&1 << EOMODS
429 if test $RC != 0 ; then
430 echo "ldapmodify failed ($RC)!"
431 test $KILLSERVERS != no && kill -HUP $KILLPIDS
435 echo "Trying to add a member as $BABSDN (should fail)..."
436 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
437 >> $TESTOUT 2>&1 << EOMODS
446 echo "ldapmodify should have failed ($RC)!"
447 test $KILLSERVERS != no && kill -HUP $KILLPIDS
451 echo "ldapmodify failed ($RC)"
454 echo "ldapmodify failed ($RC)!"
455 test $KILLSERVERS != no && kill -HUP $KILLPIDS
460 echo "Refreshing the meeting as $BABSDN..."
461 $LDAPEXOP -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
462 "refresh" "$MEETINGDN" "180" \
465 if test $RC != 0 ; then
466 echo "ldapexop failed ($RC)!"
467 test $KILLSERVERS != no && kill -HUP $KILLPIDS
471 echo "Trying to refresh the meeting anonymously (should fail)..."
472 $LDAPEXOP -h $LOCALHOST -p $PORT1 \
473 "refresh" "$MEETINGDN" "240" \
476 if test $RC = 0 ; then
477 echo "ldapexop should have failed ($RC)!"
478 test $KILLSERVERS != no && kill -HUP $KILLPIDS
482 echo "Trying to refresh the meeting as $JAJDN (should fail)..."
483 $LDAPEXOP -D "$JAJDN" -w "jaj" -h $LOCALHOST -p $PORT1 \
484 "refresh" "$MEETINGDN" "240" \
487 if test $RC = 0 ; then
488 echo "ldapexop should have failed ($RC)!"
489 test $KILLSERVERS != no && kill -HUP $KILLPIDS
493 echo "Trying to delete the meeting as $BABSDN (should fail)..."
494 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
495 >> $TESTOUT 2>&1 << EOMODS
502 echo "ldapdelete should have failed ($RC)!"
503 test $KILLSERVERS != no && kill -HUP $KILLPIDS
507 echo "ldapdelete failed ($RC)"
510 echo "ldapdelete failed ($RC)!"
511 test $KILLSERVERS != no && kill -HUP $KILLPIDS
516 echo "Deleting the meeting as $BJORNSDN..."
517 $LDAPMODIFY -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
518 >> $TESTOUT 2>&1 << EOMODS
523 if test $RC != 0 ; then
524 echo "ldapdelete failed ($RC)!"
525 test $KILLSERVERS != no && kill -HUP $KILLPIDS
529 test $KILLSERVERS != no && kill -HUP $KILLPIDS
533 echo "Filtering ldapsearch results..."
534 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
535 echo "Filtering original ldif used to create database..."
536 $LDIFFILTER < $LDIF > $LDIFFLT
537 echo "Comparing filter output..."
538 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
540 if test $? != 0 ; then
541 echo "Comparison failed"
545 echo ">>>>> Test succeeded"
547 test $KILLSERVERS != no && wait