]> git.sur5r.net Git - openldap/blob - tests/scripts/test041-aci
Disable test for now.
[openldap] / tests / scripts / test041-aci
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 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 "Test disabled."
17 exit 0
18
19 case "$BACKEND" in
20 bdb|hdb|ldbm)
21         ;;
22 *)
23         echo "Test does not support $BACKEND backend"
24         exit 0
25         ;;
26 esac
27
28 echo "running defines.sh"
29 . $SRCDIR/scripts/defines.sh
30
31 if test "$ACI" = "acino" ; then
32         echo "ACI not enabled; skipping..."
33         exit 0
34 fi
35
36 mkdir -p $TESTDIR $DBDIR1
37
38 echo "Running slapadd to build slapd database..."
39 . $CONFFILTER $BACKEND $MONITORDB < $ACICONF > $CONF1
40 $SLAPADD -f $CONF1 -l $LDIFORDERED
41 RC=$?
42 if test $RC != 0 ; then
43         echo "slapadd failed ($RC)!"
44         exit $RC
45 fi
46
47 echo "Starting slapd on TCP/IP port $PORT1..."
48 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
49 PID=$!
50 if test $WAIT != 0 ; then
51     echo PID $PID
52     read foo
53 fi
54 KILLPIDS="$PID"
55
56 echo "Testing slapd ACI access control..."
57 for i in 0 1 2 3 4 5; do
58         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
59                 'objectclass=*' > /dev/null 2>&1
60         RC=$?
61         if test $RC = 0 ; then
62                 break
63         fi
64         echo "Waiting 5 seconds for slapd to start..."
65         sleep 5
66 done
67
68 if test $RC != 0 ; then
69         echo "ldapsearch failed ($RC)!"
70         test $KILLSERVERS != no && kill -HUP $KILLPIDS
71         exit $RC
72 fi
73
74 cat /dev/null > $SEARCHOUT
75 cat /dev/null > $TESTOUT
76
77 # Search must fail
78 BASEDN="dc=example,dc=com"
79 echo "Searching \"$BASEDN\" (should fail)..."
80 echo "# Searching \"$BASEDN\" (should fail)..." >> $SEARCHOUT
81 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
82         '(objectclass=*)' >> $SEARCHOUT 2>> $TESTOUT
83 RC=$?
84 if test $RC != 32 ; then
85         echo "ldapsearch should have failed with noSuchObject ($RC)!"
86         test $KILLSERVERS != no && kill -HUP $KILLPIDS
87         if test $RC = 0 ; then
88                 exit -1
89         fi
90         exit $RC
91 fi
92
93 # Bind must fail
94 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
95 BINDPW=bjensen
96 echo "Testing ldapwhoami as ${BINDDN} (should fail)..."
97 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
98 RC=$?
99 if test $RC = 0 ; then
100         echo "ldapwhoami should have failed!"
101         test $KILLSERVERS != no && kill -HUP $KILLPIDS
102         exit -1
103 fi
104
105 # Populate ACIs
106 echo "Writing ACIs as \"$MANAGERDN\"..."
107 $LDAPMODIFY -D "$MANAGERDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \
108         >> $TESTOUT 2>&1 << EOMODS0
109 dn: dc=example,dc=com
110 changetype: modify
111 add: OpenLDAPaci
112 OpenLDAPaci: 0#subtree#grant;d,c,s,r;[all]#group/groupOfUniqueNames/uniqueMe
113  mber#cn=ITD Staff,ou=Groups,dc=example,dc=com
114 OpenLDAPaci: 1#entry#grant;d;[all]#public#
115
116 dn: ou=People,dc=example,dc=com
117 changetype: modify
118 add: OpenLDAPaci
119 OpenLDAPaci: 0#subtree#grant;x;userPassword#public#
120 OpenLDAPaci: 1#subtree#grant;w;userPassword#self#
121 OpenLDAPaci: 2#subtree#grant;w;userPassword#access-id#cn=Bjorn Jensen,ou=Inf
122  ormation Technology Division,ou=People,dc=example,dc=com
123
124 dn: ou=Groups,dc=example,dc=com
125 changetype: modify
126 add: OpenLDAPaci
127 OpenLDAPaci: 0#entry#grant;s;[all]#public#
128 OpenLDAPaci: 1#children#grant;r;member;r;uniqueMember#access-id#cn=Bjorn Jen
129  sen,ou=Information Technology Division,ou=People,dc=example,dc=com
130 EOMODS0
131 RC=$?
132 if test $RC != 0 ; then
133         echo "ldapmodify failed ($RC)!"
134         test $KILLSERVERS != no && kill -HUP $KILLPIDS
135         exit $RC
136 fi
137
138 # Search must succeed with no results
139 BASEDN="dc=example,dc=com"
140 echo "Searching \"$BASEDN\" (should succeed with no results)..."
141 echo "# Searching \"$BASEDN\" (should succeed with no results)..." >> $SEARCHOUT
142 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
143         '(objectclass=*)' >> $SEARCHOUT 2>> $TESTOUT
144 RC=$?
145 if test $RC != 0 ; then
146         ### TEMPORARY (see ITS#3963)
147         echo "ldapsearch failed ($RC)! IGNORED..."
148         ###echo "ldapsearch failed ($RC)!"
149         ###test $KILLSERVERS != no && kill -HUP $KILLPIDS
150         ###exit $RC
151 fi
152
153 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
154 BINDPW=bjensen
155 echo "Testing ldapwhoami as ${BINDDN}..."
156 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
157 RC=$?
158 if test $RC != 0 ; then
159         echo "ldapwhoami failed ($RC)!"
160         test $KILLSERVERS != no && kill -HUP $KILLPIDS
161         exit $RC
162 fi
163
164 # Search must succeed 
165 BINDDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
166 BINDPW=bjorn
167 BASEDN="dc=example,dc=com"
168 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..."
169 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..." >> $SEARCHOUT
170 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
171         -D "$BINDDN" -w "$BINDPW" \
172         '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
173 RC=$?
174 if test $RC != 0 ; then
175         echo "ldapsearch failed ($RC)!"
176         test $KILLSERVERS != no && kill -HUP $KILLPIDS
177         exit $RC
178 fi
179
180 # Passwd must succeed 
181 BINDDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
182 BINDPW=bjorn
183 TGT="cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com"
184 NEWPW=jdoe
185 echo "Setting \"$TGT\" password..."
186 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
187         -w "$BINDPW" -s "$NEWPW" \
188         -D "$BINDDN" "$TGT" >> $TESTOUT 2>&1
189 RC=$?
190 if test $RC != 0 ; then
191         echo "ldappasswd failed ($RC)!"
192         test $KILLSERVERS != no && kill -HUP $KILLPIDS
193         exit $RC
194 fi
195
196 # Re-change as self...
197 echo "Changing self password..."
198 BINDDN="$TGT"
199 BINDPW=$NEWPW
200 TGT="cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com"
201 NEWPW=newcred
202 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
203         -w "$BINDPW" -s "$NEWPW" \
204         -D "$BINDDN" "$TGT" >> $TESTOUT 2>&1
205 RC=$?
206 if test $RC != 0 ; then
207         echo "ldappasswd failed ($RC)!"
208         test $KILLSERVERS != no && kill -HUP $KILLPIDS
209         exit $RC
210 fi
211
212 # Searching groups
213 BINDPW=$NEWPW
214 BASEDN="ou=Groups,dc=example,dc=com"
215 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..."
216 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..." >> $SEARCHOUT
217 $LDAPSEARCH -s one -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
218         -D "$BINDDN" -w "$BINDPW" \
219         '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
220 RC=$?
221 if test $RC != 0 ; then
222         echo "ldapsearch failed ($RC)!"
223         test $KILLSERVERS != no && kill -HUP $KILLPIDS
224         exit $RC
225 fi
226
227 # Search must fail
228 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
229 BINDPW=bjensen
230 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed with no results)..."
231 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed with no results)..." >> $SEARCHOUT
232 $LDAPSEARCH -s one -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
233         -D "$BINDDN" -w "$BINDPW" \
234         '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
235 RC=$?
236 if test $RC != 0 ; then
237         echo "ldapsearch failed ($RC)!"
238         test $KILLSERVERS != no && kill -HUP $KILLPIDS
239         exit $RC
240 fi
241
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
243
244 LDIF=$ACIOUT
245
246 echo "Filtering ldapsearch results..."
247 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
248 echo "Filtering original ldif used to create database..."
249 . $LDIFFILTER < $LDIF > $LDIFFLT
250 echo "Comparing filter output..."
251 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
252
253 if test $? != 0 ; then
254         echo "comparison failed - operations did not complete correctly"
255         exit 1
256 fi
257
258 echo ">>>>> Test succeeded"
259 exit 0