]> 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-2015 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 if test $BACKEND = "ldif" ; then 
20         echo "LDIF backend does not support relax control, test skipped"
21         exit 0
22 fi 
23
24 mkdir -p $TESTDIR $DBDIR1
25
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
28 $SLAPADD -f $CONF1 -l $LDIFORDERED
29 RC=$?
30 if test $RC != 0 ; then
31         echo "slapadd failed ($RC)!"
32         exit $RC
33 fi
34
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
37 PID=$!
38 if test $WAIT != 0 ; then
39     echo PID $PID
40     read foo
41 fi
42 KILLPIDS="$PID"
43
44 sleep 1
45
46 echo "Testing slapd Manage operations..."
47 for i in 0 1 2 3 4 5; do
48         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
49                 'objectclass=*' > /dev/null 2>&1
50         RC=$?
51         if test $RC = 0 ; then
52                 break
53         fi
54         echo "Waiting 5 seconds for slapd to start..."
55         sleep 5
56 done
57
58 if test $RC != 0 ; then
59         echo "ldapsearch failed ($RC)!"
60         test $KILLSERVERS != no && kill -HUP $KILLPIDS
61         exit $RC
62 fi
63
64 echo "Testing modify, add, and delete..."
65 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
66         -e \!relax > \
67         $TESTOUT 2>&1 << EOMODS
68 version: 1
69 #
70 # Working Tests
71 #
72
73 #
74 # ObjectClass tests
75 #
76
77 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
78  dc=com
79 # add obsolete auxiliary objectclass
80 changetype: modify
81 add: objectClass
82 objectClass: obsoletePerson
83
84 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
85  dc=com
86 # add obsolete attribute
87 changetype: modify
88 add: testObsolete
89 testObsolete: TRUE
90
91 #
92 # create/modify timestamp test
93 #
94
95 dn: ou=Groups,dc=example,dc=com
96 # change creatorsName
97 changetype: modify
98 replace: creatorsName
99 creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
100
101 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
102 # change modifiersName
103 changetype: modify
104 replace: modifiersName
105 modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
106
107 dn: dc=example,dc=com
108 # change timestamps
109 changetype: modify
110 replace: modifyTimestamp
111 modifyTimestamp: 19700101000000Z
112 -
113 replace: createTimestamp
114 createTimestamp: 19700101000000Z
115 -
116
117 dn: cn=All Staff,ou=Groups,dc=example,dc=com
118 # change entryUUID
119 changetype: modify
120 replace: entryUUID
121 entryUUID: badbadba-dbad-1029-92f7-badbadbadbad
122
123 dn: cn=All Staff,dc=example,dc=com
124 changetype: add
125 objectClass: groupOfNames
126 cn: All Staff
127 member:
128 creatorsName: cn=Someone
129 createTimestamp: 19700101000000Z
130 modifiersName: cn=Someone Else
131 modifyTimestamp: 19700101000000Z
132 entryUUID: badbadef-dbad-1029-92f7-badbadbadbad
133
134 #
135 # Tests that did not work until ITS#5792
136 #
137
138 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
139  dc=com
140 # update structural object class of entry via objectClass replace
141 changetype: modify
142 replace: objectClass
143 objectClass: obsoletePerson
144 objectClass: testPerson
145 -
146
147 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
148 # update structural object class of entry via objectClass add
149 changetype: modify
150 add: objectClass
151 objectClass: testPerson
152 -
153
154 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
155 # update structural object class of entry via objectClass delete/add
156 changetype: modify
157 delete: objectClass
158 objectClass: OpenLDAPperson
159 -
160 add: objectClass
161 objectClass: testPerson
162 -
163 EOMODS
164
165 RC=$?
166 if test $RC != 0 ; then
167         echo "ldapmodify failed ($RC)!"
168         test $KILLSERVERS != no && kill -HUP $KILLPIDS
169         exit $RC
170 fi
171
172 echo "Using ldapsearch to retrieve all the entries..."
173 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
174     'objectClass=*' '*' creatorsName modifiersName > $SEARCHOUT 2>&1
175 RC=$?
176 if test $RC != 0 ; then
177         test $KILLSERVERS != no && kill -HUP $KILLPIDS
178         echo "ldapsearch failed ($RC)!"
179         exit $RC
180 fi
181
182 $LDAPSEARCH -S "" -b "$BASEDN" -s base -h $LOCALHOST -p $PORT1 \
183     'objectClass=*' '*' creatorsName createTimestamp \
184     modifiersName modifyTimestamp >> $SEARCHOUT 2>&1
185 RC=$?
186 if test $RC != 0 ; then
187         test $KILLSERVERS != no && kill -HUP $KILLPIDS
188         echo "ldapsearch failed ($RC)!"
189         exit $RC
190 fi
191
192 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
193     '(cn=All Staff)' '*' entryUUID >> $SEARCHOUT 2>&1
194 RC=$?
195 test $KILLSERVERS != no && kill -HUP $KILLPIDS
196 if test $RC != 0 ; then
197         echo "ldapsearch failed ($RC)!"
198         exit $RC
199 fi
200
201 LDIF=$MANAGEOUT
202
203 echo "Filtering ldapsearch results..."
204 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
205 echo "Filtering original ldif used to create database..."
206 $LDIFFILTER < $LDIF > $LDIFFLT
207 echo "Comparing filter output..."
208 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
209
210 if test $? != 0 ; then
211         echo "comparison failed - manage operations did not complete correctly"
212         exit 1
213 fi
214
215 echo ">>>>> Test succeeded"
216
217 test $KILLSERVERS != no && wait
218
219 exit 0