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