3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 2004-2012 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 $REFINT = refintno; then
20 echo "Referential Integrity overlay not available, test skipped"
24 mkdir -p $TESTDIR $DBDIR1
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $REFINTCONF > $CONF1
28 $SLAPADD -f $CONF1 -l $LDIFREFINT
30 if test $RC != 0 ; then
31 echo "slapadd failed ($RC)!"
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
38 if test $WAIT != 0 ; then
46 echo "Testing slapd referential integrity operations..."
47 for i in 0 1 2 3 4 5; do
48 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
49 'objectclass=*' > /dev/null 2>&1
51 if test $RC = 0 ; then
54 echo "Waiting 5 seconds for slapd to start..."
58 if test $RC != 0 ; then
59 echo "ldapsearch failed ($RC)!"
60 test $KILLSERVERS != no && kill -HUP $KILLPIDS
64 echo "Searching unmodified database..."
66 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
68 if test $RC != 0 ; then
69 echo "ldapsearch failed ($RC)!"
70 test $KILLSERVERS != no && kill -HUP $KILLPIDS
74 $EGREP_CMD "(manager|secretary):" $SEARCHOUT | sed "s/george/foster/g" | \
77 echo "Testing modrdn..."
78 $LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
79 /dev/null 2>&1 'uid=george,ou=users,o=refint' 'uid=foster'
80 #$LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD \
81 # 'uid=george,ou=users,o=refint' 'uid=foster'
84 if test $RC != 0 ; then
85 echo "ldapmodrdn failed ($RC)!"
86 test $KILLSERVERS != no && kill -HUP $KILLPIDS
92 echo "Using ldapsearch to check dependents new rdn..."
94 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 $EGREP_CMD "(manager|secretary):" $SEARCHOUT | sort > $SEARCHFLT 2>&1
105 echo "Comparing ldapsearch results against original..."
106 $CMP $TESTOUT $SEARCHFLT > $CMPOUT
108 if test $? != 0 ; then
109 echo "comparison failed - modify operations did not complete correctly"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 echo "Testing delete..."
115 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
116 $TESTOUT 2>&1 << EDEL
118 dn: uid=foster,ou=users,o=refint
123 if test $RC != 0 ; then
124 echo "ldapmodify failed ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "Using ldapsearch to verify dependents have been deleted..."
132 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 > $SEARCHOUT 2>&1
135 if test $RC != 0 ; then
136 echo "ldapsearch failed ($RC)!"
137 test $KILLSERVERS != no && kill -HUP $KILLPIDS
141 $EGREP_CMD "(manager|secretary):" $SEARCHOUT > $SEARCHFLT 2>&1
143 RC=`grep -c foster $SEARCHFLT`
144 if test $RC != 0 ; then
145 echo "dependent modify failed - dependents were not deleted"
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
150 echo "Additional test records..."
152 $LDAPADD -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
153 $TESTOUT 2>&1 << ETEST
154 dn: uid=special,ou=users,o=refint
155 objectClass: inetOrgPerson
156 objectClass: extensibleObject
160 businessCategory: nothing
162 departmentNumber: 933
164 employeeNumber: 41491
167 member: uid=alice,ou=users,o=refint
171 if test $RC != 0 ; then
172 echo "ldapadd failed ($RC)!"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177 echo "Testing delete when referential attribute is a MUST..."
178 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
179 $TESTOUT 2>&1 << EDEL
181 dn: uid=alice,ou=users,o=refint
186 if test $RC != 0 ; then
187 echo "ldapmodify failed ($RC)!"
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 if test $BACKEND != "bdb" ; then
193 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
194 $TESTOUT 2>&1 << EDEL
196 dn: cn=group,o=refint
198 objectClass: groupOfNames
200 member: uid=bill,ou=users,o=refint
201 member: uid=bob,ou=users,o=refint
202 member: uid=dave,ou=users,o=refint
203 member: uid=jorge,ou=users,o=refint
204 member: uid=theman,ou=users,o=refint
205 member: uid=richard,ou=users,o=refint
209 if test $RC != 0 ; then
210 echo "ldapmodify failed ($RC)!"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
217 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 \
218 manager member secretary > $SEARCHOUT 2>&1
220 if test $RC != 0 ; then
221 echo "ldapsearch failed ($RC)!"
222 test $KILLSERVERS != no && kill -HUP $KILLPIDS
226 $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \
227 | sed "s/ou=users/ou=people/g" | \
230 echo "testing subtree rename"
231 $LDAPMODRDN -D "$REFINTDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
232 /dev/null 2>&1 'ou=users,o=refint' 'ou=people'
234 if test $RC != 0 ; then
235 echo "ldapmodrdn failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
242 echo "Using ldapsearch to check dependents new rdn..."
244 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 \
245 manager member secretary > $SEARCHOUT 2>&1
248 if test $RC != 0 ; then
249 echo "ldapsearch failed ($RC)!"
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
254 $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \
255 | sort > $SEARCHFLT 2>&1
257 echo "Comparing ldapsearch results against original..."
258 $CMP $TESTOUT $SEARCHFLT > $CMPOUT
260 if test $? != 0 ; then
261 echo "comparison failed - subtree rename operations did not complete correctly"
262 test $KILLSERVERS != no && kill -HUP $KILLPIDS
267 test $KILLSERVERS != no && kill -HUP $KILLPIDS
269 echo ">>>>> Test succeeded"
271 test $KILLSERVERS != no && wait