X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tests%2Fscripts%2Fsql-test900-write;h=eb860414b5e84a16556f63fde1b8376f6849885a;hb=4b73fa4c237aae65ef15a3e448fc33a9f47d0b8e;hp=b9b24d27d2fa9fc9c653b1ef435657d19b830b01;hpb=b68129fc39b67c9194dc7bef1039e680d572c71d;p=openldap diff --git a/tests/scripts/sql-test900-write b/tests/scripts/sql-test900-write index b9b24d27d2..eb860414b5 100755 --- a/tests/scripts/sql-test900-write +++ b/tests/scripts/sql-test900-write @@ -2,7 +2,7 @@ # $OpenLDAP$ ## This work is part of OpenLDAP Software . ## -## Copyright 1998-2004 The OpenLDAP Foundation. +## Copyright 1998-2012 The OpenLDAP Foundation. ## All rights reserved. ## ## Redistribution and use in source and binary forms, with or without @@ -61,15 +61,29 @@ if test $RC != 0 ; then exit $RC fi +cat /dev/null > $SEARCHOUT + BASEDN="dc=example,dc=com" + +echo "Using ldapsearch to retrieve all the entries..." +echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT +$LDAPSEARCH -S "" -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 + case ${RDBMS} in # list here the RDBMSes whose mapping allows writes -postgres) +pgsql|ibmdb2) MANAGERDN="cn=Manager,${BASEDN}" echo "Testing add..." $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ - -h $LOCALHOST -p $PORT1 > \ - $TESTOUT 2>&1 << EOMODS + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS version: 1 # Adding an organization... @@ -86,6 +100,14 @@ objectClass: dcObject o: SubNet dc: subnet +# Adding another organization with an "auxiliary" objectClass.. +dn: dc=subnet2,${BASEDN} +changetype: add +objectClass: organization +objectClass: dcObject +o: SubNet 2 +dc: subnet2 + # Adding a person... dn: cn=Lev Tolstoij,${BASEDN} changetype: add @@ -95,6 +117,7 @@ sn: Tolstoij givenName: Lev telephoneNumber: +39 02 XXXX YYYY telephoneNumber: +39 02 XXXX ZZZZ +userPassword: tanja # Adding a person with an "auxiliary" objectClass... dn: cn=Some One,${BASEDN} @@ -124,7 +147,6 @@ description: Historical novel documentTitle: War and Peace documentAuthor: cn=Lev Tolstoij,dc=example,dc=com documentIdentifier: document 3 - EOMODS RC=$? @@ -134,10 +156,21 @@ EOMODS exit $RC fi + echo "Using ldapsearch to retrieve all the entries..." + echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT + $LDAPSEARCH -S "" -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 modify..." $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ - -h $LOCALHOST -p $PORT1 > \ - $TESTOUT 2>&1 << EOMODS + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS version: 1 # Deleting all telephone numbers... @@ -190,9 +223,12 @@ changetype: modify delete: objectClass objectClass: simpleSecurityObject - + +# Deleting userPasswords +dn: cn=Lev Tolstoij,${BASEDN} +changetype: modify delete: userPassword - - EOMODS RC=$? @@ -202,10 +238,21 @@ EOMODS exit $RC fi + echo "Using ldapsearch to retrieve all the entries..." + echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT + $LDAPSEARCH -S "" -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 delete..." $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ - -h $LOCALHOST -p $PORT1 > \ - $TESTOUT 2>&1 << EOMODS + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS version: 1 # Deleting a person... @@ -213,13 +260,12 @@ dn: cn=Torvlobnor Puzdoy,${BASEDN} changetype: delete # Deleting a document... -dn: documentTitle=book1,dc=example,dc=com +dn: documentTitle=book1,${BASEDN} changetype: delete -# Deleting a person with an "auxiliary" objectClass... -dn: cn=Akakiy Zinberstein,dc=example,dc=com +# Deleting an organization with an "auxiliary" objectClass... +dn: dc=subnet2,${BASEDN} changetype: delete - EOMODS RC=$? @@ -229,18 +275,223 @@ EOMODS exit $RC fi + echo "Using ldapsearch to retrieve all the entries..." + echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT + $LDAPSEARCH -S "" -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 rename..." $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ - -h $LOCALHOST -p $PORT1 > \ - $TESTOUT 2>&1 << EOMODS + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS version: 1 -# Renaming an organization +# Renaming an organization... dn: o=An Org,${BASEDN} changetype: modrdn -newrdn: o=Another Org +newrdn: o=Renamed Org +deleteoldrdn: 1 + +# Moving a person to another subtree... +dn: cn=Lev Tolstoij,${BASEDN} +changetype: modrdn +newrdn: cn=Lev Tolstoij +deleteoldrdn: 0 +newsuperior: dc=subnet,${BASEDN} + +# Renaming a book... +dn: documentTitle=book2,${BASEDN} +changetype: modrdn +newrdn: documentTitle=Renamed Book +deleteoldrdn: 1 +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..." + echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT + $LDAPSEARCH -S "" -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 "Adding a child to a referral (should fail)..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: cn=Should Fail,ou=Referral,${BASEDN} +changetype: add +objectClass: inetOrgPerson +cn: Should Fail +sn: Fail +telephoneNumber: +39 02 23456789 +EOMODS + + RC=$? + if test $RC = 0 ; then + echo "ldapmodify should have failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 + fi + + echo "Modifying a referral (should fail)..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: ou=Referral,${BASEDN} +changetype: modify +replace: ref +ref: ldap://localhost:9009/ +- +EOMODS + + RC=$? + if test $RC = 0 ; then + echo "ldapmodify should have failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 + fi + + echo "Renaming a referral (should fail)..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: ou=Referral,${BASEDN} +changetype: modrdn +newrdn: ou=Renamed Referral +deleteoldrdn: 1 +EOMODS + + RC=$? + if test $RC = 0 ; then + echo "ldapmodify should have failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 + fi + + echo "Deleting a referral (should fail)..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: ou=Referral,${BASEDN} +changetype: delete +EOMODS + + RC=$? + if test $RC = 0 ; then + echo "ldapmodify should have failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit 1 + fi + + echo "Adding a referral..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: ou=Another Referral,${BASEDN} +changetype: add +objectClass: referral +objectClass: extensibleObject +ou: Another Referral +ref: ldap://localhost:9009/ +EOMODS + + RC=$? + if test $RC != 0 ; then + echo "ldapmodify failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + echo "Modifying a referral with manageDSAit..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: ou=Referral,${BASEDN} +changetype: modify +replace: ref +ref: ldap://localhost:9009/ +- +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 the modified entry..." + echo "# Using ldapsearch to retrieve the modified entry..." >> $SEARCHOUT + $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Referral,$BASEDN" -M \ + "objectClass=*" '*' ref >> $SEARCHOUT 2>&1 + + RC=$? + if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + echo "Renaming a referral with manageDSAit..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: ou=Referral,${BASEDN} +changetype: modrdn +newrdn: ou=Renamed Referral deleteoldrdn: 1 +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 the renamed entry..." + echo "# Using ldapsearch to retrieve the renamed entry..." >> $SEARCHOUT + $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "ou=Renamed Referral,$BASEDN" -M \ + "objectClass=*" '*' ref >> $SEARCHOUT 2>&1 + RC=$? + if test $RC != 0 ; then + echo "ldapsearch failed ($RC)!" + test $KILLSERVERS != no && kill -HUP $KILLPIDS + exit $RC + fi + + echo "Deleting a referral with manageDSAit..." + $LDAPMODIFY -v -c -D "$MANAGERDN" -w $PASSWD \ + -h $LOCALHOST -p $PORT1 -M >> $TESTOUT 2>&1 << EOMODS +version: 1 + +dn: ou=Renamed Referral,${BASEDN} +changetype: delete EOMODS RC=$? @@ -286,8 +537,9 @@ EOMODS fi echo "Using ldapsearch to retrieve all the entries..." - $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ - "objectClass=*" > $SEARCHOUT 2>&1 + echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT + $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT1 -b "$BASEDN" \ + "objectClass=*" >> $SEARCHOUT 2>&1 RC=$? if test $RC != 0 ; then @@ -297,9 +549,9 @@ EOMODS fi echo "Filtering ldapsearch results..." - . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT + $LDIFFILTER < $SEARCHOUT > $SEARCHFLT echo "Filtering modified ldif..." - . $LDIFFILTER < $SQLWRITE > $LDIFFLT + $LDIFFILTER < $SQLWRITE > $LDIFFLT echo "Comparing filter output..." $CMP $SEARCHFLT $LDIFFLT > $CMPOUT @@ -319,4 +571,3 @@ test $KILLSERVERS != no && kill -HUP $KILLPIDS echo ">>>>> Test succeeded" exit 0 -