3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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
21 if test $BACKMETA = metano ; then
22 echo "meta backend not available, test skipped"
28 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
30 echo "Starting slapd on TCP/IP port $PORT1..."
31 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
32 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
34 if test $WAIT != 0 ; then
40 echo "Using ldapsearch to check that slapd is running..."
41 for i in 0 1 2 3 4 5; do
42 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
43 'objectclass=*' > /dev/null 2>&1
45 if test $RC = 0 ; then
48 echo "Waiting 5 seconds for slapd to start..."
51 if test $RC != 0 ; then
52 echo "ldapsearch failed ($RC)!"
53 test $KILLSERVERS != no && kill -HUP $KILLPIDS
57 echo "Using ldapadd to populate the database..."
58 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
59 $LDIFORDERED > $TESTOUT 2>&1
61 if test $RC != 0 ; then
62 echo "ldapadd failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 echo "Starting slapd on TCP/IP port $PORT2..."
68 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
69 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
71 if test $WAIT != 0 ; then
75 KILLPIDS="$KILLPIDS $PID"
77 echo "Using ldapsearch to check that slapd is running..."
78 for i in 0 1 2 3 4 5; do
79 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
80 'objectclass=*' > /dev/null 2>&1
82 if test $RC = 0 ; then
85 echo "Waiting 5 seconds for slapd to start..."
88 if test $RC != 0 ; then
89 echo "ldapsearch failed ($RC)!"
90 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94 echo "Using ldapadd to populate the database..."
95 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
96 $LDIFMETA >> $TESTOUT 2>&1
98 if test $RC != 0 ; then
99 echo "ldapadd failed ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 echo "Starting slapd on TCP/IP port $PORT3..."
105 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
106 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
108 if test $WAIT != 0 ; then
112 KILLPIDS="$KILLPIDS $PID"
114 echo "Using ldapsearch to check that slapd is running..."
115 for i in 0 1 2 3 4 5; do
116 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
117 'objectclass=*' > /dev/null 2>&1
119 if test $RC = 0 ; then
122 echo "Waiting 5 seconds for slapd to start..."
125 if test $RC != 0 ; then
126 echo "ldapsearch failed ($RC)!"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 cat /dev/null > $SEARCHOUT
133 BASEDN="o=Example,c=US"
134 echo "Searching base=\"$BASEDN\"..."
135 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
136 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" >> $SEARCHOUT 2>&1
138 #if test $RC != 0 ; then
139 # echo "Search failed ($RC)!"
140 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
147 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 echo "Compare failed ($RC)!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 # Do some modifications
162 BASEDN="o=Example,c=US"
163 echo "Modifying database \"$BASEDN\"..."
164 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT3 -w $PASSWD \
165 -M >> $TESTOUT 2>&1 << EOMODS
166 # These operations (updates with objectClass mapping) triggered ITS#3499
167 dn: cn=Added Group,ou=Groups,$BASEDN
169 objectClass: groupOfNames
170 objectClass: uidObject
172 member: cn=Added Group,ou=Groups,$BASEDN
175 dn: cn=Another Added Group,ou=Groups,$BASEDN
177 objectClass: groupOfNames
178 cn: Another Added Group
179 member: cn=Added Group,ou=Groups,$BASEDN
180 member: cn=Another Added Group,ou=Groups,$BASEDN
182 dn: cn=Another Added Group,ou=Groups,$BASEDN
185 objectClass: uidObject
191 dn: cn=Added Group,ou=Groups,$BASEDN
194 objectClass: uidObject
202 description: added to "ou=Meta,$BASEDN"
205 dn: ou=Who's going to handle this?,$BASEDN
207 objectClass: organizationalUnit
208 ou: Who's going to handle this?
210 description: will be deleted
212 dn: ou=Same as above,$BASEDN
214 objectClass: organizationalUnit
216 description: added right after "Who's going to handle this?"
217 description: will be preserved
219 dn: ou=Who's going to handle this?,$BASEDN
222 dn: ou=Who's going to handle this?,ou=Meta,$BASEDN
224 objectClass: organizationalUnit
225 ou: Who's going to handle this?
227 description: will be deleted
229 dn: ou=Same as above,ou=Meta,$BASEDN
231 objectClass: organizationalUnit
233 description: added right after "Who's going to handle this?"
234 description: will be preserved
236 dn: cn=Added User,ou=Same as above,ou=Meta,$BASEDN
238 objectClass: inetOrgPerson
243 dn: ou=Who's going to handle this?,ou=Meta,$BASEDN
248 #if test $RC != 0 ; then
249 # echo "Modify failed ($RC)!"
250 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
257 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
258 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 echo "Compare failed ($RC)!"
263 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 echo "Searching base=\"$BASEDN\"..."
269 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
270 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" >> $SEARCHOUT 2>&1
272 #if test $RC != 0 ; then
273 # echo "Search failed ($RC)!"
274 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
281 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
282 test $KILLSERVERS != no && kill -HUP $KILLPIDS
286 echo "Compare failed ($RC)!"
287 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 BASEDN="o=Example,c=US"
293 echo " base=\"$BASEDN\"..."
294 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
295 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" -M "$FILTER" '*' ref \
298 #if test $RC != 0 ; then
299 # echo "Search failed ($RC)!"
300 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
307 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
308 test $KILLSERVERS != no && kill -HUP $KILLPIDS
312 echo "Compare failed ($RC)!"
313 test $KILLSERVERS != no && kill -HUP $KILLPIDS
318 BASEDN="o=Example,c=US"
319 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
320 echo "Searching filter=\"$FILTER\""
321 echo " attrs=\"seeAlso\""
322 echo " base=\"$BASEDN\"..."
323 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
324 echo "# attrs=\"seeAlso\"" >> $SEARCHOUT
325 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
326 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" seeAlso \
329 #if test $RC != 0 ; then
330 # echo "Search failed ($RC)!"
331 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
338 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
339 test $KILLSERVERS != no && kill -HUP $KILLPIDS
343 echo "Compare failed ($RC)!"
344 test $KILLSERVERS != no && kill -HUP $KILLPIDS
349 FILTER="(uid=example)"
350 echo "Searching filter=\"$FILTER\""
351 echo " attrs=\"uid\""
352 echo " base=\"$BASEDN\"..."
353 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
354 echo "# attrs=\"uid\"" >> $SEARCHOUT
355 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
356 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" uid \
359 #if test $RC != 0 ; then
360 # echo "Search failed ($RC)!"
361 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
368 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
369 test $KILLSERVERS != no && kill -HUP $KILLPIDS
373 echo "Compare failed ($RC)!"
374 test $KILLSERVERS != no && kill -HUP $KILLPIDS
379 FILTER="(member=cn=Another Added Group,ou=Groups,$BASEDN)"
380 echo "Searching filter=\"$FILTER\""
381 echo " attrs=\"member\""
382 echo " base=\"$BASEDN\"..."
383 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
384 echo "# attrs=\"member\"" >> $SEARCHOUT
385 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
386 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" member \
389 #if test $RC != 0 ; then
390 # echo "Search failed ($RC)!"
391 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
398 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
399 test $KILLSERVERS != no && kill -HUP $KILLPIDS
403 echo "Compare failed ($RC)!"
404 test $KILLSERVERS != no && kill -HUP $KILLPIDS
409 echo "Filtering ldapsearch results..."
410 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
411 echo "Filtering original ldif used to create database..."
412 . $LDIFFILTER < $METAOUT > $LDIFFLT
413 echo "Comparing filter output..."
414 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
416 if test $? != 0 ; then
417 echo "comparison failed - meta search/modification didn't succeed"
418 test $KILLSERVERS != no && kill -HUP $KILLPIDS
422 BASEDN="o=Example,c=US"
423 echo "Changing password to database \"$BASEDN\"..."
424 $LDAPPASSWD -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
425 -s $PASSWD "cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN" \
428 #if test $RC != 0 ; then
429 # echo "Passwd ExOp failed ($RC)!"
430 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
437 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
438 test $KILLSERVERS != no && kill -HUP $KILLPIDS
442 echo "Compare failed ($RC)!"
443 test $KILLSERVERS != no && kill -HUP $KILLPIDS
448 echo "Binding with newly changed password to database \"$BASEDN\"..."
449 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
450 -D "cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN" \
451 -w $PASSWD >> $TESTOUT 2>&1
453 #if test $RC != 0 ; then
454 # echo "WhoAmI failed ($RC)!"
455 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
462 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
465 echo "Compare failed ($RC)!"
466 test $KILLSERVERS != no && kill -HUP $KILLPIDS
471 echo "Binding as newly added user to database \"$BASEDN\"..."
472 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
473 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
474 -w $PASSWD >> $TESTOUT 2>&1
476 #if test $RC != 0 ; then
477 # echo "WhoAmI failed ($RC)!"
478 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
485 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
488 echo "Compare failed ($RC)!"
489 test $KILLSERVERS != no && kill -HUP $KILLPIDS
494 echo "Changing password to database \"$BASEDN\"..."
495 $LDAPPASSWD -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
496 -s meta "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
499 #if test $RC != 0 ; then
500 # echo "Passwd ExOp failed ($RC)!"
501 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
508 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
509 test $KILLSERVERS != no && kill -HUP $KILLPIDS
513 echo "Compare failed ($RC)!"
514 test $KILLSERVERS != no && kill -HUP $KILLPIDS
519 echo "Binding with newly changed password to database \"$BASEDN\"..."
520 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
521 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
522 -w meta >> $TESTOUT 2>&1
524 #if test $RC != 0 ; then
525 # echo "WhoAmI failed ($RC)!"
526 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
533 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
536 echo "Compare failed ($RC)!"
537 test $KILLSERVERS != no && kill -HUP $KILLPIDS
542 echo "Comparing to database \"$BASEDN\"..."
543 $LDAPCOMPARE -h $LOCALHOST -p $PORT3 \
544 "cn=Another Added Group,ou=Groups,$BASEDN" \
545 "member:cn=Added Group,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
547 #if test $RC != 6 ; then
548 # echo "Compare failed ($RC)!"
549 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
556 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
559 echo "Compare failed ($RC)!"
560 test $KILLSERVERS != no && kill -HUP $KILLPIDS
565 test $KILLSERVERS != no && kill -HUP $KILLPIDS
567 echo ">>>>> Test succeeded"