]> git.sur5r.net Git - openldap/blobdiff - tests/scripts/test044-dynlist
ITS#5189
[openldap] / tests / scripts / test044-dynlist
index faf24eeee803ac8e382ffaf497ea9de764c3121f..02032be291368a4eb9785d924fa2ab7ee913967c 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
 ##
-## Copyright 1998-2005 The OpenLDAP Foundation.
+## Copyright 1998-2007 The OpenLDAP Foundation.
 ## All rights reserved.
 ##
 ## Redistribution and use in source and binary forms, with or without
@@ -22,6 +22,9 @@ fi
 
 mkdir -p $TESTDIR $DBDIR1
 
+$SLAPPASSWD -g -n >$CONFIGPWF
+echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
+
 echo "Running slapadd to build slapd database..."
 . $CONFFILTER $BACKEND $MONITORDB < $MCONF > $ADDCONF
 $SLAPADD -f $ADDCONF -l $LDIFORDERED
@@ -31,14 +34,7 @@ if test $RC != 0 ; then
        exit $RC
 fi
 
-echo "Running slapindex to index slapd database..."
 . $CONFFILTER $BACKEND $MONITORDB < $DYNLISTCONF > $CONF1
-$SLAPINDEX -f $CONF1
-RC=$?
-if test $RC != 0 ; then
-       echo "warning: slapindex failed ($RC)"
-       echo "  assuming no indexing support"
-fi
 
 echo "Starting slapd on TCP/IP port $PORT1..."
 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
@@ -151,8 +147,36 @@ case $RC in
 0)
        echo "ldapcompare returned success ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit -1
+       ;;
+*)
+       echo "ldapcompare failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+esac
+echo "" >> $SEARCHOUT
+
+echo "Testing list compare (should return FALSE)..."
+echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
+$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
+       "cn=Dynamic List,$LISTDN" "cn:FALSE" \
+       >> $SEARCHOUT 2>&1
+RC=$?
+case $RC in
+5)
+       echo "ldapcompare returned FALSE ($RC)"
+       ;;
+6)
+       echo "ldapcompare returned TRUE ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
        ;;
+0)
+       echo "ldapcompare returned success ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit -1
+       ;;
 *)
        echo "ldapcompare failed ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -161,6 +185,37 @@ case $RC in
 esac
 echo "" >> $SEARCHOUT
 
+echo "Testing list compare (should return UNDEFINED)..."
+echo "# Testing list compare (should return UNDEFINED)..." >> $SEARCHOUT
+$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
+       "cn=Dynamic List,$LISTDN" "dc:UNDEFINED" \
+       >> $SEARCHOUT 2>&1
+RC=$?
+case $RC in
+5)
+       echo "ldapcompare returned FALSE ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+6)
+       echo "ldapcompare returned TRUE ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+16|32)
+       echo "ldapcompare returned UNDEFINED ($RC)"
+       ;;
+0)
+       echo "ldapcompare returned success ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit -1
+       ;;
+*)
+       echo "ldapcompare failed ($RC)"
+       ;;
+esac
+echo "" >> $SEARCHOUT
+
 echo "Testing list compare with manageDSAit..."
 echo "# Testing list compare with manageDSAit..." >> $SEARCHOUT
 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 -MM \
@@ -179,7 +234,7 @@ case $RC in
 0)
        echo "ldapcompare returned success ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
+       exit -1
        ;;
 *)
        echo "ldapcompare failed ($RC)!"
@@ -189,44 +244,21 @@ case $RC in
 esac
 echo "" >> $SEARCHOUT
 
-echo "Stopping slapd..."
-kill -HUP $KILLPIDS
-wait $KILLPIDS
-
 echo "Reconfiguring slapd..."
-echo "dynlist-member-ad        member" >> $CONF1
+$LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
+       $TESTOUT 2>&1 << EOMODS
+version: 1
+dn: olcOverlay={0}dynlist,olcDatabase={2}$BACKEND,cn=config
+changetype: modify
+delete: olcDLattrSet
+olcDLattrSet: {0}
+-
+add: olcDLattrSet
+olcDLattrSet: groupOfURLs memberURL member
+EOMODS
 
 echo "==========================================================" >> $LOG1
 
-echo "Starting slapd on TCP/IP port $PORT1..."
-$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"
-
-sleep 1
-
-echo "Testing slapd searching..."
-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
-
 echo "Adding a dynamic list..."
 $LDAPADD -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
        > $TESTOUT 2>&1 << EOMODS
@@ -303,8 +335,36 @@ case $RC in
 0)
        echo "ldapcompare returned success ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit -1
+       ;;
+*)
+       echo "ldapcompare failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
        exit $RC
        ;;
+esac
+echo "" >> $SEARCHOUT
+
+echo "Testing list compare (should return FALSE)..."
+echo "# Testing list compare (should return FALSE)..." >> $SEARCHOUT
+$LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
+       "cn=Dynamic List of Members,$LISTDN" "member:cn=Foo Bar" \
+       >> $SEARCHOUT 2>&1
+RC=$?
+case $RC in
+5)
+       echo "ldapcompare returned FALSE ($RC)"
+       ;;
+6)
+       echo "ldapcompare returned TRUE ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+       ;;
+0)
+       echo "ldapcompare returned success ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit -1
+       ;;
 *)
        echo "ldapcompare failed ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
@@ -331,7 +391,7 @@ case $RC in
 0)
        echo "ldapcompare returned success ($RC)!"
        test $KILLSERVERS != no && kill -HUP $KILLPIDS
-       exit $RC
+       exit -1
        ;;
 *)
        echo "ldapcompare failed ($RC)!"
@@ -341,6 +401,56 @@ case $RC in
 esac
 echo "" >> $SEARCHOUT
 
+echo "==========================================================" >> $LOG1
+
+echo "Testing dgIdentity..."
+
+# Set ACL, require authentication to get list contents
+$LDAPMODIFY -x -D cn=config -h $LOCALHOST -p $PORT1 -y $CONFIGPWF > \
+       $TESTOUT 2>&1 << EOMODS
+version: 1
+dn: olcDatabase={2}$BACKEND,cn=config
+changetype: modify
+add: olcAccess
+olcAccess: to dn.base="cn=Dynamic List of Members,$LISTDN" by * read
+olcAccess: to * by users read by * search
+EOMODS
+
+echo "Testing list search without dgIdentity..."
+echo "# Testing list search without dgIdentity..." >> $SEARCHOUT
+$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
+       '(cn=Dynamic List of Members)' '*' \
+       >> $SEARCHOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
+$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
+       > $TESTOUT 2>&1 << EOMODS
+dn: cn=Dynamic List of Members,$LISTDN
+changetype: modify
+add: objectClass
+objectClass: dgIdentityAux
+-
+add: dgIdentity
+dgIdentity: $CMPDN
+EOMODS
+
+echo "Testing list search with dgIdentity..."
+echo "# Testing list search with dgIdentity..." >> $SEARCHOUT
+$LDAPSEARCH -S "" -b "$LISTDN" -h $LOCALHOST -p $PORT1 \
+       '(cn=Dynamic List of Members)' '*' \
+       >> $SEARCHOUT 2>&1
+RC=$?
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 test $KILLSERVERS != no && kill -HUP $KILLPIDS
 
 LDIF=$DYNLISTOUT
@@ -358,4 +468,7 @@ if test $? != 0 ; then
 fi
 
 echo ">>>>> Test succeeded"
+
+test $KILLSERVERS != no && wait
+
 exit 0