X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tests%2Fscripts%2Ftest032-chain;h=88ac726f376e80e8552bcb22d9dca07fc6b49ab7;hb=dac408369b0812762b3e85f7e024ea472ce79abc;hp=442863a5c4c73092e654f6cc98d87fcececcf98f;hpb=ba6e6b4640c1d08ffb4cab46f063bc0cc8aa3493;p=openldap diff --git a/tests/scripts/test032-chain b/tests/scripts/test032-chain index 442863a5c4..88ac726f37 100755 --- a/tests/scripts/test032-chain +++ b/tests/scripts/test032-chain @@ -2,7 +2,7 @@ # $OpenLDAP$ ## This work is part of OpenLDAP Software . ## -## Copyright 1998-2005 The OpenLDAP Foundation. +## Copyright 1998-2011 The OpenLDAP Foundation. ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without @@ -21,6 +21,8 @@ if test $BACKLDAP = "ldapno" ; then exit 0 fi +rm -rf $TESTDIR + mkdir -p $TESTDIR $DBDIR1 $DBDIR2 echo "Running slapadd to build slapd database..." @@ -50,6 +52,7 @@ if test $WAIT != 0 ; then echo PID $PID1 read foo fi +KILLPIDS="$PID1" echo "Starting second slapd on TCP/IP port $PORT2..." . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $CONF2 @@ -60,7 +63,9 @@ if test $WAIT != 0 ; then read foo fi -KILLPIDS="$PID1 $PID2" +KILLPIDS="$KILLPIDS $PID2" + +sleep 1 echo "Using ldapsearch to check that first slapd is running..." for i in 0 1 2 3 4 5; do @@ -74,6 +79,12 @@ for i in 0 1 2 3 4 5; do sleep 5 done +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + echo "Using ldapsearch to check that second slapd is running..." for i in 0 1 2 3 4 5; do $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \ @@ -86,6 +97,12 @@ for i in 0 1 2 3 4 5; do sleep 5 done +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + for P in $PORT1 $PORT2 ; do echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..." $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \ @@ -99,9 +116,9 @@ for P in $PORT1 $PORT2 ; do fi echo "Filtering ldapsearch results..." - . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + $LDIFFILTER < $SEARCHOUT > $SEARCHFLT echo "Filtering original ldif used to create database..." - . $LDIFFILTER < $CHAINOUT > $LDIFFLT + $LDIFFILTER < $CHAINOUT > $LDIFFLT echo "Comparing filter output..." $CMP $SEARCHFLT $LDIFFLT > $CMPOUT @@ -110,6 +127,54 @@ for P in $PORT1 $PORT2 ; do test $KILLSERVERS != no && kill -HUP $KILLPIDS exit 1 fi + + echo "Reading the referral entry \"ou=Other,$BASEDN\" as anonymous on port $P..." + $LDAPSEARCH -h $LOCALHOST -p $P -b "ou=Other,$BASEDN" -S "" \ + > $SEARCHOUT 2>&1 + + RC=$? + if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + echo "Filtering ldapsearch results..." + $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + echo "Filtering original ldif used to create database..." + $LDIFFILTER < $CHAINREFOUT > $LDIFFLT + echo "Comparing filter output..." + $CMP $SEARCHFLT $LDIFFLT > $CMPOUT + + if test $? != 0 ; then + echo "comparison failed - chained search didn't succeed" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 + fi + + DN="cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN" + echo "Comparing \"$DN\" on port $P..." + $LDAPCOMPARE -h $LOCALHOST -p $P "$DN" "cn:Mark Elliot" \ + > $TESTOUT 2>&1 + + RC=$? + if test $RC != 6 && test $RC,$BACKEND != 5,null ; then + echo "ldapcompare failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 + fi + + DN="ou=Other,$BASEDN" + echo "Comparing \"$DN\" on port $P with manageDSAit control..." + $LDAPCOMPARE -h $LOCALHOST -p $P -M "$DN" "ou:Other" \ + > $TESTOUT 2>&1 + + RC=$? + if test $RC != 6 && test $RC,$BACKEND != 5,null ; then + echo "ldapcompare failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 + fi done # @@ -204,9 +269,9 @@ for P in $PORT1 $PORT2 ; do fi echo "Filtering ldapsearch results..." - . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + $LDIFFILTER < $SEARCHOUT > $SEARCHFLT echo "Filtering original ldif used to create database..." - . $LDIFFILTER < $CHAINMODOUT > $LDIFFLT + $LDIFFILTER < $CHAINMODOUT > $LDIFFLT echo "Comparing filter output..." $CMP $SEARCHFLT $LDIFFLT > $CMPOUT @@ -217,8 +282,57 @@ for P in $PORT1 $PORT2 ; do fi done +NEWPW=newsecret +echo "Using ldappasswd on second server with scope on first server..." +$LDAPPASSWD -h $LOCALHOST -p $PORT2 \ + -w secret -s $NEWPW \ + -D "$MANAGERDN" "$BJORNSDN" >> $TESTOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldappasswd failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Binding with newly changed password on first server..." +$LDAPWHOAMI -h $LOCALHOST -p $PORT1 \ + -D "$BJORNSDN" -w $NEWPW +RC=$? +if test $RC != 0 ; then + echo "ldapwhoami failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +# ITS#57?? +$LDAPADD -h $LOCALHOST -p $PORT1 \ + -D "$MANAGERDN" -w secret \ + >> $TESTOUT 2>&1 \ + << EOMODS +dn: ou=Can't Contact,dc=example,dc=com +changetype: add +objectclass: referral +objectclass: extensibleobject +ou: Can't Contact +# invalid URI to test broken connectivity handling (search only) +ref: ${URI3}ou=Can't%20Contact,dc=example,dc=com +EOMODS + +echo "Reading the referral entry \"ou=Can't Contact,$BASEDN\" as anonymous on port $PORT1..." +$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -S "" "(cn=Can't Contact)" \ + > $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + test $KILLSERVERS != no && kill -HUP $KILLPIDS echo ">>>>> Test succeeded" -exit 0 +test $KILLSERVERS != no && wait + +exit 0