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