]> git.sur5r.net Git - openldap/blob - tests/scripts/test006-acls
Finish adding subclassing indexing support
[openldap] / tests / scripts / test006-acls
1 #! /bin/sh
2 # $OpenLDAP$
3
4 SRCDIR="."
5 if test $# -ge 1 ; then
6         SRCDIR=$1; shift
7 fi
8 BACKEND=bdb
9 if test $# -ge 1 ; then
10         BACKEND=$1; shift
11 fi
12 MONITORDB=no
13 if test $# -ge 1 ; then
14         MONITORDB=$1; shift
15 fi
16 WAIT=0
17 if test $# -ge 1 ; then
18         WAIT=1; shift
19 fi
20
21 echo "running defines.sh"
22 . $SRCDIR/scripts/defines.sh
23
24 echo "Cleaning up in $DBDIR..."
25
26 rm -f $DBDIR/[!C]*
27
28 echo "Running slapadd to build slapd database..."
29 . $CONFFILTER $BACKEND $MONITORDB < $ACLCONF > $DBCONF
30 $SLAPADD -f $DBCONF -l $LDIFORDERED
31 RC=$?
32 if test $RC != 0 ; then
33         echo "slapadd failed ($RC)!"
34         exit $RC
35 fi
36
37 echo "Starting slapd on TCP/IP port $PORT..."
38 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
39 PID=$!
40 if test $WAIT != 0 ; then
41     echo PID $PID
42     read foo
43 fi
44
45 echo "Testing slapd access control..."
46 for i in 0 1 2 3 4 5; do
47         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
48                 'objectclass=*' > /dev/null 2>&1
49         RC=$?
50         if test $RC = 1 ; then
51                 echo "Waiting 5 seconds for slapd to start..."
52                 sleep 5
53         fi
54 done
55
56 if test $RC != 0 ; then
57         echo "ldapsearch failed ($RC)!"
58         kill -HUP $PID
59         exit $RC
60 fi
61
62 cat /dev/null > $SEARCHOUT
63
64 #
65 # Try to read an entry inside the Alumni Association container.  It should
66 # give us nothing if we're not bound, and should return all attributes
67 # if we're bound as anyone under UM.
68 #
69 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT "objectclass=*" \
70         >> $SEARCHOUT 2>&1
71
72 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT \
73         -D "$BABSDN" -w bjensen "objectclass=*"  >> $SEARCHOUT 2>&1
74
75
76 #
77 # Try to add a "member" attribute to the "All Staff" group.  It should
78 # fail when we add some DN other than our own, and should succeed when
79 # we add our own DN.
80 # bjensen
81 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT -w jaj > \
82         $TESTOUT 2>&1 << EOMODS1
83 version: 1
84 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
85 changetype: modify
86 add: member
87 member: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
88
89 EOMODS1
90
91 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT -w jaj >> \
92         $TESTOUT 2>&1 << EOMODS2
93 version: 1
94
95 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
96 changetype: modify
97 add: member
98 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
99 EOMODS2
100
101 #
102 # Try to modify the "All Staff" group.  Two attempts are made:
103 # 1) bound as "James A Jones 1" - should fail
104 # 2) bound as "Barbara Jensen" - should succeed
105 #
106 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT -w jaj >> \
107         $TESTOUT 2>&1 << EOMODS3
108
109 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
110 changetype: modify
111 delete: member
112
113 EOMODS3
114
115 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT -w bjorn >> \
116         $TESTOUT 2>&1 << EOMODS4
117 # COMMENT
118 version: 1
119 # comment
120 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
121 # comment
122 changetype: modify
123 # comment
124 add: ou
125 # comment
126 ou: Groups
127 # comment
128 EOMODS4
129
130 echo "Using ldapsearch to retrieve all the entries..."
131 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
132             'objectClass=*' >> $SEARCHOUT 2>&1
133 RC=$?
134 kill -HUP $PID
135 if test $RC != 0 ; then
136         echo "ldapsearch failed ($RC)!"
137         exit $RC
138 fi
139
140 LDIF=$ACLOUTMASTER
141
142 echo "Filtering ldapsearch results..."
143 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
144 echo "Filtering original ldif used to create database..."
145 . $LDIFFILTER < $LDIF > $LDIFFLT
146 echo "Comparing filter output..."
147 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
148
149 if test $? != 0 ; then
150         echo "comparison failed - modify operations did not complete correctly"
151         exit 1
152 fi
153
154 echo ">>>>> Test succeeded"
155
156
157 exit 0