1 #! /bin/sh 2 # $OpenLDAP$ 3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4 ## 5 ## Copyright 1998-2024 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 < $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 < $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 > $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 $URI1 \ 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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 if test $INDEXDB = indexdb ; then 505 506 echo "Testing higher than unchecked limit requested for unchecked limited ID..." 507 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -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 $URI1 -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 else 558 echo "Skipping test for unchecked limit with $BACKEND backend." 559 fi 560 561 echo "Testing no limits requested for limited regex..." 562 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 -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 $URI1 \ 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 if test $MAINDB != maindb ; then 753 # only mdb currently supports pagedResults control 754 test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait 755 756 echo ">>>>> Test succeeded" 757 exit 0 758 fi 759 760 if test x"$SLAPD_PAGE_SIZE" != x ; then 761 PAGESIZE="$SLAPD_PAGE_SIZE" 762 if test "$PAGESIZE" -le 0 ; then 763 test $KILLSERVERS != no && kill -HUP $KILLPIDS 764 765 echo "" 766 echo "Testing with pagedResults control disabled" 767 echo "" 768 echo ">>>>> Test succeeded" 769 exit 0 770 fi 771 else 772 PAGESIZE=5 773 fi 774 775 echo "" 776 echo "Testing regular search limits with pagedResults control (page size $PAGESIZE)" 777 echo "" 778 779 echo "Testing no limits requested for unlimited ID..." 780 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 781 -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \ 782 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' >$SEARCHOUT 2>&1 783 RC=$? 784 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 785 case $RC in 786 0) 787 if test x"$COUNT" != x ; then 788 echo "...success (got $COUNT entries)" 789 else 790 echo "...error: did not expect ldapsearch success ($RC)!" 791 test $KILLSERVERS != no && kill -HUP $KILLPIDS 792 exit 1 793 fi 794 ;; 795 *) 796 echo "ldapsearch failed ($RC)!" 797 test $KILLSERVERS != no && kill -HUP $KILLPIDS 798 exit $RC 799 ;; 800 esac 801 802 SIZELIMIT=2 803 echo "Testing size limit request ($SIZELIMIT) for unlimited ID..." 804 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret -z $SIZELIMIT \ 805 -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \ 806 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 807 RC=$? 808 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 809 case $RC in 810 0) 811 if test x"$COUNT" != x ; then 812 if test "$COUNT" -gt "$SIZELIMIT" ; then 813 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT" 814 test $KILLSERVERS != no && kill -HUP $KILLPIDS 815 exit 1 816 fi 817 echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)" 818 else 819 echo "...error: did not expect ldapsearch success ($RC)!" 820 test $KILLSERVERS != no && kill -HUP $KILLPIDS 821 exit 1 822 fi 823 ;; 824 4) 825 if test x"$COUNT" != x ; then 826 if test $COUNT = $SIZELIMIT ; then 827 echo "...bumped into requested size limit ($SIZELIMIT)" 828 else 829 echo "...error: got $COUNT entries while requesting $SIZELIMIT..." 830 test $KILLSERVERS != no && kill -HUP $KILLPIDS 831 exit $RC 832 fi 833 else 834 echo "...error: bumped into server-side size limit, but got no entries!" 835 test $KILLSERVERS != no && kill -HUP $KILLPIDS 836 exit $RC 837 fi 838 ;; 839 *) 840 echo "ldapsearch failed ($RC)!" 841 test $KILLSERVERS != no && kill -HUP $KILLPIDS 842 exit $RC 843 ;; 844 esac 845 846 TIMELIMIT=10 847 echo "Testing time limit request ($TIMELIMIT s) for unlimited ID..." 848 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret -l $TIMELIMIT \ 849 -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \ 850 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 851 RC=$? 852 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 853 case $RC in 854 0) 855 if test x"$COUNT" != x ; then 856 echo "...didn't bump into the requested time limit ($TIMELIMIT s; got $COUNT entries)" 857 else 858 echo "...error: did not expect ldapsearch success ($RC)!" 859 test $KILLSERVERS != no && kill -HUP $KILLPIDS 860 exit 1 861 fi 862 ;; 863 3) 864 if test x"$COUNT" = x ; then 865 COUNT=0 866 fi 867 echo "...bumped into requested time limit ($TIMELIMIT s; got $COUNT entries)" 868 ;; 869 *) 870 echo "ldapsearch failed ($RC)!" 871 test $KILLSERVERS != no && kill -HUP $KILLPIDS 872 exit $RC 873 ;; 874 esac 875 876 echo "Testing no limits requested for soft limited ID..." 877 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 878 -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \ 879 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 880 RC=$? 881 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 882 case $RC in 883 0) 884 if test x"$COUNT" != x ; then 885 echo "...didn't bump into server-side size limit (got $COUNT entries)" 886 else 887 echo "...error: did not expect ldapsearch success ($RC)!" 888 test $KILLSERVERS != no && kill -HUP $KILLPIDS 889 exit 1 890 fi 891 ;; 892 4) 893 if test x"$COUNT" != x ; then 894 echo "...bumped into server-side size limit (got $COUNT entries)" 895 else 896 echo "...error: bumped into server-side size limit, but got no entries!" 897 test $KILLSERVERS != no && kill -HUP $KILLPIDS 898 exit $RC 899 fi 900 ;; 901 *) 902 echo "ldapsearch failed ($RC)!" 903 test $KILLSERVERS != no && kill -HUP $KILLPIDS 904 exit $RC 905 ;; 906 esac 907 908 SIZELIMIT=2 909 echo "Testing lower than soft limit request ($SIZELIMIT) for soft limited ID..." 910 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret -z $SIZELIMIT \ 911 -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \ 912 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 913 RC=$? 914 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 915 case $RC in 916 0) 917 if test x"$COUNT" != x ; then 918 if test "$COUNT" -gt "$SIZELIMIT" ; then 919 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT" 920 test $KILLSERVERS != no && kill -HUP $KILLPIDS 921 exit 1 922 fi 923 echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)" 924 else 925 echo "...error: did not expect ldapsearch success ($RC)!" 926 test $KILLSERVERS != no && kill -HUP $KILLPIDS 927 exit 1 928 fi 929 ;; 930 4) 931 if test "x$COUNT" != "x" ; then 932 if test "x$SIZELIMIT" = "x$COUNT" ; then 933 echo "...bumped into requested ($SIZELIMIT) size limit" 934 else 935 echo "...bumped into server-side size limit ($COUNT)" 936 fi 937 else 938 echo "...bumped into either requested ($SIZELIMIT) or server-side size limit" 939 fi 940 ;; 941 *) 942 echo "ldapsearch failed ($RC)!" 943 test $KILLSERVERS != no && kill -HUP $KILLPIDS 944 exit $RC 945 ;; 946 esac 947 948 SIZELIMIT=100 949 echo "Testing higher than soft limit request ($SIZELIMIT) for soft limited ID..." 950 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret -z $SIZELIMIT \ 951 -D 'cn=Soft Limited User,ou=People,dc=example,dc=com' \ 952 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 953 RC=$? 954 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 955 case $RC in 956 0) 957 if test x"$COUNT" != x ; then 958 if test "$COUNT" -gt "$SIZELIMIT" ; then 959 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT" 960 test $KILLSERVERS != no && kill -HUP $KILLPIDS 961 exit 1 962 fi 963 echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)" 964 else 965 echo "...error: did not expect ldapsearch success ($RC)!" 966 test $KILLSERVERS != no && kill -HUP $KILLPIDS 967 exit 1 968 fi 969 ;; 970 4) 971 if test "x$COUNT" != "x" ; then 972 if test "x$SIZELIMIT" = "x$COUNT" ; then 973 echo "...bumped into requested ($SIZELIMIT) size limit" 974 else 975 echo "...bumped into server-side size limit ($COUNT)" 976 fi 977 else 978 echo "...bumped into either requested ($SIZELIMIT) or server-side size limit" 979 fi 980 ;; 981 *) 982 echo "ldapsearch failed ($RC)!" 983 test $KILLSERVERS != no && kill -HUP $KILLPIDS 984 exit $RC 985 ;; 986 esac 987 988 SIZELIMIT=2 989 echo "Testing lower than hard limit request ($SIZELIMIT) for hard limited ID..." 990 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret -z $SIZELIMIT \ 991 -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \ 992 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 993 RC=$? 994 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 995 case $RC in 996 0) 997 if test x"$COUNT" != x ; then 998 if test "$COUNT" -gt "$SIZELIMIT" ; then 999 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT" 1000 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1001 exit 1 1002 fi 1003 echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)" 1004 else 1005 echo "...error: did not expect ldapsearch success ($RC)!" 1006 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1007 exit 1 1008 fi 1009 ;; 1010 4) 1011 if test x"$COUNT" != x ; then 1012 if test "$COUNT" = "$SIZELIMIT" ; then 1013 echo "...bumped into requested ($SIZELIMIT) size limit" 1014 else 1015 echo "...error: got size limit $SIZELIMIT but $COUNT entries" 1016 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1017 exit $RC 1018 fi 1019 else 1020 echo "...error: bumped into server-side size limit, but got no entries!" 1021 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1022 exit $RC 1023 fi 1024 ;; 1025 *) 1026 echo "ldapsearch failed ($RC)!" 1027 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1028 exit $RC 1029 ;; 1030 esac 1031 1032 SIZELIMIT=100 1033 echo "Testing higher than hard limit request ($SIZELIMIT) for hard limited ID..." 1034 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret -z $SIZELIMIT \ 1035 -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \ 1036 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1037 RC=$? 1038 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1039 case $RC in 1040 0) 1041 if test x"$COUNT" != x ; then 1042 if test "$COUNT" -gt "$SIZELIMIT" ; then 1043 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT" 1044 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1045 exit 1 1046 fi 1047 echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)" 1048 else 1049 echo "...error: did not expect ldapsearch success ($RC)!" 1050 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1051 exit 1 1052 fi 1053 ;; 1054 4) 1055 if test x"$COUNT" != x ; then 1056 if test "$COUNT" = "$SIZELIMIT" ; then 1057 echo "...error: bumped into requested ($SIZELIMIT) size limit" 1058 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1059 exit $RC 1060 else 1061 echo "...got size limit $COUNT instead of requested $SIZELIMIT entries" 1062 fi 1063 else 1064 echo "...error: bumped into server-side size limit, but got no entries!" 1065 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1066 exit $RC 1067 fi 1068 ;; 1069 # 11) 1070 # echo "...bumped into hard size administrative limit" 1071 # ;; 1072 *) 1073 echo "ldapsearch failed ($RC)!" 1074 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1075 exit $RC 1076 ;; 1077 esac 1078 1079 SIZELIMIT=max 1080 echo "Testing max limit request ($SIZELIMIT) for hard limited ID..." 1081 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret -z $SIZELIMIT \ 1082 -D 'cn=Hard Limited User,ou=People,dc=example,dc=com' \ 1083 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1084 RC=$? 1085 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1086 case $RC in 1087 0) 1088 if test x"$COUNT" != x ; then 1089 echo "...didn't bump into either requested ($SIZELIMIT) or server-side size limit (got $COUNT entries)" 1090 else 1091 echo "...error: did not expect ldapsearch success ($RC)!" 1092 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1093 exit 1 1094 fi 1095 ;; 1096 4) 1097 if test x"$COUNT" != x ; then 1098 echo "...bumped into requested ($SIZELIMIT=$COUNT) size limit" 1099 else 1100 echo "...error: bumped into size limit but got no entries!" 1101 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1102 exit $RC 1103 fi 1104 ;; 1105 # 11) 1106 # echo "...bumped into hard size administrative limit" 1107 # ;; 1108 *) 1109 echo "ldapsearch failed ($RC)!" 1110 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1111 exit $RC 1112 ;; 1113 esac 1114 1115 echo "Testing lower than unchecked limit request for unchecked limited ID..." 1116 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1117 -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \ 1118 -E '!pr='$PAGESIZE'/noprompt' '(uid=uncheckedlimited)' > $SEARCHOUT 2>&1 1119 RC=$? 1120 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1121 case $RC in 1122 0) 1123 if test x"$COUNT" != x ; then 1124 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)" 1125 else 1126 echo "...error: did not expect ldapsearch success ($RC)!" 1127 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1128 exit 1 1129 fi 1130 ;; 1131 # 11) 1132 # echo "...bumped into unchecked administrative limit" 1133 # ;; 1134 *) 1135 echo "ldapsearch failed ($RC)!" 1136 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1137 exit $RC 1138 ;; 1139 esac 1140 1141 echo "Testing higher than unchecked limit requested for unchecked limited ID..." 1142 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1143 -D 'cn=Unchecked Limited User,ou=People,dc=example,dc=com' \ 1144 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1145 RC=$? 1146 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1147 case $RC in 1148 0) 1149 if test x"$COUNT" != x ; then 1150 echo "...error: didn't bump into server-side unchecked limit (got $COUNT entries)" 1151 else 1152 echo "...error: did not expect ldapsearch success ($RC)!" 1153 fi 1154 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1155 exit 1 1156 ;; 1157 11) 1158 echo "...bumped into unchecked administrative limit" 1159 ;; 1160 *) 1161 echo "ldapsearch failed ($RC)!" 1162 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1163 exit $RC 1164 ;; 1165 esac 1166 1167 echo "" 1168 echo "Testing specific search limits with pagedResults control" 1169 echo "" 1170 1171 echo "Testing no limit requested for unlimited page size ID..." 1172 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1173 -D 'cn=Unlimited User,ou=Paged Results Users,dc=example,dc=com' \ 1174 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1175 RC=$? 1176 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1177 case $RC in 1178 0) 1179 if test x"$COUNT" != x ; then 1180 echo "...success; didn't bump into server-side size limit (got $COUNT entries)" 1181 else 1182 echo "...error: did not expect ldapsearch success ($RC)!" 1183 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1184 exit 1 1185 fi 1186 ;; 1187 4) 1188 if test x"$COUNT" != x ; then 1189 echo "...bumped into server-side size limit (got $COUNT entries)" 1190 else 1191 echo "...error: bumped into server-side size limit, but got no entries!" 1192 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1193 exit $RC 1194 fi 1195 ;; 1196 *) 1197 echo "ldapsearch failed ($RC)!" 1198 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1199 exit $RC 1200 ;; 1201 esac 1202 1203 echo "Testing no limit requested for limited page size ID..." 1204 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1205 -D 'cn=Page Size Limited User,ou=Paged Results Users,dc=example,dc=com' \ 1206 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1207 RC=$? 1208 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1209 case $RC in 1210 0) 1211 echo "...success; didn't bump into server-side page size limit (got $COUNT entries)" 1212 ;; 1213 4) 1214 echo "...bumped into page size limit ($COUNT)" 1215 ;; 1216 11) 1217 echo "...bumped into page size administrative limit" 1218 ;; 1219 *) 1220 echo "ldapsearch failed ($RC)!" 1221 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1222 exit $RC 1223 ;; 1224 esac 1225 1226 echo "Testing no limit requested for pagedResults disabled ID..." 1227 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1228 -D 'cn=Paged Results Disabled User,ou=Paged Results Users,dc=example,dc=com' \ 1229 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1230 RC=$? 1231 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1232 case $RC in 1233 0) 1234 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)" 1235 ;; 1236 4) 1237 echo "...bumped into server-side size limit ($COUNT)" 1238 ;; 1239 11) 1240 echo "...bumped into pagedResults disabled administrative limit" 1241 ;; 1242 *) 1243 echo "ldapsearch failed ($RC)!" 1244 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1245 exit $RC 1246 ;; 1247 esac 1248 1249 echo "Testing no limit requested for pagedResults total count limited ID..." 1250 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1251 -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \ 1252 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1253 RC=$? 1254 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1255 case $RC in 1256 0) 1257 echo "...success; didn't bump into server-side unchecked limit (got $COUNT entries)" 1258 ;; 1259 4) 1260 echo "...bumped into server-side size limit ($COUNT)" 1261 ;; 1262 11) 1263 echo "...bumped into pagedResults total count administrative limit" 1264 ;; 1265 *) 1266 echo "ldapsearch failed ($RC)!" 1267 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1268 exit $RC 1269 ;; 1270 esac 1271 1272 SIZELIMIT=8 1273 echo "Testing higher than hard but lower then total count limit requested for pagedResults total count limited ID..." 1274 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1275 -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \ 1276 -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1277 RC=$? 1278 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1279 case $RC in 1280 0) 1281 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)" 1282 ;; 1283 4) 1284 if test "x$COUNT" != "x" ; then 1285 if test "x$SIZELIMIT" = "x$COUNT" ; then 1286 echo "...bumped into requested ($SIZELIMIT) size limit" 1287 else 1288 echo "...bumped into server-side size limit ($COUNT)" 1289 fi 1290 else 1291 echo "...bumped into either requested ($SIZELIMIT) or server-side size limit" 1292 fi 1293 ;; 1294 11) 1295 echo "...bumped into either hard size or pagedResults total count administrative limit" 1296 ;; 1297 *) 1298 echo "ldapsearch failed ($RC)!" 1299 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1300 exit $RC 1301 ;; 1302 esac 1303 1304 SIZELIMIT=15 1305 echo "Testing higher than total count limit requested for pagedResults total count limited ID..." 1306 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1307 -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \ 1308 -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1309 RC=$? 1310 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1311 case $RC in 1312 0) 1313 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)" 1314 ;; 1315 4) 1316 if test "x$COUNT" != "x" ; then 1317 if test "x$SIZELIMIT" = "x$COUNT" ; then 1318 echo "...bumped into requested ($SIZELIMIT) size limit" 1319 else 1320 echo "...bumped into server-side size limit ($COUNT)" 1321 fi 1322 else 1323 echo "...bumped into either requested ($SIZELIMIT) or server-side size limit" 1324 fi 1325 ;; 1326 11) 1327 echo "...bumped into pagedResults total count administrative limit" 1328 ;; 1329 *) 1330 echo "ldapsearch failed ($RC)!" 1331 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1332 exit $RC 1333 ;; 1334 esac 1335 1336 SIZELIMIT=max 1337 echo "Testing max limit requested for pagedResults total count limited ID..." 1338 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret \ 1339 -D 'cn=Paged Results Limited User,ou=Paged Results Users,dc=example,dc=com' \ 1340 -z $SIZELIMIT -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1341 RC=$? 1342 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1343 case $RC in 1344 0) 1345 echo "...success; didn't bump into either requested ($SIZELIMIT) or server-side unchecked limit (got $COUNT entries)" 1346 ;; 1347 4) 1348 if test "x$COUNT" != "x" ; then 1349 if test "x$SIZELIMIT" = "x$COUNT" ; then 1350 echo "...bumped into requested ($SIZELIMIT) size limit" 1351 else 1352 echo "...bumped into server-side size limit ($COUNT)" 1353 fi 1354 else 1355 echo "...bumped into either requested ($SIZELIMIT) or server-side size limit" 1356 fi 1357 ;; 1358 11) 1359 echo "...bumped into pagedResults total count administrative limit" 1360 ;; 1361 *) 1362 echo "ldapsearch failed ($RC)!" 1363 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1364 exit $RC 1365 ;; 1366 esac 1367 1368 # ITS#4479 1369 PAGESIZE=1 1370 SIZELIMIT=2 1371 echo "Testing size limit request ($SIZELIMIT) for unlimited ID and pagesize=$PAGESIZE..." 1372 $LDAPRSEARCH -S "" -b "$BASEDN" -H $URI1 -w secret -z $SIZELIMIT \ 1373 -D 'cn=Unlimited User,ou=People,dc=example,dc=com' \ 1374 -E '!pr='$PAGESIZE'/noprompt' '(objectClass=*)' > $SEARCHOUT 2>&1 1375 RC=$? 1376 COUNT=`awk '/^# numEntries:/ {print $3}' $SEARCHOUT` 1377 case $RC in 1378 0) 1379 if test x"$COUNT" != x ; then 1380 if test "$COUNT" -gt "$SIZELIMIT" ; then 1381 echo "...error: got $COUNT entries instead of the requested $SIZELIMIT" 1382 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1383 exit 1 1384 fi 1385 echo "...didn't bump into the requested size limit ($SIZELIMIT; got $COUNT entries)" 1386 else 1387 echo "...error: did not expect ldapsearch success ($RC)!" 1388 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1389 exit 1 1390 fi 1391 ;; 1392 4) 1393 if test x"$COUNT" != x ; then 1394 if test $COUNT = $SIZELIMIT ; then 1395 echo "...bumped into requested size limit ($SIZELIMIT)" 1396 else 1397 echo "...error: got $COUNT entries while requesting $SIZELIMIT..." 1398 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1399 exit $RC 1400 fi 1401 else 1402 echo "...error: bumped into server-side size limit, but got no entries!" 1403 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1404 exit $RC 1405 fi 1406 ;; 1407 *) 1408 echo "ldapsearch failed ($RC)!" 1409 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1410 exit $RC 1411 ;; 1412 esac 1413 1414 test $KILLSERVERS != no && kill -HUP $KILLPIDS 1415 1416 echo ">>>>> Test succeeded" 1417 1418 test $KILLSERVERS != no && wait 1419 1420 exit 0 1421