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