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 echo "Using SASL authc/authz..."
27 echo "SASL not available; using proxyAuthz with simple authc..."
30 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
32 echo "Running slapadd to build slapd database..."
33 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $ADDCONF
34 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT1 -n 1
36 if test $RC != 0 ; then
37 echo "slapadd -n 1 failed ($RC)!"
40 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT2 -n 2
42 if test $RC != 0 ; then
43 echo "slapadd -n 2 failed ($RC)!"
47 echo "Starting slapd on TCP/IP port $PORT..."
48 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $CONF1
49 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
51 if test $WAIT != 0 ; then
57 echo "Using ldapsearch to check that slapd is running..."
58 for i in 0 1 2 3 4 5; do
59 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
60 'objectclass=*' > /dev/null 2>&1
62 if test $RC = 0 ; then
65 echo "Waiting 5 seconds for slapd to start..."
69 echo "Testing ldapwhoami as proxy US..."
70 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy
72 if test $RC != 0 ; then
73 echo "ldapwhoami failed ($RC)!"
74 test $KILLSERVERS != no && kill -HUP $KILLPIDS
79 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
80 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
82 if test $RC != 0 ; then
83 echo "ldapwhoami failed ($RC)!"
84 test $KILLSERVERS != no && kill -HUP $KILLPIDS
89 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
90 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
92 if test $RC != 1 ; then
93 echo "ldapwhoami should have failed ($RC)!"
94 test $KILLSERVERS != no && kill -HUP $KILLPIDS
99 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
100 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
102 if test $RC != 1 ; then
103 echo "ldapwhoami should have failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 echo "Testing ldapwhoami as proxy IT..."
109 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy
111 if test $RC != 0 ; then
112 echo "ldapwhoami failed ($RC)!"
113 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
119 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
121 if test $RC != 1 ; then
122 echo "ldapwhoami should have failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
129 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
131 if test $RC != 1 ; then
132 echo "ldapwhoami should have failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 AUTHZID="dn:cn=Sandbox,ou=Admin,dc=example,dc=com"
138 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
139 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
141 if test $RC != 0 ; then
142 echo "ldapwhoami failed ($RC)!"
143 test $KILLSERVERS != no && kill -HUP $KILLPIDS
147 AUTHZID="dn:uid=bjorn,ou=People,o=Example,c=US"
148 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
149 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
151 if test $RC != 0 ; then
152 echo "ldapwhoami failed ($RC)!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 AUTHZID="dn:uid=bjorn,ou=People,o=Esempio,c=IT"
158 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
159 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
161 if test $RC != 0 ; then
162 echo "ldapwhoami failed ($RC)!"
163 test $KILLSERVERS != no && kill -HUP $KILLPIDS
167 test $KILLSERVERS != no && kill -HUP $KILLPIDS
169 echo ">>>>> Test succeeded"