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/>.
5
## Copyright 2005-2008 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 $DDS = ddsno; then
20
echo "Dynamic Directory Services overlay not available, test skipped"
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
30
if test $RC != 0 ; then
31
echo "slapadd failed ($RC)!"
35
echo "Running slapindex to index slapd database..."
36
. $CONFFILTER $BACKEND $MONITORDB < $DDSCONF > $CONF1
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 &
47
if test $WAIT != 0 ; then
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
60
if test $RC = 0 ; then
63
echo "Waiting 5 seconds for slapd to start..."
67
if test $RC != 0 ; then
68
echo "ldapsearch failed ($RC)!"
69
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
85
if test $RC != 0 ; then
86
echo "ldapadd failed ($RC)!"
87
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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" \
96
if test $RC != 0 ; then
97
echo "ldapexop failed ($RC)!"
98
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
108
userPassword: dynamic
111
if test $RC != 0 ; then
112
echo "ldapadd failed ($RC)!"
113
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
121
if test $RC != 0 ; then
122
echo "ldapwhoami failed ($RC)!"
123
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
135
userPassword: dynamic
138
if test $RC != 0 ; then
139
echo "ldapadd failed ($RC)!"
140
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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 \
152
if test $RC != 0 ; then
153
echo "ldapsearch failed ($RC)!"
154
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
170
echo "ldapadd should have failed ($RC)!"
171
test $KILLSERVERS != no && kill -HUP $KILLPIDS
175
echo "ldapadd failed ($RC)"
178
echo "ldapadd failed ($RC)!"
179
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
190
objectClass: dynamicObject
195
echo "ldapmodify should have failed ($RC)!"
196
test $KILLSERVERS != no && kill -HUP $KILLPIDS
200
echo "ldapmodify failed ($RC)"
203
echo "ldapmodify failed ($RC)!"
204
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
215
objectClass: dynamicObject
220
echo "ldapmodify should have failed ($RC)!"
221
test $KILLSERVERS != no && kill -HUP $KILLPIDS
225
echo "ldapmodify failed ($RC)"
228
echo "ldapmodify failed ($RC)!"
229
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
239
newrdn: cn=Renamed Dynamic Object
243
if test $RC != 0 ; then
244
echo "ldapmodrdn failed ($RC)!"
245
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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 \
255
if test $RC != 0 ; then
256
echo "ldapsearch failed ($RC)!"
257
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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" \
266
if test $RC != 0 ; then
267
echo "ldapexop failed ($RC)!"
268
test $KILLSERVERS != no && kill -HUP $KILLPIDS
273
echo "Waiting $SLEEP seconds to force a subordinate/superior expiration conflict..."
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" \
281
if test $RC != 0 ; then
282
echo "ldapexop failed ($RC)!"
283
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
292
newrdn: cn=Renamed Dynamic Object
294
newsuperior: dc=example,dc=com
297
if test $RC != 0 ; then
298
echo "ldapmodrdn failed ($RC)!"
299
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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 \
309
if test $RC != 0 ; then
310
echo "ldapsearch failed ($RC)!"
311
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
322
if test $RC != 0 ; then
323
echo "ldapdelete failed ($RC)!"
324
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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 \
334
if test $RC != 0 ; then
335
echo "ldapsearch failed ($RC)!"
336
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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" \
345
if test $RC != 0 ; then
346
echo "ldapexop failed ($RC)!"
347
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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 \
357
if test $RC != 0 ; then
358
echo "ldapsearch failed ($RC)!"
359
test $KILLSERVERS != no && kill -HUP $KILLPIDS
364
echo "Waiting $SLEEP seconds for remaining entry to expire..."
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 \
373
if test $RC != 0 ; then
374
echo "ldapsearch failed ($RC)!"
375
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
386
objectClass: groupOfNames
387
objectClass: dynamicObject
397
if test $RC != 0 ; then
398
echo "ldapmodify failed ($RC)!"
399
test $KILLSERVERS != no && kill -HUP $KILLPIDS
403
echo "Refreshing the meeting as $BJORNSDN..."
404
$LDAPEXOP -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
405
"refresh" "$MEETINGDN" "120" \
408
if test $RC != 0 ; then
409
echo "ldapexop failed ($RC)!"
410
test $KILLSERVERS != no && kill -HUP $KILLPIDS
414
echo "Joining the meeting as $BABSDN..."
415
$LDAPMODIFY -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
416
>> $TESTOUT 2>&1 << EOMODS
423
if test $RC != 0 ; then
424
echo "ldapmodify failed ($RC)!"
425
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
440
echo "ldapmodify should have failed ($RC)!"
441
test $KILLSERVERS != no && kill -HUP $KILLPIDS
445
echo "ldapmodify failed ($RC)"
448
echo "ldapmodify failed ($RC)!"
449
test $KILLSERVERS != no && kill -HUP $KILLPIDS
454
echo "Refreshing the meeting as $BABSDN..."
455
$LDAPEXOP -D "$BABSDN" -w bjensen -h $LOCALHOST -p $PORT1 \
456
"refresh" "$MEETINGDN" "180" \
459
if test $RC != 0 ; then
460
echo "ldapexop failed ($RC)!"
461
test $KILLSERVERS != no && kill -HUP $KILLPIDS
465
echo "Trying to refresh the meeting anonymously (should fail)..."
466
$LDAPEXOP -h $LOCALHOST -p $PORT1 \
467
"refresh" "$MEETINGDN" "240" \
470
if test $RC = 0 ; then
471
echo "ldapexop should have failed ($RC)!"
472
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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
485
echo "ldapdelete should have failed ($RC)!"
486
test $KILLSERVERS != no && kill -HUP $KILLPIDS
490
echo "ldapdelete failed ($RC)"
493
echo "ldapdelete failed ($RC)!"
494
test $KILLSERVERS != no && kill -HUP $KILLPIDS
499
echo "Deleting the meeting as $BJORNSDN..."
500
$LDAPMODIFY -D "$BJORNSDN" -w bjorn -h $LOCALHOST -p $PORT1 \
501
>> $TESTOUT 2>&1 << EOMODS
506
if test $RC != 0 ; then
507
echo "ldapdelete failed ($RC)!"
508
test $KILLSERVERS != no && kill -HUP $KILLPIDS
512
test $KILLSERVERS != no && kill -HUP $KILLPIDS
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"
528
echo ">>>>> Test succeeded"
530
test $KILLSERVERS != no && wait