3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-2007 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 if test "$BACKEND" != "bdb" && test "$BACKEND" != "hdb" ; then
17 echo "Test does not support $BACKEND"
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
24 if test $REFINT = refintno; then
25 echo "Referential Integrity overlay not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1
31 echo "Running slapadd to build slapd database..."
32 . $CONFFILTER $BACKEND $MONITORDB < $REFINTCONF > $CONF1
33 $SLAPADD -f $CONF1 -l $LDIFREFINT
35 if test $RC != 0 ; then
36 echo "slapadd failed ($RC)!"
40 echo "Starting slapd on TCP/IP port $PORT1..."
41 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
43 if test $WAIT != 0 ; then
51 echo "Testing slapd referential integrity operations..."
52 for i in 0 1 2 3 4 5; do
53 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
54 'objectclass=*' > /dev/null 2>&1
56 if test $RC = 0 ; then
59 echo "Waiting 5 seconds for slapd to start..."
63 if test $RC != 0 ; then
64 echo "ldapsearch failed ($RC)!"
65 test $KILLSERVERS != no && kill -HUP $KILLPIDS
69 echo "Searching unmodified database..."
71 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
73 if test $RC != 0 ; then
74 echo "ldapsearch failed ($RC)!"
75 test $KILLSERVERS != no && kill -HUP $KILLPIDS
79 $EGREP_CMD "(manager|secretary):" $SEARCHOUT | sed "s/george/foster/g" | \
82 echo "Testing modrdn..."
83 $LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
84 /dev/null 2>&1 'uid=george,ou=users,o=refint' 'uid=foster'
85 #$LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD \
86 # 'uid=george,ou=users,o=refint' 'uid=foster'
89 if test $RC != 0 ; then
90 echo "ldapmodrdn failed ($RC)!"
91 test $KILLSERVERS != no && kill -HUP $KILLPIDS
97 echo "Using ldapsearch to check dependents new rdn..."
99 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
102 if test $RC != 0 ; then
103 echo "ldapsearch failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 $EGREP_CMD "(manager|secretary):" $SEARCHOUT | sort > $SEARCHFLT 2>&1
110 echo "Comparing ldapsearch results against original..."
111 $CMP $TESTOUT $SEARCHFLT > $CMPOUT
113 if test $? != 0 ; then
114 echo "comparison failed - modify operations did not complete correctly"
115 test $KILLSERVERS != no && kill -HUP $KILLPIDS
119 echo "Testing delete..."
120 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
121 $TESTOUT 2>&1 << EDEL
123 dn: uid=foster,ou=users,o=refint
128 if test $RC != 0 ; then
129 echo "ldapmodify failed ($RC)!"
130 test $KILLSERVERS != no && kill -HUP $KILLPIDS
136 echo "Using ldapsearch to verify dependents have been deleted..."
137 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
140 if test $RC != 0 ; then
141 echo "ldapsearch failed ($RC)!"
142 test $KILLSERVERS != no && kill -HUP $KILLPIDS
146 $EGREP_CMD "(manager|secretary):" $SEARCHOUT > $SEARCHFLT 2>&1
148 RC=`grep -c foster $SEARCHFLT`
149 if test $RC != 0 ; then
150 echo "dependent modify failed - dependents were not deleted"
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 echo "Additional test records..."
157 $LDAPADD -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
158 $TESTOUT 2>&1 << ETEST
159 dn: uid=special,ou=users,o=refint
160 objectClass: inetOrgPerson
164 businessCategory: nothing
166 departmentNumber: 933
168 employeeNumber: 41491
171 member: uid=alice,ou=users,o=refint
174 echo "Testing delete when referential attribute is a MUST..."
175 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
176 $TESTOUT 2>&1 << EDEL
178 dn: uid=alice,ou=users,o=refint
183 if test $RC != 0 ; then
184 echo "ldapmodify failed ($RC)!"
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 if test $BACKEND = "hdb" ; then
190 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
191 $TESTOUT 2>&1 << EDEL
193 dn: cn=group,o=refint
195 objectClass: groupOfNames
197 member: uid=bill,ou=users,o=refint
198 member: uid=bob,ou=users,o=refint
199 member: uid=dave,ou=users,o=refint
200 member: uid=jorge,ou=users,o=refint
201 member: uid=theman,ou=users,o=refint
202 member: uid=richard,ou=users,o=refint
206 if test $RC != 0 ; then
207 echo "ldapmodify failed ($RC)!"
208 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 \
215 manager member secretary > $SEARCHOUT 2>&1
217 if test $RC != 0 ; then
218 echo "ldapsearch failed ($RC)!"
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \
224 | sed "s/ou=users/ou=people/g" | \
227 echo "testing subtree rename"
228 $LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
229 /dev/null 2>&1 'ou=users,o=refint' 'ou=people'
231 if test $RC != 0 ; then
232 echo "ldapmodrdn failed ($RC)!"
233 test $KILLSERVERS != no && kill -HUP $KILLPIDS
239 echo "Using ldapsearch to check dependents new rdn..."
241 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 \
242 manager member secretary > $SEARCHOUT 2>&1
245 if test $RC != 0 ; then
246 echo "ldapsearch failed ($RC)!"
247 test $KILLSERVERS != no && kill -HUP $KILLPIDS
251 $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \
252 | sort > $SEARCHFLT 2>&1
254 echo "Comparing ldapsearch results against original..."
255 $CMP $TESTOUT $SEARCHFLT > $CMPOUT
257 if test $? != 0 ; then
258 echo "comparison failed - subtree rename operations did not complete correctly"
259 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 test $KILLSERVERS != no && kill -HUP $KILLPIDS
266 echo ">>>>> Test succeeded"
268 test $KILLSERVERS != no && wait