2
# $OpenLDAP: pkg/ldap/tests/scripts/test004-modify,v 1.60.2.4 2009/01/22 00:01:18 kurt Exp $
3
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5
## Copyright 1998-2009 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
mkdir -p $TESTDIR $DBDIR1
21
echo "Running slapadd to build slapd database..."
22
. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
23
$SLAPADD -f $CONF1 -l $LDIFORDERED
25
if test $RC != 0 ; then
26
echo "slapadd failed ($RC)!"
30
echo "Starting slapd on TCP/IP port $PORT1..."
31
$SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
33
if test $WAIT != 0 ; then
41
echo "Testing slapd modify 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
46
if test $RC = 0 ; then
49
echo "Waiting 5 seconds for slapd to start..."
53
if test $RC != 0 ; then
54
echo "ldapsearch failed ($RC)!"
55
test $KILLSERVERS != no && kill -HUP $KILLPIDS
59
echo "Testing modify, add, and delete..."
60
$LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
61
$TESTOUT 2>&1 << EOMODS
64
# LEADING COMMENT AND WHITE SPACE
66
dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
84
dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
89
description: The replaced multiLineDescription $ Blah Woof.
95
dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
98
uniquemember: cn=James A Jones 2,ou=Information Technology Division,
99
ou=People,dc=example,dc=com
100
uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,
101
ou=People,dc=example,dc=com
104
uniquemember: cn=Dorothy Stevens,ou=Alumni Association,
105
ou=People,dc=example,dc=com
106
uniquemember: cn=James A Jones 1,ou=Alumni Association,
107
ou=People,dc=example,dc=com
110
objectClass: OpenLDAPdisplayableObject
112
objectClass: userSecurityInformation
115
objectClass: userSecurityInformation
117
objectClass: OpenLDAPdisplayableObject
119
dn: cn=All Staff,ou=Groups,dc=example,dc=com
124
member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
129
objectClass: OpenLDAPdisplayableObject
131
objectClass: userSecurityInformation
134
objectClass: OpenLDAPdisplayableObject
136
objectClass: userSecurityInformation
138
dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
140
objectclass: testPerson
144
title: Chief Investigator, ITD
145
postaladdress: ITD $ 535 W. William St $ Anytown, MI 48103
146
seealso: cn=All Staff,ou=Groups,dc=example,dc=com
148
homepostaladdress: 844 Brown St. Apt. 4 $ Anytown, MI 48104
149
description: Very odd
150
facsimiletelephonenumber: +1 313 555 7557
151
telephonenumber: +1 313 555 8343
152
mail: gjensen@mailgw.example.com
153
homephone: +1 313 555 8844
154
testTime: 20050304001801.234Z
156
dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=example,dc=com
158
# TRAILING COMMENT AND WHITE SPACE
160
dn: ou=People,dc=example,dc=com
168
dn: dc=example,dc=com
170
# EMPTY SEQUENCE OF CHANGE
175
if test $RC != 0 ; then
176
echo "ldapmodify failed ($RC)!"
177
test $KILLSERVERS != no && kill -HUP $KILLPIDS
181
echo "Using ldapmodify to add an empty entry (should fail with protocolError)..."
182
$LDAPMODIFY -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
183
>> $TESTOUT 2>&1 << EOMODS
184
dn: cn=Foo Bar,dc=example,dc=com
186
# EMPTY SEQUENCE OF ATTRS
192
echo " ldapmodify failed ($RC)"
195
echo " ldapmodify should have failed ($RC)!"
196
test $KILLSERVERS != no && kill -HUP $KILLPIDS
200
echo " ldapmodify failed ($RC)!"
201
test $KILLSERVERS != no && kill -HUP $KILLPIDS
206
echo "Using ldapsearch to retrieve all the entries..."
207
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
208
'objectClass=*' > $SEARCHOUT 2>&1
210
test $KILLSERVERS != no && kill -HUP $KILLPIDS
211
if test $RC != 0 ; then
212
echo "ldapsearch failed ($RC)!"
216
LDIF=$MODIFYOUTMASTER
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
225
if test $? != 0 ; then
226
echo "comparison failed - modify operations did not complete correctly"
230
echo ">>>>> Test succeeded"
232
test $KILLSERVERS != no && wait