3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2006 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 subtree search with manageDSAit..."
114 echo "# Testing subtree search with manageDSAit..." >> $SEARCHOUT
115 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M '*' ref >> $SEARCHOUT 2>&1
118 if test $RC != 0 ; then
119 echo "ldapsearch failed ($RC)!"
120 test $KILLSERVERS != no && kill -HUP $KILLPIDS
124 echo "Testing invalid filter..."
125 echo "# Testing invalid filter..." >> $SEARCHOUT
126 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
127 "(foo=)" >> $SEARCHOUT 2>&1
130 if test $RC != 0 ; then
131 echo "ldapsearch failed ($RC)!"
132 test $KILLSERVERS != no && kill -HUP $KILLPIDS
136 echo "Testing exact search..."
137 echo "# Testing exact search..." >> $SEARCHOUT
138 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
139 "(sn=Kovalev)" >> $SEARCHOUT 2>&1
142 if test $RC != 0 ; then
143 echo "ldapsearch failed ($RC)!"
144 test $KILLSERVERS != no && kill -HUP $KILLPIDS
148 echo "Testing substrings initial search..."
149 echo "# Testing substrings initial search..." >> $SEARCHOUT
150 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
151 "(cn=m*)" >> $SEARCHOUT 2>&1
154 if test $RC != 0 ; then
155 echo "ldapsearch failed ($RC)!"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160 echo "Testing substrings any search..."
161 echo "# Testing substrings any search..." >> $SEARCHOUT
162 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
163 "(cn=*m*)" >> $SEARCHOUT 2>&1
166 if test $RC != 0 ; then
167 echo "ldapsearch failed ($RC)!"
168 test $KILLSERVERS != no && kill -HUP $KILLPIDS
172 echo "Testing substrings final search..."
173 echo "# Testing substrings final search..." >> $SEARCHOUT
174 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
175 "(cn=*v)" >> $SEARCHOUT 2>&1
178 if test $RC != 0 ; then
179 echo "ldapsearch failed ($RC)!"
180 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 echo "Testing approx search..."
185 echo "# Testing approx search..." >> $SEARCHOUT
186 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
187 "(sn~=kovalev)" >> $SEARCHOUT 2>&1
190 if test $RC != 0 ; then
191 echo "ldapsearch failed ($RC)!"
192 test $KILLSERVERS != no && kill -HUP $KILLPIDS
196 echo "Testing extensible filter search..."
197 echo "# Testing extensible filter search..." >> $SEARCHOUT
198 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
199 "(sn:caseExactMatch:=Kovalev)" >> $SEARCHOUT 2>&1
202 if test $RC != 0 ; then
203 echo "ldapsearch failed ($RC)!"
204 test $KILLSERVERS != no && kill -HUP $KILLPIDS
208 echo "Testing search for telephoneNumber..."
209 echo "# Testing search for telephoneNumber..." >> $SEARCHOUT
210 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
211 "(telephoneNumber=3322334)" >> $SEARCHOUT 2>&1
214 if test $RC != 0 ; then
215 echo "ldapsearch failed ($RC)!"
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 echo "Testing AND search..."
221 echo "# Testing AND search..." >> $SEARCHOUT
222 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
223 "(&(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1
226 if test $RC != 0 ; then
227 echo "ldapsearch failed ($RC)!"
228 test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 echo "Testing AND search on objectClass..."
233 echo "# Testing AND search on objectClass..." >> $SEARCHOUT
234 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
235 "(&(objectClass=organization)(objectClass=dcObject))" >> $SEARCHOUT 2>&1
238 if test $RC != 0 ; then
239 echo "ldapsearch failed ($RC)!"
240 test $KILLSERVERS != no && kill -HUP $KILLPIDS
244 echo "Testing OR search..."
245 echo "# Testing OR search..." >> $SEARCHOUT
246 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
247 "(|(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1
250 if test $RC != 0 ; then
251 echo "ldapsearch failed ($RC)!"
252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
256 echo "Testing OR search on objectClass..."
257 echo "# Testing OR search on objectClass..." >> $SEARCHOUT
258 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
259 "(|(objectClass=document)(objectClass=organization))" >> $SEARCHOUT 2>&1
262 if test $RC != 0 ; then
263 echo "ldapsearch failed ($RC)!"
264 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 echo "Testing NOT search..."
269 echo "# Testing NOT search..." >> $SEARCHOUT
270 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
271 '(!(sn=kovalev))' >> $SEARCHOUT 2>&1
274 if test $RC != 0 ; then
275 echo "ldapsearch failed ($RC)!"
276 test $KILLSERVERS != no && kill -HUP $KILLPIDS
280 echo "Testing NOT search on objectClass..."
281 echo "# Testing NOT search on objectClass..." >> $SEARCHOUT
282 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
283 '(!(objectClass=inetOrgPerson))' >> $SEARCHOUT 2>&1
286 if test $RC != 0 ; then
287 echo "ldapsearch failed ($RC)!"
288 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 echo "Testing NOT search on \"auxiliary\" objectClass..."
293 echo "# Testing NOT search on \"auxiliary\" objectClass..." >> $SEARCHOUT
294 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
295 '(!(objectClass=dcObject))' >> $SEARCHOUT 2>&1
298 if test $RC != 0 ; then
299 echo "ldapsearch failed ($RC)!"
300 test $KILLSERVERS != no && kill -HUP $KILLPIDS
305 echo "Testing NOT presence search... (disabled)"
306 ###echo "# Testing NOT presence search..." >> $SEARCHOUT
307 ###$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
308 ### '(!(sn=*))' >> $SEARCHOUT 2>&1
311 ###if test $RC != 0 ; then
312 ### echo "ldapsearch failed ($RC)!"
313 ### test $KILLSERVERS != no && kill -HUP $KILLPIDS
317 echo "Testing attribute inheritance in filter..."
318 echo "# Testing attribute inheritance in filter..." >> $SEARCHOUT
319 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
320 "(name=example)" >> $SEARCHOUT 2>&1
323 if test $RC != 0 ; then
324 echo "ldapsearch failed ($RC)!"
325 test $KILLSERVERS != no && kill -HUP $KILLPIDS
329 echo "Testing objectClass inheritance in filter..."
330 echo "# Testing objectClass inheritance in filter..." >> $SEARCHOUT
331 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
332 "(objectClass=person)" >> $SEARCHOUT 2>&1
335 if test $RC != 0 ; then
336 echo "ldapsearch failed ($RC)!"
337 test $KILLSERVERS != no && kill -HUP $KILLPIDS
341 echo "Testing \"auxiliary\" objectClass in filter..."
342 echo "# Testing \"auxiliary\" objectClass in filter..." >> $SEARCHOUT
343 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
344 "(objectClass=dcObject)" >> $SEARCHOUT 2>&1
347 if test $RC != 0 ; then
348 echo "ldapsearch failed ($RC)!"
349 test $KILLSERVERS != no && kill -HUP $KILLPIDS
353 echo "Testing hasSubordinates in filter..."
354 echo "# Testing hasSubordinates in filter..." >> $SEARCHOUT
355 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
356 "(hasSubordinates=TRUE)" >> $SEARCHOUT 2>&1
359 if test $RC != 0 ; then
360 echo "ldapsearch failed ($RC)!"
361 test $KILLSERVERS != no && kill -HUP $KILLPIDS
365 echo "Testing entryUUID in filter..."
366 echo "# Testing entryUUID in filter..." >> $SEARCHOUT
367 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
368 "(entryUUID=00000001-0000-0001-0000-000000000000)" >> $SEARCHOUT 2>&1
371 if test $RC != 0 ; then
372 echo "ldapsearch failed ($RC)!"
373 test $KILLSERVERS != no && kill -HUP $KILLPIDS
377 echo "Testing attribute inheritance in requested attributes..."
378 echo "# Testing attribute inheritance in requested attributes..." >> $SEARCHOUT
379 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
380 "(sn=kovalev)" name >> $SEARCHOUT 2>&1
383 if test $RC != 0 ; then
384 echo "ldapsearch failed ($RC)!"
385 test $KILLSERVERS != no && kill -HUP $KILLPIDS
389 echo "Testing objectClass in requested attributes..."
390 echo "# Testing objectClass in requested attributes..." >> $SEARCHOUT
391 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
392 objectClass >> $SEARCHOUT 2>&1
395 if test $RC != 0 ; then
396 echo "ldapsearch failed ($RC)!"
397 test $KILLSERVERS != no && kill -HUP $KILLPIDS
401 echo "Testing operational attributes in request..."
402 echo "# Testing operational attributes in request..." >> $SEARCHOUT
403 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
404 '+' 2>&1 > $SEARCHFLT
407 if test $RC != 0 ; then
408 echo "ldapsearch failed ($RC)!"
409 test $KILLSERVERS != no && kill -HUP $KILLPIDS
413 grep -v '^entryCSN:' $SEARCHFLT >> $SEARCHOUT
416 echo "Testing size limit..."
417 $LDAPRSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
418 -z $SIZELIMIT -S "" '(objectClass=*)' >$SEARCHFLT 2>&1
420 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHFLT`
423 if test x"$COUNT" != x ; then
424 if test "$COUNT" -gt "$SIZELIMIT" ; then
425 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
426 test $KILLSERVERS != no && kill -HUP $KILLPIDS
429 echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
431 echo "...error: did not expect ldapsearch success ($RC)!"
432 test $KILLSERVERS != no && kill -HUP $KILLPIDS
437 if test x"$COUNT" != x ; then
438 if test "$COUNT" = "$SIZELIMIT" ; then
439 echo "...bumped into requested size limit ($SIZELIMIT)"
441 echo "...error: got $COUNT entries with a requested sizelimit of $SIZELIMIT"
442 test $KILLSERVERS != no && kill -HUP $KILLPIDS
446 echo "...error: bumped into server-side size limit, but got no entries!"
447 test $KILLSERVERS != no && kill -HUP $KILLPIDS
452 echo "ldapsearch failed ($RC)!"
453 test $KILLSERVERS != no && kill -HUP $KILLPIDS
458 echo -n "Testing compare (should be TRUE)... "
459 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
460 "sn:kovalev" >> $TESTOUT 2>&1
468 test $KILLSERVERS != no && kill -HUP $KILLPIDS
471 *) echo "failed ($RC)!"
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
477 echo -n "Testing compare (should be FALSE)... "
478 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
479 "cn:foobar" >> $TESTOUT 2>&1
485 test $KILLSERVERS != no && kill -HUP $KILLPIDS
490 *) echo "failed ($RC)!"
491 test $KILLSERVERS != no && kill -HUP $KILLPIDS
496 echo -n "Testing compare (should be UNDEFINED)... "
497 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
498 "o:example" >> $TESTOUT 2>&1
504 test $KILLSERVERS != no && kill -HUP $KILLPIDS
508 test $KILLSERVERS != no && kill -HUP $KILLPIDS
511 *) echo "failed ($RC)"
515 echo -n "Testing compare on hasSubordinates (should be TRUE)... "
516 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BASEDN" \
517 "hasSubordinates:TRUE" >> $TESTOUT 2>&1
525 test $KILLSERVERS != no && kill -HUP $KILLPIDS
528 *) echo "failed ($RC)!"
529 test $KILLSERVERS != no && kill -HUP $KILLPIDS
534 echo "Filtering ldapsearch results..."
535 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
536 echo "Filtering original ldif..."
537 . $LDIFFILTER < $SQLREAD > $LDIFFLT
538 echo "Comparing filter output..."
539 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
541 if test $? != 0 ; then
542 echo "comparison failed - SQL search didn't succeed"
543 test $KILLSERVERS != no && kill -HUP $KILLPIDS
547 test $KILLSERVERS != no && kill -HUP $KILLPIDS
549 echo ">>>>> Test succeeded"