3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2006 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 the rwm 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 $RWM = "rwmno" ; then
31 echo "Rewrite/remap overlay not available, test skipped"
35 if test $THREADS = "threadsno" ; then
36 echo "Need threads support, test skipped"
40 if test $WITH_SASL = "yes" ; then
41 if test $USE_SASL != "no" ; then
42 if test $USE_SASL = "yes" ; then
47 echo "Using SASL authc[/authz] with mech=$MECH; unset SLAPD_USE_SASL to disable"
49 echo "Using proxyAuthz with simple authc..."
52 echo "SASL not available; using proxyAuthz with simple authc..."
55 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
57 echo "Running slapadd to build slapd database..."
58 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $ADDCONF
59 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT1 -n 1
61 if test $RC != 0 ; then
62 echo "slapadd -n 1 failed ($RC)!"
65 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT2 -n 2
67 if test $RC != 0 ; then
68 echo "slapadd -n 2 failed ($RC)!"
72 echo "Starting slapd on TCP/IP port $PORT..."
73 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $CONF1
74 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
76 if test $WAIT != 0 ; then
84 echo "Using ldapsearch to check that slapd is running..."
85 for i in 0 1 2 3 4 5; do
86 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
87 'objectclass=*' > /dev/null 2>&1
89 if test $RC = 0 ; then
92 echo "Waiting 5 seconds for slapd to start..."
96 echo "Testing ldapwhoami as proxy US..."
97 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy
99 if test $RC != 0 ; then
100 echo "ldapwhoami failed ($RC)!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
107 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
109 if test $RC != 0 ; then
110 echo "ldapwhoami failed ($RC)!"
111 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116 echo "Testing ldapwhoami as proxy US, $AUTHZID... (should fail)"
117 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
119 if test $RC != 1 ; then
120 echo "ldapwhoami should have failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 echo "Testing ldapwhoami as proxy US, $AUTHZID... (should fail)"
127 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
129 if test $RC != 1 ; then
130 echo "ldapwhoami should have failed ($RC)!"
131 test $KILLSERVERS != no && kill -HUP $KILLPIDS
135 echo "Testing ldapwhoami as proxy IT..."
136 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy
138 if test $RC != 0 ; then
139 echo "ldapwhoami failed ($RC)!"
140 test $KILLSERVERS != no && kill -HUP $KILLPIDS
145 echo "Testing ldapwhoami as proxy IT, $AUTHZID... (should fail)"
146 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
148 if test $RC != 1 ; then
149 echo "ldapwhoami should have failed ($RC)!"
150 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 echo "Testing ldapwhoami as proxy IT, $AUTHZID... (should fail)"
156 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
158 if test $RC != 1 ; then
159 echo "ldapwhoami should have failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 AUTHZID="dn:cn=Sandbox,ou=Admin,dc=example,dc=com"
165 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
166 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
168 if test $RC != 0 ; then
169 echo "ldapwhoami failed ($RC)!"
170 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 AUTHZID="dn:uid=bjorn,ou=People,o=Example,c=US"
175 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
176 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
178 if test $RC != 0 ; then
179 echo "ldapwhoami failed ($RC)!"
180 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 AUTHZID="dn:uid=bjorn,ou=People,o=Esempio,c=IT"
185 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
186 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
188 if test $RC != 0 ; then
189 echo "ldapwhoami failed ($RC)!"
190 test $KILLSERVERS != no && kill -HUP $KILLPIDS
194 ID="uid=jaj,ou=People,dc=example,dc=it"
195 BASE="o=Example,c=US"
196 echo "Testing ldapsearch as $ID for \"$BASE\"..."
197 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
198 -D "$ID" -w jaj > $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 < $IDASSERTOUT > $LDIFFLT
211 echo "Comparing filter output..."
212 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
214 if test $? != 0 ; then
215 echo "comparison failed - search with identity assertion didn't succeed"
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 if test $USE_SASL != "no" ; then
222 BASE="o=Example,c=US"
223 echo "Testing ldapsearch as $ID for \"$BASE\" with SASL bind and identity assertion..."
224 $LDAPSASLSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
225 -Q -U "$ID" -w jaj -Y $MECH > $SEARCHOUT 2>&1
228 if test $RC != 0 ; then
229 echo "ldapsearch failed ($RC)!"
230 test $KILLSERVERS != no && kill -HUP $KILLPIDS
234 echo "Filtering ldapsearch results..."
235 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
236 echo "Filtering original ldif used to create database..."
237 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
238 echo "Comparing filter output..."
239 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
241 if test $? != 0 ; then
242 echo "comparison failed - search with SASL bind and identity assertion didn't succeed"
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
248 test $KILLSERVERS != no && kill -HUP $KILLPIDS
250 echo ">>>>> Test succeeded"
252 test $KILLSERVERS != no && wait