]> git.sur5r.net Git - openldap/blob - tests/scripts/test028-idassert
add test for idassert
[openldap] / tests / scripts / test028-idassert
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2004 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $BACKLDAP = "ldapno" ; then 
20         echo "LDAP backend not available, test skipped"
21         exit 0
22 fi 
23
24 if test $WITH_SASL = "yes" ; then
25         echo "Using SASL authc/authz..."
26 else
27         echo "SASL not available; using proxyAuthz with simple authc..."
28 fi
29
30 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
31
32 echo "Running slapadd to build slapd database..."
33 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $ADDCONF
34 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT1 -n 1
35 RC=$?
36 if test $RC != 0 ; then
37         echo "slapadd -n 1 failed ($RC)!"
38         exit $RC
39 fi
40 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT2 -n 2
41 RC=$?
42 if test $RC != 0 ; then
43         echo "slapadd -n 2 failed ($RC)!"
44         exit $RC
45 fi
46
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 &
50 PID=$!
51 if test $WAIT != 0 ; then
52     echo PID $PID
53     read foo
54 fi
55 KILLPIDS="$PID"
56
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
61         RC=$?
62         if test $RC = 0 ; then
63                 break
64         fi
65         echo "Waiting 5 seconds for slapd to start..."
66         sleep 5
67 done
68
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
71 RC=$?
72 if test $RC != 0 ; then
73         echo "ldapwhoami failed ($RC)!"
74         test $KILLSERVERS != no && kill -HUP $KILLPIDS
75         exit $RC
76 fi
77
78 AUTHZID="u:it/jaj"
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"
81 RC=$?
82 if test $RC != 0 ; then
83         echo "ldapwhoami failed ($RC)!"
84         test $KILLSERVERS != no && kill -HUP $KILLPIDS
85         exit $RC
86 fi
87
88 AUTHZID="u:bjorn"
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"
91 RC=$?
92 if test $RC != 1 ; then
93         echo "ldapwhoami should have failed ($RC)!"
94         test $KILLSERVERS != no && kill -HUP $KILLPIDS
95         exit $RC
96 fi
97
98 AUTHZID="u:bjensen"
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"
101 RC=$?
102 if test $RC != 1 ; then
103         echo "ldapwhoami should have failed ($RC)!"
104         test $KILLSERVERS != no && kill -HUP $KILLPIDS
105         exit $RC
106 fi
107
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
110 RC=$?
111 if test $RC != 0 ; then
112         echo "ldapwhoami failed ($RC)!"
113         test $KILLSERVERS != no && kill -HUP $KILLPIDS
114         exit $RC
115 fi
116
117 AUTHZID="u:it/jaj"
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"
120 RC=$?
121 if test $RC != 1 ; then
122         echo "ldapwhoami should have failed ($RC)!"
123         test $KILLSERVERS != no && kill -HUP $KILLPIDS
124         exit $RC
125 fi
126
127 AUTHZID="u:bjorn"
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"
130 RC=$?
131 if test $RC != 1 ; then
132         echo "ldapwhoami should have failed ($RC)!"
133         test $KILLSERVERS != no && kill -HUP $KILLPIDS
134         exit $RC
135 fi
136
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"
140 RC=$?
141 if test $RC != 0 ; then
142         echo "ldapwhoami failed ($RC)!"
143         test $KILLSERVERS != no && kill -HUP $KILLPIDS
144         exit $RC
145 fi
146
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"
150 RC=$?
151 if test $RC != 0 ; then
152         echo "ldapwhoami failed ($RC)!"
153         test $KILLSERVERS != no && kill -HUP $KILLPIDS
154         exit $RC
155 fi
156
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"
160 RC=$?
161 if test $RC != 0 ; then
162         echo "ldapwhoami failed ($RC)!"
163         test $KILLSERVERS != no && kill -HUP $KILLPIDS
164         exit $RC
165 fi
166
167 test $KILLSERVERS != no && kill -HUP $KILLPIDS
168
169 echo ">>>>> Test succeeded"
170 exit 0
171