mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
388 lines
9.7 KiB
Bash
Executable File
388 lines
9.7 KiB
Bash
Executable File
#! /bin/sh
|
|
# $OpenLDAP$
|
|
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
##
|
|
## Copyright 1998-2004 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 "running defines.sh"
|
|
. $SRCDIR/scripts/defines.sh
|
|
|
|
echo "### This test requires the sql backend, a properly configured"
|
|
echo "### ODBC and a database poulated with data from the applicable"
|
|
echo "### servers/slapd/back-sql/rdbms_depend/* files."
|
|
echo "### Set SLAPD_USE_SQL to the desired RDBMS to enable this test;"
|
|
echo "### Supported RDBMSes are: mysql,postgres"
|
|
echo "### Set SLAPD_USE_SQLWRITE=yes to enable the write test"
|
|
echo "### See servers/slapd/back-sql/rdbms_depend/README for more "
|
|
echo "### details on how to set up the RDBMS and the ODBC"
|
|
|
|
if test $BACKSQL = "sqlno" ; then
|
|
echo "SQL backend not available, test skipped"
|
|
exit 0
|
|
fi
|
|
|
|
if test $RDBMS = "rdbmsno" ; then
|
|
echo "SQL test not requested, test skipped"
|
|
exit 0
|
|
fi
|
|
|
|
mkdir -p $TESTDIR
|
|
|
|
echo "Starting slapd on TCP/IP port $PORT1..."
|
|
. $CONFFILTER $BACKEND $MONITORDB < $SQLCONF > $CONF1
|
|
$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
|
|
PID=$!
|
|
if test $WAIT != 0 ; then
|
|
echo PID $PID
|
|
read foo
|
|
fi
|
|
KILLPIDS="$PID"
|
|
|
|
echo "Testing SQL backend operations..."
|
|
for i in 0 1 2 3 4 5; do
|
|
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
|
|
'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)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
BASEDN="o=Example,c=RU"
|
|
BINDDN="cn=Mitya Kovalev,${BASEDN}"
|
|
BINDPW="mit"
|
|
echo "Testing bind..."
|
|
$LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapwhoami failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing search..."
|
|
echo "# Testing search..." > $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing exact search..."
|
|
echo "# Testing exact search..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(sn=Kovalev)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing substrings initial search..."
|
|
echo "# Testing substrings initial search..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(cn=m*)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing substrings any search..."
|
|
echo "# Testing substrings any search..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(cn=*m*)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing substrings final search..."
|
|
echo "# Testing substrings final search..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(cn=*v)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing approx search..."
|
|
echo "# Testing approx search..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(sn~=kovalev)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing extensible filter search..."
|
|
echo "# Testing extensible filter search..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(sn:caseExactMatch:=Kovalev)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing attribute inheritance in filter..."
|
|
echo "# Testing attribute inheritance in filter..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(name=example)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing objectClass inheritance in filter..."
|
|
echo "# Testing objectClass inheritance in filter..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(objectClass=person)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing \"auxiliary\" objectClass in filter..."
|
|
echo "# Testing \"auxiliary\" objectClass in filter..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(objectClass=posixAccount)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing hasSubordinates in filter..."
|
|
echo "# Testing hasSubordinates in filter..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(hasSubordinates=TRUE)" >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing attribute inheritance in requested attributes..."
|
|
echo "# Testing attribute inheritance in requested attributes..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"(sn=kovalev)" name >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing objectClass in requested attributes..."
|
|
echo "# Testing objectClass in requested attributes..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
objectClass >> $SEARCHOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapsearch failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing operational attributes in request..."
|
|
echo "# Testing operational attributes in request..." >> $SEARCHOUT
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
'+' >> $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..."
|
|
. $LDIFFILTER < $SQLMASTER > $LDIFFLT
|
|
echo "Comparing filter output..."
|
|
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
|
|
|
|
if test $? != 0 ; then
|
|
echo "comparison failed - SQL master search didn't succeed"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit 1
|
|
fi
|
|
|
|
echo "Testing modify, add, and delete..."
|
|
if test "${RDBMSWRITE}" != "yes"; then
|
|
echo "write test disabled; set SLAPD_USE_SQLWRITE=yes to enable"
|
|
else
|
|
case ${RDBMS} in
|
|
# list here the RDBMSes whose mapping allows writes
|
|
postgres)
|
|
MANAGERDN="cn=Manager,${BASEDN}"
|
|
$LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \
|
|
-h $LOCALHOST -p $PORT1 > \
|
|
$TESTOUT 2>&1 << EOMODS
|
|
version: 1
|
|
|
|
dn: cn=Mitya Kovalev,${BASEDN}
|
|
changetype: modify
|
|
add: telephoneNumber
|
|
telephoneNumber: +1 800 123 4567
|
|
-
|
|
|
|
dn: cn=Pierangelo Masarati,${BASEDN}
|
|
changetype: add
|
|
objectClass: inetOrgPerson
|
|
cn: Pierangelo Masarati
|
|
sn: Masarati
|
|
givenName: Pierangelo
|
|
telephoneNumber: +39 02 XXXX YYYY
|
|
telephoneNumber: +39 02 XXXX ZZZZ
|
|
|
|
dn: cn=Pierangelo Masarati,${BASEDN}
|
|
changetype: modify
|
|
delete: telephoneNumber
|
|
telephoneNumber: +39 02 XXXX YYYY
|
|
-
|
|
add: telephoneNumber
|
|
telephoneNumber: +39 333 ZZZ 1234
|
|
-
|
|
|
|
dn: cn=Torvlobnor Puzdoy,${BASEDN}
|
|
changetype: delete
|
|
|
|
dn: o=An Org,${BASEDN}
|
|
changetype: add
|
|
objectClass: organization
|
|
o: An Org
|
|
|
|
dn: o=An Org,${BASEDN}
|
|
changetype: modrdn
|
|
newrdn: o=Another Org
|
|
deleteoldrdn: 1
|
|
|
|
dn: documentTitle=book1,${BASEDN}
|
|
changetype: modify
|
|
add: documentAuthor
|
|
documentAuthor: cn=Pierangelo Masarati,${BASEDN}
|
|
-
|
|
|
|
dn: documentTitle=book2,${BASEDN}
|
|
changetype: modify
|
|
add: documentAuthor
|
|
documentAuthor: cn=Pierangelo Masarati,${BASEDN}
|
|
-
|
|
|
|
EOMODS
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapmodify failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
NEWPW="newsecret"
|
|
echo "Testing passwd change..."
|
|
$LDAPPASSWD -h $LOCALHOST -p $PORT1 \
|
|
-D "${BINDDN}" -w ${BINDPW} -s ${NEWPW} \
|
|
"$BINDDN" >> $TESTOUT 2>&1
|
|
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldappasswd failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Testing bind with new secret..."
|
|
$LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $NEWPW
|
|
RC=$?
|
|
if test $RC != 0 ; then
|
|
echo "ldapwhoami failed ($RC)!"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit $RC
|
|
fi
|
|
|
|
echo "Using ldapsearch to retrieve all the entries..."
|
|
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
|
|
"objectClass=*" > $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 modified ldif..."
|
|
. $LDIFFILTER < $SQLMODS > $LDIFFLT
|
|
echo "Comparing filter output..."
|
|
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
|
|
|
|
if test $? != 0 ; then
|
|
echo "comparison failed - SQL mods search didn't succeed"
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
*)
|
|
echo "apparently ${RDBMS} does not support writes; skipping..."
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
echo ">>>>> Test succeeded"
|
|
exit 0
|