test for back-sql; disbled by default, requires some preparation (essentially the RDBMS and the ODBC) before being run

This commit is contained in:
Pierangelo Masarati 2004-08-20 14:26:18 +00:00
parent 3052ce6ffd
commit fe6ac06ef3
2 changed files with 425 additions and 3 deletions

View File

@ -1,18 +1,22 @@
# refldap://localhost/o=example,c=ru??sub
# Testing search...
# refldap://localhost/o=Example,c=RU??sub
dn: cn=Torvlobnor Puzdoy,o=Example,c=RU
objectClass: inetOrgPerson
cn: Torvlobnor Puzdoy
telephoneNumber: 545-4563
sn: Torvlobnor Puzdoy
givenName: Torvlobnor
sn: Puzdoy
documentIdentifier: documentTitle=book1,o=Example,c=RU
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
cn: Mitya Kovalev
telephoneNumber: 332-2334
telephoneNumber: 222-3234
sn: Mitya Kovalev
givenName: Mitya
sn: Kovalev
documentIdentifier: documentTitle=book1,o=Example,c=RU
documentIdentifier: documentTitle=book2,o=Example,c=RU
@ -33,3 +37,126 @@ dn: o=Example,c=RU
objectClass: organization
o: Example
# Testing exact search...
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
cn: Mitya Kovalev
telephoneNumber: 332-2334
telephoneNumber: 222-3234
givenName: Mitya
sn: Kovalev
documentIdentifier: documentTitle=book1,o=Example,c=RU
documentIdentifier: documentTitle=book2,o=Example,c=RU
# Testing substrings initial search...
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
cn: Mitya Kovalev
telephoneNumber: 332-2334
telephoneNumber: 222-3234
givenName: Mitya
sn: Kovalev
documentIdentifier: documentTitle=book1,o=Example,c=RU
documentIdentifier: documentTitle=book2,o=Example,c=RU
# Testing substrings any search...
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
cn: Mitya Kovalev
telephoneNumber: 332-2334
telephoneNumber: 222-3234
givenName: Mitya
sn: Kovalev
documentIdentifier: documentTitle=book1,o=Example,c=RU
documentIdentifier: documentTitle=book2,o=Example,c=RU
# Testing substrings final search...
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
cn: Mitya Kovalev
telephoneNumber: 332-2334
telephoneNumber: 222-3234
givenName: Mitya
sn: Kovalev
documentIdentifier: documentTitle=book1,o=Example,c=RU
documentIdentifier: documentTitle=book2,o=Example,c=RU
# Testing approx search...
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
cn: Mitya Kovalev
telephoneNumber: 332-2334
telephoneNumber: 222-3234
givenName: Mitya
sn: Kovalev
documentIdentifier: documentTitle=book1,o=Example,c=RU
documentIdentifier: documentTitle=book2,o=Example,c=RU
# Testing attribute inheritance in filter...
dn: o=Example,c=RU
objectClass: organization
o: Example
# Testing objectClass inheritance in filter...
# refldap://localhost/o=Example,c=RU??sub
dn: cn=Torvlobnor Puzdoy,o=Example,c=RU
objectClass: inetOrgPerson
cn: Torvlobnor Puzdoy
telephoneNumber: 545-4563
givenName: Torvlobnor
sn: Puzdoy
documentIdentifier: documentTitle=book1,o=Example,c=RU
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
cn: Mitya Kovalev
telephoneNumber: 332-2334
telephoneNumber: 222-3234
givenName: Mitya
sn: Kovalev
documentIdentifier: documentTitle=book1,o=Example,c=RU
documentIdentifier: documentTitle=book2,o=Example,c=RU
# Testing "auxiliary" objectClass in filter...
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
cn: Mitya Kovalev
telephoneNumber: 332-2334
telephoneNumber: 222-3234
givenName: Mitya
sn: Kovalev
documentIdentifier: documentTitle=book1,o=Example,c=RU
documentIdentifier: documentTitle=book2,o=Example,c=RU
# Testing attribute inheritance in requested attributes...
dn: cn=Mitya Kovalev,o=Example,c=RU
cn: Mitya Kovalev
givenName: Mitya
sn: Kovalev
# Testing objectClass in requested attributes...
Additional information: bad_referral object
dn: cn=Torvlobnor Puzdoy,o=Example,c=RU
objectClass: inetOrgPerson
dn: cn=Mitya Kovalev,o=Example,c=RU
objectClass: inetOrgPerson
objectClass: posixAccount
dn: documentTitle=book2,o=Example,c=RU
objectClass: document
dn: documentTitle=book1,o=Example,c=RU
objectClass: document
dn: o=Example,c=RU
objectClass: organization

295
tests/scripts/test031-sql Executable file
View File

@ -0,0 +1,295 @@
#! /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"
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 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 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 "Filtering ldapsearch results..."
. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
echo "Filtering original ldif used to create database..."
. $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..."
case ${RDBMS} in
# list here the RDBMSes whose mapping allows writes
postgres)
MANAGERDN="cn=Manager,${BASEDN}"
$LDAPMODIFY -v -D "$MANAGERDN" -w $PASSWD \
-h $LOCALHOST -p $PORT1 > \
$TESTOUT 2>&1 << EOMODS
version: 1
# LEADING COMMENT AND WHITE SPACE
dn: cn=Mitya Kovalev,${BASEDN}
# EMBEDDED COMMENT
changetype: modify
add: telephoneNumber
telephoneNumber: +1 800 123 4567
-
dn: cn=Pierangelo Masarati,${BASEDN}
changetype: add
# EMBEDDED COMMENT
CONTINUED
objectClass: inetOrgPerson
cn: Pierangelo Masarati
sn: Masarati
givenName: Pierangelo
telephoneNumber: +39 02 XXXX YYYY
dn: cn=Torvlobnor Puzdoy,${BASEDN}
changetype: delete
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify 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 original ldif used to create database..."
. $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
test $KILLSERVERS != no && kill -HUP $KILLPIDS
echo ">>>>> Test succeeded"
exit 0