test023-refint revision 1.1.1.5 1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 2004-2016 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 $MONITORDB < $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 $TIMING > $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 $LOCALHOST -p $PORT1 \
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 $LOCALHOST -p $PORT1 > $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 $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'
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 $LOCALHOST -p $PORT1 > $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 $LOCALHOST -p $PORT1 -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 $LOCALHOST -p $PORT1 > $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 $LOCALHOST -p $PORT1 -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 $LOCALHOST -p $PORT1 -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 if test $BACKEND != "bdb" ; then
193 $LDAPMODIFY -v -D "$REFINTDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
194 $TESTOUT 2>&1 << EDEL
195 version: 1
196 dn: cn=group,o=refint
197 changetype: add
198 objectClass: groupOfNames
199 cn: group
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
206 EDEL
207
208 RC=$?
209 if test $RC != 0 ; then
210 echo "ldapmodify failed ($RC)!"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
212 exit $RC
213 fi
214
215 sleep 1;
216
217 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 \
218 manager member secretary > $SEARCHOUT 2>&1
219 RC=$?
220 if test $RC != 0 ; then
221 echo "ldapsearch failed ($RC)!"
222 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 exit $RC
224 fi
225
226 $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \
227 | sed "s/ou=users/ou=people/g" | \
228 sort > $TESTOUT 2>&1
229
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'
233 RC=$?
234 if test $RC != 0 ; then
235 echo "ldapmodrdn failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
237 exit $RC
238 fi
239
240 sleep 1;
241
242 echo "Using ldapsearch to check dependents new rdn..."
243
244 $LDAPSEARCH -S "" -b "o=refint" -h $LOCALHOST -p $PORT1 \
245 manager member secretary > $SEARCHOUT 2>&1
246
247 RC=$?
248 if test $RC != 0 ; then
249 echo "ldapsearch failed ($RC)!"
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
251 exit $RC
252 fi
253
254 $EGREP_CMD "(manager|member|secretary):" $SEARCHOUT \
255 | sort > $SEARCHFLT 2>&1
256
257 echo "Comparing ldapsearch results against original..."
258 $CMP $TESTOUT $SEARCHFLT > $CMPOUT
259
260 if test $? != 0 ; then
261 echo "comparison failed - subtree rename operations did not complete correctly"
262 test $KILLSERVERS != no && kill -HUP $KILLPIDS
263 exit 1
264 fi
265 fi
266
267 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268
269 echo ">>>>> Test succeeded"
270
271 test $KILLSERVERS != no && wait
272
273 exit 0
274