From: Pierangelo Masarati Date: Tue, 24 Aug 2004 09:26:39 +0000 (+0000) Subject: rework SQL tests invocation; improve all tests X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~662 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b68129fc39b67c9194dc7bef1039e680d572c71d;p=openldap rework SQL tests invocation; improve all tests --- diff --git a/tests/Makefile.in b/tests/Makefile.in index 642f394465..c237d6daa1 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -19,11 +19,13 @@ SUBDIRS= progs BUILD_BDB=@BUILD_BDB@ BUILD_HDB=@BUILD_HDB@ BUILD_LDBM=@BUILD_LDBM@ +BUILD_SQL=@BUILD_SQL@ test tests: @$(MAKE) bdb @$(MAKE) hdb @$(MAKE) ldbm + @$(MAKE) sql bdb test-bdb: bdb-$(BUILD_BDB) bdb-no: @@ -49,6 +51,14 @@ ldbm-yes ldbm-mod: FORCE @echo "Initiating LDAP tests for LDBM..." @$(RUN) -b ldbm all +sql test-sql: sql-$(BUILD_SQL) +sql-no: + @echo "run configure with --enable-sql" + +sql-yes sql-mod: FORCE + @echo "Initiating LDAP tests for SQL..." + @$(RUN) -b sql sql-all + clean-local: FORCE -$(RM) -r testrun *leak *gmon *core diff --git a/tests/README b/tests/README index 2ede0e995f..5f4e307d6a 100644 --- a/tests/README +++ b/tests/README @@ -5,6 +5,9 @@ verify basic functionality of the LDAP libraries, slapd, and slurpd. To run BDB tests, type "make bdb". To run HDB tests, type "make hdb". To run LDBM tests, type "make ldbm". + To run SQL tests, define SLAPD_USE_SQL= and type + "make sql"; define SLAPD_USE_SQLWRITE=yes + to enable write tests as well. The test scripts depends on a number of tools commonly available on Unix (and Unix-like) systems. While attempts have been made to make diff --git a/tests/data/slapd-sql.conf b/tests/data/slapd-sql.conf index 13356523fe..075960dfce 100644 --- a/tests/data/slapd-sql.conf +++ b/tests/data/slapd-sql.conf @@ -44,8 +44,8 @@ access to * ####################################################################### database sql -suffix "o=Example,c=RU" -rootdn "cn=Manager,o=Example,c=RU" +suffix "dc=example,dc=com" +rootdn "cn=Manager,dc=example,dc=com" rootpw secret dbname example dbuser manager diff --git a/tests/data/sql-read.out b/tests/data/sql-read.out new file mode 100644 index 0000000000..03aad0580a --- /dev/null +++ b/tests/data/sql-read.out @@ -0,0 +1,339 @@ +# Testing search... +dn: documentTitle=book1,dc=example,dc=com +objectClass: document +description: abstract1 +documentTitle: book1 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentAuthor: cn=Torvlobnor Puzdoy,dc=example,dc=com +documentIdentifier: document 1 + +dn: documentTitle=book2,dc=example,dc=com +objectClass: document +description: abstract2 +documentTitle: book2 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentIdentifier: document 2 + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example +dc: example + +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +dn: cn=Torvlobnor Puzdoy,dc=example,dc=com +objectClass: inetOrgPerson +cn: Torvlobnor Puzdoy +sn: Puzdoy +seeAlso: documentTitle=book1,dc=example,dc=com +givenName: Torvlobnor +telephoneNumber: 545-4563 + +# refldap://localhost/dc=example,dc=com??sub + +# Testing exact search... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing substrings initial search... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing substrings any search... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing substrings final search... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing approx search... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing extensible filter search... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing search for telephoneNumber... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing AND search... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing AND search on objectClass... +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example +dc: example + +# Testing OR search... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +# Testing OR search on objectClass... +dn: documentTitle=book1,dc=example,dc=com +objectClass: document +description: abstract1 +documentTitle: book1 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentAuthor: cn=Torvlobnor Puzdoy,dc=example,dc=com +documentIdentifier: document 1 + +dn: documentTitle=book2,dc=example,dc=com +objectClass: document +description: abstract2 +documentTitle: book2 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentIdentifier: document 2 + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example +dc: example + +# Testing NOT search... +dn: cn=Torvlobnor Puzdoy,dc=example,dc=com +objectClass: inetOrgPerson +cn: Torvlobnor Puzdoy +sn: Puzdoy +seeAlso: documentTitle=book1,dc=example,dc=com +givenName: Torvlobnor +telephoneNumber: 545-4563 + +# refldap://localhost/dc=example,dc=com??sub + +# Testing NOT search on objectClass... +dn: documentTitle=book1,dc=example,dc=com +objectClass: document +description: abstract1 +documentTitle: book1 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentAuthor: cn=Torvlobnor Puzdoy,dc=example,dc=com +documentIdentifier: document 1 + +dn: documentTitle=book2,dc=example,dc=com +objectClass: document +description: abstract2 +documentTitle: book2 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentIdentifier: document 2 + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example +dc: example + +# Testing NOT search on "auxiliary" objectClass... +dn: documentTitle=book1,dc=example,dc=com +objectClass: document +description: abstract1 +documentTitle: book1 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentAuthor: cn=Torvlobnor Puzdoy,dc=example,dc=com +documentIdentifier: document 1 + +dn: documentTitle=book2,dc=example,dc=com +objectClass: document +description: abstract2 +documentTitle: book2 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentIdentifier: document 2 + +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +dn: cn=Torvlobnor Puzdoy,dc=example,dc=com +objectClass: inetOrgPerson +cn: Torvlobnor Puzdoy +sn: Puzdoy +seeAlso: documentTitle=book1,dc=example,dc=com +givenName: Torvlobnor +telephoneNumber: 545-4563 + +# refldap://localhost/dc=example,dc=com??sub + +# Testing NOT search on sn... +# Testing attribute inheritance in filter... +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example +dc: example + +# Testing objectClass inheritance in filter... +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book1,dc=example,dc=com +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 + +dn: cn=Torvlobnor Puzdoy,dc=example,dc=com +objectClass: inetOrgPerson +cn: Torvlobnor Puzdoy +sn: Puzdoy +seeAlso: documentTitle=book1,dc=example,dc=com +givenName: Torvlobnor +telephoneNumber: 545-4563 + +# refldap://localhost/dc=example,dc=com??sub + +# Testing "auxiliary" objectClass in filter... +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example +dc: example + +# refldap://localhost/dc=example,dc=com??sub + +# Testing hasSubordinates in filter... +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example +dc: example + +# refldap://localhost/dc=example,dc=com??sub + +# Testing attribute inheritance in requested attributes... +dn: cn=Mitya Kovalev,dc=example,dc=com +cn: Mitya Kovalev +sn: Kovalev +givenName: Mitya + +# Testing objectClass in requested attributes... +dn: documentTitle=book1,dc=example,dc=com +objectClass: document + +dn: documentTitle=book2,dc=example,dc=com +objectClass: document + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject + +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson + +dn: cn=Torvlobnor Puzdoy,dc=example,dc=com +objectClass: inetOrgPerson + +# refldap://localhost/dc=example,dc=com??sub + +# Testing operational attributes in request... +dn: documentTitle=book1,dc=example,dc=com +structuralObjectClass: document +subschemaSubentry: cn=Subschema +hasSubordinates: FALSE + +dn: documentTitle=book2,dc=example,dc=com +structuralObjectClass: document +subschemaSubentry: cn=Subschema +hasSubordinates: FALSE + +dn: dc=example,dc=com +structuralObjectClass: organization +subschemaSubentry: cn=Subschema +hasSubordinates: TRUE + +dn: cn=Mitya Kovalev,dc=example,dc=com +structuralObjectClass: inetOrgPerson +subschemaSubentry: cn=Subschema +hasSubordinates: FALSE + +dn: cn=Torvlobnor Puzdoy,dc=example,dc=com +structuralObjectClass: inetOrgPerson +subschemaSubentry: cn=Subschema +hasSubordinates: FALSE + +# refldap://localhost/dc=example,dc=com??sub + diff --git a/tests/data/sql-write.out b/tests/data/sql-write.out new file mode 100644 index 0000000000..5fea109892 --- /dev/null +++ b/tests/data/sql-write.out @@ -0,0 +1,64 @@ +dn: documentTitle=book2,dc=example,dc=com +objectClass: document +description: abstract2 +documentTitle: book2 +documentAuthor: cn=Mitya Kovalev,dc=example,dc=com +documentAuthor: cn=Lev Tolstoij,dc=example,dc=com +documentIdentifier: document 2 + +dn: documentTitle=War and Peace,dc=example,dc=com +objectClass: document +description: Historical novel +documentTitle: War and Peace +documentAuthor: cn=Lev Tolstoij,dc=example,dc=com +documentIdentifier: document 3 + +dn: dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: Example +dc: example + +dn: dc=subnet,dc=example,dc=com +objectClass: organization +objectClass: dcObject +o: SubNet +dc: subnet + +dn: o=Another Org,dc=example,dc=com +objectClass: organization +o: Another Org + +dn: cn=Mitya Kovalev,dc=example,dc=com +objectClass: inetOrgPerson +cn: Mitya Kovalev +sn: Kovalev +seeAlso: documentTitle=book2,dc=example,dc=com +givenName: Mitya +telephoneNumber: 332-2334 +telephoneNumber: 222-3234 +telephoneNumber: +1 800 123 4567 + +dn: cn=Lev Tolstoij,dc=example,dc=com +objectClass: inetOrgPerson +cn: Lev Tolstoij +sn: Tolstoij +seeAlso: documentTitle=book2,dc=example,dc=com +seeAlso: documentTitle=War and Peace,dc=example,dc=com +givenName: Lev +telephoneNumber: +39 02 XXXX ZZZZ +telephoneNumber: +39 333 ZZZ 1234 + +dn: cn=Some One,dc=example,dc=com +objectClass: inetOrgPerson +objectClass: simpleSecurityObject +cn: Some One +sn: One +givenName: Some + +dn: cn=SubNet User,dc=subnet,dc=example,dc=com +objectClass: inetOrgPerson +cn: SubNet User +sn: User +givenName: SubNet + diff --git a/tests/data/sqlmaster.out b/tests/data/sqlmaster.out deleted file mode 100644 index 578b310bc1..0000000000 --- a/tests/data/sqlmaster.out +++ /dev/null @@ -1,212 +0,0 @@ -# Testing search... -dn: documentTitle=book1,o=Example,c=RU -objectClass: document -description: abstract1 -documentTitle: book1 -documentAuthor: cn=Mitya Kovalev,o=Example,c=RU -documentAuthor: cn=Torvlobnor Puzdoy,o=Example,c=RU -documentIdentifier: document 1 - -dn: documentTitle=book2,o=Example,c=RU -objectClass: document -description: abstract2 -documentTitle: book2 -documentAuthor: cn=Mitya Kovalev,o=Example,c=RU -documentIdentifier: document 2 - -dn: o=Example,c=RU -objectClass: organization -o: Example - -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -dn: cn=Torvlobnor Puzdoy,o=Example,c=RU -objectClass: inetOrgPerson -cn: Torvlobnor Puzdoy -sn: Puzdoy -seeAlso: documentTitle=book1,o=Example,c=RU -givenName: Torvlobnor -telephoneNumber: 545-4563 - -# refldap://localhost/o=Example,c=RU??sub - -# Testing exact search... -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -# Testing substrings initial search... -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -# Testing substrings any search... -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -# Testing substrings final search... -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -# Testing approx search... -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -# Testing extensible filter search... -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -# Testing attribute inheritance in filter... -dn: o=Example,c=RU -objectClass: organization -o: Example - -# Testing objectClass inheritance in filter... -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -dn: cn=Torvlobnor Puzdoy,o=Example,c=RU -objectClass: inetOrgPerson -cn: Torvlobnor Puzdoy -sn: Puzdoy -seeAlso: documentTitle=book1,o=Example,c=RU -givenName: Torvlobnor -telephoneNumber: 545-4563 - -# refldap://localhost/o=Example,c=RU??sub - -# Testing "auxiliary" objectClass in filter... -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 - -# Testing hasSubordinates in filter... -dn: o=Example,c=RU -objectClass: organization -o: Example - -# refldap://localhost/o=Example,c=RU??sub - -# Testing attribute inheritance in requested attributes... -dn: cn=Mitya Kovalev,o=Example,c=RU -cn: Mitya Kovalev -sn: Kovalev -givenName: Mitya - -# Testing objectClass in requested attributes... -dn: documentTitle=book1,o=Example,c=RU -objectClass: document - -dn: documentTitle=book2,o=Example,c=RU -objectClass: document - -dn: o=Example,c=RU -objectClass: organization - -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount - -dn: cn=Torvlobnor Puzdoy,o=Example,c=RU -objectClass: inetOrgPerson - -# refldap://localhost/o=Example,c=RU??sub - -# Testing operational attributes in request... -dn: documentTitle=book1,o=Example,c=RU -structuralObjectClass: document -subschemaSubentry: cn=Subschema -hasSubordinates: FALSE - -dn: documentTitle=book2,o=Example,c=RU -structuralObjectClass: document -subschemaSubentry: cn=Subschema -hasSubordinates: FALSE - -dn: o=Example,c=RU -structuralObjectClass: organization -subschemaSubentry: cn=Subschema -hasSubordinates: TRUE - -dn: cn=Mitya Kovalev,o=Example,c=RU -structuralObjectClass: inetOrgPerson -subschemaSubentry: cn=Subschema -hasSubordinates: FALSE - -dn: cn=Torvlobnor Puzdoy,o=Example,c=RU -structuralObjectClass: inetOrgPerson -subschemaSubentry: cn=Subschema -hasSubordinates: FALSE - -# refldap://localhost/o=Example,c=RU??sub - diff --git a/tests/data/sqlmods.out b/tests/data/sqlmods.out deleted file mode 100644 index e4a7cdf4eb..0000000000 --- a/tests/data/sqlmods.out +++ /dev/null @@ -1,48 +0,0 @@ -dn: documentTitle=book1,o=Example,c=RU -objectClass: document -description: abstract1 -documentTitle: book1 -documentAuthor: cn=Mitya Kovalev,o=Example,c=RU -documentAuthor: cn=Pierangelo Masarati,o=Example,c=RU -documentIdentifier: document 1 - -dn: documentTitle=book2,o=Example,c=RU -objectClass: document -description: abstract2 -documentTitle: book2 -documentAuthor: cn=Mitya Kovalev,o=Example,c=RU -documentAuthor: cn=Pierangelo Masarati,o=Example,c=RU -documentIdentifier: document 2 - -dn: o=Example,c=RU -objectClass: organization -o: Example - -dn: o=Another Org,o=Example,c=RU -objectClass: organization -o: Another Org - -dn: cn=Mitya Kovalev,o=Example,c=RU -objectClass: inetOrgPerson -objectClass: posixAccount -cn: Mitya Kovalev -sn: Kovalev -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Mitya -telephoneNumber: 332-2334 -telephoneNumber: 222-3234 -telephoneNumber: +1 800 123 4567 - -# refldap://localhost/o=Example,c=RU??sub - -dn: cn=Pierangelo Masarati,o=Example,c=RU -objectClass: inetOrgPerson -cn: Pierangelo Masarati -sn: Masarati -seeAlso: documentTitle=book1,o=Example,c=RU -seeAlso: documentTitle=book2,o=Example,c=RU -givenName: Pierangelo -telephoneNumber: +39 02 XXXX ZZZZ -telephoneNumber: +39 333 ZZZ 1234 - diff --git a/tests/scripts/all b/tests/scripts/all index bd307fd894..54f9fafc5e 100755 --- a/tests/scripts/all +++ b/tests/scripts/all @@ -16,6 +16,7 @@ SHTOOL="$SRCDIR/../build/shtool" TB=`$SHTOOL echo -e "%B"` TN=`$SHTOOL echo -e "%b"` +SLEEPTIME=10 echo ">>>>> Executing all LDAP tests for $BACKEND" @@ -37,7 +38,7 @@ for CMD in $SRCDIR/scripts/test*; do exit $RC fi - echo ">>>>> waiting 10 seconds for things to exit" - sleep 10 + echo ">>>>> waiting $SLEEPTIME seconds for things to exit" + sleep $SLEEPTIME echo "" done diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index a1212d6b27..2a4aca3887 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -222,8 +222,8 @@ IDASSERTOUT=$DATADIR/idassert.out LDAPGLUEOUT=$DATADIR/ldapglue.out LDAPGLUEANONYMOUSOUT=$DATADIR/ldapglueanonymous.out RELAYOUT=$DATADIR/relay.out -SQLMASTER=$DATADIR/sqlmaster.out -SQLMODS=$DATADIR/sqlmods.out +SQLREAD=$DATADIR/sql-read.out +SQLWRITE=$DATADIR/sql-write.out # Just in case we linked the binaries dynamically LD_LIBRARY_PATH=`pwd`/../libraries:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH diff --git a/tests/scripts/sql-all b/tests/scripts/sql-all new file mode 100755 index 0000000000..becd8f0b8a --- /dev/null +++ b/tests/scripts/sql-all @@ -0,0 +1,53 @@ +#! /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 +## . + +SHTOOL="$SRCDIR/../build/shtool" +TB=`$SHTOOL echo -e "%B"` +TN=`$SHTOOL echo -e "%b"` +SLEEPTIME=10 + +echo "### SQL tests require 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 tests" +echo "### See servers/slapd/back-sql/rdbms_depend/README for more " +echo "### details on how to set up the RDBMS and the ODBC" + +echo ">>>>> Executing all LDAP tests for $BACKEND" + +for CMD in $SRCDIR/scripts/sql-test*; do + # remove cruft from prior test + if test $PRESERVE = yes ; then + /bin/rm -rf testrun/db.* + else + /bin/rm -rf testrun + fi + + echo ">>>>> Starting ${TB}`basename $CMD`${TN} ..." + $CMD + RC=$? + if test $RC -eq 0 ; then + echo ">>>>> $CMD completed ${TB}OK${TN}." + else + echo ">>>>> $CMD ${TB}failed${TN} (exit $RC)" + exit $RC + fi + + echo ">>>>> waiting $SLEEPTIME seconds for things to exit" + sleep $SLEEPTIME + echo "" +done diff --git a/tests/scripts/sql-test000-read b/tests/scripts/sql-test000-read new file mode 100755 index 0000000000..d9ea0b18c4 --- /dev/null +++ b/tests/scripts/sql-test000-read @@ -0,0 +1,429 @@ +#! /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 + +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 read 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="dc=example,dc=com" +BINDDN="cn=Mitya Kovalev,${BASEDN}" +BINDPW="mit" +echo -n "Testing correct 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 -n "Testing incorrect bind (should fail)... " +$LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w "XXX" +RC=$? +if test $RC == 0 ; then + echo "ldapwhoami should have 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 search for telephoneNumber..." +echo "# Testing search for telephoneNumber..." >> $SEARCHOUT +$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ + "(telephoneNumber=3322334)" >> $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing AND search..." +echo "# Testing AND search..." >> $SEARCHOUT +$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ + "(&(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing AND search on objectClass..." +echo "# Testing AND search on objectClass..." >> $SEARCHOUT +$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ + "(&(objectClass=organization)(objectClass=dcObject))" >> $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing OR search..." +echo "# Testing OR search..." >> $SEARCHOUT +$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ + "(|(sn=kovalev)(givenName=mitya))" >> $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing OR search on objectClass..." +echo "# Testing OR search on objectClass..." >> $SEARCHOUT +$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ + "(|(objectClass=document)(objectClass=organization))" >> $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing NOT search..." +echo "# Testing NOT 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 NOT search on objectClass..." +echo "# Testing NOT search on objectClass..." >> $SEARCHOUT +$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ + '(!(objectClass=inetOrgPerson))' >> $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +echo "Testing NOT search on \"auxiliary\" objectClass..." +echo "# Testing NOT search on \"auxiliary\" objectClass..." >> $SEARCHOUT +$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ + '(!(objectClass=dcObject))' >> $SEARCHOUT 2>&1 + +RC=$? +if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC +fi + +#### Needs work... +echo "Testing NOT presence search... (disabled)" +###echo "# Testing NOT search on sn..." >> $SEARCHOUT +###$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ +### '(!(sn=*))' >> $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=dcObject)" >> $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 -n "Testing compare (should be TRUE)... " +$LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \ + "sn:kovalev" >> $TESTOUT 2>&1 + +RC=$? +case $RC in +6) + echo "TRUE" + ;; +5) echo "FALSE!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + ;; +*) echo "failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + ;; +esac + +echo -n "Testing compare (should be FALSE)... " +$LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \ + "cn:foobar" >> $TESTOUT 2>&1 + +RC=$? +case $RC in +6) + echo "TRUE!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + ;; +5) echo "FALSE" + ;; +*) echo "failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + ;; +esac + +echo -n "Testing compare (should be UNDEFINED)... " +$LDAPCOMPARE -h $LOCALHOST -p $PORT1 "$BINDDN" \ + "o:example" >> $TESTOUT 2>&1 + +RC=$? +case $RC in +6) + echo "TRUE!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + ;; +5) echo "FALSE!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + ;; +*) echo "failed ($RC)" + ;; +esac + +echo "Filtering ldapsearch results..." +. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT +echo "Filtering original ldif..." +. $LDIFFILTER < $SQLREAD > $LDIFFLT +echo "Comparing filter output..." +$CMP $SEARCHFLT $LDIFFLT > $CMPOUT + +if test $? != 0 ; then + echo "comparison failed - SQL search didn't succeed" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 +fi + +test $KILLSERVERS != no && kill -HUP $KILLPIDS + +echo ">>>>> Test succeeded" +exit 0 diff --git a/tests/scripts/sql-test900-write b/tests/scripts/sql-test900-write new file mode 100755 index 0000000000..b9b24d27d2 --- /dev/null +++ b/tests/scripts/sql-test900-write @@ -0,0 +1,322 @@ +#! /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 + +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 + +if test "${RDBMSWRITE}" != "yes"; then + echo "write test disabled for ${RDBMS}; set SLAPD_USE_SQLWRITE=yes to enable" + 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 write 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="dc=example,dc=com" +case ${RDBMS} in + # list here the RDBMSes whose mapping allows writes +postgres) + MANAGERDN="cn=Manager,${BASEDN}" + echo "Testing add..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 > \ + $TESTOUT 2>&1 << EOMODS +version: 1 + +# Adding an organization... +dn: o=An Org,${BASEDN} +changetype: add +objectClass: organization +o: An Org + +# Adding an organization with an "auxiliary" objectClass.. +dn: dc=subnet,${BASEDN} +changetype: add +objectClass: organization +objectClass: dcObject +o: SubNet +dc: subnet + +# Adding a person... +dn: cn=Lev Tolstoij,${BASEDN} +changetype: add +objectClass: inetOrgPerson +cn: Lev Tolstoij +sn: Tolstoij +givenName: Lev +telephoneNumber: +39 02 XXXX YYYY +telephoneNumber: +39 02 XXXX ZZZZ + +# Adding a person with an "auxiliary" objectClass... +dn: cn=Some One,${BASEDN} +changetype: add +objectClass: inetOrgPerson +objectClass: simpleSecurityObject +cn: Some One +sn: One +givenName: Some +telephoneNumber: +1 800 900 1234 +telephoneNumber: +1 800 900 1235 +userPassword: someone + +# Adding a person in another subtree... +dn: cn=SubNet User,dc=subnet,${BASEDN} +changetype: add +objectClass: inetOrgPerson +cn: SubNet User +sn: User +givenName: SubNet + +# Adding a document... +dn: documentTitle=War and Peace,${BASEDN} +changetype: add +objectClass: document +description: Historical novel +documentTitle: War and Peace +documentAuthor: cn=Lev Tolstoij,dc=example,dc=com +documentIdentifier: document 3 + +EOMODS + + RC=$? + if test $RC != 0 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + echo "Testing modify..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 > \ + $TESTOUT 2>&1 << EOMODS +version: 1 + +# Deleting all telephone numbers... +dn: cn=Some One,${BASEDN} +changetype: modify +delete: telephoneNumber +- + +# Adding a telephone number... +dn: cn=Mitya Kovalev,${BASEDN} +changetype: modify +add: telephoneNumber +telephoneNumber: +1 800 123 4567 +- + +# Deleting a specific telephone number and adding a new one... +dn: cn=Lev Tolstoij,${BASEDN} +changetype: modify +delete: telephoneNumber +telephoneNumber: +39 02 XXXX YYYY +- +add: telephoneNumber +telephoneNumber: +39 333 ZZZ 1234 +- + +# Adding an author to a document... +dn: documentTitle=book1,${BASEDN} +changetype: modify +add: documentAuthor +documentAuthor: cn=Lev Tolstoij,${BASEDN} +- + +# Adding an author to another document... +dn: documentTitle=book2,${BASEDN} +changetype: modify +add: documentAuthor +documentAuthor: cn=Lev Tolstoij,${BASEDN} +- + +# Adding an "auxiliary" objectClass... +dn: cn=Mitya Kovalev,${BASEDN} +changetype: modify +add: objectClass +objectClass: simpleSecurityObject +- + +# Deleting an "auxiliary" objectClass... +dn: cn=Some One,${BASEDN} +changetype: modify +delete: objectClass +objectClass: simpleSecurityObject +- +delete: userPassword +- + +EOMODS + + RC=$? + if test $RC != 0 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + echo "Testing delete..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 > \ + $TESTOUT 2>&1 << EOMODS +version: 1 + +# Deleting a person... +dn: cn=Torvlobnor Puzdoy,${BASEDN} +changetype: delete + +# Deleting a document... +dn: documentTitle=book1,dc=example,dc=com +changetype: delete + +# Deleting a person with an "auxiliary" objectClass... +dn: cn=Akakiy Zinberstein,dc=example,dc=com +changetype: delete + +EOMODS + + RC=$? + if test $RC != 0 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + echo "Testing rename..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 > \ + $TESTOUT 2>&1 << EOMODS +version: 1 + +# Renaming an organization +dn: o=An Org,${BASEDN} +changetype: modrdn +newrdn: o=Another Org +deleteoldrdn: 1 + +EOMODS + + RC=$? + if test $RC != 0 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + BINDDN="cn=Mitya Kovalev,${BASEDN}" + BINDPW="mit" + 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 -n "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 + + BINDDN="cn=Some One,${BASEDN}" + BINDPW="someone" + echo -n "Testing bind with newly added user... " + $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 "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 < $SQLWRITE > $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 + diff --git a/tests/scripts/test031-sql b/tests/scripts/test031-sql deleted file mode 100755 index 174a77ffef..0000000000 --- a/tests/scripts/test031-sql +++ /dev/null @@ -1,387 +0,0 @@ -#! /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" -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