ITS#10248 Regression test script

This commit is contained in:
Michael Nolta 2024-09-03 11:38:48 +01:00 committed by Quanah Gibson-Mount
parent a6f6c2f8bf
commit 12eeb27d5b
3 changed files with 288 additions and 0 deletions
tests/data/regressions/its10248

@ -0,0 +1,205 @@
#! /bin/sh
# $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
## 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
## <http://www.OpenLDAP.org/license.html>.
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

@ -0,0 +1,77 @@
# stand-alone slapd config -- for testing (with translucent overlay)
# $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
## 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
## <http://www.OpenLDAP.org/license.html>.
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

@ -0,0 +1,6 @@
dn: uid=subuser,ou=users,ou=sub,o=translucent
objectClass: inetOrgPerson
uid: subuser
cn: subuser
sn: subuser