2 # $OpenLDAP: pkg/ldap/tests/scripts/test037-manage,v 1.12.2.5 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2008 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
16 echo "running defines.sh"
17 .
$SRCDIR/scripts
/defines.sh
19 if test $BACKEND = "ldif" ; then
20 echo "LDIF backend does not support manageDIT control, test skipped"
24 mkdir
-p $TESTDIR $DBDIR1
26 echo "Running slapadd to build slapd database..."
27 .
$CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
28 $SLAPADD -f $CONF1 -l $LDIFORDERED
30 if test $RC != 0 ; then
31 echo "slapadd failed ($RC)!"
35 echo "Starting slapd on TCP/IP port $PORT1..."
36 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
38 if test $WAIT != 0 ; then
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
51 if test $RC = 0 ; then
54 echo "Waiting 5 seconds for slapd to start..."
58 if test $RC != 0 ; then
59 echo "ldapsearch failed ($RC)!"
60 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
64 echo "Testing modify, add, and delete..."
65 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
67 $TESTOUT 2>&1 << EOMODS
77 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
79 # add obsolete auxiliary objectclass
82 objectClass: obsoletePerson
84 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
86 # add obsolete attribute
92 # create/modify timestamp test
95 dn: ou=Groups,dc=example,dc=com
99 creatorsName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
101 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
102 # change modifiersName
104 replace: modifiersName
105 modifiersName: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
107 dn: dc=example,dc=com
110 replace: modifyTimestamp
111 modifyTimestamp: 19700101000000Z
113 replace: createTimestamp
114 createTimestamp: 19700101000000Z
117 dn: cn=All Staff,ou=Groups,dc=example,dc=com
121 entryUUID: badbadba-dbad-1029-92f7-badbadbadbad
123 dn: cn=All Staff,dc=example,dc=com
125 objectClass: groupOfNames
128 creatorsName: cn=Someone
129 createTimestamp: 19700101000000Z
130 modifiersName: cn=Someone Else
131 modifyTimestamp: 19700101000000Z
132 entryUUID: badbadef-dbad-1029-92f7-badbadbadbad
136 if test $RC != 0 ; then
137 echo "ldapmodify failed ($RC)!"
138 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
142 echo "Testing modify, add, and delete..."
143 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
145 $TESTOUT 2>&1 << EOMODS
151 dn: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,
153 # update structural object class of entry via objectClass replace
156 objectClass: obsoletePerson
158 replace: structuralObjectClass
159 structuralObjectClass: testPerson
161 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
162 # update structural object class of entry via objectClass add
165 objectClass: testPerson
167 replace: structuralObjectClass
168 structuralObjectClass: testPerson
170 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
171 # update structural object class of entry via objectClass delete/add
174 objectClass: OpenLDAPperson
177 objectClass: testPerson
179 delete: structuralObjectClass
181 add: structuralObjectClass
182 structuralObjectClass: testPerson
186 if test $RC != 0 ; then
187 echo "ldapmodify failed ($RC)! IGNORED"
188 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 echo "Using ldapsearch to retrieve all the entries..."
193 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
194 'objectClass=*' '*' creatorsName modifiersName
> $SEARCHOUT 2>&1
196 if test $RC != 0 ; then
197 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
198 echo "ldapsearch failed ($RC)!"
202 $LDAPSEARCH -S "" -b "$BASEDN" -s base
-h $LOCALHOST -p $PORT1 \
203 'objectClass=*' '*' creatorsName createTimestamp \
204 modifiersName modifyTimestamp
>> $SEARCHOUT 2>&1
206 if test $RC != 0 ; then
207 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
208 echo "ldapsearch failed ($RC)!"
212 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
213 '(cn=All Staff)' '*' entryUUID
>> $SEARCHOUT 2>&1
215 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
216 if test $RC != 0 ; then
217 echo "ldapsearch failed ($RC)!"
223 echo "Filtering ldapsearch results..."
224 .
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
225 echo "Filtering original ldif used to create database..."
226 .
$LDIFFILTER < $LDIF > $LDIFFLT
227 echo "Comparing filter output..."
228 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
230 if test $?
!= 0 ; then
231 echo "comparison failed - manage operations did not complete correctly"
235 echo ">>>>> Test succeeded"
237 test $KILLSERVERS != no
&& wait