]> git.sur5r.net Git - openldap/blob - tests/scripts/test025-limits
use awk instead of sed
[openldap] / tests / scripts / test025-limits
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2004 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 mkdir -p $TESTDIR $DBDIR1
20
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $LIMITSCONF > $ADDCONF
23 $SLAPADD -f $ADDCONF -l $LDIFLIMITS
24 RC=$?
25 if test $RC != 0 ; then
26         echo "slapadd failed ($RC)!"
27         exit $RC
28 fi
29
30 echo "Running slapindex to index slapd database..."
31 . $CONFFILTER $BACKEND $MONITORDB < $LIMITSCONF > $CONF1
32 $SLAPINDEX -f $CONF1
33 RC=$?
34 if test $RC != 0 ; then
35         echo "warning: slapindex failed ($RC)"
36         echo "  assuming no indexing support"
37 fi
38
39 echo "Starting slapd on TCP/IP port $PORT1..."
40 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 PID=$!
42 if test $WAIT != 0 ; then
43     echo PID $PID
44     read foo
45 fi
46 KILLPIDS="$PID"
47
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
52         RC=$?
53         if test $RC = 0 ; then
54                 break
55         fi
56         echo "Waiting 5 seconds for slapd to start..."
57         sleep 5
58 done
59
60 if test $RC != 0 ; then
61         echo "ldapsearch failed ($RC)!"
62         test $KILLSERVERS != no && kill -HUP $KILLPIDS
63         exit $RC
64 fi
65
66 cat /dev/null > $SEARCHOUT
67
68 echo ""
69 echo "Testing regular search limits"
70 echo ""
71
72 echo "Testing no limits requested for unlimited ID..."
73 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
74         -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
75         '(objectClass=*)' >$SEARCHOUT 2>&1
76 RC=$?
77 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
78 case $RC in
79         0)
80                 echo "...success (got $COUNT entries)"
81         ;;
82         *)
83                 echo "ldapsearch failed ($RC)!"
84                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
85                 exit $RC
86         ;;
87 esac
88
89 SIZELIMIT=2
90 echo "Testing size limit request ($SIZELIMIT) for unlimited ID..."
91 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
92         -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
93         '(objectClass=*)' > $SEARCHOUT 2>&1
94 RC=$?
95 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
96 case $RC in
97         0)
98                 echo "...success (got $COUNT entries)"
99         ;;
100         4)
101                 echo "...bumped into requested size limit ($SIZELIMIT)"
102         ;;
103         *)
104                 echo "ldapsearch failed ($RC)!"
105                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106                 exit $RC
107         ;;
108 esac
109
110 TIMELIMIT=10
111 echo "Testing time limit request ($TIMELIMIT s) for unlimited ID..."
112 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -l $TIMELIMIT \
113         -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
114         '(objectClass=*)' > $SEARCHOUT 2>&1
115 RC=$?
116 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
117 case $RC in
118         0)
119                 echo "...success (got $COUNT entries)"
120         ;;
121         3)
122                 echo "...bumped into requested time limit ($TIMELIMIT s; $COUNT entries)"
123         ;;
124         *)
125                 echo "ldapsearch failed ($RC)!"
126                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127                 exit $RC
128         ;;
129 esac
130
131 echo "Testing no limits requested for soft limited ID..."
132 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
133         -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
134         '(objectClass=*)' > $SEARCHOUT 2>&1
135 RC=$?
136 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
137 case $RC in
138         0)
139                 echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
140         ;;
141         4)
142                 echo "...bumped into server-side size limit ($COUNT)"
143         ;;
144         *)
145                 echo "ldapsearch failed ($RC)!"
146                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
147                 exit $RC
148         ;;
149 esac
150
151 SIZELIMIT=2
152 echo "Testing lower than soft limit request ($SIZELIMIT) for soft limited ID..."
153 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
154         -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
155         '(objectClass=*)' > $SEARCHOUT 2>&1
156 RC=$?
157 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
158 case $RC in
159         0)
160                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
161         ;;
162         4)
163                 if test "x$COUNT" != "x" ; then
164                         if test "x$SIZELIMIT" = "x$COUNT" ; then
165                                 echo "...bumped into requested ($SIZELIMIT) size limit"
166                         else
167                                 echo "...bumped into server-side size limit ($COUNT)"
168                         fi
169                 else
170                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
171                 fi
172         ;;
173         *)
174                 echo "ldapsearch failed ($RC)!"
175                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
176                 exit $RC
177         ;;
178 esac
179
180 SIZELIMIT=100
181 echo "Testing higher than soft limit request ($SIZELIMIT) for soft limited ID..."
182 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
183         -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
184         '(objectClass=*)' > $SEARCHOUT 2>&1
185 RC=$?
186 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
187 case $RC in
188         0)
189                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
190         ;;
191         4)
192                 if test "x$COUNT" != "x" ; then
193                         if test "x$SIZELIMIT" = "x$COUNT" ; then
194                                 echo "...bumped into requested ($SIZELIMIT) size limit"
195                         else
196                                 echo "...bumped into server-side size limit ($COUNT)"
197                         fi
198                 else
199                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
200                 fi
201         ;;
202         *)
203                 echo "ldapsearch failed ($RC)!"
204                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
205                 exit $RC
206         ;;
207 esac
208
209 SIZELIMIT=2
210 echo "Testing lower than hard limit request ($SIZELIMIT) for hard limited ID..."
211 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
212         -D 'cn=Hard Limited User,ou=People,o=University of Michigan,c=US' \
213         '(objectClass=*)' > $SEARCHOUT 2>&1
214 RC=$?
215 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
216 case $RC in
217         0)
218                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
219         ;;
220         4)
221                 echo "...bumped into requested ($SIZELIMIT) size limit"
222         ;;
223         *)
224                 echo "ldapsearch failed ($RC)!"
225                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
226                 exit $RC
227         ;;
228 esac
229
230 SIZELIMIT=100
231 echo "Testing higher than hard limit request ($SIZELIMIT) for hard limited ID..."
232 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
233         -D 'cn=Hard Limited User,ou=People,o=University of Michigan,c=US' \
234         '(objectClass=*)' > $SEARCHOUT 2>&1
235 RC=$?
236 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
237 case $RC in
238         0)
239                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
240         ;;
241         4)
242                 echo "...bumped into requested ($SIZELIMIT) size limit"
243         ;;
244         11)
245                 echo "...bumped into server-side hard size administrative limit"
246         ;;
247         *)
248                 echo "ldapsearch failed ($RC)!"
249                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
250                 exit $RC
251         ;;
252 esac
253
254 echo "Testing lower than unchecked limit request for unchecked limited ID..."
255 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
256         -D 'cn=Unchecked Limited User,ou=People,o=University of Michigan,c=US' \
257         '(uid=uncheckedlimited)' > $SEARCHOUT 2>&1
258 RC=$?
259 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
260 case $RC in
261         0)
262                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
263         ;;
264         11)
265                 echo "...bumped into unchecked administrative limit"
266         ;;
267         *)
268                 echo "ldapsearch failed ($RC)!"
269                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
270                 exit $RC
271         ;;
272 esac
273
274 echo "Testing higher than unchecked limit requested for unchecked limited ID..."
275 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
276         -D 'cn=Unchecked Limited User,ou=People,o=University of Michigan,c=US' \
277         '(objectClass=*)' > $SEARCHOUT 2>&1
278 RC=$?
279 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
280 case $RC in
281         0)
282                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
283         ;;
284         11)
285                 echo "...bumped into unchecked administrative limit"
286         ;;
287         *)
288                 echo "ldapsearch failed ($RC)!"
289                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
290                 exit $RC
291         ;;
292 esac
293
294 echo "Testing no limits requested for unchecked limited group..."
295 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
296         -D 'cn=Unchecked Limited User 2,ou=People,o=University of Michigan,c=US' \
297         '(objectClass=*)' > $SEARCHOUT 2>&1
298 RC=$?
299 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
300 case $RC in
301         0)
302                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
303         ;;
304         11)
305                 echo "...bumped into unchecked administrative limit"
306         ;;
307         *)
308                 echo "ldapsearch failed ($RC)!"
309                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
310                 exit $RC
311         ;;
312 esac
313
314 echo "Testing no limits requested for limited regex..."
315 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
316         -D 'cn=Foo User,ou=People,o=University of Michigan,c=US' \
317         '(objectClass=*)' > $SEARCHOUT 2>&1
318 RC=$?
319 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
320 case $RC in
321         0)
322                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
323         ;;
324         4)
325                 if test "x$COUNT" != "x" ; then
326                         if test "x$SIZELIMIT" = "x$COUNT" ; then
327                                 echo "...bumped into requested ($SIZELIMIT) size limit"
328                         else
329                                 echo "...bumped into server-side size limit ($COUNT)"
330                         fi
331                 else
332                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
333                 fi
334         ;;
335         *)
336                 echo "ldapsearch failed ($RC)!"
337                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
338                 exit $RC
339         ;;
340 esac
341
342 echo "Testing no limits requested for limited onelevel..."
343 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
344         -D 'cn=Bar User,ou=People,o=University of Michigan,c=US' \
345         '(objectClass=*)' > $SEARCHOUT 2>&1
346 RC=$?
347 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
348 case $RC in
349         0)
350                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
351         ;;
352         4)
353                 if test "x$COUNT" != "x" ; then
354                         if test "x$SIZELIMIT" = "x$COUNT" ; then
355                                 echo "...bumped into requested ($SIZELIMIT) size limit"
356                         else
357                                 echo "...bumped into server-side size limit ($COUNT)"
358                         fi
359                 else
360                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
361                 fi
362         ;;
363         *)
364                 echo "ldapsearch failed ($RC)!"
365                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
366                 exit $RC
367         ;;
368 esac
369
370 echo "Testing no limit requested for limited children..."
371 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
372         -D 'cn=Unchecked Limited Users,ou=Groups,o=University of Michigan,c=US' \
373         '(objectClass=*)' > $SEARCHOUT 2>&1
374 RC=$?
375 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
376 case $RC in
377         0)
378                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
379         ;;
380         4)
381                 if test "x$COUNT" != "x" ; then
382                         if test "x$SIZELIMIT" = "x$COUNT" ; then
383                                 echo "...bumped into requested ($SIZELIMIT) size limit"
384                         else
385                                 echo "...bumped into server-side size limit ($COUNT)"
386                         fi
387                 else
388                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
389                 fi
390         ;;
391         *)
392                 echo "ldapsearch failed ($RC)!"
393                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
394                 exit $RC
395         ;;
396 esac
397
398 echo "Testing no limit requested for limited subtree..."
399 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
400         -D 'cn=Unchecked Limited User 3,ou=Admin,o=University of Michigan,c=US' \
401         '(objectClass=*)' > $SEARCHOUT 2>&1
402 RC=$?
403 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
404 case $RC in
405         0)
406                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
407         ;;
408         4)
409                 if test "x$COUNT" != "x" ; then
410                         if test "x$SIZELIMIT" = "x$COUNT" ; then
411                                 echo "...bumped into requested ($SIZELIMIT) size limit"
412                         else
413                                 echo "...bumped into server-side size limit ($COUNT)"
414                         fi
415                 else
416                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
417                 fi
418         ;;
419         *)
420                 echo "ldapsearch failed ($RC)!"
421                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
422                 exit $RC
423         ;;
424 esac
425
426 echo "Testing no limit requested for limited users..."
427 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
428         -D 'cn=Special User,o=University of Michigan,c=US' \
429         '(objectClass=*)' > $SEARCHOUT 2>&1
430 RC=$?
431 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
432 case $RC in
433         0)
434                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
435         ;;
436         4)
437                 if test "x$COUNT" != "x" ; then
438                         if test "x$SIZELIMIT" = "x$COUNT" ; then
439                                 echo "...bumped into requested ($SIZELIMIT) size limit"
440                         else
441                                 echo "...bumped into server-side size limit ($COUNT)"
442                         fi
443                 else
444                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
445                 fi
446         ;;
447         *)
448                 echo "ldapsearch failed ($RC)!"
449                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
450                 exit $RC
451         ;;
452 esac
453
454 echo "Testing no limit requested for limited anonymous..."
455 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
456         '(objectClass=*)' > $SEARCHOUT 2>&1
457 RC=$?
458 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
459 case $RC in
460         0)
461                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
462         ;;
463         4)
464                 if test "x$COUNT" != "x" ; then
465                         if test "x$SIZELIMIT" = "x$COUNT" ; then
466                                 echo "...bumped into requested ($SIZELIMIT) size limit"
467                         else
468                                 echo "...bumped into server-side size limit ($COUNT)"
469                         fi
470                 else
471                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
472                 fi
473         ;;
474         *)
475                 echo "ldapsearch failed ($RC)!"
476                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
477                 exit $RC
478         ;;
479 esac
480
481 case $BACKEND in
482         bdb | hdb)
483                 # only bdb|hdb currently supports pagedResults control
484                 ;;
485         *)
486                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
487
488                 echo ">>>>> Test succeeded"
489                 exit 0
490         ;;
491 esac
492
493 echo ""
494 echo "Testing regular search limits with pagedResults control"
495 echo ""
496
497 PAGESIZE=5
498 echo "Testing no limits requested for unlimited ID..."
499 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
500         -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
501         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null >$SEARCHOUT 2>&1
502 RC=$?
503 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
504 case $RC in
505         0)
506                 echo "...success (got $COUNT entries)"
507         ;;
508         *)
509                 echo "ldapsearch failed ($RC)!"
510                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
511                 exit $RC
512         ;;
513 esac
514
515 SIZELIMIT=2
516 echo "Testing size limit request ($SIZELIMIT) for unlimited ID..."
517 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
518         -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
519         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
520 RC=$?
521 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
522 case $RC in
523         0)
524                 echo "...success (got $COUNT entries)"
525         ;;
526         4)
527                 echo "...bumped into requested size limit ($SIZELIMIT)"
528         ;;
529         *)
530                 echo "ldapsearch failed ($RC)!"
531                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
532                 exit $RC
533         ;;
534 esac
535
536 TIMELIMIT=10
537 echo "Testing time limit request ($TIMELIMIT s) for unlimited ID..."
538 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -l $TIMELIMIT \
539         -D 'cn=Unlimited User,ou=People,o=University of Michigan,c=US' \
540         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
541 RC=$?
542 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
543 case $RC in
544         0)
545                 echo "...success (got $COUNT entries)"
546         ;;
547         3)
548                 echo "...bumped into requested time limit ($TIMELIMIT s; $COUNT entries)"
549         ;;
550         *)
551                 echo "ldapsearch failed ($RC)!"
552                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
553                 exit $RC
554         ;;
555 esac
556
557 echo "Testing no limits requested for soft limited ID..."
558 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
559         -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
560         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
561 RC=$?
562 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
563 case $RC in
564         0)
565                 echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
566         ;;
567         4)
568                 echo "...bumped into server-side size limit ($COUNT)"
569         ;;
570         *)
571                 echo "ldapsearch failed ($RC)!"
572                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
573                 exit $RC
574         ;;
575 esac
576
577 SIZELIMIT=2
578 echo "Testing lower than soft limit request ($SIZELIMIT) for soft limited ID..."
579 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
580         -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
581         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
582 RC=$?
583 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
584 case $RC in
585         0)
586                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
587         ;;
588         4)
589                 if test "x$COUNT" != "x" ; then
590                         if test "x$SIZELIMIT" = "x$COUNT" ; then
591                                 echo "...bumped into requested ($SIZELIMIT) size limit"
592                         else
593                                 echo "...bumped into server-side size limit ($COUNT)"
594                         fi
595                 else
596                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
597                 fi
598         ;;
599         *)
600                 echo "ldapsearch failed ($RC)!"
601                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
602                 exit $RC
603         ;;
604 esac
605
606 SIZELIMIT=100
607 echo "Testing higher than soft limit request ($SIZELIMIT) for soft limited ID..."
608 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
609         -D 'cn=Soft Limited User,ou=People,o=University of Michigan,c=US' \
610         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
611 RC=$?
612 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
613 case $RC in
614         0)
615                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
616         ;;
617         4)
618                 if test "x$COUNT" != "x" ; then
619                         if test "x$SIZELIMIT" = "x$COUNT" ; then
620                                 echo "...bumped into requested ($SIZELIMIT) size limit"
621                         else
622                                 echo "...bumped into server-side size limit ($COUNT)"
623                         fi
624                 else
625                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
626                 fi
627         ;;
628         *)
629                 echo "ldapsearch failed ($RC)!"
630                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
631                 exit $RC
632         ;;
633 esac
634
635 SIZELIMIT=2
636 echo "Testing lower than hard limit request ($SIZELIMIT) for hard limited ID..."
637 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
638         -D 'cn=Hard Limited User,ou=People,o=University of Michigan,c=US' \
639         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
640 RC=$?
641 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
642 case $RC in
643         0)
644                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
645         ;;
646         4)
647                 echo "...bumped into requested ($SIZELIMIT) size limit"
648         ;;
649         *)
650                 echo "ldapsearch failed ($RC)!"
651                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
652                 exit $RC
653         ;;
654 esac
655
656 SIZELIMIT=100
657 echo "Testing higher than hard limit request ($SIZELIMIT) for hard limited ID..."
658 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
659         -D 'cn=Hard Limited User,ou=People,o=University of Michigan,c=US' \
660         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
661 RC=$?
662 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
663 case $RC in
664         0)
665                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
666         ;;
667         4)
668                 echo "...bumped into requested ($SIZELIMIT) size limit"
669         ;;
670         11)
671                 echo "...bumped into hard size administrative limit"
672         ;;
673         *)
674                 echo "ldapsearch failed ($RC)!"
675                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
676                 exit $RC
677         ;;
678 esac
679
680 echo "Testing lower than unchecked limit request for unchecked limited ID..."
681 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
682         -D 'cn=Unchecked Limited User,ou=People,o=University of Michigan,c=US' \
683         -E '!pr='$PAGESIZE '(uid=uncheckedlimited)' </dev/null > $SEARCHOUT 2>&1
684 RC=$?
685 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
686 case $RC in
687         0)
688                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
689         ;;
690         11)
691                 echo "...bumped into unchecked administrative limit"
692         ;;
693         *)
694                 echo "ldapsearch failed ($RC)!"
695                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
696                 exit $RC
697         ;;
698 esac
699
700 echo "Testing higher than unchecked limit requested for unchecked limited ID..."
701 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
702         -D 'cn=Unchecked Limited User,ou=People,o=University of Michigan,c=US' \
703         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
704 RC=$?
705 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
706 case $RC in
707         0)
708                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
709         ;;
710         11)
711                 echo "...bumped into unchecked administrative limit"
712         ;;
713         *)
714                 echo "ldapsearch failed ($RC)!"
715                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
716                 exit $RC
717         ;;
718 esac
719
720 echo ""
721 echo "Testing specific search limits with pagedResults control"
722 echo ""
723
724 echo "Testing no limit requested for unlimited page size ID..."
725 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
726         -D 'cn=Unlimited User,ou=Paged Results Users,o=University of Michigan,c=US' \
727         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
728 RC=$?
729 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
730 case $RC in
731         0)
732                 echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
733         ;;
734         4)
735                 echo "...bumped into server-side size limit ($COUNT)"
736         ;;
737         *)
738                 echo "ldapsearch failed ($RC)!"
739                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
740                 exit $RC
741         ;;
742 esac
743
744 echo "Testing no limit requested for limited page size ID..."
745 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
746         -D 'cn=Page Size Limited User,ou=Paged Results Users,o=University of Michigan,c=US' \
747         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
748 RC=$?
749 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
750 case $RC in
751         0)
752                 echo "...success; didn't bump into server-side page size limit (got $COUNT entries)"
753         ;;
754         4)
755                 echo "...bumped into page size limit ($COUNT)"
756         ;;
757         11)
758                 echo "...bumped into page size administrative limit"
759         ;;
760         *)
761                 echo "ldapsearch failed ($RC)!"
762                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
763                 exit $RC
764         ;;
765 esac
766
767 echo "Testing no limit requested for pagedResults disabled ID..."
768 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
769         -D 'cn=Paged Results Disabled User,ou=Paged Results Users,o=University of Michigan,c=US' \
770         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
771 RC=$?
772 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
773 case $RC in
774         0)
775                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
776         ;;
777         4)
778                 echo "...bumped into server-side size limit ($COUNT)"
779         ;;
780         11)
781                 echo "...bumped into pagedResults disabled administrative limit"
782         ;;
783         *)
784                 echo "ldapsearch failed ($RC)!"
785                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
786                 exit $RC
787         ;;
788 esac
789
790 echo "Testing no limit requested for pagedResults total count limited ID..."
791 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
792         -D 'cn=Paged Results Limited User,ou=Paged Results Users,o=University of Michigan,c=US' \
793         -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
794 RC=$?
795 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
796 case $RC in
797         0)
798                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
799         ;;
800         4)
801                 echo "...bumped into server-side size limit ($COUNT)"
802         ;;
803         11)
804                 echo "...bumped into pagedResults total count administrative limit"
805         ;;
806         *)
807                 echo "ldapsearch failed ($RC)!"
808                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
809                 exit $RC
810         ;;
811 esac
812
813 SIZELIMIT=8
814 echo "Testing higher than hard but lower then total count limit requested for pagedResults total count limited ID..."
815 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
816         -D 'cn=Paged Results Limited User,ou=Paged Results Users,o=University of Michigan,c=US' \
817         -z $SIZELIMIT -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
818 RC=$?
819 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
820 case $RC in
821         0)
822                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
823         ;;
824         4)
825                 if test "x$COUNT" != "x" ; then
826                         if test "x$SIZELIMIT" = "x$COUNT" ; then
827                                 echo "...bumped into requested ($SIZELIMIT) size limit"
828                         else
829                                 echo "...bumped into server-side size limit ($COUNT)"
830                         fi
831                 else
832                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
833                 fi
834         ;;
835         11)
836                 echo "...bumped into either hard size or pagedResults total count administrative limit"
837         ;;
838         *)
839                 echo "ldapsearch failed ($RC)!"
840                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
841                 exit $RC
842         ;;
843 esac
844
845 SIZELIMIT=15
846 echo "Testing higher than total count limit requested for pagedResults total count limited ID..."
847 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
848         -D 'cn=Paged Results Limited User,ou=Paged Results Users,o=University of Michigan,c=US' \
849         -z $SIZELIMIT -E '!pr='$PAGESIZE '(objectClass=*)' </dev/null > $SEARCHOUT 2>&1
850 RC=$?
851 COUNT=`cat $SEARCHOUT | egrep '^# numEntries:' | awk '{print $3}'`
852 case $RC in
853         0)
854                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
855         ;;
856         4)
857                 if test "x$COUNT" != "x" ; then
858                         if test "x$SIZELIMIT" = "x$COUNT" ; then
859                                 echo "...bumped into requested ($SIZELIMIT) size limit"
860                         else
861                                 echo "...bumped into server-side size limit ($COUNT)"
862                         fi
863                 else
864                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
865                 fi
866         ;;
867         11)
868                 echo "...bumped into pagedResults total count administrative limit"
869         ;;
870         *)
871                 echo "ldapsearch failed ($RC)!"
872                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
873                 exit $RC
874         ;;
875 esac
876
877 test $KILLSERVERS != no && kill -HUP $KILLPIDS
878
879 echo ">>>>> Test succeeded"
880 exit 0