3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 echo "### This test requires the ldap backend and glue overlay."
20 echo "### If available, and explicitly requested, it can use SASL bind;"
21 echo "### note that SASL must be properly set up, and the requested"
22 echo "### mechanism must be available. Define SLAPD_USE_SASL={yes|<mech>},"
23 echo "### with \"yes\" defaulting to DIGEST-MD5 to enable SASL authc[/authz]."
25 if test $BACKLDAP = "ldapno" ; then
26 echo "LDAP backend not available, test skipped"
30 if test $GLUE = "glueno" ; then
31 echo "glue overlay not available, test skipped"
35 if test $WITH_SASL = "yes" ; then
36 if test $USE_SASL != "no" ; then
37 if test $USE_SASL = "yes" ; then
42 echo "Using SASL authc[/authz] with mech=$MECH; unset SLAPD_USE_SASL to disable"
44 echo "Using proxyAuthz with simple authc..."
47 echo "SASL not available; using proxyAuthz with simple authc..."
50 mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3
52 echo "Running slapadd to build slapd database..."
53 . $CONFFILTER $BACKEND $MONITORDB < $LDAPGLUECONF1 > $ADDCONF
54 $SLAPADD -f $ADDCONF -l $LDIFLDAPGLUE1
56 if test $RC != 0 ; then
57 echo "slapadd 1 failed ($RC)!"
61 . $CONFFILTER $BACKEND $MONITORDB < $LDAPGLUECONF2 > $ADDCONF
62 $SLAPADD -f $ADDCONF -l $LDIFLDAPGLUE2
64 if test $RC != 0 ; then
65 echo "slapadd 2 failed ($RC)!"
69 . $CONFFILTER $BACKEND $MONITORDB < $LDAPGLUECONF3 > $ADDCONF
70 $SLAPADD -f $ADDCONF -l $LDIFLDAPGLUE3
72 if test $RC != 0 ; then
73 echo "slapadd 3 failed ($RC)!"
77 echo "Starting local slapd on TCP/IP port $PORT1..."
78 . $CONFFILTER $BACKEND $MONITORDB < $LDAPGLUECONF1 > $CONF1
79 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
81 if test $WAIT != 0 ; then
86 echo "Starting remote slapd 1 on TCP/IP port $PORT2..."
87 . $CONFFILTER $BACKEND $MONITORDB < $LDAPGLUECONF2 > $CONF2
88 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
90 if test $WAIT != 0 ; then
95 echo "Starting remote slapd 2 on TCP/IP port $PORT3..."
96 . $CONFFILTER $BACKEND $MONITORDB < $LDAPGLUECONF3 > $CONF3
97 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
99 if test $WAIT != 0 ; then
103 KILLPIDS="$PID1 $PID2 $PID3"
105 echo "Using ldapsearch to check that slapd is running..."
106 for i in 0 1 2 3 4 5; do
107 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
108 'objectclass=*' > /dev/null 2>&1
110 if test $RC = 0 ; then
113 echo "Waiting 5 seconds for slapd to start..."
117 echo "Using ldapsearch to check that slapd is running..."
118 for i in 0 1 2 3 4 5; do
119 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
120 'objectclass=*' > /dev/null 2>&1
122 if test $RC = 0 ; then
125 echo "Waiting 5 seconds for slapd to start..."
129 echo "Using ldapsearch to check that slapd is running..."
130 for i in 0 1 2 3 4 5; do
131 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
132 'objectclass=*' > /dev/null 2>&1
134 if test $RC = 0 ; then
137 echo "Waiting 5 seconds for slapd to start..."
141 ID="uid=bjorn,ou=People,dc=example,dc=com"
142 BASE="dc=example,dc=com"
143 echo "Testing ldapsearch as $ID for \"$BASE\"..."
144 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
145 -D "$ID" -w bjorn > $SEARCHOUT 2>&1
148 if test $RC != 0 ; then
149 echo "ldapsearch failed ($RC)!"
150 test $KILLSERVERS != no && kill -HUP $KILLPIDS
154 echo "Filtering ldapsearch results..."
155 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
156 echo "Filtering original ldif used to create database..."
157 . $LDIFFILTER < $LDAPGLUEOUT > $LDIFFLT
158 echo "Comparing filter output..."
159 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
161 if test $? != 0 ; then
162 echo "comparison failed - glued search with identity assertion didn't succeed"
163 test $KILLSERVERS != no && kill -HUP $KILLPIDS
167 BASE="dc=example,dc=com"
168 echo "Testing ldapsearch as anonymous for \"$BASE\"..."
169 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
173 if test $RC != 0 ; then
174 echo "ldapsearch failed ($RC)!"
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 echo "Filtering ldapsearch results..."
180 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
181 echo "Filtering original ldif used to create database..."
182 . $LDIFFILTER < $LDAPGLUEANONYMOUSOUT > $LDIFFLT
183 echo "Comparing filter output..."
184 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
186 if test $? != 0 ; then
187 echo "comparison failed - anonymous glued search with identity assertion didn't succeed"
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 # FIXME: this cannot work as is, because SASL bind cannot be proxied!
193 if test $USE_SASL != "no" ; then
195 BASE="dc=example,dc=com"
196 echo "Testing ldapsearch as $ID for \"$BASE\" with SASL bind and identity assertion..."
197 $LDAPSASLSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
198 -Q -U "$ID" -w bjorn -Y $MECH > $SEARCHOUT 2>&1
201 if test $RC != 0 ; then
202 echo "ldapsearch failed ($RC)!"
203 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207 echo "Filtering ldapsearch results..."
208 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
209 echo "Filtering original ldif used to create database..."
210 . $LDIFFILTER < $LDAPGLUEOUT > $LDIFFLT
211 echo "Comparing filter output..."
212 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
214 if test $? != 0 ; then
215 echo "comparison failed - glued search with SASL bind and identity assertion didn't succeed"
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 echo ">>>>> Test succeeded"