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 mkdir -p $TESTDIR $DBDIR1
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $LIMITSCONF > $ADDCONF
23 $SLAPADD -f $ADDCONF -l $LDIFLIMITS
25 if test $RC != 0 ; then
26 echo "slapadd failed ($RC)!"
30 echo "Running slapindex to index slapd database..."
31 . $CONFFILTER $BACKEND $MONITORDB < $LIMITSCONF > $CONF1
34 if test $RC != 0 ; then
35 echo "warning: slapindex failed ($RC)"
36 echo " assuming no indexing support"
39 echo "Starting slapd on TCP/IP port $PORT1..."
40 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
42 if test $WAIT != 0 ; then
48 echo "Testing slapd searching..."
49 for i in 0 1 2 3 4 5; do
50 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
51 '(objectclass=*)' > /dev/null 2>&1
53 if test $RC = 0 ; then
56 echo "Waiting 5 seconds for slapd to start..."
60 if test $RC != 0 ; then
61 echo "ldapsearch failed ($RC)!"
62 test $KILLSERVERS != no && kill -HUP $KILLPIDS
66 cat /dev/null > $SEARCHOUT
68 echo "Testing no limits requested for unlimited ID..."
69 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
70 -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
71 '(objectClass=*)' >$SEARCHOUT 2>&1
73 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
76 echo "...success (got $COUNT entries)"
79 echo "ldapsearch failed ($RC)!"
80 test $KILLSERVERS != no && kill -HUP $KILLPIDS
86 echo "Testing size limit request ($SIZELIMIT) for unlimited ID..."
87 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
88 -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
89 '(objectClass=*)' > $SEARCHOUT 2>&1
91 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
94 echo "...success (got $COUNT entries)"
97 echo "...bumped into requested size limit ($SIZELIMIT)"
100 echo "ldapsearch failed ($RC)!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
107 echo "Testing time limit request ($TIMELIMIT s) for unlimited ID..."
108 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -l $TIMELIMIT \
109 -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
110 '(objectClass=*)' > $SEARCHOUT 2>&1
112 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
115 echo "...success (got $COUNT entries)"
118 echo "...bumped into requested time limit ($TIMELIMIT s; $COUNT entries)"
121 echo "ldapsearch failed ($RC)!"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127 echo "Testing no limits requested for soft limited ID..."
128 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
129 -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
130 '(objectClass=*)' > $SEARCHOUT 2>&1
132 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
135 echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
138 echo "...bumped into server-side size limit ($COUNT)"
141 echo "ldapsearch failed ($RC)!"
142 test $KILLSERVERS != no && kill -HUP $KILLPIDS
148 echo "Testing lower than soft limit request ($SIZELIMIT) for soft limited ID..."
149 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
150 -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
151 '(objectClass=*)' > $SEARCHOUT 2>&1
153 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
156 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
159 if test "x$COUNT" != "x" ; then
160 if test $SIZELIMIT = $COUNT ; then
161 echo "...bumped into requested ($SIZELIMIT) size limit"
163 echo "...bumped into server-side size limit ($COUNT)"
166 echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
170 echo "ldapsearch failed ($RC)!"
171 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177 echo "Testing higher than soft limit request ($SIZELIMIT) for soft limited ID..."
178 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
179 -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
180 '(objectClass=*)' > $SEARCHOUT 2>&1
182 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
185 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
188 if test "x$COUNT" != "x" ; then
189 if test $SIZELIMIT = $COUNT ; then
190 echo "...bumped into requested ($SIZELIMIT) size limit"
192 echo "...bumped into server-side size limit ($COUNT)"
195 echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
199 echo "ldapsearch failed ($RC)!"
200 test $KILLSERVERS != no && kill -HUP $KILLPIDS
206 echo "Testing lower than hard limit request ($SIZELIMIT) for hard limited ID..."
207 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
208 -D 'cn=Hard Limited User,ou=People,o=University of Michigan,c=US' \
209 '(objectClass=*)' > $SEARCHOUT 2>&1
211 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
214 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
217 echo "...bumped into requested ($SIZELIMIT) size limit"
220 echo "ldapsearch failed ($RC)!"
221 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227 echo "Testing higher than hard limit request ($SIZELIMIT) for hard limited ID..."
228 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
229 -D 'cn=Hard Limited User,ou=People,o=University of Michigan,c=US' \
230 '(objectClass=*)' > $SEARCHOUT 2>&1
232 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
235 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
238 echo "...bumped into requested ($SIZELIMIT) size limit"
241 echo "...bumped into server-side size limit"
244 echo "ldapsearch failed ($RC)!"
245 test $KILLSERVERS != no && kill -HUP $KILLPIDS
250 echo "Testing lower than unchecked limit request for unchecked limited ID..."
251 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
252 -D 'cn=Unchecked Limited User,ou=People,o=University of Michigan,c=US' \
253 '(uid=uncheckedlimited)' > $SEARCHOUT 2>&1
255 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
258 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
261 echo "...bumped into server-side unchecked limit"
264 echo "ldapsearch failed ($RC)!"
265 test $KILLSERVERS != no && kill -HUP $KILLPIDS
270 echo "Testing higher than unchecked limit requested for unchecked limited ID..."
271 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
272 -D 'cn=Unchecked Limited User,ou=People,o=University of Michigan,c=US' \
273 '(objectClass=*)' > $SEARCHOUT 2>&1
275 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
278 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
281 echo "...bumped into server-side unchecked limit"
284 echo "ldapsearch failed ($RC)!"
285 test $KILLSERVERS != no && kill -HUP $KILLPIDS
290 echo "Testing higher than unchecked limit requested for unchecked limited group..."
291 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
292 -D 'cn=Unchecked Limited User 2,ou=People,o=University of Michigan,c=US' \
293 '(objectClass=*)' > $SEARCHOUT 2>&1
295 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
298 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
301 echo "...bumped into server-side unchecked limit"
304 echo "ldapsearch failed ($RC)!"
305 test $KILLSERVERS != no && kill -HUP $KILLPIDS
310 echo "Testing higher than unchecked limit requested for unchecked limited regex..."
311 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
312 -D 'cn=Foo User,ou=People,o=University of Michigan,c=US' \
313 '(objectClass=*)' > $SEARCHOUT 2>&1
315 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
318 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
321 echo "...bumped into server-side unchecked limit"
324 echo "ldapsearch failed ($RC)!"
325 test $KILLSERVERS != no && kill -HUP $KILLPIDS
330 echo "Testing higher than unchecked limit requested for unchecked limited onelevel..."
331 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
332 -D 'cn=Bar User,ou=People,o=University of Michigan,c=US' \
333 '(objectClass=*)' > $SEARCHOUT 2>&1
335 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
338 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
341 echo "...bumped into server-side unchecked limit"
344 echo "ldapsearch failed ($RC)!"
345 test $KILLSERVERS != no && kill -HUP $KILLPIDS
350 echo "Testing higher than unchecked limit requested for unchecked limited children..."
351 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
352 -D 'cn=Unchecked Limited Users,ou=Groups,o=University of Michigan,c=US' \
353 '(objectClass=*)' > $SEARCHOUT 2>&1
355 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
358 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
361 echo "...bumped into server-side unchecked limit"
364 echo "ldapsearch failed ($RC)!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
370 echo "Testing higher than unchecked limit requested for unchecked limited subtree..."
371 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
372 -D 'cn=Unchecked Limited User 3,ou=Admin,o=University of Michigan,c=US' \
373 '(objectClass=*)' > $SEARCHOUT 2>&1
375 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
378 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
381 echo "...bumped into server-side unchecked limit"
384 echo "ldapsearch failed ($RC)!"
385 test $KILLSERVERS != no && kill -HUP $KILLPIDS
390 echo "Testing higher than unchecked limit requested for unchecked limited users..."
391 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
392 -D 'cn=Special User,o=University of Michigan,c=US' \
393 '(objectClass=*)' > $SEARCHOUT 2>&1
395 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
398 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
401 echo "...bumped into server-side unchecked limit"
404 echo "ldapsearch failed ($RC)!"
405 test $KILLSERVERS != no && kill -HUP $KILLPIDS
410 echo "Testing higher than unchecked limit requested for unchecked limited anonymous..."
411 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
412 '(objectClass=*)' > $SEARCHOUT 2>&1
414 COUNT=`cat $SEARCHOUT | grep '^# numEntries:' | sed 's;.*\([0-9]\+\)$;\1;'`
417 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
420 echo "...bumped into server-side unchecked limit"
423 echo "ldapsearch failed ($RC)!"
424 test $KILLSERVERS != no && kill -HUP $KILLPIDS
429 test $KILLSERVERS != no && kill -HUP $KILLPIDS
431 echo ">>>>> Test succeeded"