From d69c41fc0f7b6fb6336bcd1b8451c6172b0180d2 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 21 Oct 2002 19:11:27 +0000 Subject: [PATCH] Add a referrals/manageDsaIT test (depends on order of reference return) --- tests/data/referrals.ldif | 27 +--- tests/data/referrals.out | 227 ++++++++++++++++++++++++++++++++ tests/data/slapd-referrals.conf | 23 ++++ tests/scripts/defines.sh | 5 + tests/scripts/test016-ref | 197 +++++++++++++++++++++++++++ 5 files changed, 455 insertions(+), 24 deletions(-) create mode 100644 tests/data/referrals.out create mode 100644 tests/data/slapd-referrals.conf create mode 100755 tests/scripts/test016-ref diff --git a/tests/data/referrals.ldif b/tests/data/referrals.ldif index 54911cb0a6..dfa34a7fb8 100644 --- a/tests/data/referrals.ldif +++ b/tests/data/referrals.ldif @@ -4,23 +4,17 @@ objectclass: country dn: o=ABC,c=US o: ABC -ref: ldap//hostA/o=abc,c=us HostA -ref: ldap//hostB/o=abc,c=us HostB +ref: ldap://hostA/o=abc,c=us HostA +ref: ldap://hostB/o=abc,c=us HostB objectclass: referral objectclass: extensibleObject dn: o=XYZ,c=US o: XYZ -ref: ldap//hostC/o=xyz,c=us HostC +ref: ldap://hostC/o=xyz,c=us HostC objectclass: referral objectclass: extensibleObject -dn: o=Alias,c=US -o: Alias -aliasedObjectName: o=University of Michigan,c=US -objectclass: alias -objectclass: extensibleObject - dn: o=University of Michigan,c=US o: University of Michigan objectclass: organization @@ -33,18 +27,3 @@ sn: Manager description: Manager of the directory userpassword:: c2VjcmV0 objectclass: person - -dn: cn=Alias,o=University of Michigan,c=US -cn: Alias -aliasedobjectname: cn=Manager,o=University of Michigan,c=US -objectclass: extensibleObject - -dn: cn=Circular,o=University of Michigan,c=US -cn: Circular -aliasedobjectname: cn=Circular,o=University of Michigan,c=US -objectclass: extensibleObject - -dn: cn=Subordinate,o=University of Michigan,c=US -cn: Subordinate -aliasedobjectname: cn=Subordinate,cn=Alias,o=University of Michigan,c=US -objectclass: extensibleObject diff --git a/tests/data/referrals.out b/tests/data/referrals.out new file mode 100644 index 0000000000..9cad1bef11 --- /dev/null +++ b/tests/data/referrals.out @@ -0,0 +1,227 @@ +# extended LDIF +# +# LDAPv3 +# filter: (objectClass=referral) +# requesting: * ref +# with manageDSAit critical control +# + +# ABC, US +dn: o=ABC,c=US +o: ABC +ref: ldap://hostA/o=abc,c=us HostA +ref: ldap://hostB/o=abc,c=us HostB +objectClass: referral +objectClass: extensibleObject + +# XYZ, US +dn: o=XYZ,c=US +o: XYZ +ref: ldap://hostC/o=xyz,c=us HostC +objectClass: referral +objectClass: extensibleObject + +# search result +search: 2 +result: 0 Success + +# numResponses: 3 +# numEntries: 2 +# extended LDIF +# +# LDAPv3 +# filter: (objectClass=referral) +# requesting: * ref +# with manageDSAit critical control +# + +# ABC, US +dn: o=ABC,c=US +o: ABC +ref: ldap://hostA/o=abc,c=us HostA +ref: ldap://hostB/o=abc,c=us HostB +objectClass: referral +objectClass: extensibleObject + +# search result +search: 2 +result: 0 Success + +# numResponses: 2 +# numEntries: 1 +# extended LDIF +# +# LDAPv3 +# filter: (objectClass=referral) +# requesting: * ref +# with manageDSAit critical control +# + +# search result +search: 2 +result: 10 Referral +matchedDN: o=ABC,c=US +ref: ldap://hostA/uid=xxx,o=abc,c=us??sub +ref: ldap://hostB/uid=xxx,o=abc,c=us??sub + +# numResponses: 1 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# US +dn: c=US + +# search result +search: 2 +result: 0 Success + +# numResponses: 2 +# numEntries: 1 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# search reference +ref: ldap://hostA/o=abc,c=us??base +ref: ldap://hostB/o=abc,c=us??base + +# search reference +ref: ldap://hostC/o=xyz,c=us??base + +# University of Michigan, US +dn: o=University of Michigan,c=US + +# search result +search: 2 +result: 0 Success + +# numResponses: 4 +# numEntries: 1 +# numReferences: 2 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# search reference +ref: ldap://hostA/o=abc,c=us??sub +ref: ldap://hostB/o=abc,c=us??sub + +# search reference +ref: ldap://hostC/o=xyz,c=us??sub + +# US +dn: c=US + +# University of Michigan, US +dn: o=University of Michigan,c=US + +# Manager, University of Michigan, US +dn: cn=Manager,o=University of Michigan,c=US + +# search result +search: 2 +result: 0 Success + +# numResponses: 6 +# numEntries: 3 +# numReferences: 2 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# search result +search: 2 +result: 10 Referral +matchedDN: o=ABC,c=US +ref: ldap://hostA/o=abc,c=us??base +ref: ldap://hostB/o=abc,c=us??base + +# numResponses: 1 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# search result +search: 2 +result: 10 Referral +matchedDN: o=ABC,c=US +ref: ldap://hostA/o=abc,c=us??one +ref: ldap://hostB/o=abc,c=us??one + +# numResponses: 1 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# search result +search: 2 +result: 10 Referral +matchedDN: o=ABC,c=US +ref: ldap://hostA/o=abc,c=us??sub +ref: ldap://hostB/o=abc,c=us??sub + +# numResponses: 1 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# search result +search: 2 +result: 10 Referral +matchedDN: o=ABC,c=US +ref: ldap://hostA/uid=xxx,o=abc,c=us??base +ref: ldap://hostB/uid=xxx,o=abc,c=us??base + +# numResponses: 1 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# search result +search: 2 +result: 10 Referral +matchedDN: o=ABC,c=US +ref: ldap://hostA/uid=xxx,o=abc,c=us??one +ref: ldap://hostB/uid=xxx,o=abc,c=us??one + +# numResponses: 1 +# extended LDIF +# +# LDAPv3 +# filter: (objectclass=*) +# requesting: 1.1 +# + +# search result +search: 2 +result: 10 Referral +matchedDN: o=ABC,c=US +ref: ldap://hostA/uid=xxx,o=abc,c=us??sub +ref: ldap://hostB/uid=xxx,o=abc,c=us??sub + +# numResponses: 1 diff --git a/tests/data/slapd-referrals.conf b/tests/data/slapd-referrals.conf new file mode 100644 index 0000000000..03255fb5bc --- /dev/null +++ b/tests/data/slapd-referrals.conf @@ -0,0 +1,23 @@ +# $OpenLDAP$ +# +# referral slapd config -- for testing +# +ucdata-path ./ucdata +include ./schema/core.schema +include ./schema/cosine.schema +include ./schema/inetorgperson.schema +include ./schema/openldap.schema +pidfile ./test-db/slapd.pid +argsfile ./test-db/slapd.args + +####################################################################### +# ldbm database definitions +####################################################################### + +database @BACKEND@ +suffix "c=US" +directory ./test-db +rootdn "cn=Manager,o=University of Michigan,c=US" +rootpw secret +#ldbm#index objectClass eq +#bdb#index objectClass eq diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index 304e43c416..407ed220a9 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -10,6 +10,7 @@ CONF=$DATADIR/slapd.conf MCONF=$DATADIR/slapd-master.conf PWCONF=$DATADIR/slapd-pw.conf ACLCONF=$DATADIR/slapd-acl.conf +RCONF=$DATADIR/slapd-referrals.conf MASTERCONF=$DATADIR/slapd-repl-master.conf SLAVECONF=$DATADIR/slapd-repl-slave.conf REFSLAVECONF=$DATADIR/slapd-ref-slave.conf @@ -47,6 +48,7 @@ SLAPD="../servers/slapd/slapd -s0" SLURPD=../servers/slurpd/slurpd LDAPPASSWD="$CLIENTDIR/ldappasswd $TOOLARGS" LDAPSEARCH="$CLIENTDIR/ldapsearch $TOOLPROTO $TOOLARGS -LLL" +LDAPRSEARCH="$CLIENTDIR/ldapsearch $TOOLPROTO $TOOLARGS" LDAPMODIFY="$CLIENTDIR/ldapmodify $TOOLPROTO $TOOLARGS" LDAPADD="$CLIENTDIR/ldapadd $TOOLPROTO $TOOLARGS" LDAPMODRDN="$CLIENTDIR/ldapmodrdn $TOOLPROTO $TOOLARGS" @@ -66,7 +68,9 @@ LDIFPASSWD=$DATADIR/passwd.ldif LDIFPASSWDOUT=$DATADIR/passwd-out.ldif LDIFLANG=$DATADIR/test-lang.ldif LDIFLANGOUT=$DATADIR/lang-out.ldif +LDIFREF=$DATADIR/referrals.ldif MONITOR="" +REFDN="c=US" BASEDN="o=University of Michigan,c=US" MANAGERDN="cn=Manager,o=University of Michigan,c=US" UPDATEDN="cn=Replica,o=University of Michigan,c=US" @@ -87,6 +91,7 @@ SLAVEOUT=$DBDIR/slave.out SUBMASTEROUT=$DBDIR/submaster.out TESTOUT=$DBDIR/test.out INITOUT=$DBDIR/init.out +REFERRALOUT=$DATADIR/referrals.out SEARCHOUTMASTER=$DATADIR/search.out.master SEARCHOUTX=$DATADIR/search.out.xsearch MODIFYOUTMASTER=$DATADIR/modify.out.master diff --git a/tests/scripts/test016-ref b/tests/scripts/test016-ref new file mode 100755 index 0000000000..686786d8ce --- /dev/null +++ b/tests/scripts/test016-ref @@ -0,0 +1,197 @@ +#! /bin/sh +# $OpenLDAP$ + +RCODE=10 +SRCDIR="." +if test $# -ge 1 ; then + SRCDIR=$1; shift +fi +BACKEND=bdb +if test $# -ge 1 ; then + BACKEND=$1; shift +fi +MONITORDB=no +if test $# -ge 1 ; then + MONITORDB=$1; shift +fi +WAIT=0 +if test $# -ge 1 ; then + WAIT=1; shift +fi + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +echo "Cleaning up in $DBDIR..." + +rm -f $DBDIR/[!C]* + +echo "Running slapadd to build slapd database..." +. $CONFFILTER $BACKEND $MONITORDB < $RCONF > $DBCONF +$SLAPADD -f $DBCONF -l $LDIFREF +RC=$? +if test $RC != 0 ; then + echo "slapadd failed ($RC)!" + exit $RC +fi + +echo "Starting slapd on TCP/IP port $PORT..." +$SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi + +echo "Testing slapd searching..." +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \ + '(objectclass=*)' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for slapd to start..." + sleep 5 +done + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + kill -HUP $PID + exit $RC +fi + +cat /dev/null > $SEARCHOUT + +echo "Testing ManageDsaIT searching at $REFDN..." +$LDAPRSEARCH -S "" -MM -b "$REFDN" -h $LOCALHOST -p $PORT \ + '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + kill -HUP $PID + exit $RC +fi + +echo "Testing ManageDsaIT searching at referral object..." +$LDAPRSEARCH -S "" -MM -b "o=abc,$REFDN" -h $LOCALHOST -p $PORT \ + '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + kill -HUP $PID + exit $RC +fi + +echo "Testing ManageDsaIT searching below referral object..." +$LDAPRSEARCH -S "" -MM -b "uid=xxx,o=abc,$REFDN" -h $LOCALHOST -p $PORT \ + '(objectClass=referral)' '*' ref >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != $RCODE ; then + echo "ldapsearch: unexpected result ($RC)! (referral expected)" + kill -HUP $PID + exit $RC +fi + +XREFDN="$REFDN" +echo "Testing base searching at $XREFDN..." +$LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + kill -HUP $PID + exit $RC +fi + +echo "Testing one-level searching at $XREFDN..." +$LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + kill -HUP $PID + exit $RC +fi + +echo "Testing subtree searching at $XREFDN..." +$LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + kill -HUP $PID + exit $RC +fi + +XREFDN="o=abc,$REFDN" +echo "Testing base searching at $XREFDN..." +$LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != $RCODE ; then + echo "ldapsearch: unexpected result ($RC)! (referral expected)" + kill -HUP $PID + exit $RC +fi + +echo "Testing one-level searching at $XREFDN..." +$LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != $RCODE ; then + echo "ldapsearch: unexpected result ($RC)! (referral expected)" + kill -HUP $PID + exit $RC +fi + +echo "Testing subtree searching at $XREFDN..." +$LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != $RCODE ; then + echo "ldapsearch: unexpected result ($RC)! (referral expected)" + kill -HUP $PID + exit $RC +fi + +XREFDN="uid=xxx,o=abc,$REFDN" +echo "Testing base searching at $XREFDN..." +$LDAPRSEARCH -S "" -s base -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != $RCODE ; then + echo "ldapsearch: unexpected result ($RC)! (referral expected)" + kill -HUP $PID + exit $RC +fi + +echo "Testing one-level searching at $XREFDN..." +$LDAPRSEARCH -S "" -s one -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != $RCODE ; then + echo "ldapsearch: unexpected result ($RC)! (referral expected)" + kill -HUP $PID + exit $RC +fi + +echo "Testing subtree searching at $XREFDN..." +$LDAPRSEARCH -S "" -s sub -b "$XREFDN" -h $LOCALHOST -p $PORT 1.1 >> $SEARCHOUT 2>&1 +RC=$? +if test $RC != $RCODE ; then + echo "ldapsearch: unexpected result ($RC)! (referral expected)" + kill -HUP $PID + exit $RC +fi + +kill -HUP $PID +LDIF=$SEARCHOUTMASTER +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT +echo "Filtering expected LDIF for comparison..." +. $LDIFFILTER < $REFERRALOUT > $LDIFFLT +echo "Comparing filter output..." +$CMP $SEARCHFLT $LDIFFLT > $CMPOUT + +if test $? != 0 ; then + echo "Comparison failed" + exit 1 +fi + +echo ">>>>> Test succeeded" + + +exit 0 -- 2.39.5