]> git.sur5r.net Git - openldap/blob - tests/scripts/test028-idassert
79815d60306e5bcbe23125d50b16986a65505053
[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         if test $USE_SASL = "yes" ; then
26                 echo "Using SASL authc/authz..."
27         else
28                 echo "Using proxyAuthz with simple authc"
29                 echo "set SLAPD_USE_SASL=yes to enable SASL authc/authz..."
30         fi
31 else
32         echo "SASL not available; using proxyAuthz with simple authc..."
33 fi
34
35 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
36
37 echo "Running slapadd to build slapd database..."
38 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $ADDCONF
39 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT1 -n 1
40 RC=$?
41 if test $RC != 0 ; then
42         echo "slapadd -n 1 failed ($RC)!"
43         exit $RC
44 fi
45 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT2 -n 2
46 RC=$?
47 if test $RC != 0 ; then
48         echo "slapadd -n 2 failed ($RC)!"
49         exit $RC
50 fi
51
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 &
55 PID=$!
56 if test $WAIT != 0 ; then
57     echo PID $PID
58     read foo
59 fi
60 KILLPIDS="$PID"
61
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
66         RC=$?
67         if test $RC = 0 ; then
68                 break
69         fi
70         echo "Waiting 5 seconds for slapd to start..."
71         sleep 5
72 done
73
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
76 RC=$?
77 if test $RC != 0 ; then
78         echo "ldapwhoami failed ($RC)!"
79         test $KILLSERVERS != no && kill -HUP $KILLPIDS
80         exit $RC
81 fi
82
83 AUTHZID="u:it/jaj"
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"
86 RC=$?
87 if test $RC != 0 ; then
88         echo "ldapwhoami failed ($RC)!"
89         test $KILLSERVERS != no && kill -HUP $KILLPIDS
90         exit $RC
91 fi
92
93 AUTHZID="u:bjorn"
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"
96 RC=$?
97 if test $RC != 1 ; then
98         echo "ldapwhoami should have failed ($RC)!"
99         test $KILLSERVERS != no && kill -HUP $KILLPIDS
100         exit $RC
101 fi
102
103 AUTHZID="u:bjensen"
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"
106 RC=$?
107 if test $RC != 1 ; then
108         echo "ldapwhoami should have failed ($RC)!"
109         test $KILLSERVERS != no && kill -HUP $KILLPIDS
110         exit $RC
111 fi
112
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
115 RC=$?
116 if test $RC != 0 ; then
117         echo "ldapwhoami failed ($RC)!"
118         test $KILLSERVERS != no && kill -HUP $KILLPIDS
119         exit $RC
120 fi
121
122 AUTHZID="u:it/jaj"
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"
125 RC=$?
126 if test $RC != 1 ; then
127         echo "ldapwhoami should have failed ($RC)!"
128         test $KILLSERVERS != no && kill -HUP $KILLPIDS
129         exit $RC
130 fi
131
132 AUTHZID="u:bjorn"
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"
135 RC=$?
136 if test $RC != 1 ; then
137         echo "ldapwhoami should have failed ($RC)!"
138         test $KILLSERVERS != no && kill -HUP $KILLPIDS
139         exit $RC
140 fi
141
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"
145 RC=$?
146 if test $RC != 0 ; then
147         echo "ldapwhoami failed ($RC)!"
148         test $KILLSERVERS != no && kill -HUP $KILLPIDS
149         exit $RC
150 fi
151
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"
155 RC=$?
156 if test $RC != 0 ; then
157         echo "ldapwhoami failed ($RC)!"
158         test $KILLSERVERS != no && kill -HUP $KILLPIDS
159         exit $RC
160 fi
161
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"
165 RC=$?
166 if test $RC != 0 ; then
167         echo "ldapwhoami failed ($RC)!"
168         test $KILLSERVERS != no && kill -HUP $KILLPIDS
169         exit $RC
170 fi
171
172 test $KILLSERVERS != no && kill -HUP $KILLPIDS
173
174 echo ">>>>> Test succeeded"
175 exit 0
176