]> git.sur5r.net Git - openldap/blob - tests/scripts/test037-manage
f28ec6ff0f21e316e2007ed4deb8bea7ce322a02
[openldap] / tests / scripts / test037-manage
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 "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 < $CONF > $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 Manage operations..."
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 # ITS#3898: #ifndef LDAP_DEVEL, the control is not available
58 MANAGEDITOID="1.3.6.1.4.1.4203.666.5.12"
59 case `$LDAPSEARCH -s base -b "" -h $LOCALHOST -p $PORT1 \
60         '(supportedControl:objectIdentifierMatch:='${MANAGEDITOID}')' \
61         supportedControl | grep "supportedControl: ${MANAGEDITOID}"` in
62 "supportedControl: ${MANAGEDITOID}")
63         ;;
64 *)
65         echo "The \"manageDIT\" control appears to be unsupported; test disabled"
66         test $KILLSERVERS != no && kill -HUP $KILLPIDS
67         exit 0
68         ;;
69 esac
70
71 echo "Testing modify, add, and delete..."
72 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
73         -e \!manageDIT > \
74         $TESTOUT 2>&1 << EOMODS
75 version: 1
76 #
77 # Working Tests
78 #
79
80 #
81 # ObjectClass tests
82 #
83
84 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
85  dc=com
86 # add obsolete auxiliary objectclass
87 changetype: modify
88 add: objectClass
89 objectClass: obsoletePerson
90
91 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
92  dc=com
93 # add obsolete attribute
94 changetype: modify
95 add: testObsolete
96 testObsolete: TRUE
97
98 #
99 # create/modify timestamp test
100 #
101
102 dn: ou=Groups,dc=example,dc=com
103 # change creatorsName
104 changetype: modify
105 replace: creatorsName
106 creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
107
108 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
109 # change modifiersName
110 changetype: modify
111 replace: modifiersName
112 modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
113
114 dn: dc=example,dc=com
115 # change timestamps
116 changetype: modify
117 replace: modifyTimestamp
118 modifyTimestamp: 19700101000000Z
119 -
120 replace: createTimestamp
121 createTimestamp: 19700101000000Z
122 -
123
124 dn: cn=All Staff,ou=Groups,dc=example,dc=com
125 # change entryUUID
126 changetype: modify
127 replace: entryUUID
128 entryUUID: badbadba-dbad-1029-92f7-badbadbadbad
129
130 dn: cn=All Staff,dc=example,dc=com
131 changetype: add
132 objectClass: groupOfNames
133 cn: All Staff
134 member:
135 creatorsName: cn=Someone
136 createTimestamp: 19700101000000Z
137 modifiersName: cn=Someone Else
138 modifyTimestamp: 19700101000000Z
139 entryUUID: badbadef-dbad-1029-92f7-badbadbadbad
140 EOMODS
141
142 RC=$?
143 if test $RC != 0 ; then
144         echo "ldapmodify failed ($RC)!"
145         test $KILLSERVERS != no && kill -HUP $KILLPIDS
146         exit $RC
147 fi
148
149 echo "Testing modify, add, and delete..."
150 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
151         -e \!manageDIT > \
152         $TESTOUT 2>&1 << EOMODS
153 version: 1
154 #
155 # Non-working tests
156 #
157
158 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
159  dc=com
160 # update structural object class of entry via objectClass replace
161 changetype: modify
162 replace: objectClass
163 objectClass: obsoletePerson
164 -
165 replace: structuralObjectClass
166 structuralObjectClass: testPerson
167
168 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
169 # update structural object class of entry via objectClass add
170 changetype: modify
171 add: objectClass
172 objectClass: testPerson
173 -
174 replace: structuralObjectClass
175 structuralObjectClass: testPerson
176
177 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
178 # update structural object class of entry via objectClass delete/add
179 changetype: modify
180 delete: objectClass
181 objectClass: OpenLDAPperson
182 -
183 add: objectClass
184 objectClass: testPerson
185 -
186 delete: structuralObjectClass
187 -
188 add: structuralObjectClass
189 structuralObjectClass: testPerson
190 EOMODS
191
192 RC=$?
193 if test $RC != 0 ; then
194         echo "ldapmodify failed ($RC)!  IGNORED"
195 #       test $KILLSERVERS != no && kill -HUP $KILLPIDS
196 #       exit $RC
197 fi
198
199 echo "Using ldapsearch to retrieve all the entries..."
200 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
201     'objectClass=*' '*' creatorsName modifiersName > $SEARCHOUT 2>&1
202 RC=$?
203 if test $RC != 0 ; then
204         test $KILLSERVERS != no && kill -HUP $KILLPIDS
205         echo "ldapsearch failed ($RC)!"
206         exit $RC
207 fi
208
209 $LDAPSEARCH -S "" -b "$BASEDN" -s base -h $LOCALHOST -p $PORT1 \
210     'objectClass=*' '*' creatorsName createTimestamp \
211     modifiersName modifyTimestamp >> $SEARCHOUT 2>&1
212 RC=$?
213 if test $RC != 0 ; then
214         test $KILLSERVERS != no && kill -HUP $KILLPIDS
215         echo "ldapsearch failed ($RC)!"
216         exit $RC
217 fi
218
219 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
220     '(cn=All Staff)' '*' entryUUID >> $SEARCHOUT 2>&1
221 RC=$?
222 test $KILLSERVERS != no && kill -HUP $KILLPIDS
223 if test $RC != 0 ; then
224         echo "ldapsearch failed ($RC)!"
225         exit $RC
226 fi
227
228 LDIF=$MANAGEOUT
229
230 echo "Filtering ldapsearch results..."
231 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
232 echo "Filtering original ldif used to create database..."
233 . $LDIFFILTER < $LDIF > $LDIFFLT
234 echo "Comparing filter output..."
235 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
236
237 if test $? != 0 ; then
238         echo "comparison failed - manage operations did not complete correctly"
239         exit 1
240 fi
241
242 echo ">>>>> Test succeeded"
243 exit 0