Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test046-dds
blob9e71b1d8a34c07e1a551185a971635f58aafa646
1 #! /bin/sh
2 # $OpenLDAP: pkg/ldap/tests/scripts/test046-dds,v 1.4.2.3 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 2005-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
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 $DDS = ddsno; then
20 echo "Dynamic Directory Services overlay not available, test skipped"
21 exit 0
22 fi
24 mkdir -p $TESTDIR $DBDIR1
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
28 $SLAPADD -f $ADDCONF -l $LDIFORDERED
29 RC=$?
30 if test $RC != 0 ; then
31 echo "slapadd failed ($RC)!"
32 exit $RC
35 echo "Running slapindex to index slapd database..."
36 . $CONFFILTER $BACKEND $MONITORDB < $DDSCONF > $CONF1
37 $SLAPINDEX -f $CONF1
38 RC=$?
39 if test $RC != 0 ; then
40 echo "warning: slapindex failed ($RC)"
41 echo " assuming no indexing support"
44 echo "Starting slapd on TCP/IP port $PORT1..."
45 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
46 PID=$!
47 if test $WAIT != 0 ; then
48 echo PID $PID
49 read foo
51 KILLPIDS="$PID"
53 sleep 1
55 echo "Testing slapd searching..."
56 for i in 0 1 2 3 4 5; do
57 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
58 '(objectclass=*)' > /dev/null 2>&1
59 RC=$?
60 if test $RC = 0 ; then
61 break
63 echo "Waiting 5 seconds for slapd to start..."
64 sleep 5
65 done
67 if test $RC != 0 ; then
68 echo "ldapsearch failed ($RC)!"
69 test $KILLSERVERS != no && kill -HUP $KILLPIDS
70 exit $RC
73 cat /dev/null > $SEARCHOUT
75 echo "Creating a dynamic entry..."
76 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
77 >> $TESTOUT 2>&1 << EOMODS
78 dn: cn=Dynamic Object,dc=example,dc=com
79 objectClass: inetOrgPerson
80 objectClass: dynamicObject
81 cn: Dynamic Object
82 sn: Object
83 EOMODS
84 RC=$?
85 if test $RC != 0 ; then
86 echo "ldapadd failed ($RC)!"
87 test $KILLSERVERS != no && kill -HUP $KILLPIDS
88 exit $RC
91 echo "Refreshing the newly created dynamic entry..."
92 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
93 "refresh" "cn=Dynamic Object,dc=example,dc=com" "120" \
94 >> $TESTOUT 2>&1
95 RC=$?
96 if test $RC != 0 ; then
97 echo "ldapexop failed ($RC)!"
98 test $KILLSERVERS != no && kill -HUP $KILLPIDS
99 exit $RC
102 echo "Modifying the newly created dynamic entry..."
103 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
104 >> $TESTOUT 2>&1 << EOMODS
105 dn: cn=Dynamic Object,dc=example,dc=com
106 changetype: modify
107 add: userPassword
108 userPassword: dynamic
109 EOMODS
110 RC=$?
111 if test $RC != 0 ; then
112 echo "ldapadd failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 exit $RC
117 echo "Binding as the newly created dynamic entry..."
118 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
119 -D "cn=Dynamic Object,dc=example,dc=com" -w dynamic
120 RC=$?
121 if test $RC != 0 ; then
122 echo "ldapwhoami failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124 exit $RC
127 echo "Creating a dynamic entry subordinate to another..."
128 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
129 >> $TESTOUT 2>&1 << EOMODS
130 dn: cn=Subordinate Dynamic Object,cn=Dynamic Object,dc=example,dc=com
131 objectClass: inetOrgPerson
132 objectClass: dynamicObject
133 cn: Subordinate Dynamic Object
134 sn: Object
135 userPassword: dynamic
136 EOMODS
137 RC=$?
138 if test $RC != 0 ; then
139 echo "ldapadd failed ($RC)!"
140 test $KILLSERVERS != no && kill -HUP $KILLPIDS
141 exit $RC
144 SEARCH=0
146 SEARCH=`expr $SEARCH + 1`
147 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
148 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
149 '(objectClass=dynamicObject)' '*' entryTtl \
150 >> $SEARCHOUT 2>&1
151 RC=$?
152 if test $RC != 0 ; then
153 echo "ldapsearch failed ($RC)!"
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 exit $RC
158 echo "Creating a static entry subordinate to a dynamic one (should fail)..."
159 $LDAPADD -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
160 >> $TESTOUT 2>&1 << EOMODS
161 dn: cn=Subordinate Static Object,cn=Dynamic Object,dc=example,dc=com
162 objectClass: inetOrgPerson
163 cn: Subordinate Static Object
164 sn: Object
165 userPassword: static
166 EOMODS
167 RC=$?
168 case $RC in
170 echo "ldapadd should have failed ($RC)!"
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
172 exit -1
175 echo "ldapadd failed ($RC)"
178 echo "ldapadd failed ($RC)!"
179 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 exit $RC
182 esac
184 echo "Turning a static into a dynamic entry (should fail)..."
185 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
186 >> $TESTOUT 2>&1 << EOMODS
187 dn: ou=People,dc=example,dc=com
188 changetype: modify
189 add: objectClass
190 objectClass: dynamicObject
191 EOMODS
192 RC=$?
193 case $RC in
195 echo "ldapmodify should have failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 exit -1
200 echo "ldapmodify failed ($RC)"
203 echo "ldapmodify failed ($RC)!"
204 test $KILLSERVERS != no && kill -HUP $KILLPIDS
205 exit $RC
207 esac
209 echo "Turning a dynamic into a static entry (should fail)..."
210 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
211 >> $TESTOUT 2>&1 << EOMODS
212 dn: cn=Dynamic Object,dc=example,dc=com
213 changetype: modify
214 delete: objectClass
215 objectClass: dynamicObject
216 EOMODS
217 RC=$?
218 case $RC in
220 echo "ldapmodify should have failed ($RC)!"
221 test $KILLSERVERS != no && kill -HUP $KILLPIDS
222 exit -1
225 echo "ldapmodify failed ($RC)"
228 echo "ldapmodify failed ($RC)!"
229 test $KILLSERVERS != no && kill -HUP $KILLPIDS
230 exit $RC
232 esac
234 echo "Renaming a dynamic entry..."
235 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
236 >> $TESTOUT 2>&1 << EOMODS
237 dn: cn=Subordinate Dynamic Object,cn=Dynamic Object,dc=example,dc=com
238 changetype: modrdn
239 newrdn: cn=Renamed Dynamic Object
240 deleteoldrdn: 1
241 EOMODS
242 RC=$?
243 if test $RC != 0 ; then
244 echo "ldapmodrdn failed ($RC)!"
245 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 exit $RC
249 SEARCH=`expr $SEARCH + 1`
250 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
251 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
252 '(objectClass=dynamicObject)' '*' entryTtl \
253 >> $SEARCHOUT 2>&1
254 RC=$?
255 if test $RC != 0 ; then
256 echo "ldapsearch failed ($RC)!"
257 test $KILLSERVERS != no && kill -HUP $KILLPIDS
258 exit $RC
261 echo "Refreshing the initial dynamic entry to make it expire earlier than the subordinate..."
262 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
263 "refresh" "cn=Dynamic Object,dc=example,dc=com" "1" \
264 >> $TESTOUT 2>&1
265 RC=$?
266 if test $RC != 0 ; then
267 echo "ldapexop failed ($RC)!"
268 test $KILLSERVERS != no && kill -HUP $KILLPIDS
269 exit $RC
272 SLEEP=10
273 echo "Waiting $SLEEP seconds to force a subordinate/superior expiration conflict..."
274 sleep $SLEEP
276 echo "Re-vitalizing the initial dynamic entry..."
277 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
278 "refresh" "cn=Dynamic Object,dc=example,dc=com" "120" \
279 >> $TESTOUT 2>&1
280 RC=$?
281 if test $RC != 0 ; then
282 echo "ldapexop failed ($RC)!"
283 test $KILLSERVERS != no && kill -HUP $KILLPIDS
284 exit $RC
287 echo "Re-renaming the subordinate dynamic entry (new superior)..."
288 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
289 >> $TESTOUT 2>&1 << EOMODS
290 dn: cn=Renamed Dynamic Object,cn=Dynamic Object,dc=example,dc=com
291 changetype: modrdn
292 newrdn: cn=Renamed Dynamic Object
293 deleteoldrdn: 1
294 newsuperior: dc=example,dc=com
295 EOMODS
296 RC=$?
297 if test $RC != 0 ; then
298 echo "ldapmodrdn failed ($RC)!"
299 test $KILLSERVERS != no && kill -HUP $KILLPIDS
300 exit $RC
303 SEARCH=`expr $SEARCH + 1`
304 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
305 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
306 '(objectClass=dynamicObject)' '*' entryTtl \
307 >> $SEARCHOUT 2>&1
308 RC=$?
309 if test $RC != 0 ; then
310 echo "ldapsearch failed ($RC)!"
311 test $KILLSERVERS != no && kill -HUP $KILLPIDS
312 exit $RC
315 echo "Deleting a dynamic entry..."
316 $LDAPMODIFY -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
317 >> $TESTOUT 2>&1 << EOMODS
318 dn: cn=Dynamic Object,dc=example,dc=com
319 changetype: delete
320 EOMODS
321 RC=$?
322 if test $RC != 0 ; then
323 echo "ldapdelete failed ($RC)!"
324 test $KILLSERVERS != no && kill -HUP $KILLPIDS
325 exit $RC
328 SEARCH=`expr $SEARCH + 1`
329 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
330 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
331 '(objectClass=dynamicObject)' '*' entryTtl \
332 >> $SEARCHOUT 2>&1
333 RC=$?
334 if test $RC != 0 ; then
335 echo "ldapsearch failed ($RC)!"
336 test $KILLSERVERS != no && kill -HUP $KILLPIDS
337 exit $RC
340 echo "Refreshing the remaining dynamic entry..."
341 $LDAPEXOP -D $MANAGERDN -w $PASSWD -h $LOCALHOST -p $PORT1 \
342 "refresh" "cn=Renamed Dynamic Object,dc=example,dc=com" "1" \
343 >> $TESTOUT 2>&1
344 RC=$?
345 if test $RC != 0 ; then
346 echo "ldapexop failed ($RC)!"
347 test $KILLSERVERS != no && kill -HUP $KILLPIDS
348 exit $RC
351 SEARCH=`expr $SEARCH + 1`
352 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
353 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
354 '(objectClass=dynamicObject)' '*' entryTtl \
355 >> $SEARCHOUT 2>&1
356 RC=$?
357 if test $RC != 0 ; then
358 echo "ldapsearch failed ($RC)!"
359 test $KILLSERVERS != no && kill -HUP $KILLPIDS
360 exit $RC
363 SLEEP=15
364 echo "Waiting $SLEEP seconds for remaining entry to expire..."
365 sleep $SLEEP
367 SEARCH=`expr $SEARCH + 1`
368 echo "# [$SEARCH] Searching the dynamic portion of the database..." >> $SEARCHOUT
369 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
370 '(objectClass=dynamicObject)' '*' entryTtl \
371 >> $SEARCHOUT 2>&1
372 RC=$?
373 if test $RC != 0 ; then
374 echo "ldapsearch failed ($RC)!"
375 test $KILLSERVERS != no && kill -HUP $KILLPIDS
376 exit $RC
379 # Meeting
380 MEETINGDN="cn=Meeting,ou=Groups,dc=example,dc=com"
381 echo "Creating a meeting as $BJORNSDN..."
382 $LDAPMODIFY -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
383 >> $TESTOUT 2>&1 << EOMODS
384 dn: $MEETINGDN
385 changetype: add
386 objectClass: groupOfNames
387 objectClass: dynamicObject
388 cn: Meeting
389 member: $BJORNSDN
391 dn: $MEETINGDN
392 changetype: modify
393 add: member
394 member: $JAJDN
395 EOMODS
396 RC=$?
397 if test $RC != 0 ; then
398 echo "ldapmodify failed ($RC)!"
399 test $KILLSERVERS != no && kill -HUP $KILLPIDS
400 exit $RC
403 echo "Refreshing the meeting as $BJORNSDN..."
404 $LDAPEXOP -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
405 "refresh" "$MEETINGDN" "120" \
406 >> $TESTOUT 2>&1
407 RC=$?
408 if test $RC != 0 ; then
409 echo "ldapexop failed ($RC)!"
410 test $KILLSERVERS != no && kill -HUP $KILLPIDS
411 exit $RC
414 echo "Joining the meeting as $BABSDN..."
415 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
416 >> $TESTOUT 2>&1 << EOMODS
417 dn: $MEETINGDN
418 changetype: modify
419 add: member
420 member: $BABSDN
421 EOMODS
422 RC=$?
423 if test $RC != 0 ; then
424 echo "ldapmodify failed ($RC)!"
425 test $KILLSERVERS != no && kill -HUP $KILLPIDS
426 exit $RC
429 echo "Trying to add a member as $BABSDN (should fail)..."
430 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
431 >> $TESTOUT 2>&1 << EOMODS
432 dn: $MEETINGDN
433 changetype: modify
434 add: member
435 member: $MELLIOTDN
436 EOMODS
437 RC=$?
438 case $RC in
440 echo "ldapmodify should have failed ($RC)!"
441 test $KILLSERVERS != no && kill -HUP $KILLPIDS
442 exit $RC
445 echo "ldapmodify failed ($RC)"
448 echo "ldapmodify failed ($RC)!"
449 test $KILLSERVERS != no && kill -HUP $KILLPIDS
450 exit $RC
452 esac
454 echo "Refreshing the meeting as $BABSDN..."
455 $LDAPEXOP -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
456 "refresh" "$MEETINGDN" "180" \
457 >> $TESTOUT 2>&1
458 RC=$?
459 if test $RC != 0 ; then
460 echo "ldapexop failed ($RC)!"
461 test $KILLSERVERS != no && kill -HUP $KILLPIDS
462 exit $RC
465 echo "Trying to refresh the meeting anonymously (should fail)..."
466 $LDAPEXOP -h $LOCALHOST -p $PORT1 \
467 "refresh" "$MEETINGDN" "240" \
468 >> $TESTOUT 2>&1
469 RC=$?
470 if test $RC = 0 ; then
471 echo "ldapexop should have failed ($RC)!"
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
473 exit $RC
476 echo "Trying to delete the meeting as $BABSDN (should fail)..."
477 $LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
478 >> $TESTOUT 2>&1 << EOMODS
479 dn: $MEETINGDN
480 changetype: delete
481 EOMODS
482 RC=$?
483 case $RC in
485 echo "ldapdelete should have failed ($RC)!"
486 test $KILLSERVERS != no && kill -HUP $KILLPIDS
487 exit $RC
490 echo "ldapdelete failed ($RC)"
493 echo "ldapdelete failed ($RC)!"
494 test $KILLSERVERS != no && kill -HUP $KILLPIDS
495 exit $RC
497 esac
499 echo "Deleting the meeting as $BJORNSDN..."
500 $LDAPMODIFY -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
501 >> $TESTOUT 2>&1 << EOMODS
502 dn: $MEETINGDN
503 changetype: delete
504 EOMODS
505 RC=$?
506 if test $RC != 0 ; then
507 echo "ldapdelete failed ($RC)!"
508 test $KILLSERVERS != no && kill -HUP $KILLPIDS
509 exit $RC
512 test $KILLSERVERS != no && kill -HUP $KILLPIDS
514 LDIF=$DDSOUT
516 echo "Filtering ldapsearch results..."
517 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
518 echo "Filtering original ldif used to create database..."
519 . $LDIFFILTER < $LDIF > $LDIFFLT
520 echo "Comparing filter output..."
521 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
523 if test $? != 0 ; then
524 echo "Comparison failed"
525 exit 1
528 echo ">>>>> Test succeeded"
530 test $KILLSERVERS != no && wait
532 exit 0