2003-10-22 15:39:18 +08:00
|
|
|
#! /bin/sh
|
|
|
|
# $OpenLDAP$
|
2003-11-29 04:00:23 +08:00
|
|
|
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
##
|
2010-04-14 06:17:29 +08:00
|
|
|
## Copyright 1998-2010 The OpenLDAP Foundation.
|
2003-11-29 04:00:23 +08:00
|
|
|
## 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
|
|
|
|
## <http://www.OpenLDAP.org/license.html>.
|
2003-10-22 15:39:18 +08:00
|
|
|
|
2009-08-21 21:25:38 +08:00
|
|
|
PCACHETTL=${PCACHETTL-"1m"}
|
|
|
|
PCACHENTTL=${PCACHENTTL-"1m"}
|
|
|
|
PCACHESTTL=${PCACHESTTL-"1m"}
|
|
|
|
PCACHE_ENTRY_LIMIT=${PCACHE_ENTRY_LIMIT-"6"}
|
|
|
|
PCACHE_CCPERIOD=${PCACHE_CCPERIOD-"2"}
|
|
|
|
PCACHETTR=${PCACHETTR-"2"}
|
|
|
|
PCACHEBTTR=${PCACHEBTTR-"5"}
|
2003-10-22 15:39:18 +08:00
|
|
|
|
|
|
|
. $SRCDIR/scripts/defines.sh
|
|
|
|
|
2003-12-06 19:46:26 +08:00
|
|
|
if test $PROXYCACHE = pcacheno; then
|
|
|
|
echo "Proxy cache overlay not available, test skipped"
|
2003-10-22 15:39:18 +08:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2004-11-13 23:04:01 +08:00
|
|
|
if test $BACKLDAP = "ldapno" ; then
|
|
|
|
echo "LDAP backend not available, test skipped"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2009-11-29 22:31:11 +08:00
|
|
|
if test $BACKEND = ldif ; then
|
|
|
|
# The (mail=example.com*) queries hit a sizelimit, so which
|
|
|
|
# entry is returned depends on the ordering in the backend.
|
|
|
|
echo "Test does not support $BACKEND backend, test skipped"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2003-10-22 15:39:18 +08:00
|
|
|
mkdir -p $TESTDIR $DBDIR1 $DBDIR2
|
|
|
|
|
|
|
|
# Test proxy caching:
|
|
|
|
# - start master
|
|
|
|
# - start proxy cache
|
|
|
|
# - populate master
|
|
|
|
# - perform first set of searches at the proxy
|
|
|
|
# - verify cacheability
|
|
|
|
# - perform second set of searches at the proxy
|
|
|
|
# - verify answerability
|
|
|
|
|
|
|
|
echo "Starting master slapd on TCP/IP port $PORT1..."
|
2003-10-22 18:46:41 +08:00
|
|
|
. $CONFFILTER < $CACHEMASTERCONF > $CONF1
|
|
|
|
$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 &
|
2003-10-22 15:39:18 +08:00
|
|
|
PID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo PID $PID
|
|
|
|
read foo
|
|
|
|
fi
|
2003-10-22 18:15:07 +08:00
|
|
|
KILLPIDS="$PID"
|
2003-10-22 15:39:18 +08:00
|
|
|
|
2005-09-30 15:32:49 +08:00
|
|
|
sleep 1
|
|
|
|
|
2003-10-22 15:39:18 +08:00
|
|
|
echo "Using ldapsearch to check that master slapd is running..."
|
|
|
|
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 "Using ldapadd to populate the master directory..."
|
|
|
|
$LDAPADD -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
|
|
|
|
$LDIFORDERED > /dev/null 2>&1
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapadd failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Starting proxy cache on TCP/IP port $PORT2..."
|
2009-08-21 21:25:38 +08:00
|
|
|
. $CONFFILTER < $PROXYCACHECONF | sed \
|
|
|
|
-e "s/@TTL@/${PCACHETTL}/" \
|
|
|
|
-e "s/@NTTL@/${PCACHENTTL}/" \
|
|
|
|
-e "s/@STTL@/${PCACHENTTL}/" \
|
|
|
|
-e "s/@TTR@/${PCACHETTR}/" \
|
|
|
|
-e "s/@ENTRY_LIMIT@/${PCACHE_ENTRY_LIMIT}/" \
|
|
|
|
-e "s/@CCPERIOD@/${PCACHE_CCPERIOD}/" \
|
|
|
|
-e "s/@BTTR@/${PCACHEBTTR}/" \
|
|
|
|
> $CONF2
|
|
|
|
|
2006-02-02 16:36:41 +08:00
|
|
|
$SLAPD -f $CONF2 -h $URI2 -d $LVL -d pcache > $LOG2 2>&1 &
|
2003-10-22 15:39:18 +08:00
|
|
|
CACHEPID=$!
|
|
|
|
if test $WAIT != 0 ; then
|
|
|
|
echo CACHEPID $CACHEPID
|
|
|
|
read foo
|
|
|
|
fi
|
|
|
|
KILLPIDS="$KILLPIDS $CACHEPID"
|
|
|
|
|
2005-09-30 15:32:49 +08:00
|
|
|
sleep 1
|
|
|
|
|
2003-10-22 15:39:18 +08:00
|
|
|
echo "Using ldapsearch to check that proxy slapd is running..."
|
|
|
|
for i in 0 1 2 3 4 5; do
|
|
|
|
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
|
|
|
|
'objectclass=*' > /dev/null 2>&1
|
|
|
|
RC=$?
|
|
|
|
if test $RC = 0 ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo "Waiting 5 seconds for slapd to start..."
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
2004-12-30 05:20:18 +08:00
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
cat /dev/null > $SEARCHOUT
|
2005-11-23 18:04:33 +08:00
|
|
|
|
2003-10-22 15:39:18 +08:00
|
|
|
echo "Making queries on the proxy cache..."
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=0
|
|
|
|
|
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(sn=Jon)"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:all (expect nothing)"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:all (expect nothing)" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2006-04-29 16:46:32 +08:00
|
|
|
# ITS#4491, if debug messages are unavailable, we can't verify the tests.
|
|
|
|
grep "query template" $LOG2 > /dev/null
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "Debug messages unavailable, test aborted..."
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(|(cn=*Jon*)(sn=Jon*))"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(sn=Smith*)"
|
|
|
|
ATTRS="cn sn uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(sn=Doe*)"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
2007-09-13 05:09:04 +08:00
|
|
|
|
|
|
|
CNT=`expr $CNT + 1`
|
2007-09-27 07:28:38 +08:00
|
|
|
FILTER="(uid=johnd)"
|
2007-09-13 05:09:04 +08:00
|
|
|
ATTRS="mail postaladdress telephonenumber cn uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(mail=*@mail.alumni.example.com)"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(mail=*)"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(mail=*example.com)"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
|
2009-08-21 21:25:38 +08:00
|
|
|
UPASSWD="bjorn"
|
2007-09-13 05:09:04 +08:00
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2009-08-21 21:25:38 +08:00
|
|
|
-D "$USERDN" -w "$UPASSWD" \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
case $RC in
|
|
|
|
0)
|
|
|
|
echo "ldapsearch should have failed!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
;;
|
|
|
|
4)
|
|
|
|
echo "ldapsearch failed ($RC)"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(uid=b*)"
|
|
|
|
ATTRS="mail"
|
|
|
|
USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
|
2009-08-21 21:25:38 +08:00
|
|
|
UPASSWD="bjorn"
|
2007-09-13 05:09:04 +08:00
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2009-08-21 21:25:38 +08:00
|
|
|
-D "$USERDN" -w "$UPASSWD" \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
case $RC in
|
|
|
|
0)
|
|
|
|
echo "ldapsearch should have failed!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
;;
|
|
|
|
4)
|
|
|
|
echo "ldapsearch failed ($RC)"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-09-07 10:03:23 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(|(cn=All Staff)(sn=All Staff))"
|
|
|
|
ATTRS="sn cn title uid undefinedAttr"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
FIRST=$CNT
|
|
|
|
|
2010-09-07 10:03:23 +08:00
|
|
|
# queries 2-6,8-10 are cacheable
|
|
|
|
CACHEABILITY=0111110111
|
2003-10-22 15:39:18 +08:00
|
|
|
grep CACHEABLE $LOG2 | awk '{
|
|
|
|
if ($2 == "NOT")
|
|
|
|
printf "Query %d not cacheable\n",NR
|
|
|
|
else
|
|
|
|
printf "Query %d cacheable\n",NR
|
|
|
|
}'
|
|
|
|
CACHED=`grep CACHEABLE $LOG2 | awk '{
|
|
|
|
if ($2 == "NOT")
|
|
|
|
printf "0"
|
|
|
|
else
|
|
|
|
printf "1"
|
|
|
|
}'`
|
|
|
|
|
2003-12-18 09:07:09 +08:00
|
|
|
if test "$CACHEABILITY" = "$CACHED" ; then
|
2003-10-22 15:39:18 +08:00
|
|
|
echo "Successfully verified cacheability"
|
|
|
|
else
|
|
|
|
echo "Error in verifying cacheability"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(|(cn=*Jones)(sn=Jones))"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(sn=Smith)"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(uid=bjorn)"
|
|
|
|
ATTRS="mail postaladdress telephonenumber cn uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(mail=jaj@mail.alumni.example.com)"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
2003-10-22 15:39:18 +08:00
|
|
|
RC=$?
|
|
|
|
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
2007-09-13 05:09:04 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(mail=*example.com)"
|
|
|
|
ATTRS="cn sn title uid"
|
|
|
|
USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
|
2009-08-21 21:25:38 +08:00
|
|
|
UPASSWD="bjorn"
|
2007-09-13 05:09:04 +08:00
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2009-08-21 21:25:38 +08:00
|
|
|
-D "$USERDN" -w "$UPASSWD" \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
case $RC in
|
|
|
|
0)
|
|
|
|
echo "ldapsearch should have failed!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
;;
|
|
|
|
4)
|
|
|
|
echo "ldapsearch failed ($RC)"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(uid=b*)"
|
|
|
|
ATTRS="mail"
|
|
|
|
USERDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
|
2009-08-21 21:25:38 +08:00
|
|
|
UPASSWD="bjorn"
|
2007-09-13 05:09:04 +08:00
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
2009-08-21 21:25:38 +08:00
|
|
|
-D "$USERDN" -w "$UPASSWD" \
|
2007-09-13 05:09:04 +08:00
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
case $RC in
|
|
|
|
0)
|
|
|
|
echo "ldapsearch should have failed!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
;;
|
|
|
|
4)
|
|
|
|
echo "ldapsearch failed ($RC)"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-09-07 10:03:23 +08:00
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(|(cn=All Staff)(sn=All Staff))"
|
|
|
|
ATTRS="sn cn title uid undefinedAttr"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
#queries 11-13,16-17 are answerable, 14-15 are not
|
|
|
|
#actually, 14 would be answerable, but since 8 made mail=*example.com
|
2007-09-13 05:09:04 +08:00
|
|
|
#not answerable because of sizelimit, queries contained in it are no longer
|
|
|
|
#answerable as well
|
2010-09-07 10:03:23 +08:00
|
|
|
ANSWERABILITY=1110011
|
2007-11-29 21:45:55 +08:00
|
|
|
grep ANSWERABLE $LOG2 | awk "BEGIN {FIRST=$FIRST}"'{
|
2007-09-13 05:09:04 +08:00
|
|
|
if (NR > FIRST) {
|
2003-10-22 15:39:18 +08:00
|
|
|
if ($2 == "NOT")
|
|
|
|
printf "Query %d not answerable\n",NR
|
|
|
|
else
|
|
|
|
printf "Query %d answerable\n",NR
|
|
|
|
}
|
|
|
|
}'
|
2007-11-29 21:45:55 +08:00
|
|
|
ANSWERED=`grep ANSWERABLE $LOG2 | awk "BEGIN {FIRST=$FIRST}"'{
|
2007-09-13 05:09:04 +08:00
|
|
|
if (NR > FIRST) {
|
2003-10-22 15:39:18 +08:00
|
|
|
if ($2 == "NOT")
|
|
|
|
printf "0"
|
|
|
|
else
|
|
|
|
printf "1"
|
|
|
|
}
|
|
|
|
}'`
|
|
|
|
|
2003-12-18 09:07:09 +08:00
|
|
|
if test "$ANSWERABILITY" = "$ANSWERED" ; then
|
2003-10-22 15:39:18 +08:00
|
|
|
echo "Successfully verified answerability"
|
|
|
|
else
|
|
|
|
echo "Error in verifying answerability"
|
2009-08-21 21:25:38 +08:00
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
2003-10-22 15:39:18 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-08-28 11:59:21 +08:00
|
|
|
echo "Filtering ldapsearch results..."
|
2010-09-07 10:03:23 +08:00
|
|
|
$LDIFFILTER -s ldif=a < $SEARCHOUT > $SEARCHFLT
|
2005-11-23 18:47:27 +08:00
|
|
|
echo "Filtering original ldif..."
|
2010-09-07 10:03:23 +08:00
|
|
|
$LDIFFILTER -s ldif=a < $PROXYCACHEOUT > $LDIFFLT
|
2005-08-28 11:59:21 +08:00
|
|
|
echo "Comparing filter output..."
|
2005-11-23 18:47:27 +08:00
|
|
|
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
|
2004-05-20 08:41:16 +08:00
|
|
|
|
|
|
|
if test $? != 0 ; then
|
|
|
|
echo "Comparison failed"
|
2009-08-21 21:25:38 +08:00
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
2004-05-20 08:41:16 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2009-08-21 21:25:38 +08:00
|
|
|
echo ""
|
|
|
|
echo "Testing cache refresh"
|
|
|
|
|
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
FILTER="(&(objectclass=person)(uid=dots))"
|
|
|
|
ATTRS="cn mail telephonenumber"
|
|
|
|
echo "Query $CNT: filter:$FILTER attrs:$ATTRS"
|
|
|
|
echo "# Query $CNT: filter:$FILTER attrs:$ATTRS" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
$LDAPMODIFY -x -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD <<EOF \
|
|
|
|
> /dev/null 2>&1
|
|
|
|
dn: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
|
|
|
|
changetype: modify
|
|
|
|
replace: mail
|
|
|
|
mail: dots@admin.example2.com
|
|
|
|
-
|
|
|
|
|
|
|
|
EOF
|
2009-08-21 21:50:59 +08:00
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapmodify failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
2009-08-21 21:25:38 +08:00
|
|
|
|
|
|
|
SLEEP=`expr $PCACHETTR + $PCACHE_CCPERIOD`
|
|
|
|
echo "Waiting $SLEEP seconds for cache to refresh"
|
|
|
|
|
|
|
|
sleep $SLEEP
|
|
|
|
|
|
|
|
echo "Checking entry again"
|
|
|
|
$LDAPSEARCH -x -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT2 \
|
|
|
|
"$FILTER" $ATTRS >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep "^mail: dots@admin" $SEARCHOUT > /dev/null
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "Refresh failed"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Testing Bind caching"
|
|
|
|
|
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
USERDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com"
|
|
|
|
UPASSWD="jaj"
|
|
|
|
echo "Query $CNT: $USERDN"
|
|
|
|
echo "# Query $CNT: $USERDN" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "" -s base -h $LOCALHOST -p $PORT2 \
|
|
|
|
-D "$USERDN" -w "$UPASSWD" >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep "CACHING BIND" $LOG2 > /dev/null
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "Refresh failed"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
USERDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com"
|
|
|
|
UPASSWD="jaj"
|
|
|
|
echo "Query $CNT: (Bind should be cached)"
|
|
|
|
echo "# Query $CNT: (Bind should be cached)" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "" -s base -h $LOCALHOST -p $PORT2 \
|
|
|
|
-D "$USERDN" -w "$UPASSWD" >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep "CACHED BIND" $LOG2 > /dev/null
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "Refresh failed"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2009-08-21 21:50:59 +08:00
|
|
|
echo ""
|
|
|
|
echo "Testing pwdModify"
|
|
|
|
$LDAPPASSWD -h $LOCALHOST -p $PORT2 \
|
|
|
|
-D "$MANAGERDN" -w "$PASSWD" -s newpw "$USERDN" >> $TESTOUT 2>&1
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldappasswd failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
RC=`grep "CACH.* BIND" $LOG2 | wc -l`
|
|
|
|
if test $RC != 3 ; then
|
|
|
|
echo "ldappasswd didn't update the cache"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
CNT=`expr $CNT + 1`
|
|
|
|
USERDN="cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com"
|
|
|
|
UPASSWD=newpw
|
|
|
|
echo "Query $CNT: (Bind should be cached)"
|
|
|
|
echo "# Query $CNT: (Bind should be cached)" >> $SEARCHOUT
|
|
|
|
$LDAPSEARCH -S "" -b "" -s base -h $LOCALHOST -p $PORT2 \
|
|
|
|
-D "$USERDN" -w "$UPASSWD" >> $SEARCHOUT 2>> $TESTOUT
|
|
|
|
RC=$?
|
|
|
|
if test $RC != 0 ; then
|
|
|
|
echo "ldapsearch failed ($RC)!"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
exit $RC
|
|
|
|
fi
|
|
|
|
|
|
|
|
RC=`grep "CACH.* BIND" $LOG2 | wc -l`
|
|
|
|
if test $RC != 4 ; then
|
|
|
|
echo "Bind wasn't answered from cache"
|
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS && wait
|
|
|
|
exit 0
|
|
|
|
fi
|
2009-08-21 21:25:38 +08:00
|
|
|
test $KILLSERVERS != no && kill -HUP $KILLPIDS
|
|
|
|
|
2003-10-22 15:39:18 +08:00
|
|
|
echo ">>>>> Test succeeded"
|
2006-01-11 13:25:09 +08:00
|
|
|
|
|
|
|
test $KILLSERVERS != no && wait
|
|
|
|
|
2003-10-22 15:39:18 +08:00
|
|
|
exit 0
|