3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2015 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 -S "" \
86 if test $RC != 0 ; then
87 echo "ldapsearch failed ($RC)!"
88 test $KILLSERVERS != no && kill -HUP $KILLPIDS
92 echo "Testing onelevel search..."
93 echo "# Testing onelevel search..." >> $SEARCHOUT
94 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -s one -S "" \
98 if test $RC != 0 ; then
99 echo "ldapsearch failed ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 echo "Testing subtree search..."
105 echo "# Testing subtree search..." >> $SEARCHOUT
106 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
110 if test $RC != 0 ; then
111 echo "ldapsearch failed ($RC)!"
112 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116 echo "Testing subtree search with manageDSAit..."
117 echo "# Testing subtree search with manageDSAit..." >> $SEARCHOUT
118 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M -S "" '*' ref \
122 if test $RC != 0 ; then
123 echo "ldapsearch failed ($RC)!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 echo "Testing invalid filter..."
129 echo "# Testing invalid filter..." >> $SEARCHOUT
130 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" "(foo=)" \
134 if test $RC != 0 ; then
135 echo "ldapsearch failed ($RC)!"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 echo "Testing exact search..."
141 echo "# Testing exact search..." >> $SEARCHOUT
142 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" "(sn=Kovalev)" \
146 if test $RC != 0 ; then
147 echo "ldapsearch failed ($RC)!"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 echo "Testing substrings initial search..."
153 echo "# Testing substrings initial search..." >> $SEARCHOUT
154 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" "(cn=m*)" \
158 if test $RC != 0 ; then
159 echo "ldapsearch failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 echo "Testing substrings any search..."
165 echo "# Testing substrings any search..." >> $SEARCHOUT
166 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" "(cn=*m*)" \
170 if test $RC != 0 ; then
171 echo "ldapsearch failed ($RC)!"
172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
176 echo "Testing substrings final search..."
177 echo "# Testing substrings final search..." >> $SEARCHOUT
178 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" "(cn=*v)" \
182 if test $RC != 0 ; then
183 echo "ldapsearch failed ($RC)!"
184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
188 echo "Testing approx search..."
189 echo "# Testing approx search..." >> $SEARCHOUT
190 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" "(sn~=kovalev)" \
194 if test $RC != 0 ; then
195 echo "ldapsearch failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
200 echo "Testing extensible filter search..."
201 echo "# Testing extensible filter search..." >> $SEARCHOUT
202 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
203 "(sn:caseExactMatch:=Kovalev)" >> $SEARCHOUT 2>&1
206 if test $RC != 0 ; then
207 echo "ldapsearch failed ($RC)!"
208 test $KILLSERVERS != no && kill -HUP $KILLPIDS
212 echo "Testing search for telephoneNumber..."
213 echo "# Testing search for telephoneNumber..." >> $SEARCHOUT
214 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
215 "(telephoneNumber=3322334)" >> $SEARCHOUT 2>&1
218 if test $RC != 0 ; then
219 echo "ldapsearch failed ($RC)!"
220 test $KILLSERVERS != no && kill -HUP $KILLPIDS
224 echo "Testing AND search..."
225 echo "# Testing AND search..." >> $SEARCHOUT
226 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
227 "(&(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1
230 if test $RC != 0 ; then
231 echo "ldapsearch failed ($RC)!"
232 test $KILLSERVERS != no && kill -HUP $KILLPIDS
236 echo "Testing AND search on objectClass..."
237 echo "# Testing AND search on objectClass..." >> $SEARCHOUT
238 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
239 "(&(objectClass=organization)(objectClass=dcObject))" >> $SEARCHOUT 2>&1
242 if test $RC != 0 ; then
243 echo "ldapsearch failed ($RC)!"
244 test $KILLSERVERS != no && kill -HUP $KILLPIDS
248 echo "Testing OR search..."
249 echo "# Testing OR search..." >> $SEARCHOUT
250 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
251 "(|(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1
254 if test $RC != 0 ; then
255 echo "ldapsearch failed ($RC)!"
256 test $KILLSERVERS != no && kill -HUP $KILLPIDS
260 echo "Testing OR search on objectClass..."
261 echo "# Testing OR search on objectClass..." >> $SEARCHOUT
262 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
263 "(|(objectClass=document)(objectClass=organization))" \
267 if test $RC != 0 ; then
268 echo "ldapsearch failed ($RC)!"
269 test $KILLSERVERS != no && kill -HUP $KILLPIDS
273 echo "Testing NOT search..."
274 echo "# Testing NOT search..." >> $SEARCHOUT
275 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
276 '(!(sn=kovalev))' >> $SEARCHOUT 2>&1
279 if test $RC != 0 ; then
280 echo "ldapsearch failed ($RC)!"
281 test $KILLSERVERS != no && kill -HUP $KILLPIDS
285 echo "Testing NOT search on objectClass..."
286 echo "# Testing NOT search on objectClass..." >> $SEARCHOUT
287 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
288 '(!(objectClass=inetOrgPerson))' >> $SEARCHOUT 2>&1
291 if test $RC != 0 ; then
292 echo "ldapsearch failed ($RC)!"
293 test $KILLSERVERS != no && kill -HUP $KILLPIDS
297 echo "Testing NOT search on \"auxiliary\" objectClass..."
298 echo "# Testing NOT search on \"auxiliary\" objectClass..." >> $SEARCHOUT
299 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
300 '(!(objectClass=dcObject))' >> $SEARCHOUT 2>&1
303 if test $RC != 0 ; then
304 echo "ldapsearch failed ($RC)!"
305 test $KILLSERVERS != no && kill -HUP $KILLPIDS
310 echo "Testing NOT presence search... (disabled)"
311 ###echo "# Testing NOT presence search..." >> $SEARCHOUT
312 ###$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
313 ### '(!(sn=*))' >> $SEARCHOUT 2>&1
316 ###if test $RC != 0 ; then
317 ### echo "ldapsearch failed ($RC)!"
318 ### test $KILLSERVERS != no && kill -HUP $KILLPIDS
322 echo "Testing attribute inheritance in filter..."
323 echo "# Testing attribute inheritance in filter..." >> $SEARCHOUT
324 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
325 "(name=example)" >> $SEARCHOUT 2>&1
328 if test $RC != 0 ; then
329 echo "ldapsearch failed ($RC)!"
330 test $KILLSERVERS != no && kill -HUP $KILLPIDS
335 echo "Testing undefined attribute in filter..."
336 echo "# Testing undefined attribute in filter..." >> $SEARCHOUT
337 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
338 "(|(o=example)(foobar=x))" >> $SEARCHOUT 2>&1
341 if test $RC != 0 ; then
342 echo "ldapsearch failed ($RC)!"
343 test $KILLSERVERS != no && kill -HUP $KILLPIDS
347 echo "Testing objectClass inheritance in filter..."
348 echo "# Testing objectClass inheritance in filter..." >> $SEARCHOUT
349 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
350 "(objectClass=person)" >> $SEARCHOUT 2>&1
353 if test $RC != 0 ; then
354 echo "ldapsearch failed ($RC)!"
355 test $KILLSERVERS != no && kill -HUP $KILLPIDS
359 echo "Testing \"auxiliary\" objectClass in filter..."
360 echo "# Testing \"auxiliary\" objectClass in filter..." >> $SEARCHOUT
361 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
362 "(objectClass=dcObject)" >> $SEARCHOUT 2>&1
365 if test $RC != 0 ; then
366 echo "ldapsearch failed ($RC)!"
367 test $KILLSERVERS != no && kill -HUP $KILLPIDS
371 echo "Testing hasSubordinates in filter..."
372 echo "# Testing hasSubordinates in filter..." >> $SEARCHOUT
373 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
374 "(hasSubordinates=TRUE)" >> $SEARCHOUT 2>&1
377 if test $RC != 0 ; then
378 echo "ldapsearch failed ($RC)!"
379 test $KILLSERVERS != no && kill -HUP $KILLPIDS
383 echo "Testing entryUUID in filter..."
384 echo "# Testing entryUUID in filter..." >> $SEARCHOUT
385 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
386 "(entryUUID=00000001-0000-0001-0000-000000000000)" >> $SEARCHOUT 2>&1
389 if test $RC != 0 ; then
390 echo "ldapsearch failed ($RC)!"
391 test $KILLSERVERS != no && kill -HUP $KILLPIDS
395 echo "Testing attribute inheritance in requested attributes..."
396 echo "# Testing attribute inheritance in requested attributes..." >> $SEARCHOUT
397 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
398 "(sn=kovalev)" name >> $SEARCHOUT 2>&1
401 if test $RC != 0 ; then
402 echo "ldapsearch failed ($RC)!"
403 test $KILLSERVERS != no && kill -HUP $KILLPIDS
407 echo "Testing objectClass in requested attributes..."
408 echo "# Testing objectClass in requested attributes..." >> $SEARCHOUT
409 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
410 objectClass >> $SEARCHOUT 2>&1
413 if test $RC != 0 ; then
414 echo "ldapsearch failed ($RC)!"
415 test $KILLSERVERS != no && kill -HUP $KILLPIDS
419 echo "Testing operational attributes in request..."
420 echo "# Testing operational attributes in request..." >> $SEARCHOUT
421 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" \
422 '+' 2>&1 > $SEARCHFLT
425 if test $RC != 0 ; then
426 echo "ldapsearch failed ($RC)!"
427 test $KILLSERVERS != no && kill -HUP $KILLPIDS
431 grep -v '^entryCSN:' $SEARCHFLT >> $SEARCHOUT
434 echo "Testing size limit..."
435 $LDAPRSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
436 -z $SIZELIMIT -S "" '(objectClass=*)' >$SEARCHFLT 2>&1
438 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHFLT`
441 if test x"$COUNT" != x ; then
442 if test "$COUNT" -gt "$SIZELIMIT" ; then
443 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
444 test $KILLSERVERS != no && kill -HUP $KILLPIDS
447 echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
449 echo "...error: did not expect ldapsearch success ($RC)!"
450 test $KILLSERVERS != no && kill -HUP $KILLPIDS
455 if test x"$COUNT" != x ; then
456 if test "$COUNT" = "$SIZELIMIT" ; then
457 echo "...bumped into requested size limit ($SIZELIMIT)"
459 echo "...error: got $COUNT entries with a requested sizelimit of $SIZELIMIT"
460 test $KILLSERVERS != no && kill -HUP $KILLPIDS
464 echo "...error: bumped into server-side size limit, but got no entries!"
465 test $KILLSERVERS != no && kill -HUP $KILLPIDS
470 echo "ldapsearch failed ($RC)!"
471 test $KILLSERVERS != no && kill -HUP $KILLPIDS
476 echo -n "Testing compare (should be TRUE)... "
477 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
478 "sn:kovalev" >> $TESTOUT 2>&1
486 test $KILLSERVERS != no && kill -HUP $KILLPIDS
489 *) echo "failed ($RC)!"
490 test $KILLSERVERS != no && kill -HUP $KILLPIDS
495 echo -n "Testing compare (should be FALSE)... "
496 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
497 "cn:foobar" >> $TESTOUT 2>&1
503 test $KILLSERVERS != no && kill -HUP $KILLPIDS
508 *) echo "failed ($RC)!"
509 test $KILLSERVERS != no && kill -HUP $KILLPIDS
514 echo -n "Testing compare (should be UNDEFINED)... "
515 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
516 "o:example" >> $TESTOUT 2>&1
522 test $KILLSERVERS != no && kill -HUP $KILLPIDS
526 test $KILLSERVERS != no && kill -HUP $KILLPIDS
529 *) echo "failed ($RC)"
533 echo -n "Testing compare on hasSubordinates (should be TRUE)... "
534 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BASEDN" \
535 "hasSubordinates:TRUE" >> $TESTOUT 2>&1
543 test $KILLSERVERS != no && kill -HUP $KILLPIDS
546 *) echo "failed ($RC)!"
547 test $KILLSERVERS != no && kill -HUP $KILLPIDS
552 echo "Filtering ldapsearch results..."
553 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
554 echo "Filtering original ldif..."
555 $LDIFFILTER < $SQLREAD > $LDIFFLT
556 echo "Comparing filter output..."
557 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
559 if test $? != 0 ; then
560 echo "comparison failed - SQL search didn't succeed"
561 test $KILLSERVERS != no && kill -HUP $KILLPIDS
565 test $KILLSERVERS != no && kill -HUP $KILLPIDS
567 echo ">>>>> Test succeeded"