test044-dynlist revision 1.1.1.1
1#! /bin/sh 2## This work is part of OpenLDAP Software <http://www.openldap.org/>. 3## 4## Copyright 1998-2008 The OpenLDAP Foundation. 5## All rights reserved. 6## 7## Redistribution and use in source and binary forms, with or without 8## modification, are permitted only as authorized by the OpenLDAP 9## Public License. 10## 11## A copy of this license is available in the file LICENSE in the 12## top-level directory of the distribution or, alternatively, at 13## <http://www.OpenLDAP.org/license.html>. 14 15echo "running defines.sh" 16. $SRCDIR/scripts/defines.sh 17 18if test $DYNLIST = "dynlistno" ; then 19 echo "dynlist overlay not available, test skipped" 20 exit 0 21fi 22 23mkdir -p $TESTDIR $DBDIR1 24 25$SLAPPASSWD -g -n >$CONFIGPWF 26echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf 27 28echo "Running slapadd to build slapd database..." 29. $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF 30$SLAPADD -f $ADDCONF -l $LDIFORDERED 31RC=$? 32if test $RC != 0 ; then 33 echo "slapadd failed ($RC)!" 34 exit $RC 35fi 36 37. $CONFFILTER $BACKEND $MONITORDB < $DYNLISTCONF > $CONF1 38 39echo "Starting slapd on TCP/IP port $PORT1..." 40$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & 41PID=$! 42if test $WAIT != 0 ; then 43 echo PID $PID 44 read foo 45fi 46KILLPIDS="$PID" 47 48sleep 1 49 50echo "Testing slapd searching..." 51for i in 0 1 2 3 4 5; do 52 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \ 53 '(objectclass=*)' > /dev/null 2>&1 54 RC=$? 55 if test $RC = 0 ; then 56 break 57 fi 58 echo "Waiting 5 seconds for slapd to start..." 59 sleep 5 60done 61 62if test $RC != 0 ; then 63 echo "ldapsearch failed ($RC)!" 64 test $KILLSERVERS != no && kill -HUP $KILLPIDS 65 exit $RC 66fi 67 68cat /dev/null > $SEARCHOUT 69 70LISTDN="ou=Dynamic Lists,$BASEDN" 71echo "Adding a dynamic list..." 72$LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ 73 > $TESTOUT 2>&1 << EOMODS 74dn: $LISTDN 75objectClass: organizationalUnit 76ou: Dynamic Lists 77 78dn: cn=Dynamic List,$LISTDN 79objectClass: groupOfURLs 80cn: Dynamic List 81memberURL: ldap:///ou=People,${BASEDN}?cn,mail?sub?(objectClass=person) 82EOMODS 83 84echo "Testing list search of all attrs..." 85echo "# Testing list search of all attrs..." >> $SEARCHOUT 86$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 87 '(cn=Dynamic List)' '*' \ 88 >> $SEARCHOUT 2>&1 89RC=$? 90if test $RC != 0 ; then 91 echo "ldapsearch failed ($RC)!" 92 test $KILLSERVERS != no && kill -HUP $KILLPIDS 93 exit $RC 94fi 95 96echo "Testing list search of a listed attr..." 97echo "# Testing list search of a listed attr..." >> $SEARCHOUT 98$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 99 '(cn=Dynamic List)' mail \ 100 >> $SEARCHOUT 2>&1 101RC=$? 102if test $RC != 0 ; then 103 echo "ldapsearch failed ($RC)!" 104 test $KILLSERVERS != no && kill -HUP $KILLPIDS 105 exit $RC 106fi 107 108echo "Testing list search of a non-listed attr..." 109echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT 110$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 111 '(cn=Dynamic List)' objectClass \ 112 >> $SEARCHOUT 2>&1 113RC=$? 114if test $RC != 0 ; then 115 echo "ldapsearch failed ($RC)!" 116 test $KILLSERVERS != no && kill -HUP $KILLPIDS 117 exit $RC 118fi 119 120echo "Testing list search with (critical) manageDSAit..." 121echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT 122$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \ 123 '(cn=Dynamic List)' '*' \ 124 >> $SEARCHOUT 2>&1 125RC=$? 126if test $RC != 0 ; then 127 echo "ldapsearch failed ($RC)!" 128 test $KILLSERVERS != no && kill -HUP $KILLPIDS 129 exit $RC 130fi 131 132echo "Testing list compare..." 133echo "# Testing list compare..." >> $SEARCHOUT 134$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \ 135 "cn=Dynamic List,$LISTDN" "cn:Bjorn Jensen" \ 136 >> $SEARCHOUT 2>&1 137RC=$? 138case $RC in 1395) 140 echo "ldapcompare returned FALSE ($RC)!" 141 test $KILLSERVERS != no && kill -HUP $KILLPIDS 142 exit $RC 143 ;; 1446) 145 echo "ldapcompare returned TRUE ($RC)" 146 ;; 1470) 148 echo "ldapcompare returned success ($RC)!" 149 test $KILLSERVERS != no && kill -HUP $KILLPIDS 150 exit -1 151 ;; 152*) 153 echo "ldapcompare failed ($RC)!" 154 test $KILLSERVERS != no && kill -HUP $KILLPIDS 155 exit $RC 156 ;; 157esac 158echo "" >> $SEARCHOUT 159 160echo "Testing list compare (should return FALSE)..." 161echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT 162$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \ 163 "cn=Dynamic List,$LISTDN" "cn:FALSE" \ 164 >> $SEARCHOUT 2>&1 165RC=$? 166case $RC in 1675) 168 echo "ldapcompare returned FALSE ($RC)" 169 ;; 1706) 171 echo "ldapcompare returned TRUE ($RC)!" 172 test $KILLSERVERS != no && kill -HUP $KILLPIDS 173 exit $RC 174 ;; 1750) 176 echo "ldapcompare returned success ($RC)!" 177 test $KILLSERVERS != no && kill -HUP $KILLPIDS 178 exit -1 179 ;; 180*) 181 echo "ldapcompare failed ($RC)!" 182 test $KILLSERVERS != no && kill -HUP $KILLPIDS 183 exit $RC 184 ;; 185esac 186echo "" >> $SEARCHOUT 187 188echo "Testing list compare (should return UNDEFINED)..." 189echo "# Testing list compare (should return UNDEFINED)..." >> $SEARCHOUT 190$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \ 191 "cn=Dynamic List,$LISTDN" "dc:UNDEFINED" \ 192 >> $SEARCHOUT 2>&1 193RC=$? 194case $RC in 1955) 196 echo "ldapcompare returned FALSE ($RC)!" 197 test $KILLSERVERS != no && kill -HUP $KILLPIDS 198 exit $RC 199 ;; 2006) 201 echo "ldapcompare returned TRUE ($RC)!" 202 test $KILLSERVERS != no && kill -HUP $KILLPIDS 203 exit $RC 204 ;; 20516|32) 206 echo "ldapcompare returned UNDEFINED ($RC)" 207 ;; 2080) 209 echo "ldapcompare returned success ($RC)!" 210 test $KILLSERVERS != no && kill -HUP $KILLPIDS 211 exit -1 212 ;; 213*) 214 echo "ldapcompare failed ($RC)" 215 ;; 216esac 217echo "" >> $SEARCHOUT 218 219echo "Testing list compare with manageDSAit..." 220echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT 221$LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \ 222 "cn=Dynamic List,$LISTDN" "cn:Bjorn Jensen" \ 223 >> $SEARCHOUT 2>&1 224RC=$? 225case $RC in 2265) 227 echo "ldapcompare returned FALSE ($RC)" 228 ;; 2296) 230 echo "ldapcompare returned TRUE ($RC)!" 231 test $KILLSERVERS != no && kill -HUP $KILLPIDS 232 exit $RC 233 ;; 2340) 235 echo "ldapcompare returned success ($RC)!" 236 test $KILLSERVERS != no && kill -HUP $KILLPIDS 237 exit -1 238 ;; 239*) 240 echo "ldapcompare failed ($RC)!" 241 test $KILLSERVERS != no && kill -HUP $KILLPIDS 242 exit $RC 243 ;; 244esac 245echo "" >> $SEARCHOUT 246 247echo "Reconfiguring slapd..." 248$LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \ 249 $TESTOUT 2>&1 << EOMODS 250version: 1 251dn: olcOverlay={0}dynlist,olcDatabase={2}$BACKEND,cn=config 252changetype: modify 253delete: olcDLattrSet 254olcDLattrSet: {0} 255- 256add: olcDLattrSet 257olcDLattrSet: groupOfURLs memberURL member 258EOMODS 259 260echo "==========================================================" >> $LOG1 261 262echo "Adding a dynamic list..." 263$LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ 264 > $TESTOUT 2>&1 << EOMODS 265dn: cn=Dynamic List of Members,$LISTDN 266objectClass: groupOfURLs 267cn: Dynamic List of Members 268memberURL: ldap:///ou=People,${BASEDN}??sub?(objectClass=person) 269EOMODS 270 271echo "Testing list search of all attrs..." 272echo "# Testing list search of all attrs..." >> $SEARCHOUT 273$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 274 '(cn=Dynamic List of Members)' '*' \ 275 >> $SEARCHOUT 2>&1 276RC=$? 277if test $RC != 0 ; then 278 echo "ldapsearch failed ($RC)!" 279 test $KILLSERVERS != no && kill -HUP $KILLPIDS 280 exit $RC 281fi 282 283echo "Testing list search of a listed attr..." 284echo "# Testing list search of a listed attr..." >> $SEARCHOUT 285$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 286 '(cn=Dynamic List of Members)' member \ 287 >> $SEARCHOUT 2>&1 288RC=$? 289if test $RC != 0 ; then 290 echo "ldapsearch failed ($RC)!" 291 test $KILLSERVERS != no && kill -HUP $KILLPIDS 292 exit $RC 293fi 294 295echo "Testing list search of a non-listed attr..." 296echo "# Testing list search of a non-listed attr..." >> $SEARCHOUT 297$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 298 '(cn=Dynamic List of Members)' objectClass \ 299 >> $SEARCHOUT 2>&1 300RC=$? 301if test $RC != 0 ; then 302 echo "ldapsearch failed ($RC)!" 303 test $KILLSERVERS != no && kill -HUP $KILLPIDS 304 exit $RC 305fi 306 307echo "Testing list search with (critical) manageDSAit..." 308echo "# Testing list search with (critical) manageDSAit..." >> $SEARCHOUT 309$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 -MM \ 310 '(&(cn=Dynamic List of Members)(objectClass=groupOfURLs))' '*' \ 311 >> $SEARCHOUT 2>&1 312RC=$? 313if test $RC != 0 ; then 314 echo "ldapsearch failed ($RC)!" 315 test $KILLSERVERS != no && kill -HUP $KILLPIDS 316 exit $RC 317fi 318 319CMPDN="$BJORNSDN" 320echo "Testing list compare..." 321echo "# Testing list compare..." >> $SEARCHOUT 322$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \ 323 "cn=Dynamic List of Members,$LISTDN" "member:$CMPDN" \ 324 >> $SEARCHOUT 2>&1 325RC=$? 326case $RC in 3275) 328 echo "ldapcompare returned FALSE ($RC)!" 329 test $KILLSERVERS != no && kill -HUP $KILLPIDS 330 exit $RC 331 ;; 3326) 333 echo "ldapcompare returned TRUE ($RC)" 334 ;; 3350) 336 echo "ldapcompare returned success ($RC)!" 337 test $KILLSERVERS != no && kill -HUP $KILLPIDS 338 exit -1 339 ;; 340*) 341 echo "ldapcompare failed ($RC)!" 342 test $KILLSERVERS != no && kill -HUP $KILLPIDS 343 exit $RC 344 ;; 345esac 346echo "" >> $SEARCHOUT 347 348echo "Testing list compare (should return FALSE)..." 349echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT 350$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \ 351 "cn=Dynamic List of Members,$LISTDN" "member:cn=Foo Bar" \ 352 >> $SEARCHOUT 2>&1 353RC=$? 354case $RC in 3555) 356 echo "ldapcompare returned FALSE ($RC)" 357 ;; 3586) 359 echo "ldapcompare returned TRUE ($RC)!" 360 test $KILLSERVERS != no && kill -HUP $KILLPIDS 361 exit $RC 362 ;; 3630) 364 echo "ldapcompare returned success ($RC)!" 365 test $KILLSERVERS != no && kill -HUP $KILLPIDS 366 exit -1 367 ;; 368*) 369 echo "ldapcompare failed ($RC)!" 370 test $KILLSERVERS != no && kill -HUP $KILLPIDS 371 exit $RC 372 ;; 373esac 374echo "" >> $SEARCHOUT 375 376echo "Testing list compare with manageDSAit..." 377echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT 378$LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \ 379 "cn=Dynamic List,$LISTDN" "member:$CMPDN" \ 380 >> $SEARCHOUT 2>&1 381RC=$? 382case $RC in 3835) 384 echo "ldapcompare returned FALSE ($RC)" 385 ;; 3866) 387 echo "ldapcompare returned TRUE ($RC)!" 388 test $KILLSERVERS != no && kill -HUP $KILLPIDS 389 exit $RC 390 ;; 3910) 392 echo "ldapcompare returned success ($RC)!" 393 test $KILLSERVERS != no && kill -HUP $KILLPIDS 394 exit -1 395 ;; 396*) 397 echo "ldapcompare failed ($RC)!" 398 test $KILLSERVERS != no && kill -HUP $KILLPIDS 399 exit $RC 400 ;; 401esac 402echo "" >> $SEARCHOUT 403 404echo "==========================================================" >> $LOG1 405 406echo "Testing dgIdentity..." 407 408# Set ACL, require authentication to get list contents 409$LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \ 410 $TESTOUT 2>&1 << EOMODS 411version: 1 412dn: olcDatabase={2}$BACKEND,cn=config 413changetype: modify 414add: olcAccess 415olcAccess: to dn.base="cn=Dynamic List of Members,$LISTDN" by * read 416olcAccess: to * by users read by * search 417EOMODS 418 419echo "Testing list search without dgIdentity..." 420echo "# Testing list search without dgIdentity..." >> $SEARCHOUT 421$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 422 '(cn=Dynamic List of Members)' '*' \ 423 >> $SEARCHOUT 2>&1 424RC=$? 425if test $RC != 0 ; then 426 echo "ldapsearch failed ($RC)!" 427 test $KILLSERVERS != no && kill -HUP $KILLPIDS 428 exit $RC 429fi 430 431$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ 432 > $TESTOUT 2>&1 << EOMODS 433dn: cn=Dynamic List of Members,$LISTDN 434changetype: modify 435add: objectClass 436objectClass: dgIdentityAux 437- 438add: dgIdentity 439dgIdentity: $CMPDN 440EOMODS 441 442echo "Testing list search with dgIdentity..." 443echo "# Testing list search with dgIdentity..." >> $SEARCHOUT 444$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 445 '(cn=Dynamic List of Members)' '*' \ 446 >> $SEARCHOUT 2>&1 447RC=$? 448if test $RC != 0 ; then 449 echo "ldapsearch failed ($RC)!" 450 test $KILLSERVERS != no && kill -HUP $KILLPIDS 451 exit $RC 452fi 453 454echo "Testing dgAuthz..." 455 456CMPDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" 457$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \ 458 > $TESTOUT 2>&1 << EOMODS 459dn: cn=Dynamic List of Members,$LISTDN 460changetype: modify 461add: dgAuthz 462dgAuthz: dn:$BABSDN 463EOMODS 464 465echo "Testing list search with dgIdentity and dgAuthz anonymously..." 466echo "# Testing list search with dgIdentity and dgAuthz anonymously..." >> $SEARCHOUT 467$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 468 '(cn=Dynamic List of Members)' '*' \ 469 >> $SEARCHOUT 2>&1 470RC=$? 471if test $RC != 0 ; then 472 echo "ldapsearch failed ($RC)!" 473 test $KILLSERVERS != no && kill -HUP $KILLPIDS 474 exit $RC 475fi 476 477echo "Testing list search with dgIdentity and dgAuthz as the authorized identity..." 478echo "# Testing list search with dgIdentity and dgAuthz as the authorized identity..." >> $SEARCHOUT 479$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \ 480 -D "$BABSDN" -w bjensen \ 481 '(cn=Dynamic List of Members)' '*' \ 482 >> $SEARCHOUT 2>&1 483RC=$? 484if test $RC != 0 ; then 485 echo "ldapsearch failed ($RC)!" 486 test $KILLSERVERS != no && kill -HUP $KILLPIDS 487 exit $RC 488fi 489 490test $KILLSERVERS != no && kill -HUP $KILLPIDS 491 492LDIF=$DYNLISTOUT 493 494echo "Filtering ldapsearch results..." 495. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT 496echo "Filtering original ldif used to create database..." 497. $LDIFFILTER < $LDIF > $LDIFFLT 498echo "Comparing filter output..." 499$CMP $SEARCHFLT $LDIFFLT > $CMPOUT 500 501if test $? != 0 ; then 502 echo "Comparison failed" 503 exit 1 504fi 505 506echo ">>>>> Test succeeded" 507 508test $KILLSERVERS != no && wait 509 510exit 0 511