3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 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 if test $BACKLDAP = "ldapno" ; then
20 echo "LDAP backend not available, test skipped"
24 if test $WITH_SASL = "yes" ; then
25 if test $USE_SASL != "no" ; then
26 if test $USE_SASL = "yes" ; then
31 echo "Using SASL authc/authz with mech=$MECH; unset SLAPD_USE_SASL to disable"
33 echo "Using proxyAuthz with simple authc..."
34 echo " set SLAPD_USE_SASL={yes|<mech>} to enable SASL authc/authz"
35 echo " if SLAPD_USE_SASL=\"yes\", <mech> defaults to DIGEST-MD5"
36 echo " FIXME: should be mandatory, right?"
37 echo " FIXME: authz with CRAM-MD5 does not work..."
40 echo "SASL not available; using proxyAuthz with simple authc..."
43 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
45 echo "Running slapadd to build slapd database..."
46 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $ADDCONF
47 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT1 -n 1
49 if test $RC != 0 ; then
50 echo "slapadd -n 1 failed ($RC)!"
53 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT2 -n 2
55 if test $RC != 0 ; then
56 echo "slapadd -n 2 failed ($RC)!"
60 echo "Starting slapd on TCP/IP port $PORT..."
61 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $CONF1
62 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
64 if test $WAIT != 0 ; then
70 echo "Using ldapsearch to check that slapd is running..."
71 for i in 0 1 2 3 4 5; do
72 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
73 'objectclass=*' > /dev/null 2>&1
75 if test $RC = 0 ; then
78 echo "Waiting 5 seconds for slapd to start..."
82 echo "Testing ldapwhoami as proxy US..."
83 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy
85 if test $RC != 0 ; then
86 echo "ldapwhoami failed ($RC)!"
87 test $KILLSERVERS != no && kill -HUP $KILLPIDS
92 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
93 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
95 if test $RC != 0 ; then
96 echo "ldapwhoami failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
102 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
103 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
105 if test $RC != 1 ; then
106 echo "ldapwhoami should have failed ($RC)!"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
112 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
113 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
115 if test $RC != 1 ; then
116 echo "ldapwhoami should have failed ($RC)!"
117 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 echo "Testing ldapwhoami as proxy IT..."
122 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy
124 if test $RC != 0 ; then
125 echo "ldapwhoami failed ($RC)!"
126 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
132 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
134 if test $RC != 1 ; then
135 echo "ldapwhoami should have failed ($RC)!"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
141 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
142 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
144 if test $RC != 1 ; then
145 echo "ldapwhoami should have failed ($RC)!"
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
150 AUTHZID="dn:cn=Sandbox,ou=Admin,dc=example,dc=com"
151 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
152 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
154 if test $RC != 0 ; then
155 echo "ldapwhoami failed ($RC)!"
156 test $KILLSERVERS != no && kill -HUP $KILLPIDS
160 AUTHZID="dn:uid=bjorn,ou=People,o=Example,c=US"
161 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
162 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
164 if test $RC != 0 ; then
165 echo "ldapwhoami failed ($RC)!"
166 test $KILLSERVERS != no && kill -HUP $KILLPIDS
170 AUTHZID="dn:uid=bjorn,ou=People,o=Esempio,c=IT"
171 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
172 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
174 if test $RC != 0 ; then
175 echo "ldapwhoami failed ($RC)!"
176 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 ID="uid=jaj,ou=People,dc=example,dc=it"
181 BASE="o=Example,c=US"
182 echo "Testing ldapsearch as $ID for \"$BASE\"..."
183 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
184 -D "$ID" -w jaj > $SEARCHOUT 2>&1
187 if test $RC != 0 ; then
188 echo "ldapsearch failed ($RC)!"
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193 echo "Filtering ldapsearch results..."
194 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
195 echo "Filtering original ldif used to create database..."
196 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
197 echo "Comparing filter output..."
198 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
200 if test $? != 0 ; then
201 echo "comparison failed - search with identity assertion didn't succeed"
205 if test $USE_SASL != "no" ; then
207 BASE="o=Example,c=US"
208 echo "Testing ldapsearch as $ID for \"$BASE\" with SASL bind and identity assertion..."
209 $LDAPSASLSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
210 -Q -U "$ID" -w jaj -Y $MECH > $SEARCHOUT 2>&1
213 if test $RC != 0 ; then
214 echo "ldapsearch failed ($RC)!"
215 test $KILLSERVERS != no && kill -HUP $KILLPIDS
219 echo "Filtering ldapsearch results..."
220 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
221 echo "Filtering original ldif used to create database..."
222 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
223 echo "Comparing filter output..."
224 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
226 if test $? != 0 ; then
227 echo "comparison failed - search with SASL bind and identity assertion didn't succeed"
232 test $KILLSERVERS != no && kill -HUP $KILLPIDS
234 echo ">>>>> Test succeeded"