From: Michael Nolta Date: Tue, 3 Sep 2024 10:38:48 +0000 (+0100) Subject: ITS#10248 Regression test script X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dd621781f075279a6495447a1c106e88682c026d;p=thirdparty%2Fopenldap.git ITS#10248 Regression test script --- diff --git a/tests/data/regressions/its10248/its10248 b/tests/data/regressions/its10248/its10248 new file mode 100755 index 0000000000..b4590e85c6 --- /dev/null +++ b/tests/data/regressions/its10248/its10248 @@ -0,0 +1,205 @@ +#! /bin/sh +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## Copyright 1998-2021 The OpenLDAP Foundation. +## All rights reserved. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted only as authorized by the OpenLDAP +## Public License. +## +## A copy of this license is available in the file LICENSE in the +## top-level directory of the distribution or, alternatively, at +## . + +echo "" +echo " Searching a translucent overlay with subordinate backend." +echo "" + +echo "running defines.sh" +. $SRCDIR/scripts/defines.sh + +PERSONAL="(objectClass=inetOrgPerson)" +NOWHERE="/dev/null" +FAILURE="additional info:" + +if test $TRANSLUCENT = translucentno ; then + echo "Translucent Proxy overlay not available, test skipped" + exit 0 +fi + +if test $AC_ldap = ldapno ; then + echo "Translucent Proxy overlay requires back-ldap backend, test skipped" + exit 0 +fi + +mkdir -p $TESTDIR $DBDIR1A $DBDIR2A $DBDIR2B + +ITS=10248 +ITSDIR=$DATADIR/regressions/its$ITS +LDIFSUBUSER=$ITSDIR/subuser.ldif + +# configure backside + +$SLAPPASSWD -g -n >$CONFIGPWF +echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf + +. $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTREMOTECONF > $CONF1 +echo "Running slapadd to build remote slapd database..." +$SLAPADD -f $CONF1 -l $LDIFTRANSLUCENTCONFIG +RC=$? +if test $RC != 0 ; then + echo "slapadd failed ($RC)!" + exit $RC +fi + +echo "Starting remote slapd on TCP/IP port $PORT1..." +$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +REMOTEPID="$PID" +KILLPIDS="$PID" + +sleep 1 + +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for remote slapd to start..." + sleep 5 +done + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +# configure frontside + +. $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-local.conf > $CONF2 +echo "Starting local slapd on TCP/IP port $PORT2..." +$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 & +PID=$! +if test $WAIT != 0 ; then + echo PID $PID + read foo +fi +LOCALPID="$PID" +KILLPIDS="$LOCALPID $REMOTEPID" + +sleep 1 + +for i in 0 1 2 3 4 5; do + $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \ + 'objectclass=*' > /dev/null 2>&1 + RC=$? + if test $RC = 0 ; then + break + fi + echo "Waiting 5 seconds for local slapd to start..." + sleep 5 +done + +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Populating remote database..." + +$LDAPADD -D "$TRANSLUCENTROOT" -H $URI1 \ + -w $PASSWD < $LDIFTRANSLUCENTDATA > $NOWHERE 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapadd failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Populating local database..." + +$LDAPADD -D "$TRANSLUCENTROOT" -H $URI2 \ + -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapadd failed ($RC)!" + grep "$FAILURE" $TESTOUT + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Populating local subordinate database..." + +$LDAPADD -D "ou=sub,o=translucent" -H $URI2 -w $PASSWD \ + > $TESTOUT 2>&1 << EOF_ADD1 +dn: ou=sub,o=translucent +objectClass: top +objectClass: organizationalUnit +ou: sub + +dn: ou=users,ou=sub,o=translucent +objectClass: top +objectClass: organizationalUnit +ou: users +EOF_ADD1 + +RC=$? +if test $RC != 0 ; then + echo "ldapadd failed ($RC)!" + grep "$FAILURE" $TESTOUT + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +$LDAPADD -D "ou=sub,o=translucent" -H $URI2 -w $PASSWD \ + < $LDIFSUBUSER > $TESTOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapadd failed ($RC)!" + grep "$FAILURE" $TESTOUT + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Search for subordiante entry..." + +$LDAPSEARCH -H $URI2 -b "o=translucent" "uid=subuser" > $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +$LDIFFILTER < $SEARCHOUT > $SEARCHFLT +$LDIFFILTER < $LDIFSUBUSER > $LDIFFLT +$CMP $SEARCHFLT $LDIFFLT > $CMPOUT + +if test $? != 0 ; then + echo "Comparison failed -- subordinate user not found!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + +echo ">>>>> Test succeeded" + +if test $KILLSERVERS != no ; then + kill -HUP $KILLPIDS + wait +fi + +exit 0 diff --git a/tests/data/regressions/its10248/slapd-local.conf b/tests/data/regressions/its10248/slapd-local.conf new file mode 100644 index 0000000000..053f34fc80 --- /dev/null +++ b/tests/data/regressions/its10248/slapd-local.conf @@ -0,0 +1,77 @@ +# stand-alone slapd config -- for testing (with translucent overlay) +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## Copyright 2004-2021 The OpenLDAP Foundation. +## All rights reserved. +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted only as authorized by the OpenLDAP +## Public License. +## +## A copy of this license is available in the file LICENSE in the +## top-level directory of the distribution or, alternatively, at +## . + +ucdata-path ./ucdata +include @SCHEMADIR@/core.schema +include @SCHEMADIR@/cosine.schema +include @SCHEMADIR@/inetorgperson.schema +include @SCHEMADIR@/openldap.schema +include @SCHEMADIR@/nis.schema + +# +pidfile @TESTDIR@/slapd.2.pid +argsfile @TESTDIR@/slapd.2.args + +#mod#modulepath ../servers/slapd/back-@BACKEND@ +#mod#moduleload back_@BACKEND@.la +#ldapmod#modulepath ../servers/slapd/back-ldap +#ldapmod#moduleload back_ldap.la +#translucentmod#modulepath ../servers/slapd/overlays +#translucentmod#moduleload translucent.la +#monitormod#modulepath ../servers/slapd/back-monitor +#monitormod#moduleload back_monitor.la + +####################################################################### +# database definitions +####################################################################### + +#monitor#database monitor + +database @BACKEND@ +suffix "ou=sub,o=translucent" +rootdn "ou=sub,o=translucent" +rootpw secret +subordinate +#null#bind on +#~null~#directory @TESTDIR@/db.2.a +#indexdb#index objectClass eq +#indexdb#index cn,sn,uid pres,eq,sub +#ndb#dbname db_2 +#ndb#include @DATADIR@/ndb.conf + +database @BACKEND@ +suffix "o=translucent" +rootdn "o=translucent" +rootpw secret +#null#bind on +#~null~#directory @TESTDIR@/db.2.b +#indexdb#index objectClass eq +#indexdb#index cn,sn,uid pres,eq,sub +#ndb#dbname db_3 +#ndb#include @DATADIR@/ndb.conf + +overlay translucent +translucent_local employeeType + +uri @URI1@ +# "lastmod off" is not strictly required because the instance of back-ldap +# added by the translucent overlay sets it off for the underlying database; +# however, the local database needs to have "lastmod off" so it's here as +# a reminder. +lastmod off +acl-bind binddn="uid=binder,o=translucent" credentials="bindtest" + +database config +include @TESTDIR@/configpw.conf diff --git a/tests/data/regressions/its10248/subuser.ldif b/tests/data/regressions/its10248/subuser.ldif new file mode 100644 index 0000000000..b47c3531db --- /dev/null +++ b/tests/data/regressions/its10248/subuser.ldif @@ -0,0 +1,6 @@ +dn: uid=subuser,ou=users,ou=sub,o=translucent +objectClass: inetOrgPerson +uid: subuser +cn: subuser +sn: subuser +