]> git.sur5r.net Git - openldap/blob - tests/scripts/test006-acls
Removing University of Michigan from installation test suite (ITS#3107)
[openldap] / tests / scripts / test006-acls
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 mkdir -p $TESTDIR $DBDIR1
20
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $ACLCONF > $CONF1
23 $SLAPADD -f $CONF1 -l $LDIFORDERED
24 RC=$?
25 if test $RC != 0 ; then
26         echo "slapadd failed ($RC)!"
27         exit $RC
28 fi
29
30 echo "Starting slapd on TCP/IP port $PORT1..."
31 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
32 PID=$!
33 if test $WAIT != 0 ; then
34     echo PID $PID
35     read foo
36 fi
37 KILLPIDS="$PID"
38
39 echo "Testing slapd access control..."
40 for i in 0 1 2 3 4 5; do
41         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
42                 'objectclass=*' > /dev/null 2>&1
43         RC=$?
44         if test $RC = 0 ; then
45                 break
46         fi
47         echo "Waiting 5 seconds for slapd to start..."
48         sleep 5
49 done
50
51 if test $RC != 0 ; then
52         echo "ldapsearch failed ($RC)!"
53         test $KILLSERVERS != no && kill -HUP $KILLPIDS
54         exit $RC
55 fi
56
57 cat /dev/null > $SEARCHOUT
58
59 #
60 # Try to read an entry inside the Alumni Association container.  It should
61 # give us nothing if we're not bound, and should return all attributes
62 # if we're bound as anyone under UM.
63 #
64 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 "objectclass=*" \
65         >> $SEARCHOUT 2>&1
66
67 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 \
68         -D "$BABSDN" -w bjensen "objectclass=*"  >> $SEARCHOUT 2>&1
69
70 #
71 # Check group access. Try to modify Babs' entry. Two attempts:
72 # 1) bound as "James A Jones 1" - should fail
73 # 2) bound as "Bjorn Jensen" - should succeed
74
75 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
76         $TESTOUT 2>&1 << EOMODS5
77 dn: $BABSDN
78 changetype: modify
79 replace: drink
80 drink: wine
81
82 EOMODS5
83
84
85 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
86         $TESTOUT 2>&1 << EOMODS6
87 dn: $BABSDN
88 changetype: modify
89 add: homephone
90 homephone: +1 313 555 5444
91
92 EOMODS6
93
94 #
95 # Try to add a "member" attribute to the "All Staff" group.  It should
96 # fail when we add some DN other than our own, and should succeed when
97 # we add our own DN.
98 # bjensen
99 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj > \
100         $TESTOUT 2>&1 << EOMODS1
101 version: 1
102 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
103 changetype: modify
104 add: uniquemember
105 uniquemember: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
106
107 EOMODS1
108
109 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
110         $TESTOUT 2>&1 << EOMODS2
111 version: 1
112
113 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
114 changetype: modify
115 add: uniquemember
116 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
117 EOMODS2
118
119 #
120 # Try to modify the "All Staff" group.  Two attempts are made:
121 # 1) bound as "James A Jones 1" - should fail
122 # 2) bound as "Barbara Jensen" - should succeed
123 #
124 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
125         $TESTOUT 2>&1 << EOMODS3
126
127 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
128 changetype: modify
129 delete: description
130
131 EOMODS3
132
133 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
134         $TESTOUT 2>&1 << EOMODS4
135 # COMMENT
136 version: 1
137 # comment
138 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
139 # comment
140 changetype: modify
141 # comment
142 add: ou
143 # comment
144 ou: Groups
145 # comment
146 EOMODS4
147
148 echo "Using ldapsearch to retrieve all the entries..."
149 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
150             'objectClass=*' >> $SEARCHOUT 2>&1
151 RC=$?
152 test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 if test $RC != 0 ; then
154         echo "ldapsearch failed ($RC)!"
155         exit $RC
156 fi
157
158 LDIF=$ACLOUTMASTER
159
160 echo "Filtering ldapsearch results..."
161 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
162 echo "Filtering original ldif used to create database..."
163 . $LDIFFILTER < $LDIF > $LDIFFLT
164 echo "Comparing filter output..."
165 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
166
167 if test $? != 0 ; then
168         echo "comparison failed - modify operations did not complete correctly"
169         exit 1
170 fi
171
172 echo ">>>>> Test succeeded"
173 exit 0