]> git.sur5r.net Git - openldap/blobdiff - tests/scripts/test034-translucent
Merge remote branch 'origin/mdb.master'
[openldap] / tests / scripts / test034-translucent
index 822704492c7eeb6c8d65fad73385a29c9c815fed..a7e47467dab86c6c42087a787e02be16620cc03f 100755 (executable)
@@ -2,7 +2,7 @@
 # $OpenLDAP$
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 2004-2006 The OpenLDAP Foundation.
+## Copyright 2004-2011 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -15,8 +15,7 @@
 
 echo "running defines.sh"
 . $SRCDIR/scripts/defines.sh
-PASSWD=`cat configpw`
-LVL=-1
+
 PERSONAL="(objectClass=inetOrgPerson)"
 NOWHERE="/dev/null"
 FAILURE="additional info:"
@@ -34,6 +33,15 @@ fi
 # configure backside
 mkdir -p $TESTDIR $DBDIR1
 
+$SLAPPASSWD -g -n >$CONFIGPWF
+echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
+
+if test $MONITORDB != no ; then
+       DBIX=2
+else
+       DBIX=1
+fi
+
 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTREMOTECONF > $CONF1
 echo "Running slapadd to build remote slapd database..."
 $SLAPADD -f $CONF1 -l $LDIFTRANSLUCENTCONFIG
@@ -74,12 +82,11 @@ fi
 
 # configure frontside
 mkdir -p $DBDIR2
-mkdir -p testrun/conf2
 
 . $CONFFILTER $BACKEND $MONITORDB < $TRANSLUCENTLOCALCONF > $CONF2
 
 echo "Starting local slapd on TCP/IP port $PORT2..."
-$SLAPD -f $CONF2 -F testrun/conf2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
+$SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
 PID=$!
 if test $WAIT != 0 ; then
     echo PID $PID
@@ -149,8 +156,8 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$LDIFFILTER < $LDIFTRANSLUCENTDATA > $LDIFFLT
+$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
+$LDIFFILTER < $LDIFTRANSLUCENTDATA > $LDIFFLT
 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
 
 if test $? != 0 ; then
@@ -178,7 +185,7 @@ $LDAPADD -v -v -v -D "$TRANSLUCENTROOT" -H $URI2 \
        -w $PASSWD < $LDIFTRANSLUCENTADD > $TESTOUT 2>&1
 
 RC=$?
-if test $RC != 32 ; then
+if test $RC != 32 && test $RC,$BACKEND != 0,null ; then
        echo "ldapadd failed ($RC), expected NO SUCH OBJECT!"
        grep "$FAILURE" $TESTOUT
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -191,7 +198,7 @@ $LDAPMODRDN -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
        $TESTOUT 2>&1 'uid=fred,ou=users,o=translucent' 'uid=someguy'
 
 RC=$?
-if test $RC != 32 ; then
+if test $RC != 32 && test $RC,$BACKEND != 0,null ; then
        echo "ldapmodrdn failed ($RC), expected NO SUCH OBJECT!"
        grep "$FAILURE" $TESTOUT
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -200,8 +207,8 @@ fi
 
 echo "Dynamically configuring local slapd without translucent_no_glue..."
 
-$LDAPMODIFY -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD <<EOF
-dn: olcOverlay={0}translucent,olcDatabase={2}bdb,cn=config
+$LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
+dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
 changetype: modify
 replace: olcTranslucentNoGlue
 olcTranslucentNoGlue: FALSE
@@ -237,8 +244,9 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-. $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
-$CMP $SEARCHFLT $LDIFTRANSLUCENTMERGED > $CMPOUT
+$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
+$LDIFFILTER < $LDIFTRANSLUCENTMERGED > $LDIFFLT
+$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
 
 if test $? != 0 ; then
        echo "Comparison failed -- local data failed to merge with remote!"
@@ -552,6 +560,24 @@ if test $RC != 16 ; then
        exit 1
 fi
 
+echo "Testing delete: valid local record, remote attribute..."
+
+$LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
+        $TESTOUT 2>&1 << EOF_MOD8
+version: 1
+dn: uid=danger,ou=users,o=translucent
+changetype: modify
+delete: initials
+EOF_MOD8
+
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapmodify failed ($RC)"
+       grep "$FAILURE" $TESTOUT
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit 1
+fi
+
 echo "Testing modify: valid remote record, combination add-modify-delete..."
 
 $LDAPMODIFY -v -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD > \
@@ -599,10 +625,10 @@ if test "$ATTR" != "preferredLanguage: ISO8859-1" ; then
        exit 1
 fi
 
-echo "Dynamically configuring local slapd with translucent_no_glue and translucent_string..."
+echo "Dynamically configuring local slapd with translucent_no_glue and translucent_strict..."
 
-$LDAPMODIFY -D "$TRANSLUCENTROOT" -H $URI2 -w $PASSWD <<EOF
-dn: olcOverlay={0}translucent,olcDatabase={2}bdb,cn=config
+$LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
+dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
 changetype: modify
 replace: olcTranslucentNoGlue
 olcTranslucentNoGlue: TRUE
@@ -698,6 +724,76 @@ if test $RC != 0 ; then
        exit 1
 fi
 
+echo "Testing search: unconfigured local filter..."
+$LDAPSEARCH -H $URI2 -b "o=translucent" "(employeeType=consultant)" > $SEARCHOUT 2>&1
+
+ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1
+if test -n "$ATTR" ; then
+       echo "got result $ATTR, should have been no result"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit 1
+fi
+
+echo "Dynamically configuring local slapd with translucent_local..."
+
+$LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
+dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
+changetype: modify
+add: olcTranslucentLocal
+olcTranslucentLocal: employeeType
+EOF
+RC=$?
+if test $RC != 0 ; then
+    echo "ldapmodify of dynamic config failed ($RC)"
+    test $KILLSERVERS != no && kill -HUP $KILLPIDS
+    exit 1
+fi
+
+echo "Testing search: configured local filter..."
+$LDAPSEARCH -H $URI2 -b "o=translucent" "(employeeType=consultant)" > $SEARCHOUT 2>&1
+
+ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1
+if test -z "$ATTR" ; then
+       echo "got no result, should have found entry"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit 1
+fi
+
+echo "Testing search: unconfigured remote filter..."
+$LDAPSEARCH -H $URI2 -b "o=translucent" "(|(employeeType=foo)(carlicense=right))" > $SEARCHOUT 2>&1
+
+ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1
+if test -n "$ATTR" ; then
+       echo "got result $ATTR, should have been no result"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit 1
+fi
+
+echo "Dynamically configuring local slapd with translucent_remote..."
+
+$LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF
+dn: olcOverlay={0}translucent,olcDatabase={$DBIX}$BACKEND,cn=config
+changetype: modify
+add: olcTranslucentRemote
+olcTranslucentRemote: carLicense
+EOF
+RC=$?
+if test $RC != 0 ; then
+    echo "ldapmodify of dynamic config failed ($RC)"
+    test $KILLSERVERS != no && kill -HUP $KILLPIDS
+    exit 1
+fi
+
+echo "Testing search: configured remote filter..."
+$LDAPSEARCH -H $URI2 -b "o=translucent" "(|(employeeType=foo)(carlicense=right))" > $SEARCHOUT 2>&1
+
+ATTR=`grep dn: $SEARCHOUT` > $NOWHERE 2>&1
+if test -z "$ATTR" ; then
+       echo "got no result, should have found entry"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit 1
+fi
+
 test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
 echo ">>>>> Test succeeded"