3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 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 $BACKSQL = "sqlno" ; then
20 echo "SQL backend not available, test skipped"
24 if test $RDBMS = "rdbmsno" ; then
25 echo "SQL test not requested, test skipped"
31 echo "Starting slapd on TCP/IP port $PORT1..."
32 . $CONFFILTER $BACKEND $MONITORDB < $SQLCONF > $CONF1
33 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
35 if test $WAIT != 0 ; then
41 echo "Testing SQL backend read operations..."
42 for i in 0 1 2 3 4 5; do
43 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
44 'objectclass=*' > /dev/null 2>&1
46 if test $RC = 0 ; then
49 echo "Waiting 5 seconds for slapd to start..."
53 if test $RC != 0 ; then
54 echo "ldapsearch failed ($RC)!"
55 test $KILLSERVERS != no && kill -HUP $KILLPIDS
59 BASEDN="dc=example,dc=com"
60 BINDDN="cn=Mitya Kovalev,${BASEDN}"
62 echo -n "Testing correct bind... "
63 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
65 if test $RC != 0 ; then
66 echo "ldapwhoami failed ($RC)!"
67 test $KILLSERVERS != no && kill -HUP $KILLPIDS
71 echo -n "Testing incorrect bind (should fail)... "
72 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w "XXX"
74 if test $RC == 0 ; then
75 echo "ldapwhoami should have failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 echo "Testing baseobject search..."
81 echo "# Testing baseobject search..." >> $SEARCHOUT
82 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -s base >> $SEARCHOUT 2>&1
85 if test $RC != 0 ; then
86 echo "ldapsearch failed ($RC)!"
87 test $KILLSERVERS != no && kill -HUP $KILLPIDS
91 echo "Testing onelevel search..."
92 echo "# Testing onelevel search..." >> $SEARCHOUT
93 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -s one >> $SEARCHOUT 2>&1
96 if test $RC != 0 ; then
97 echo "ldapsearch failed ($RC)!"
98 test $KILLSERVERS != no && kill -HUP $KILLPIDS
102 echo "Testing subtree search..."
103 echo "# Testing subtree search..." >> $SEARCHOUT
104 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
107 if test $RC != 0 ; then
108 echo "ldapsearch failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 echo "Testing invalid filter..."
114 echo "# Testing invalid filter..." >> $SEARCHOUT
115 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
116 "(foo=)" >> $SEARCHOUT 2>&1
119 if test $RC != 0 ; then
120 echo "ldapsearch failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Testing exact search..."
126 echo "# Testing exact search..." >> $SEARCHOUT
127 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
128 "(sn=Kovalev)" >> $SEARCHOUT 2>&1
131 if test $RC != 0 ; then
132 echo "ldapsearch failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 echo "Testing substrings initial search..."
138 echo "# Testing substrings initial search..." >> $SEARCHOUT
139 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
140 "(cn=m*)" >> $SEARCHOUT 2>&1
143 if test $RC != 0 ; then
144 echo "ldapsearch failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 echo "Testing substrings any search..."
150 echo "# Testing substrings any search..." >> $SEARCHOUT
151 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
152 "(cn=*m*)" >> $SEARCHOUT 2>&1
155 if test $RC != 0 ; then
156 echo "ldapsearch failed ($RC)!"
157 test $KILLSERVERS != no && kill -HUP $KILLPIDS
161 echo "Testing substrings final search..."
162 echo "# Testing substrings final search..." >> $SEARCHOUT
163 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
164 "(cn=*v)" >> $SEARCHOUT 2>&1
167 if test $RC != 0 ; then
168 echo "ldapsearch failed ($RC)!"
169 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173 echo "Testing approx search..."
174 echo "# Testing approx search..." >> $SEARCHOUT
175 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
176 "(sn~=kovalev)" >> $SEARCHOUT 2>&1
179 if test $RC != 0 ; then
180 echo "ldapsearch failed ($RC)!"
181 test $KILLSERVERS != no && kill -HUP $KILLPIDS
185 echo "Testing extensible filter search..."
186 echo "# Testing extensible filter search..." >> $SEARCHOUT
187 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
188 "(sn:caseExactMatch:=Kovalev)" >> $SEARCHOUT 2>&1
191 if test $RC != 0 ; then
192 echo "ldapsearch failed ($RC)!"
193 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 echo "Testing search for telephoneNumber..."
198 echo "# Testing search for telephoneNumber..." >> $SEARCHOUT
199 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
200 "(telephoneNumber=3322334)" >> $SEARCHOUT 2>&1
203 if test $RC != 0 ; then
204 echo "ldapsearch failed ($RC)!"
205 test $KILLSERVERS != no && kill -HUP $KILLPIDS
209 echo "Testing AND search..."
210 echo "# Testing AND search..." >> $SEARCHOUT
211 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
212 "(&(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1
215 if test $RC != 0 ; then
216 echo "ldapsearch failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 echo "Testing AND search on objectClass..."
222 echo "# Testing AND search on objectClass..." >> $SEARCHOUT
223 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
224 "(&(objectClass=organization)(objectClass=dcObject))" >> $SEARCHOUT 2>&1
227 if test $RC != 0 ; then
228 echo "ldapsearch failed ($RC)!"
229 test $KILLSERVERS != no && kill -HUP $KILLPIDS
233 echo "Testing OR search..."
234 echo "# Testing OR search..." >> $SEARCHOUT
235 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
236 "(|(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1
239 if test $RC != 0 ; then
240 echo "ldapsearch failed ($RC)!"
241 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 echo "Testing OR search on objectClass..."
246 echo "# Testing OR search on objectClass..." >> $SEARCHOUT
247 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
248 "(|(objectClass=document)(objectClass=organization))" >> $SEARCHOUT 2>&1
251 if test $RC != 0 ; then
252 echo "ldapsearch failed ($RC)!"
253 test $KILLSERVERS != no && kill -HUP $KILLPIDS
257 echo "Testing NOT search..."
258 echo "# Testing NOT search..." >> $SEARCHOUT
259 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
260 '(!(sn=kovalev))' >> $SEARCHOUT 2>&1
263 if test $RC != 0 ; then
264 echo "ldapsearch failed ($RC)!"
265 test $KILLSERVERS != no && kill -HUP $KILLPIDS
269 echo "Testing NOT search on objectClass..."
270 echo "# Testing NOT search on objectClass..." >> $SEARCHOUT
271 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
272 '(!(objectClass=inetOrgPerson))' >> $SEARCHOUT 2>&1
275 if test $RC != 0 ; then
276 echo "ldapsearch failed ($RC)!"
277 test $KILLSERVERS != no && kill -HUP $KILLPIDS
281 echo "Testing NOT search on \"auxiliary\" objectClass..."
282 echo "# Testing NOT search on \"auxiliary\" objectClass..." >> $SEARCHOUT
283 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
284 '(!(objectClass=dcObject))' >> $SEARCHOUT 2>&1
287 if test $RC != 0 ; then
288 echo "ldapsearch failed ($RC)!"
289 test $KILLSERVERS != no && kill -HUP $KILLPIDS
294 echo "Testing NOT presence search... (disabled)"
295 ###echo "# Testing NOT presence search..." >> $SEARCHOUT
296 ###$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
297 ### '(!(sn=*))' >> $SEARCHOUT 2>&1
300 ###if test $RC != 0 ; then
301 ### echo "ldapsearch failed ($RC)!"
302 ### test $KILLSERVERS != no && kill -HUP $KILLPIDS
306 echo "Testing attribute inheritance in filter..."
307 echo "# Testing attribute inheritance in filter..." >> $SEARCHOUT
308 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
309 "(name=example)" >> $SEARCHOUT 2>&1
312 if test $RC != 0 ; then
313 echo "ldapsearch failed ($RC)!"
314 test $KILLSERVERS != no && kill -HUP $KILLPIDS
318 echo "Testing objectClass inheritance in filter..."
319 echo "# Testing objectClass inheritance in filter..." >> $SEARCHOUT
320 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
321 "(objectClass=person)" >> $SEARCHOUT 2>&1
324 if test $RC != 0 ; then
325 echo "ldapsearch failed ($RC)!"
326 test $KILLSERVERS != no && kill -HUP $KILLPIDS
330 echo "Testing \"auxiliary\" objectClass in filter..."
331 echo "# Testing \"auxiliary\" objectClass in filter..." >> $SEARCHOUT
332 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
333 "(objectClass=dcObject)" >> $SEARCHOUT 2>&1
336 if test $RC != 0 ; then
337 echo "ldapsearch failed ($RC)!"
338 test $KILLSERVERS != no && kill -HUP $KILLPIDS
342 echo "Testing hasSubordinates in filter..."
343 echo "# Testing hasSubordinates in filter..." >> $SEARCHOUT
344 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
345 "(hasSubordinates=TRUE)" >> $SEARCHOUT 2>&1
348 if test $RC != 0 ; then
349 echo "ldapsearch failed ($RC)!"
350 test $KILLSERVERS != no && kill -HUP $KILLPIDS
354 echo "Testing entryUUID in filter..."
355 echo "# Testing entryUUID in filter..." >> $SEARCHOUT
356 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
357 "(entryUUID=00000001-0000-0001-0000-000000000000)" >> $SEARCHOUT 2>&1
360 if test $RC != 0 ; then
361 echo "ldapsearch failed ($RC)!"
362 test $KILLSERVERS != no && kill -HUP $KILLPIDS
366 echo "Testing attribute inheritance in requested attributes..."
367 echo "# Testing attribute inheritance in requested attributes..." >> $SEARCHOUT
368 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
369 "(sn=kovalev)" name >> $SEARCHOUT 2>&1
372 if test $RC != 0 ; then
373 echo "ldapsearch failed ($RC)!"
374 test $KILLSERVERS != no && kill -HUP $KILLPIDS
378 echo "Testing objectClass in requested attributes..."
379 echo "# Testing objectClass in requested attributes..." >> $SEARCHOUT
380 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
381 objectClass >> $SEARCHOUT 2>&1
384 if test $RC != 0 ; then
385 echo "ldapsearch failed ($RC)!"
386 test $KILLSERVERS != no && kill -HUP $KILLPIDS
390 echo "Testing operational attributes in request..."
391 echo "# Testing operational attributes in request..." >> $SEARCHOUT
392 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
393 '+' 2>&1 | grep -v '^entryCSN:' >> $SEARCHOUT
396 if test $RC != 0 ; then
397 echo "ldapsearch failed ($RC)!"
398 test $KILLSERVERS != no && kill -HUP $KILLPIDS
402 echo -n "Testing compare (should be TRUE)... "
403 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
404 "sn:kovalev" >> $TESTOUT 2>&1
412 test $KILLSERVERS != no && kill -HUP $KILLPIDS
415 *) echo "failed ($RC)!"
416 test $KILLSERVERS != no && kill -HUP $KILLPIDS
421 echo -n "Testing compare (should be FALSE)... "
422 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
423 "cn:foobar" >> $TESTOUT 2>&1
429 test $KILLSERVERS != no && kill -HUP $KILLPIDS
434 *) echo "failed ($RC)!"
435 test $KILLSERVERS != no && kill -HUP $KILLPIDS
440 echo -n "Testing compare (should be UNDEFINED)... "
441 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
442 "o:example" >> $TESTOUT 2>&1
448 test $KILLSERVERS != no && kill -HUP $KILLPIDS
452 test $KILLSERVERS != no && kill -HUP $KILLPIDS
455 *) echo "failed ($RC)"
459 echo "Filtering ldapsearch results..."
460 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
461 echo "Filtering original ldif..."
462 . $LDIFFILTER < $SQLREAD > $LDIFFLT
463 echo "Comparing filter output..."
464 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
466 if test $? != 0 ; then
467 echo "comparison failed - SQL search didn't succeed"
468 test $KILLSERVERS != no && kill -HUP $KILLPIDS
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
474 echo ">>>>> Test succeeded"