test023-refint revision 1.1.1.9 1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 2004-2021 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.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $REFINT = refintno; then
20 echo "Referential Integrity overlay not available, test skipped"
21 exit 0
22 fi
23
24 mkdir -p $TESTDIR $DBDIR1
25
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND < $REFINTCONF > $CONF1
28 $SLAPADD -f $CONF1 -l $LDIFREFINT
29 RC=$?
30 if test $RC != 0 ; then
31 echo "slapadd failed ($RC)!"
32 exit $RC
33 fi
34
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
37 PID=$!
38 if test $WAIT != 0 ; then
39 echo PID $PID
40 read foo
41 fi
42 KILLPIDS="$PID"
43
44 sleep 1
45
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 $URI1 \
49 'objectclass=*' > /dev/null 2>&1
50 RC=$?
51 if test $RC = 0 ; then
52 break
53 fi
54 echo "Waiting 5 seconds for slapd to start..."
55 sleep 5
56 done
57
58 if test $RC != 0 ; then
59 echo "ldapsearch failed ($RC)!"
60 test $KILLSERVERS != no && kill -HUP $KILLPIDS
61 exit $RC
62 fi
63
64 echo "Searching unmodified database..."
65
66 $LDAPSEARCH -S "" -b "o=refint" -H $URI1 > $SEARCHOUT 2>&1
67 RC=$?
68 if test $RC != 0 ; then
69 echo "ldapsearch failed ($RC)!"
70 test $KILLSERVERS != no && kill -HUP $KILLPIDS
71 exit $RC
72 fi
73
74 $EGREP_CMD "(manager|secretary):" $SEARCHOUT | sed "s/george/foster/g" | \
75 sort > $TESTOUT 2>&1
76
77 echo "Testing modrdn..."
78 $LDAPMODRDN -D "$REFINTDN" -r -H $URI1 -w $PASSWD > \
79 /dev/null 2>&1 'uid=george,ou=users,o=refint' 'uid=foster'
80 #$LDAPMODRDN -D "$REFINTDN" -r -H $URI1 -w $PASSWD \
81 # 'uid=george,ou=users,o=refint' 'uid=foster'
82
83 RC=$?
84 if test $RC != 0 ; then
85 echo "ldapmodrdn failed ($RC)!"
86 test $KILLSERVERS != no && kill -HUP $KILLPIDS
87 exit $RC
88 fi
89
90 sleep 1;
91
92 echo "Using ldapsearch to check dependents new rdn..."
93
94 $LDAPSEARCH -S "" -b "o=refint" -H $URI1 > $SEARCHOUT 2>&1
95
96 RC=$?
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100 exit $RC
101 fi
102
103 $EGREP_CMD "(manager|secretary):" $SEARCHOUT | sort > $SEARCHFLT 2>&1
104
105 echo "Comparing ldapsearch results against original..."
106 $CMP $TESTOUT $SEARCHFLT > $CMPOUT
107
108 if test $? != 0 ; then
109 echo "comparison failed - modify operations did not complete correctly"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 exit 1
112 fi
113
114 echo "Testing delete..."
115 $LDAPMODIFY -v -D "$REFINTDN" -H $URI1 -w $PASSWD > \
116 $TESTOUT 2>&1 << EDEL
117 version: 1
118 dn: uid=foster,ou=users,o=refint
119 changetype: delete
120 EDEL
121
122 RC=$?
123 if test $RC != 0 ; then
124 echo "ldapmodify failed ($RC)!"
125 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 exit $RC
127 fi
128
129 sleep 1;
130
131 echo "Using ldapsearch to verify dependents have been deleted..."
132 $LDAPSEARCH -S "" -b "o=refint" -H $URI1 > $SEARCHOUT 2>&1
133
134 RC=$?
135 if test $RC != 0 ; then
136 echo "ldapsearch failed ($RC)!"
137 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138 exit $RC
139 fi
140
141 $EGREP_CMD "(manager|secretary):" $SEARCHOUT > $SEARCHFLT 2>&1
142
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
147 exit 1
148 fi
149
150 echo "Additional test records..."
151
152 $LDAPADD -D "$REFINTDN" -H $URI1 -w $PASSWD > \
153 $TESTOUT 2>&1 << ETEST
154 dn: uid=special,ou=users,o=refint
155 objectClass: inetOrgPerson
156 objectClass: extensibleObject
157 uid: special
158 sn: special
159 cn: special
160 businessCategory: nothing
161 carLicense: FOO
162 departmentNumber: 933
163 displayName: special
164 employeeNumber: 41491
165 employeeType: vendor
166 givenName: special
167 member: uid=alice,ou=users,o=refint
168 ETEST
169
170 RC=$?
171 if test $RC != 0 ; then
172 echo "ldapadd failed ($RC)!"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 exit $RC
175 fi
176
177 echo "Testing delete when referential attribute is a MUST..."
178 $LDAPMODIFY -v -D "$REFINTDN" -H $URI1 -w $PASSWD > \
179 $TESTOUT 2>&1 << EDEL
180 version: 1
181 dn: uid=alice,ou=users,o=refint
182 changetype: delete
183 EDEL
184
185 RC=$?
186 if test $RC != 0 ; then
187 echo "ldapmodify failed ($RC)!"
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 exit $RC
190 fi
191
192 $LDAPMODIFY -v -D "$REFINTDN" -H $URI1 -w $PASSWD > \
193 $TESTOUT 2>&1 << EDEL
194 version: 1
195 dn: cn=group,o=refint
196 changetype: add
197 objectClass: groupOfNames
198 cn: group
199 member: uid=bill,ou=users,o=refint
200 member: uid=bob,ou=users,o=refint
201 member: uid=dave,ou=users,o=refint
202 member: uid=jorge,ou=users,o=refint
203 member: uid=theman,ou=users,o=refint
204 member: uid=richard,ou=users,o=refint
205 EDEL
206
207 RC=$?
208 if test $RC != 0 ; then
209 echo "ldapmodify failed ($RC)!"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
211 exit $RC
212 fi
213
214 sleep 1;
215
216 $LDAPSEARCH -S "" -b "o=refint" -H $URI1 \
217 manager member secretary > $SEARCHOUT 2>&1
218 RC=$?
219 if test $RC != 0 ; then
220 echo "ldapsearch failed ($RC)!"
221 test $KILLSERVERS != no && kill -HUP $KILLPIDS
222 exit $RC
223 fi
224
225 $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \
226 | sed "s/ou=users/ou=people/g" | \
227 sort > $TESTOUT 2>&1
228
229 echo "testing subtree rename"
230 $LDAPMODRDN -D "$REFINTDN" -r -H $URI1 -w $PASSWD > \
231 /dev/null 2>&1 'ou=users,o=refint' 'ou=people'
232 RC=$?
233 if test $RC != 0 ; then
234 echo "ldapmodrdn failed ($RC)!"
235 test $KILLSERVERS != no && kill -HUP $KILLPIDS
236 exit $RC
237 fi
238
239 sleep 1;
240
241 echo "Using ldapsearch to check dependents new rdn..."
242
243 $LDAPSEARCH -S "" -b "o=refint" -H $URI1 \
244 manager member secretary > $SEARCHOUT 2>&1
245
246 RC=$?
247 if test $RC != 0 ; then
248 echo "ldapsearch failed ($RC)!"
249 test $KILLSERVERS != no && kill -HUP $KILLPIDS
250 exit $RC
251 fi
252
253 $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \
254 | sort > $SEARCHFLT 2>&1
255
256 echo "Comparing ldapsearch results against original..."
257 $CMP $TESTOUT $SEARCHFLT > $CMPOUT
258
259 if test $? != 0 ; then
260 echo "comparison failed - subtree rename operations did not complete correctly"
261 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 exit 1
263 fi
264
265 test $KILLSERVERS != no && kill -HUP $KILLPIDS
266
267 echo ">>>>> Test succeeded"
268
269 test $KILLSERVERS != no && wait
270
271 exit 0
272