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