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