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 search..."
81 echo "# Testing search..." > $SEARCHOUT
82 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
85 if test $RC != 0 ; then
86 echo "ldapsearch failed ($RC)!"
87 test $KILLSERVERS != no && kill -HUP $KILLPIDS
91 echo "Testing invalid filter..."
92 echo "# Testing invalid filter..." >> $SEARCHOUT
93 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
94 "(foo=)" >> $SEARCHOUT 2>&1
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 echo "Testing exact search..."
104 echo "# Testing exact search..." >> $SEARCHOUT
105 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
106 "(sn=Kovalev)" >> $SEARCHOUT 2>&1
109 if test $RC != 0 ; then
110 echo "ldapsearch failed ($RC)!"
111 test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 echo "Testing substrings initial search..."
116 echo "# Testing substrings initial search..." >> $SEARCHOUT
117 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
118 "(cn=m*)" >> $SEARCHOUT 2>&1
121 if test $RC != 0 ; then
122 echo "ldapsearch failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127 echo "Testing substrings any search..."
128 echo "# Testing substrings any search..." >> $SEARCHOUT
129 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
130 "(cn=*m*)" >> $SEARCHOUT 2>&1
133 if test $RC != 0 ; then
134 echo "ldapsearch failed ($RC)!"
135 test $KILLSERVERS != no && kill -HUP $KILLPIDS
139 echo "Testing substrings final search..."
140 echo "# Testing substrings final search..." >> $SEARCHOUT
141 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
142 "(cn=*v)" >> $SEARCHOUT 2>&1
145 if test $RC != 0 ; then
146 echo "ldapsearch failed ($RC)!"
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 echo "Testing approx search..."
152 echo "# Testing approx search..." >> $SEARCHOUT
153 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
154 "(sn~=kovalev)" >> $SEARCHOUT 2>&1
157 if test $RC != 0 ; then
158 echo "ldapsearch failed ($RC)!"
159 test $KILLSERVERS != no && kill -HUP $KILLPIDS
163 echo "Testing extensible filter search..."
164 echo "# Testing extensible filter search..." >> $SEARCHOUT
165 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
166 "(sn:caseExactMatch:=Kovalev)" >> $SEARCHOUT 2>&1
169 if test $RC != 0 ; then
170 echo "ldapsearch failed ($RC)!"
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
175 echo "Testing search for telephoneNumber..."
176 echo "# Testing search for telephoneNumber..." >> $SEARCHOUT
177 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
178 "(telephoneNumber=3322334)" >> $SEARCHOUT 2>&1
181 if test $RC != 0 ; then
182 echo "ldapsearch failed ($RC)!"
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
187 echo "Testing AND search..."
188 echo "# Testing AND search..." >> $SEARCHOUT
189 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
190 "(&(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1
193 if test $RC != 0 ; then
194 echo "ldapsearch failed ($RC)!"
195 test $KILLSERVERS != no && kill -HUP $KILLPIDS
199 echo "Testing AND search on objectClass..."
200 echo "# Testing AND search on objectClass..." >> $SEARCHOUT
201 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
202 "(&(objectClass=organization)(objectClass=dcObject))" >> $SEARCHOUT 2>&1
205 if test $RC != 0 ; then
206 echo "ldapsearch failed ($RC)!"
207 test $KILLSERVERS != no && kill -HUP $KILLPIDS
211 echo "Testing OR search..."
212 echo "# Testing OR search..." >> $SEARCHOUT
213 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
214 "(|(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1
217 if test $RC != 0 ; then
218 echo "ldapsearch failed ($RC)!"
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 echo "Testing OR search on objectClass..."
224 echo "# Testing OR search on objectClass..." >> $SEARCHOUT
225 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
226 "(|(objectClass=document)(objectClass=organization))" >> $SEARCHOUT 2>&1
229 if test $RC != 0 ; then
230 echo "ldapsearch failed ($RC)!"
231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
235 echo "Testing NOT search..."
236 echo "# Testing NOT search..." >> $SEARCHOUT
237 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
238 '(!(sn=kovalev))' >> $SEARCHOUT 2>&1
241 if test $RC != 0 ; then
242 echo "ldapsearch failed ($RC)!"
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
247 echo "Testing NOT search on objectClass..."
248 echo "# Testing NOT search on objectClass..." >> $SEARCHOUT
249 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
250 '(!(objectClass=inetOrgPerson))' >> $SEARCHOUT 2>&1
253 if test $RC != 0 ; then
254 echo "ldapsearch failed ($RC)!"
255 test $KILLSERVERS != no && kill -HUP $KILLPIDS
259 echo "Testing NOT search on \"auxiliary\" objectClass..."
260 echo "# Testing NOT search on \"auxiliary\" objectClass..." >> $SEARCHOUT
261 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
262 '(!(objectClass=dcObject))' >> $SEARCHOUT 2>&1
265 if test $RC != 0 ; then
266 echo "ldapsearch failed ($RC)!"
267 test $KILLSERVERS != no && kill -HUP $KILLPIDS
272 echo "Testing NOT presence search... (disabled)"
273 ###echo "# Testing NOT presence search..." >> $SEARCHOUT
274 ###$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
275 ### '(!(sn=*))' >> $SEARCHOUT 2>&1
278 ###if test $RC != 0 ; then
279 ### echo "ldapsearch failed ($RC)!"
280 ### test $KILLSERVERS != no && kill -HUP $KILLPIDS
284 echo "Testing attribute inheritance in filter..."
285 echo "# Testing attribute inheritance in filter..." >> $SEARCHOUT
286 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
287 "(name=example)" >> $SEARCHOUT 2>&1
290 if test $RC != 0 ; then
291 echo "ldapsearch failed ($RC)!"
292 test $KILLSERVERS != no && kill -HUP $KILLPIDS
296 echo "Testing objectClass inheritance in filter..."
297 echo "# Testing objectClass inheritance in filter..." >> $SEARCHOUT
298 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
299 "(objectClass=person)" >> $SEARCHOUT 2>&1
302 if test $RC != 0 ; then
303 echo "ldapsearch failed ($RC)!"
304 test $KILLSERVERS != no && kill -HUP $KILLPIDS
308 echo "Testing \"auxiliary\" objectClass in filter..."
309 echo "# Testing \"auxiliary\" objectClass in filter..." >> $SEARCHOUT
310 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
311 "(objectClass=dcObject)" >> $SEARCHOUT 2>&1
314 if test $RC != 0 ; then
315 echo "ldapsearch failed ($RC)!"
316 test $KILLSERVERS != no && kill -HUP $KILLPIDS
320 echo "Testing hasSubordinates in filter..."
321 echo "# Testing hasSubordinates in filter..." >> $SEARCHOUT
322 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
323 "(hasSubordinates=TRUE)" >> $SEARCHOUT 2>&1
326 if test $RC != 0 ; then
327 echo "ldapsearch failed ($RC)!"
328 test $KILLSERVERS != no && kill -HUP $KILLPIDS
332 echo "Testing attribute inheritance in requested attributes..."
333 echo "# Testing attribute inheritance in requested attributes..." >> $SEARCHOUT
334 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
335 "(sn=kovalev)" name >> $SEARCHOUT 2>&1
338 if test $RC != 0 ; then
339 echo "ldapsearch failed ($RC)!"
340 test $KILLSERVERS != no && kill -HUP $KILLPIDS
344 echo "Testing objectClass in requested attributes..."
345 echo "# Testing objectClass in requested attributes..." >> $SEARCHOUT
346 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
347 objectClass >> $SEARCHOUT 2>&1
350 if test $RC != 0 ; then
351 echo "ldapsearch failed ($RC)!"
352 test $KILLSERVERS != no && kill -HUP $KILLPIDS
356 echo "Testing operational attributes in request..."
357 echo "# Testing operational attributes in request..." >> $SEARCHOUT
358 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
359 '+' >> $SEARCHOUT 2>&1
362 if test $RC != 0 ; then
363 echo "ldapsearch failed ($RC)!"
364 test $KILLSERVERS != no && kill -HUP $KILLPIDS
368 echo -n "Testing compare (should be TRUE)... "
369 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
370 "sn:kovalev" >> $TESTOUT 2>&1
378 test $KILLSERVERS != no && kill -HUP $KILLPIDS
381 *) echo "failed ($RC)!"
382 test $KILLSERVERS != no && kill -HUP $KILLPIDS
387 echo -n "Testing compare (should be FALSE)... "
388 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
389 "cn:foobar" >> $TESTOUT 2>&1
395 test $KILLSERVERS != no && kill -HUP $KILLPIDS
400 *) echo "failed ($RC)!"
401 test $KILLSERVERS != no && kill -HUP $KILLPIDS
406 echo -n "Testing compare (should be UNDEFINED)... "
407 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \
408 "o:example" >> $TESTOUT 2>&1
414 test $KILLSERVERS != no && kill -HUP $KILLPIDS
418 test $KILLSERVERS != no && kill -HUP $KILLPIDS
421 *) echo "failed ($RC)"
425 echo "Filtering ldapsearch results..."
426 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
427 echo "Filtering original ldif..."
428 . $LDIFFILTER < $SQLREAD > $LDIFFLT
429 echo "Comparing filter output..."
430 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
432 if test $? != 0 ; then
433 echo "comparison failed - SQL search didn't succeed"
434 test $KILLSERVERS != no && kill -HUP $KILLPIDS
438 test $KILLSERVERS != no && kill -HUP $KILLPIDS
440 echo ">>>>> Test succeeded"