]> git.sur5r.net Git - openldap/blobdiff - tests/scripts/test005-modrdn
s/ldap_sync.h/ldap.h/
[openldap] / tests / scripts / test005-modrdn
index c8154149b05cd3ba2a0cbbae725e0870ec025612..b334ad0bbafe8fe8a9a1d01c98a15abc037ec6b3 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2005 The OpenLDAP Foundation.
+## Copyright 1998-2008 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
 echo "running defines.sh"
 . $SRCDIR/scripts/defines.sh
 
-mkdir -p $TESTDIR $DBDIR1
+mkdir -p $TESTDIR $DBDIR1A $DBDIR1B
 
 echo "Running slapadd to build slapd database..."
-. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
-$SLAPADD -f $CONF1 -l $LDIFORDERED
+. $CONFFILTER $BACKEND $MONITORDB < $CONF2DB > $CONF1
+$SLAPADD -f $CONF1 -b "$BASEDN" -l $LDIFORDERED
 RC=$?
 if test $RC != 0 ; then
        echo "slapadd failed ($RC)!"
@@ -36,6 +36,8 @@ if test $WAIT != 0 ; then
 fi
 KILLPIDS="$PID"
 
+sleep 1
+
 echo "Testing slapd modrdn operations..."
 
 # Make sure we can search the database
@@ -105,7 +107,7 @@ $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
 if test $? != 0 ; then
        echo "comparison failed - modrdn operations did not complete correctly"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit 1
+       exit -1
 fi
 
 
@@ -132,7 +134,7 @@ $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
 if test $? != 0 ; then
        echo "comparison failed - modrdn operations did not complete correctly"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit 1
+       exit -1
 fi
 
 # Ensure that you cannot find the entry for which the rdn was deleted as
@@ -151,7 +153,7 @@ $CMP $SEARCHOUT - < /dev/null > $CMPOUT
 if test $? != 0 ; then
        echo "failure: ldapsearch found attribute that was to be removed!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit 1
+       exit -1
 fi
 
 echo "Using ldapsearch to retrieve all the entries..."
@@ -176,7 +178,7 @@ $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
 if test $? != 0 ; then
        echo "comparison failed - modrdn operations did not complete correctly"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit 1
+       exit -1
 fi
 
 # Test that you can use modrdn with an attribute value which was previously
@@ -216,22 +218,83 @@ $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
 if test $? != 0 ; then
        echo "comparison failed - modrdn operations did not complete correctly"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit 1
+       exit -1
 fi
 
-echo "Testing modrdn with newSuperior as child of target "
+echo "Testing modrdn to another database (should fail with affectsMultipleDSAs)"
 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
-       $TESTOUT 2>&1  -s 'cn=Sub1, ou=FooBar, cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' \
+       $TESTOUT 2>&1 'cn=All Staff,ou=Groups,dc=example,dc=com' 'cn=Everyone'
+RC=$?
+case $RC in
+0)
+       echo "ldapmodrdn succeeded, should have failed!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit -1
+       ;;
+71)
+       ;;
+*)
+       echo "ldapmodrdn failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+esac
+
+echo "Testing modrdn with newSuperior = target (should fail with unwillingToPerform)"
+$LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
+       $TESTOUT 2>&1  -s 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' \
        'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A Jones 1'
 
 RC=$?
-if test $RC -eq 0 ; then
+case $RC in
+0)
        echo "ldapmodrdn succeeded, should have failed!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit 1
-fi
+       exit -1
+       ;;
+53)
+       ;;
+*)
+       echo "ldapmodrdn failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+esac
+
+echo "Testing modrdn with newRdn exact same as target..."
+$LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
+       $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A Jones 1'
+
+RC=$?
+case $RC in
+0)
+       ;;
+*)
+       echo "ldapmodrdn failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+esac
+
+echo "Testing modrdn with newRdn same as target, changed case..."
+$LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
+       $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A JONES 1'
+
+RC=$?
+case $RC in
+0)
+       ;;
+*)
+       echo "ldapmodrdn failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+esac
 
 test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
 echo ">>>>> Test succeeded"
+
+test $KILLSERVERS != no && wait
+
 exit 0