]> git.sur5r.net Git - openldap/blob - tests/scripts/relay
Update BDB requirements
[openldap] / tests / scripts / relay
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2007 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 "Using $RELAY backend..."
17 echo ""
18
19 echo "Starting slapd on TCP/IP port $PORT1..."
20 . $CONFFILTER $BACKEND $MONITORDB < $RELAYCONF > $CONF1
21 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
22 PID=$!
23 if test $WAIT != 0 ; then
24     echo PID $PID
25     read foo
26 fi
27 KILLPIDS="$PID"
28
29 sleep 1
30
31 echo "Using ldapsearch to check that slapd is running..."
32 for i in 0 1 2 3 4 5; do
33         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
34                 'objectclass=*' > /dev/null 2>&1
35         RC=$?
36         if test $RC = 0 ; then
37                 break
38         fi
39         echo "Waiting 5 seconds for slapd to start..."
40         sleep 5
41 done
42 if test $RC != 0 ; then
43         echo "ldapsearch failed ($RC)!"
44         test $KILLSERVERS != no && kill -HUP $KILLPIDS
45         exit $RC
46 fi
47
48 echo "Using ldapadd to populate the database..."
49 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
50         $LDIFORDERED > $TESTOUT 2>&1
51 RC=$?
52 if test $RC != 0 ; then
53         echo "ldapadd failed ($RC)!"
54         test $KILLSERVERS != no && kill -HUP $KILLPIDS
55         exit $RC
56 fi
57
58 cat /dev/null > $SEARCHOUT
59
60 BASEDN="dc=example,dc=com"
61 echo "Searching base=\"$BASEDN\"..."
62 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
63 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
64 RC=$?
65 if test $RC != 0 ; then
66         echo "Search failed ($RC)!"
67         test $KILLSERVERS != no && kill -HUP $KILLPIDS
68         exit $RC
69 fi
70
71 BASEDN="o=Example,c=US"
72 echo "Searching base=\"$BASEDN\"..."
73 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
74 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
75 RC=$?
76 if test $RC != 0 ; then
77         echo "Search failed ($RC)!"
78         test $KILLSERVERS != no && kill -HUP $KILLPIDS
79         exit $RC
80 fi
81
82 BASEDN="o=Esempio,c=IT"
83 echo "Searching base=\"$BASEDN\"..."
84 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
85 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
86 RC=$?
87 if test $RC != 0 ; then
88         echo "Search failed ($RC)!"
89         test $KILLSERVERS != no && kill -HUP $KILLPIDS
90         exit $RC
91 fi
92
93 BASEDN="o=Beispiel,c=DE"
94 echo "Searching base=\"$BASEDN\"..."
95 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
96 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
97 RC=$?
98 if test $RC != 0 ; then
99         echo "Search failed ($RC)!"
100         test $KILLSERVERS != no && kill -HUP $KILLPIDS
101         exit $RC
102 fi
103
104 #
105 # Do some modifications
106 #
107
108 BASEDN="o=Beispiel,c=DE"
109 echo "Modifying database \"$BASEDN\"..."
110 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
111         -M >> $TESTOUT 2>&1 << EOMODS
112 dn: cn=Added User,ou=Alumni Association,ou=People,$BASEDN
113 changetype: add
114 objectClass: OpenLDAPperson
115 cn: Added User
116 sn: User
117 uid: auser
118 seealso: cn=All Staff,ou=Groups,$BASEDN
119 homephone: +49 1234567890
120 drink: Beer
121 mail: auser@mail.alumni.example.com
122 telephonenumber: +49 1234-567-890
123 description: Just added in o=Beispiel,c=DE naming context
124
125 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
126 changetype: modify
127 add: seeAlso
128 seeAlso: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
129 -
130 add: description
131 description: Just added self to seeAlso in $BASEDN virtual naming context
132 -
133
134 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN
135 changetype: delete
136
137 dn: cn=John Doe,ou=Information Technology Division,ou=People,$BASEDN
138 changetype: modrdn
139 newrdn: cn=John P. Doe
140 deleteoldrdn: 1
141
142 dn: cn=Jane Doe,ou=Alumni Association,ou=People,$BASEDN
143 changetype: modrdn
144 newrdn: cn=Jane Q. Doe
145 deleteoldrdn: 1
146 newsuperior: ou=Information Technology Division,ou=People,$BASEDN
147
148 dn: cn=Jane Q. Doe,ou=Information Technology Division,ou=People,$BASEDN
149 changetype: modify
150 add: cn
151 cn: Jane Qissapaolo Doe
152 -
153 # This operation (delete of DN-valued attribute) triggered ITS#3498
154 delete: seeAlso
155 -
156
157 dn: cn=Jane Q. Doe,ou=Information Technology Division,ou=People,$BASEDN
158 changetype: modify
159 add: seeAlso
160 seeAlso: cn=All Staff,ou=Groups,$BASEDN
161 -
162
163 dn: ou=Referrals,$BASEDN
164 changetype: add
165 objectclass: referral
166 objectclass: extensibleObject
167 ou: Referrals
168 ref: ldap://localhost.localdomain/ou=Referrals,$BASEDN
169 description: Just added as ldap://localhost.localdomain:389/ou=Referrals,$BASEDN
170
171 dn: ou=Referrals,$BASEDN
172 changetype: modify
173 replace: ref
174 ref: ldap://localhost:9012/ou=Referrals,$BASEDN
175 -
176 add: description
177 description: ...and modified as ldap://localhost:9012/ou=Referrals,$BASEDN
178 -
179 EOMODS
180
181 RC=$?
182 if test $RC != 0 ; then
183         echo "Modify failed ($RC)!"
184         test $KILLSERVERS != no && kill -HUP $KILLPIDS
185         exit $RC
186 fi
187
188 BASEDN="o=Example,c=US"
189 echo "Modifying database \"$BASEDN\"..."
190 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
191         -M >> $TESTOUT 2>&1 << EOMODS
192 # These operations (updates with objectClass mapping) triggered ITS#3499
193 dn: cn=Added Group,ou=Groups,$BASEDN
194 changetype: add
195 objectClass: groupOfNames
196 objectClass: uidObject
197 cn: Added Group
198 member: cn=Added Group,ou=Groups,$BASEDN
199 uid: added
200
201 dn: cn=Another Added Group,ou=Groups,$BASEDN
202 changetype: add
203 objectClass: groupOfNames
204 cn: Another Added Group
205 member: cn=Added Group,ou=Groups,$BASEDN
206 member: cn=Another Added Group,ou=Groups,$BASEDN
207
208 dn: cn=Another Added Group,ou=Groups,$BASEDN
209 changetype: modify
210 add: objectClass
211 objectClass: uidObject
212 -
213 add: uid
214 uid: added
215 -
216
217 dn: cn=Added Group,ou=Groups,$BASEDN
218 changetype: modify
219 delete: objectClass
220 objectClass: uidObject
221 -
222 delete: uid
223 -
224 EOMODS
225
226 RC=$?
227 if test $RC != 0 ; then
228         echo "Modify failed ($RC)!"
229         test $KILLSERVERS != no && kill -HUP $KILLPIDS
230         exit $RC
231 fi
232
233 echo "Searching base=\"$BASEDN\"..."
234 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
235 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
236 RC=$?
237 if test $RC != 0 ; then
238         echo "Search failed ($RC)!"
239         test $KILLSERVERS != no && kill -HUP $KILLPIDS
240         exit $RC
241 fi
242
243 BASEDN="o=Esempio,c=IT"
244 echo "Searching base=\"$BASEDN\"..."
245 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
246 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
247 RC=$?
248 if test $RC != 0 ; then
249         echo "Search failed ($RC)!"
250         test $KILLSERVERS != no && kill -HUP $KILLPIDS
251         exit $RC
252 fi
253
254 FILTER="(objectClass=referral)"
255 echo "Searching filter=\"$FILTER\""
256 echo "  attrs=\"'*' ref\""
257 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
258 echo "#         attrs=\"'*' ref\"" >> $SEARCHOUT
259
260 BASEDN="dc=example,dc=com"
261 echo "  base=\"$BASEDN\"..."
262 echo "#         base=\"$BASEDN\"..." >> $SEARCHOUT
263 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" '*' ref \
264         >> $SEARCHOUT 2>&1
265 RC=$?
266 if test $RC != 0 ; then
267         echo "Search failed ($RC)!"
268         test $KILLSERVERS != no && kill -HUP $KILLPIDS
269         exit $RC
270 fi
271
272 BASEDN="o=Example,c=US"
273 echo "  base=\"$BASEDN\"..."
274 echo "#         base=\"$BASEDN\"..." >> $SEARCHOUT
275 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" '*' ref \
276         >> $SEARCHOUT 2>&1
277 RC=$?
278 if test $RC != 0 ; then
279         echo "Search failed ($RC)!"
280         test $KILLSERVERS != no && kill -HUP $KILLPIDS
281         exit $RC
282 fi
283
284 BASEDN="o=Esempio,c=IT"
285 echo "  base=\"$BASEDN\"..."
286 echo "#         base=\"$BASEDN\"..." >> $SEARCHOUT
287 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" '*' ref \
288         >> $SEARCHOUT 2>&1
289 RC=$?
290 if test $RC != 0 ; then
291         echo "Search failed ($RC)!"
292         test $KILLSERVERS != no && kill -HUP $KILLPIDS
293         exit $RC
294 fi
295
296 BASEDN="o=Example,c=US"
297 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
298 echo "Searching filter=\"$FILTER\""
299 echo "  attrs=\"seeAlso\""
300 echo "  base=\"$BASEDN\"..."
301 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
302 echo "#         attrs=\"seeAlso\"" >> $SEARCHOUT
303 echo "#         base=\"$BASEDN\"..." >> $SEARCHOUT
304 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" seeAlso \
305         >> $SEARCHOUT 2>&1
306 RC=$?
307 if test $RC != 0 ; then
308         echo "Search failed ($RC)!"
309         test $KILLSERVERS != no && kill -HUP $KILLPIDS
310         exit $RC
311 fi
312
313 FILTER="(uid=example)"
314 echo "Searching filter=\"$FILTER\""
315 echo "  attrs=\"uid\""
316 echo "  base=\"$BASEDN\"..."
317 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
318 echo "#         attrs=\"uid\"" >> $SEARCHOUT
319 echo "#         base=\"$BASEDN\"..." >> $SEARCHOUT
320 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" uid \
321         >> $SEARCHOUT 2>&1
322 RC=$?
323 if test $RC != 0 ; then
324         echo "Search failed ($RC)!"
325         test $KILLSERVERS != no && kill -HUP $KILLPIDS
326         exit $RC
327 fi
328
329 FILTER="(member=cn=Another Added Group,ou=Groups,$BASEDN)"
330 echo "Searching filter=\"$FILTER\""
331 echo "  attrs=\"member\""
332 echo "  base=\"$BASEDN\"..."
333 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
334 echo "#         attrs=\"member\"" >> $SEARCHOUT
335 echo "#         base=\"$BASEDN\"..." >> $SEARCHOUT
336 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" member \
337         >> $SEARCHOUT 2>&1
338 RC=$?
339 if test $RC != 0 ; then
340         echo "Search failed ($RC)!"
341         test $KILLSERVERS != no && kill -HUP $KILLPIDS
342         exit $RC
343 fi
344
345 echo "Filtering ldapsearch results..."
346 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
347 echo "Filtering original ldif used to create database..."
348 . $LDIFFILTER < $RELAYOUT > $LDIFFLT
349 echo "Comparing filter output..."
350 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
351         
352 if test $? != 0 ; then
353         echo "comparison failed - relay search/modification didn't succeed"
354         test $KILLSERVERS != no && kill -HUP $KILLPIDS
355         exit 1
356 fi
357
358 BASEDN="o=Example,c=US"
359 echo "Changing password to database \"$BASEDN\"..."
360 $LDAPPASSWD -h $LOCALHOST -p $PORT1 -D "cn=Manager,$BASEDN" -w $PASSWD \
361         -s $PASSWD "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
362         >> $TESTOUT 2>&1
363 RC=$?
364 if test $RC != 0 ; then
365         echo "Passwd ExOp failed ($RC)!"
366         test $KILLSERVERS != no && kill -HUP $KILLPIDS
367         exit $RC
368 fi
369
370 BASEDN="o=Beispiel,c=DE"
371 echo "Binding with newly changed password to database \"$BASEDN\"..."
372 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
373         -D "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
374         -w $PASSWD >> $TESTOUT 2>&1
375 RC=$?
376 if test $RC != 0 ; then
377         echo "WhoAmI failed ($RC)!"
378         test $KILLSERVERS != no && kill -HUP $KILLPIDS
379         exit $RC
380 fi
381
382 BASEDN="o=Esempio,c=IT"
383 echo "Comparing to database \"$BASEDN\"..."
384 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
385         "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
386         "seeAlso:cn=All Staff,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
387 RC=$?
388 if test $RC != 6 ; then
389         echo "Compare failed ($RC)!"
390         test $KILLSERVERS != no && kill -HUP $KILLPIDS
391         exit $RC
392 fi
393
394 test $KILLSERVERS != no && kill -HUP $KILLPIDS
395