]> git.sur5r.net Git - openldap/blob - tests/scripts/test025-limits
Regenerated with new OL_ARG_ENABLE
[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-2005 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 ## FIXME: need to exclude legal but wrong results...
17
18 echo "running defines.sh"
19 . $SRCDIR/scripts/defines.sh
20
21 mkdir -p $TESTDIR $DBDIR1
22
23 echo "Running slapadd to build slapd database..."
24 . $CONFFILTER $BACKEND $MONITORDB < $LIMITSCONF > $ADDCONF
25 $SLAPADD -f $ADDCONF -l $LDIFLIMITS
26 RC=$?
27 if test $RC != 0 ; then
28         echo "slapadd failed ($RC)!"
29         exit $RC
30 fi
31
32 echo "Running slapindex to index slapd database..."
33 . $CONFFILTER $BACKEND $MONITORDB < $LIMITSCONF > $CONF1
34 $SLAPINDEX -f $CONF1
35 RC=$?
36 if test $RC != 0 ; then
37         echo "warning: slapindex failed ($RC)"
38         echo "  assuming no indexing support"
39 fi
40
41 echo "Starting slapd on TCP/IP port $PORT1..."
42 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
43 PID=$!
44 if test $WAIT != 0 ; then
45     echo PID $PID
46     read foo
47 fi
48 KILLPIDS="$PID"
49
50 echo "Testing slapd searching..."
51 for i in 0 1 2 3 4 5; do
52         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
53                 '(objectclass=*)' > /dev/null 2>&1
54         RC=$?
55         if test $RC = 0 ; then
56                 break
57         fi
58         echo "Waiting 5 seconds for slapd to start..."
59         sleep 5
60 done
61
62 if test $RC != 0 ; then
63         echo "ldapsearch failed ($RC)!"
64         test $KILLSERVERS != no && kill -HUP $KILLPIDS
65         exit $RC
66 fi
67
68 cat /dev/null > $SEARCHOUT
69
70 echo ""
71 echo "Testing regular search limits"
72 echo ""
73
74 echo "Testing no limits requested for unlimited ID..."
75 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
76         -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
77         '(objectClass=*)' >$SEARCHOUT 2>&1
78 RC=$?
79 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
80 case $RC in
81         0)
82                 if test x"$COUNT" != x ; then
83                         echo "...success (got $COUNT entries)"
84                 else
85                         echo "...error: did not expect ldapsearch success ($RC)!"
86                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
87                         exit $RC
88                 fi
89         ;;
90         *)
91                 echo "ldapsearch failed ($RC)!"
92                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
93                 exit $RC
94         ;;
95 esac
96
97 echo "Testing no limits requested for rootdn=$MANAGERDN..."
98 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
99         -D "$MANAGERDN" \
100         '(objectClass=*)' >$SEARCHOUT 2>&1
101 RC=$?
102 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
103 case $RC in
104         0)
105                 if test x"$COUNT" != x ; then
106                         echo "...success (got $COUNT entries)"
107                 else
108                         echo "...error: did not expect ldapsearch success ($RC)!"
109                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
110                         exit $RC
111                 fi
112         ;;
113         *)
114                 echo "ldapsearch failed ($RC)!"
115                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116                 exit $RC
117         ;;
118 esac
119
120 SIZELIMIT=4
121 echo "Testing limit requested for rootdn=$MANAGERDN..."
122 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
123         -D "$MANAGERDN" \
124         '(objectClass=*)' >$SEARCHOUT 2>&1
125 RC=$?
126 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
127 case $RC in
128         0)
129                 if test x"$COUNT" != x ; then
130                         if test "$COUNT" -gt "$SIZELIMIT" ; then
131                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
132                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
133                                 exit $RC
134                         fi
135                         echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
136                 else
137                         echo "...error: did not expect ldapsearch success ($RC)!"
138                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
139                         exit $RC
140                 fi
141         ;;
142         4)
143                 if test x"$COUNT" != x ; then
144                         if test "$COUNT" = "$SIZELIMIT" ; then
145                                 echo "...bumped into requested size limit ($SIZELIMIT)"
146                         else
147                                 echo "...error: got $COUNT entries with a requested sizelimit of $SIZELIMIT"
148                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149                                 exit $RC
150                         fi
151                 else
152                         echo "...error: bumped into server-side size limit, but got no entries!"
153                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
154                         exit $RC
155                 fi
156         ;;
157         *)
158                 echo "ldapsearch failed ($RC)!"
159                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160                 exit $RC
161         ;;
162 esac
163
164 SIZELIMIT=2
165 echo "Testing size limit request ($SIZELIMIT) for unlimited ID..."
166 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
167         -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
168         '(objectClass=*)' > $SEARCHOUT 2>&1
169 RC=$?
170 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
171 case $RC in
172         0)
173                 if test x"$COUNT" != x ; then
174                         if test "$COUNT" -gt "$SIZELIMIT" ; then
175                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
176                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177                                 exit $RC
178                         fi
179                         echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
180                 else
181                         echo "...error: did not expect ldapsearch success ($RC)!"
182                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
183                         exit $RC
184                 fi
185         ;;
186         4)
187                 if test x"$COUNT" != x ; then
188                         if test "$COUNT" = "$SIZELIMIT" ; then
189                                 echo "...bumped into requested size limit ($SIZELIMIT)"
190                         else
191                                 echo "...error: got $COUNT entries with a requested sizelimit of $SIZELIMIT"
192                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193                                 exit $RC
194                         fi
195                 else
196                         echo "...error: bumped into server-side size limit, but got no entries!"
197                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
198                         exit $RC
199                 fi
200         ;;
201         *)
202                 echo "ldapsearch failed ($RC)!"
203                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
204                 exit $RC
205         ;;
206 esac
207
208 TIMELIMIT=10
209 echo "Testing time limit request ($TIMELIMIT s) for unlimited ID..."
210 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -l $TIMELIMIT \
211         -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
212         '(objectClass=*)' > $SEARCHOUT 2>&1
213 RC=$?
214 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
215 case $RC in
216         0)
217                 if test x"$COUNT" != x ; then
218                         echo "...didn't bump into the requested time limit ($TIMELIMIT s; got $COUNT entries)"
219                 else
220                         echo "...error: did not expect ldapsearch success ($RC)!"
221                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
222                         exit $RC
223                 fi
224         ;;
225         3)
226                 if test x"$COUNT" != x ; then
227                         COUNT=0
228                 fi
229                 echo "...bumped into requested time limit ($TIMELIMIT s; got $COUNT entries)"
230         ;;
231         *)
232                 echo "ldapsearch failed ($RC)!"
233                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
234                 exit $RC
235         ;;
236 esac
237
238 echo "Testing no limits requested for soft limited ID..."
239 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
240         -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
241         '(objectClass=*)' > $SEARCHOUT 2>&1
242 RC=$?
243 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
244 case $RC in
245         0)
246                 if test x"$COUNT" != x ; then
247                         echo "...didn't bump into server-side size limit (got $COUNT entries)"
248                 else
249                         echo "...error: did not expect ldapsearch success ($RC)!"
250                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
251                         exit $RC
252                 fi
253         ;;
254         4)
255                 if test x"$COUNT" != x ; then
256                         echo "...bumped into server-side size limit (got $COUNT entries)"
257                 else
258                         echo "...error: bumped into server-side size limit, but got no entries!"
259                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
260                         exit $RC
261                 fi
262         ;;
263         *)
264                 echo "ldapsearch failed ($RC)!"
265                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
266                 exit $RC
267         ;;
268 esac
269
270 SIZELIMIT=2
271 echo "Testing lower than soft limit request ($SIZELIMIT) for soft limited ID..."
272 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
273         -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
274         '(objectClass=*)' > $SEARCHOUT 2>&1
275 RC=$?
276 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
277 case $RC in
278         0)
279                 if test x"$COUNT" != x ; then
280                         if test "$COUNT" -gt "$SIZELIMIT" ; then
281                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
282                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
283                                 exit $RC
284                         fi
285                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
286                 else
287                         echo "...error: did not expect ldapsearch success ($RC)!"
288                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
289                         exit $RC
290                 fi
291         ;;
292         4)
293                 if test "x$COUNT" != "x" ; then
294                         if test "x$SIZELIMIT" = "x$COUNT" ; then
295                                 echo "...bumped into requested ($SIZELIMIT) size limit"
296                         else
297                                 echo "...bumped into server-side size limit ($COUNT)"
298                         fi
299                 else
300                         echo "...error: bumped into server-side size limit, but got no entries!"
301                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
302                         exit $RC
303                 fi
304         ;;
305         *)
306                 echo "ldapsearch failed ($RC)!"
307                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
308                 exit $RC
309         ;;
310 esac
311
312 SIZELIMIT=100
313 echo "Testing higher than soft limit request ($SIZELIMIT) for soft limited ID..."
314 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
315         -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
316         '(objectClass=*)' > $SEARCHOUT 2>&1
317 RC=$?
318 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
319 case $RC in
320         0)
321                 if test x"$COUNT" != x ; then
322                         if test "$COUNT" -gt "$SIZELIMIT" ; then
323                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
324                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
325                                 exit $RC
326                         fi
327                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
328                 else
329                         echo "...error: did not expect ldapsearch success ($RC)!"
330                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
331                         exit $RC
332                 fi
333         ;;
334         4)
335                 if test "x$COUNT" != "x" ; then
336                         if test "x$SIZELIMIT" = "x$COUNT" ; then
337                                 echo "...bumped into requested ($SIZELIMIT) size limit"
338                         else
339                                 echo "...bumped into server-side size limit ($COUNT)"
340                         fi
341                 else
342                         echo "...error: bumped into server-side size limit, but got no entries!"
343                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
344                         exit $RC
345                 fi
346         ;;
347         *)
348                 echo "ldapsearch failed ($RC)!"
349                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
350                 exit $RC
351         ;;
352 esac
353
354 SIZELIMIT=2
355 echo "Testing lower than hard limit request ($SIZELIMIT) for hard limited ID..."
356 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
357         -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
358         '(objectClass=*)' > $SEARCHOUT 2>&1
359 RC=$?
360 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
361 case $RC in
362         0)
363                 if test x"$COUNT" != x ; then
364                         if test "$COUNT" -gt "$SIZELIMIT" ; then
365                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
366                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
367                                 exit $RC
368                         fi
369                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
370                 else
371                         echo "...error: did not expect ldapsearch success ($RC)!"
372                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
373                         exit $RC
374                 fi
375         ;;
376         4)
377                 echo "...bumped into requested ($SIZELIMIT) size limit"
378         ;;
379         *)
380                 echo "ldapsearch failed ($RC)!"
381                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
382                 exit $RC
383         ;;
384 esac
385
386 SIZELIMIT=100
387 echo "Testing higher than hard limit request ($SIZELIMIT) for hard limited ID..."
388 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
389         -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
390         '(objectClass=*)' > $SEARCHOUT 2>&1
391 RC=$?
392 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
393 case $RC in
394         0)
395                 if test x"$COUNT" != x ; then
396                         if test "$COUNT" -gt "$SIZELIMIT" ; then
397                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
398                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
399                                 exit $RC
400                         fi
401                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
402                 else
403                         echo "...error: did not expect ldapsearch success ($RC)!"
404                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
405                         exit $RC
406                 fi
407         ;;
408         4)
409                 if test x"$COUNT" != x ; then
410                         if test "$COUNT" = "$SIZELIMIT" ; then
411                                 echo "...error: bumped into requested ($SIZELIMIT) size limit"
412                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
413                                 exit $RC
414                         else
415                                 echo "...got size limit $COUNT instead of requested $SIZELIMIT entries"
416                         fi
417                 else
418                         echo "...error: bumped into server-side size limit, but got no entries!"
419                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
420                         exit $RC
421                 fi
422         ;;
423 #       11)
424 #               echo "...bumped into server-side hard size administrative limit"
425 #       ;;
426         *)
427                 echo "ldapsearch failed ($RC)!"
428                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
429                 exit $RC
430         ;;
431 esac
432
433 SIZELIMIT=max
434 echo "Testing max limit request ($SIZELIMIT) for hard limited ID..."
435 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
436         -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
437         '(objectClass=*)' > $SEARCHOUT 2>&1
438 RC=$?
439 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
440 case $RC in
441         0)
442                 if test x"$COUNT" != x ; then
443                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
444                 else
445                         echo "...error: did not expect ldapsearch success ($RC)!"
446                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
447                         exit $RC
448                 fi
449         ;;
450         4)
451                 if test x"$COUNT" != x ; then
452                         echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit"
453                 else
454                         echo "...error: bumped into server-side size limit, but got no entries!"
455                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
456                         exit $RC
457                 fi
458         ;;
459 #       11)
460 #               echo "...bumped into server-side hard size administrative limit"
461 #       ;;
462         *)
463                 echo "ldapsearch failed ($RC)!"
464                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
465                 exit $RC
466         ;;
467 esac
468
469 echo "Testing lower than unchecked limit request for unchecked limited ID..."
470 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
471         -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \
472         '(uid=uncheckedlimited)' > $SEARCHOUT 2>&1
473 RC=$?
474 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
475 case $RC in
476         0)
477                 if test x"$COUNT" != x ; then
478                         echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
479                 else
480                         echo "...error: did not expect ldapsearch success ($RC)!"
481                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
482                         exit $RC
483                 fi
484         ;;
485         11)
486                 echo "...error: bumped into unchecked administrative limit"
487                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
488                 exit $RC
489         ;;
490         *)
491                 echo "ldapsearch failed ($RC)!"
492                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
493                 exit $RC
494         ;;
495 esac
496
497 echo "Testing higher than unchecked limit requested for unchecked limited ID..."
498 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
499         -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \
500         '(objectClass=*)' > $SEARCHOUT 2>&1
501 RC=$?
502 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
503 case $RC in
504         0)
505                 if test x"$COUNT" != x ; then
506                         echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
507                 else
508                         echo "...error: did not expect ldapsearch success ($RC)!"
509                 fi
510                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
511                 exit $RC
512         ;;
513         11)
514                 echo "...bumped into unchecked administrative limit"
515         ;;
516         *)
517                 echo "ldapsearch failed ($RC)!"
518                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
519                 exit $RC
520         ;;
521 esac
522
523 echo "Testing no limits requested for unchecked limited group..."
524 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
525         -D 'cn=Unchecked Limited User 2,ou=People,dc=example,dc=com' \
526         '(objectClass=*)' > $SEARCHOUT 2>&1
527 RC=$?
528 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
529 case $RC in
530         0)
531                 if test x"$COUNT" != x ; then
532                         echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
533                 else
534                         echo "...error: did not expect ldapsearch success ($RC)!"
535                 fi
536                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
537                 exit $RC
538         ;;
539         11)
540                 echo "...bumped into unchecked administrative limit"
541         ;;
542         *)
543                 echo "ldapsearch failed ($RC)!"
544                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
545                 exit $RC
546         ;;
547 esac
548
549 echo "Testing no limits requested for limited regex..."
550 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
551         -D 'cn=Foo User,ou=People,dc=example,dc=com' \
552         '(objectClass=*)' > $SEARCHOUT 2>&1
553 RC=$?
554 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
555 case $RC in
556         0)
557                 if test x"$COUNT" != x ; then
558                         echo "...didn't bump into server-side size limit (got $COUNT entries)"
559                 else
560                         echo "...error: did not expect ldapsearch success ($RC)!"
561                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
562                         exit $RC
563                 fi
564         ;;
565         4)
566                 if test "x$COUNT" != "x" ; then
567                         echo "...bumped into server-side size limit ($COUNT)"
568                 else
569                         echo "...error: bumped into server-side size limit, but got no entries!"
570                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
571                         exit $RC
572                 fi
573         ;;
574         *)
575                 echo "ldapsearch failed ($RC)!"
576                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
577                 exit $RC
578         ;;
579 esac
580
581 echo "Testing no limits requested for limited onelevel..."
582 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
583         -D 'cn=Bar User,ou=People,dc=example,dc=com' \
584         '(objectClass=*)' > $SEARCHOUT 2>&1
585 RC=$?
586 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
587 case $RC in
588         0)
589                 if test x"$COUNT" != x ; then
590                         echo "...didn't bump into server-side size limit (got $COUNT entries)"
591                 else
592                         echo "...error: did not expect ldapsearch success ($RC)!"
593                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
594                         exit $RC
595                 fi
596         ;;
597         4)
598                 if test "x$COUNT" != "x" ; then
599                         echo "...bumped into server-side size limit ($COUNT)"
600                 else
601                         echo "...error: bumped into server-side size limit, but got no entries!"
602                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
603                         exit $RC
604                 fi
605         ;;
606         *)
607                 echo "ldapsearch failed ($RC)!"
608                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
609                 exit $RC
610         ;;
611 esac
612
613 echo "Testing no limit requested for limited children..."
614 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
615         -D 'cn=Unchecked Limited Users,ou=Groups,dc=example,dc=com' \
616         '(objectClass=*)' > $SEARCHOUT 2>&1
617 RC=$?
618 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
619 case $RC in
620         0)
621                 if test x"$COUNT" != x ; then
622                         echo "...didn't bump into server-side size limit (got $COUNT entries)"
623                 else
624                         echo "...error: did not expect ldapsearch success ($RC)!"
625                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
626                         exit $RC
627                 fi
628         ;;
629         4)
630                 if test "x$COUNT" != "x" ; then
631                         echo "...bumped into server-side size limit ($COUNT)"
632                 else
633                         echo "...error: bumped into server-side size limit, but got no entries!"
634                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
635                         exit $RC
636                 fi
637         ;;
638         *)
639                 echo "ldapsearch failed ($RC)!"
640                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
641                 exit $RC
642         ;;
643 esac
644
645 echo "Testing no limit requested for limited subtree..."
646 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
647         -D 'cn=Unchecked Limited User 3,ou=Admin,dc=example,dc=com' \
648         '(objectClass=*)' > $SEARCHOUT 2>&1
649 RC=$?
650 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
651 case $RC in
652         0)
653                 if test x"$COUNT" != x ; then
654                         echo "...didn't bump into server-side size limit (got $COUNT entries)"
655                 else
656                         echo "...error: did not expect ldapsearch success ($RC)!"
657                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
658                         exit $RC
659                 fi
660         ;;
661         4)
662                 if test "x$COUNT" != "x" ; then
663                         echo "...bumped into server-side size limit ($COUNT)"
664                 else
665                         echo "...error: bumped into server-side size limit, but got no entries!"
666                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
667                         exit $RC
668                 fi
669         ;;
670         *)
671                 echo "ldapsearch failed ($RC)!"
672                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
673                 exit $RC
674         ;;
675 esac
676
677 echo "Testing no limit requested for limited users..."
678 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
679         -D 'cn=Special User,dc=example,dc=com' \
680         '(objectClass=*)' > $SEARCHOUT 2>&1
681 RC=$?
682 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
683 case $RC in
684         0)
685                 if test x"$COUNT" != x ; then
686                         echo "...didn't bump into server-side size limit (got $COUNT entries)"
687                 else
688                         echo "...error: did not expect ldapsearch success ($RC)!"
689                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
690                         exit $RC
691                 fi
692         ;;
693         4)
694                 if test "x$COUNT" != "x" ; then
695                         echo "...bumped into server-side size limit ($COUNT)"
696                 else
697                         echo "...error: bumped into server-side size limit, but got no entries!"
698                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
699                         exit $RC
700                 fi
701         ;;
702         *)
703                 echo "ldapsearch failed ($RC)!"
704                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
705                 exit $RC
706         ;;
707 esac
708
709 echo "Testing no limit requested for limited anonymous..."
710 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
711         '(objectClass=*)' > $SEARCHOUT 2>&1
712 RC=$?
713 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
714 case $RC in
715         0)
716                 if test x"$COUNT" != x ; then
717                         echo "...didn't bump into server-side size limit (got $COUNT entries)"
718                 else
719                         echo "...error: did not expect ldapsearch success ($RC)!"
720                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
721                         exit $RC
722                 fi
723         ;;
724         4)
725                 if test "x$COUNT" != "x" ; then
726                         echo "...bumped into server-side size limit ($COUNT)"
727                 else
728                         echo "...error: bumped into server-side size limit, but got no entries!"
729                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
730                         exit $RC
731                 fi
732         ;;
733         *)
734                 echo "ldapsearch failed ($RC)!"
735                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
736                 exit $RC
737         ;;
738 esac
739
740 case $BACKEND in
741         bdb | hdb)
742                 # only bdb|hdb currently supports pagedResults control
743                 ;;
744         *)
745                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
746
747                 echo ">>>>> Test succeeded"
748                 exit 0
749         ;;
750 esac
751
752 if test x"$SLAPD_PAGE_SIZE" != x ; then
753         PAGESIZE="$SLAPD_PAGE_SIZE"
754         if test "$PAGESIZE" -le 0 ; then
755                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
756
757                 echo ""
758                 echo "Testing with pagedResults control disabled"
759                 echo ""
760                 echo ">>>>> Test succeeded"
761                 exit 0
762         fi
763 else
764         PAGESIZE=5
765 fi
766
767 echo ""
768 echo "Testing regular search limits with pagedResults control (page size $PAGESIZE)"
769 echo ""
770
771 echo "Testing no limits requested for unlimited ID..."
772 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
773         -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
774         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' >$SEARCHOUT 2>&1
775 RC=$?
776 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
777 case $RC in
778         0)
779                 if test x"$COUNT" != x ; then
780                         echo "...success (got $COUNT entries)"
781                 else
782                         echo "...error: did not expect ldapsearch success ($RC)!"
783                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
784                         exit $RC
785                 fi
786         ;;
787         *)
788                 echo "ldapsearch failed ($RC)!"
789                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
790                 exit $RC
791         ;;
792 esac
793
794 SIZELIMIT=2
795 echo "Testing size limit request ($SIZELIMIT) for unlimited ID..."
796 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
797         -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
798         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
799 RC=$?
800 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
801 case $RC in
802         0)
803                 if test x"$COUNT" != x ; then
804                         if test "$COUNT" -gt "$SIZELIMIT" ; then
805                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
806                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
807                                 exit $RC
808                         fi
809                         echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)"
810                 else
811                         echo "...error: did not expect ldapsearch success ($RC)!"
812                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
813                         exit $RC
814                 fi
815         ;;
816         4)
817                 if test x"$COUNT" != x ; then
818                         if test $COUNT = $SIZELIMIT ; then
819                                 echo "...bumped into requested size limit ($SIZELIMIT)"
820                         else
821                                 echo "...error: got $COUNT entries while requesting $SIZELIMIT..."
822                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
823                                 exit $RC
824                         fi
825                 else
826                         echo "...error: bumped into server-side size limit, but got no entries!"
827                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
828                         exit $RC
829                 fi
830         ;;
831         *)
832                 echo "ldapsearch failed ($RC)!"
833                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
834                 exit $RC
835         ;;
836 esac
837
838 TIMELIMIT=10
839 echo "Testing time limit request ($TIMELIMIT s) for unlimited ID..."
840 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -l $TIMELIMIT \
841         -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \
842         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
843 RC=$?
844 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
845 case $RC in
846         0)
847                 if test x"$COUNT" != x ; then
848                         echo "...didn't bump into the requested time limit ($TIMELIMIT s; got $COUNT entries)"
849                 else
850                         echo "...error: did not expect ldapsearch success ($RC)!"
851                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
852                         exit $RC
853                 fi
854         ;;
855         3)
856                 if test x"$COUNT" = x ; then
857                         COUNT=0
858                 fi
859                 echo "...bumped into requested time limit ($TIMELIMIT s; got $COUNT entries)"
860         ;;
861         *)
862                 echo "ldapsearch failed ($RC)!"
863                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
864                 exit $RC
865         ;;
866 esac
867
868 echo "Testing no limits requested for soft limited ID..."
869 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
870         -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
871         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
872 RC=$?
873 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
874 case $RC in
875         0)
876                 if test x"$COUNT" != x ; then
877                         echo "...didn't bump into server-side size limit (got $COUNT entries)"
878                 else
879                         echo "...error: did not expect ldapsearch success ($RC)!"
880                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
881                         exit $RC
882                 fi
883         ;;
884         4)
885                 if test x"$COUNT" != x ; then
886                         echo "...bumped into server-side size limit (got $COUNT entries)"
887                 else
888                         echo "...error: bumped into server-side size limit, but got no entries!"
889                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
890                         exit $RC
891                 fi
892         ;;
893         *)
894                 echo "ldapsearch failed ($RC)!"
895                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
896                 exit $RC
897         ;;
898 esac
899
900 SIZELIMIT=2
901 echo "Testing lower than soft limit request ($SIZELIMIT) for soft limited ID..."
902 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
903         -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
904         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
905 RC=$?
906 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
907 case $RC in
908         0)
909                 if test x"$COUNT" != x ; then
910                         if test "$COUNT" -gt "$SIZELIMIT" ; then
911                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
912                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
913                                 exit $RC
914                         fi
915                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
916                 else
917                         echo "...error: did not expect ldapsearch success ($RC)!"
918                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
919                         exit $RC
920                 fi
921         ;;
922         4)
923                 if test "x$COUNT" != "x" ; then
924                         if test "x$SIZELIMIT" = "x$COUNT" ; then
925                                 echo "...bumped into requested ($SIZELIMIT) size limit"
926                         else
927                                 echo "...bumped into server-side size limit ($COUNT)"
928                         fi
929                 else
930                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
931                 fi
932         ;;
933         *)
934                 echo "ldapsearch failed ($RC)!"
935                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
936                 exit $RC
937         ;;
938 esac
939
940 SIZELIMIT=100
941 echo "Testing higher than soft limit request ($SIZELIMIT) for soft limited ID..."
942 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
943         -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \
944         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
945 RC=$?
946 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
947 case $RC in
948         0)
949                 if test x"$COUNT" != x ; then
950                         if test "$COUNT" -gt "$SIZELIMIT" ; then
951                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
952                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
953                                 exit $RC
954                         fi
955                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
956                 else
957                         echo "...error: did not expect ldapsearch success ($RC)!"
958                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
959                         exit $RC
960                 fi
961         ;;
962         4)
963                 if test "x$COUNT" != "x" ; then
964                         if test "x$SIZELIMIT" = "x$COUNT" ; then
965                                 echo "...bumped into requested ($SIZELIMIT) size limit"
966                         else
967                                 echo "...bumped into server-side size limit ($COUNT)"
968                         fi
969                 else
970                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
971                 fi
972         ;;
973         *)
974                 echo "ldapsearch failed ($RC)!"
975                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
976                 exit $RC
977         ;;
978 esac
979
980 SIZELIMIT=2
981 echo "Testing lower than hard limit request ($SIZELIMIT) for hard limited ID..."
982 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
983         -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
984         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
985 RC=$?
986 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
987 case $RC in
988         0)
989                 if test x"$COUNT" != x ; then
990                         if test "$COUNT" -gt "$SIZELIMIT" ; then
991                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
992                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
993                                 exit $RC
994                         fi
995                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
996                 else
997                         echo "...error: did not expect ldapsearch success ($RC)!"
998                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
999                         exit $RC
1000                 fi
1001         ;;
1002         4)
1003                 if test x"$COUNT" != x ; then
1004                         if test "$COUNT" = "$SIZELIMIT" ; then
1005                                 echo "...bumped into requested ($SIZELIMIT) size limit"
1006                         else
1007                                 echo "...error: got size limit $SIZELIMIT but $COUNT entries"
1008                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1009                                 exit $RC
1010                         fi
1011                 else
1012                         echo "...error: bumped into server-side size limit, but got no entries!"
1013                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1014                         exit $RC
1015                 fi
1016         ;;
1017         *)
1018                 echo "ldapsearch failed ($RC)!"
1019                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1020                 exit $RC
1021         ;;
1022 esac
1023
1024 SIZELIMIT=100
1025 echo "Testing higher than hard limit request ($SIZELIMIT) for hard limited ID..."
1026 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
1027         -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
1028         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1029 RC=$?
1030 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1031 case $RC in
1032         0)
1033                 if test x"$COUNT" != x ; then
1034                         if test "$COUNT" -gt "$SIZELIMIT" ; then
1035                                 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT"
1036                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1037                                 exit $RC
1038                         fi
1039                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
1040                 else
1041                         echo "...error: did not expect ldapsearch success ($RC)!"
1042                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1043                         exit $RC
1044                 fi
1045         ;;
1046         4)
1047                 if test x"$COUNT" != x ; then
1048                         if test "$COUNT" = "$SIZELIMIT" ; then
1049                                 echo "...error: bumped into requested ($SIZELIMIT) size limit"
1050                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1051                                 exit $RC
1052                         else
1053                                 echo "...got size limit $COUNT instead of requested $SIZELIMIT entries"
1054                         fi
1055                 else
1056                         echo "...error: bumped into server-side size limit, but got no entries!"
1057                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1058                         exit $RC
1059                 fi
1060         ;;
1061 #       11)
1062 #               echo "...bumped into hard size administrative limit"
1063 #       ;;
1064         *)
1065                 echo "ldapsearch failed ($RC)!"
1066                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1067                 exit $RC
1068         ;;
1069 esac
1070
1071 SIZELIMIT=max
1072 echo "Testing max limit request ($SIZELIMIT) for hard limited ID..."
1073 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret -z $SIZELIMIT \
1074         -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \
1075         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1076 RC=$?
1077 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1078 case $RC in
1079         0)
1080                 if test x"$COUNT" != x ; then
1081                         echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)"
1082                 else
1083                         echo "...error: did not expect ldapsearch success ($RC)!"
1084                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1085                         exit $RC
1086                 fi
1087         ;;
1088         4)
1089                 if test x"$COUNT" != x ; then
1090                         echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit"
1091                 else
1092                         echo "...error: bumped into size limit but got no entries!"
1093                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1094                         exit $RC
1095                 fi
1096         ;;
1097 #       11)
1098 #               echo "...bumped into hard size administrative limit"
1099 #       ;;
1100         *)
1101                 echo "ldapsearch failed ($RC)!"
1102                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1103                 exit $RC
1104         ;;
1105 esac
1106
1107 echo "Testing lower than unchecked limit request for unchecked limited ID..."
1108 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1109         -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \
1110         -E '!pr='$PAGESIZE'/noprompt' '(uid=uncheckedlimited)' > $SEARCHOUT 2>&1
1111 RC=$?
1112 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1113 case $RC in
1114         0)
1115                 if test x"$COUNT" != x ; then
1116                         echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
1117                 else
1118                         echo "...error: did not expect ldapsearch success ($RC)!"
1119                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1120                         exit $RC
1121                 fi
1122         ;;
1123 #       11)
1124 #               echo "...bumped into unchecked administrative limit"
1125 #       ;;
1126         *)
1127                 echo "ldapsearch failed ($RC)!"
1128                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1129                 exit $RC
1130         ;;
1131 esac
1132
1133 echo "Testing higher than unchecked limit requested for unchecked limited ID..."
1134 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1135         -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \
1136         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1137 RC=$?
1138 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1139 case $RC in
1140         0)
1141                 if test x"$COUNT" != x ; then
1142                         echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)"
1143                 else
1144                         echo "...error: did not expect ldapsearch success ($RC)!"
1145                 fi
1146                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1147                 exit $RC
1148         ;;
1149         11)
1150                 echo "...bumped into unchecked administrative limit"
1151         ;;
1152         *)
1153                 echo "ldapsearch failed ($RC)!"
1154                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1155                 exit $RC
1156         ;;
1157 esac
1158
1159 echo ""
1160 echo "Testing specific search limits with pagedResults control"
1161 echo ""
1162
1163 echo "Testing no limit requested for unlimited page size ID..."
1164 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1165         -D 'cn=Unlimited User,ou=Paged Results Users,dc=example,dc=com' \
1166         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1167 RC=$?
1168 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1169 case $RC in
1170         0)
1171                 if test x"$COUNT" != x ; then
1172                         echo "...success; didn't bump into server-side size limit (got $COUNT entries)"
1173                 else
1174                         echo "...error: did not expect ldapsearch success ($RC)!"
1175                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1176                         exit $RC
1177                 fi
1178         ;;
1179         4)
1180                 if test x"$COUNT" != x ; then
1181                         echo "...bumped into server-side size limit (got $COUNT entries)"
1182                 else
1183                         echo "...error: bumped into server-side size limit, but got no entries!"
1184                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
1185                         exit $RC
1186                 fi
1187         ;;
1188         *)
1189                 echo "ldapsearch failed ($RC)!"
1190                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1191                 exit $RC
1192         ;;
1193 esac
1194
1195 echo "Testing no limit requested for limited page size ID..."
1196 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1197         -D 'cn=Page Size Limited User,ou=Paged Results Users,dc=example,dc=com' \
1198         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1199 RC=$?
1200 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1201 case $RC in
1202         0)
1203                 echo "...success; didn't bump into server-side page size limit (got $COUNT entries)"
1204         ;;
1205         4)
1206                 echo "...bumped into page size limit ($COUNT)"
1207         ;;
1208         11)
1209                 echo "...bumped into page size administrative limit"
1210         ;;
1211         *)
1212                 echo "ldapsearch failed ($RC)!"
1213                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1214                 exit $RC
1215         ;;
1216 esac
1217
1218 echo "Testing no limit requested for pagedResults disabled ID..."
1219 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1220         -D 'cn=Paged Results Disabled User,ou=Paged Results Users,dc=example,dc=com' \
1221         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1222 RC=$?
1223 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1224 case $RC in
1225         0)
1226                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
1227         ;;
1228         4)
1229                 echo "...bumped into server-side size limit ($COUNT)"
1230         ;;
1231         11)
1232                 echo "...bumped into pagedResults disabled administrative limit"
1233         ;;
1234         *)
1235                 echo "ldapsearch failed ($RC)!"
1236                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1237                 exit $RC
1238         ;;
1239 esac
1240
1241 echo "Testing no limit requested for pagedResults total count limited ID..."
1242 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1243         -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
1244         -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1245 RC=$?
1246 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1247 case $RC in
1248         0)
1249                 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)"
1250         ;;
1251         4)
1252                 echo "...bumped into server-side size limit ($COUNT)"
1253         ;;
1254         11)
1255                 echo "...bumped into pagedResults total count administrative limit"
1256         ;;
1257         *)
1258                 echo "ldapsearch failed ($RC)!"
1259                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1260                 exit $RC
1261         ;;
1262 esac
1263
1264 SIZELIMIT=8
1265 echo "Testing higher than hard but lower then total count limit requested for pagedResults total count limited ID..."
1266 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1267         -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
1268         -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1269 RC=$?
1270 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1271 case $RC in
1272         0)
1273                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
1274         ;;
1275         4)
1276                 if test "x$COUNT" != "x" ; then
1277                         if test "x$SIZELIMIT" = "x$COUNT" ; then
1278                                 echo "...bumped into requested ($SIZELIMIT) size limit"
1279                         else
1280                                 echo "...bumped into server-side size limit ($COUNT)"
1281                         fi
1282                 else
1283                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
1284                 fi
1285         ;;
1286         11)
1287                 echo "...bumped into either hard size or pagedResults total count administrative limit"
1288         ;;
1289         *)
1290                 echo "ldapsearch failed ($RC)!"
1291                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1292                 exit $RC
1293         ;;
1294 esac
1295
1296 SIZELIMIT=15
1297 echo "Testing higher than total count limit requested for pagedResults total count limited ID..."
1298 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1299         -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
1300         -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1301 RC=$?
1302 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1303 case $RC in
1304         0)
1305                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
1306         ;;
1307         4)
1308                 if test "x$COUNT" != "x" ; then
1309                         if test "x$SIZELIMIT" = "x$COUNT" ; then
1310                                 echo "...bumped into requested ($SIZELIMIT) size limit"
1311                         else
1312                                 echo "...bumped into server-side size limit ($COUNT)"
1313                         fi
1314                 else
1315                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
1316                 fi
1317         ;;
1318         11)
1319                 echo "...bumped into pagedResults total count administrative limit"
1320         ;;
1321         *)
1322                 echo "ldapsearch failed ($RC)!"
1323                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1324                 exit $RC
1325         ;;
1326 esac
1327
1328 SIZELIMIT=max
1329 echo "Testing max limit requested for pagedResults total count limited ID..."
1330 $LDAPRSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 -w secret \
1331         -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \
1332         -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1
1333 RC=$?
1334 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT`
1335 case $RC in
1336         0)
1337                 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)"
1338         ;;
1339         4)
1340                 if test "x$COUNT" != "x" ; then
1341                         if test "x$SIZELIMIT" = "x$COUNT" ; then
1342                                 echo "...bumped into requested ($SIZELIMIT) size limit"
1343                         else
1344                                 echo "...bumped into server-side size limit ($COUNT)"
1345                         fi
1346                 else
1347                         echo "...bumped into either requested ($SIZELIMIT) or server-side size limit"
1348                 fi
1349         ;;
1350         11)
1351                 echo "...bumped into pagedResults total count administrative limit"
1352         ;;
1353         *)
1354                 echo "ldapsearch failed ($RC)!"
1355                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1356                 exit $RC
1357         ;;
1358 esac
1359
1360 test $KILLSERVERS != no && kill -HUP $KILLPIDS
1361
1362 echo ">>>>> Test succeeded"
1363 exit 0