From: Pierangelo Masarati Date: Fri, 20 Aug 2004 14:26:18 +0000 (+0000) Subject: test for back-sql; disbled by default, requires some preparation (essentially the... X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~681 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fe6ac06ef34e0a7f2e0a67c02824beb35a5fda7f;p=openldap test for back-sql; disbled by default, requires some preparation (essentially the RDBMS and the ODBC) before being run --- diff --git a/tests/data/sqlmaster.out b/tests/data/sqlmaster.out index 637fac5ee5..bc118b2ff7 100644 --- a/tests/data/sqlmaster.out +++ b/tests/data/sqlmaster.out @@ -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 + diff --git a/tests/scripts/test031-sql b/tests/scripts/test031-sql new file mode 100755 index 0000000000..80aab28768 --- /dev/null +++ b/tests/scripts/test031-sql @@ -0,0 +1,295 @@ +#! /bin/sh +# $OpenLDAP$ +## This work is part of OpenLDAP Software . +## +## 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 +## . + +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