Debian Codegraph @

tests/scripts/test023-refint

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