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 = "yes" ; then
26 echo "Using SASL authc/authz..."
28 echo "Using proxyAuthz with simple authc"
29 echo "set SLAPD_USE_SASL=yes to enable SASL authc/authz..."
32 echo "SASL not available; using proxyAuthz with simple authc..."
35 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
37 echo "Running slapadd to build slapd database..."
38 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $ADDCONF
39 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT1 -n 1
41 if test $RC != 0 ; then
42 echo "slapadd -n 1 failed ($RC)!"
45 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT2 -n 2
47 if test $RC != 0 ; then
48 echo "slapadd -n 2 failed ($RC)!"
52 echo "Starting slapd on TCP/IP port $PORT..."
53 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $CONF1
54 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
56 if test $WAIT != 0 ; then
62 echo "Using ldapsearch to check that slapd is running..."
63 for i in 0 1 2 3 4 5; do
64 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
65 'objectclass=*' > /dev/null 2>&1
67 if test $RC = 0 ; then
70 echo "Waiting 5 seconds for slapd to start..."
74 echo "Testing ldapwhoami as proxy US..."
75 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy
77 if test $RC != 0 ; then
78 echo "ldapwhoami failed ($RC)!"
79 test $KILLSERVERS != no && kill -HUP $KILLPIDS
84 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
85 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
87 if test $RC != 0 ; then
88 echo "ldapwhoami failed ($RC)!"
89 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
95 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
97 if test $RC != 1 ; then
98 echo "ldapwhoami should have failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
105 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
107 if test $RC != 1 ; then
108 echo "ldapwhoami should have failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
113 echo "Testing ldapwhoami as proxy IT..."
114 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy
116 if test $RC != 0 ; then
117 echo "ldapwhoami failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
124 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
126 if test $RC != 1 ; then
127 echo "ldapwhoami should have failed ($RC)!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
133 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
134 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
136 if test $RC != 1 ; then
137 echo "ldapwhoami should have failed ($RC)!"
138 test $KILLSERVERS != no && kill -HUP $KILLPIDS
142 AUTHZID="dn:cn=Sandbox,ou=Admin,dc=example,dc=com"
143 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
144 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
146 if test $RC != 0 ; then
147 echo "ldapwhoami failed ($RC)!"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 AUTHZID="dn:uid=bjorn,ou=People,o=Example,c=US"
153 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
154 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
156 if test $RC != 0 ; then
157 echo "ldapwhoami failed ($RC)!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 AUTHZID="dn:uid=bjorn,ou=People,o=Esempio,c=IT"
163 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
164 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
166 if test $RC != 0 ; then
167 echo "ldapwhoami failed ($RC)!"
168 test $KILLSERVERS != no && kill -HUP $KILLPIDS
172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 echo ">>>>> Test succeeded"