Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / openldap / dist / tests / scripts / test004-modify
blobbf52a9289759b188e12870f493e4b6998ba2150b
1 #! /bin/sh
2 # $OpenLDAP: pkg/ldap/tests/scripts/test004-modify,v 1.60.2.3 2008/02/11 23:26:51 kurt Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2008 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.
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
24 RC=$?
25 if test $RC != 0 ; then
26 echo "slapadd failed ($RC)!"
27 exit $RC
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
37 KILLPIDS="$PID"
39 sleep 1
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
45 RC=$?
46 if test $RC = 0 ; then
47 break
49 echo "Waiting 5 seconds for slapd to start..."
50 sleep 5
51 done
53 if test $RC != 0 ; then
54 echo "ldapsearch failed ($RC)!"
55 test $KILLSERVERS != no && kill -HUP $KILLPIDS
56 exit $RC
59 echo "Testing modify, add, and delete..."
60 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
61 $TESTOUT 2>&1 << EOMODS
62 version: 1
64 # LEADING COMMENT AND WHITE SPACE
66 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
67 # EMBEDDED COMMENT
68 changetype: modify
69 add: drink
70 drink: Pils
72 add: drink
73 drink: Orange Juice
75 delete: drink
76 drink: Pils
78 delete: sn
79 sn: Jones
81 add: sn
82 sn: Jones
84 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
85 changetype: modify
86 # EMBEDDED COMMENT
87 CONTINUED
88 replace: description
89 description: The replaced multiLineDescription $ Blah Woof.
91 replace: drink
92 drink: Iced Tea
93 drink: Mad Dog 20/20
95 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
96 changetype: modify
97 delete: uniquemember
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
103 add: uniquemember
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
109 add: objectClass
110 objectClass: OpenLDAPdisplayableObject
111 objectClass: pkiUser
112 objectClass: userSecurityInformation
114 delete: objectClass
115 objectClass: userSecurityInformation
116 objectClass: pkiUser
117 objectClass: OpenLDAPdisplayableObject
119 dn: cn=All Staff,ou=Groups,dc=example,dc=com
120 changetype: modify
121 delete: member
123 add: member
124 member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
126 delete: description
128 add: objectClass
129 objectClass: OpenLDAPdisplayableObject
130 objectClass: pkiUser
131 objectClass: userSecurityInformation
133 delete: objectClass
134 objectClass: OpenLDAPdisplayableObject
135 objectClass: pkiUser
136 objectClass: userSecurityInformation
138 dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
139 changetype: add
140 objectclass: testPerson
141 cn: Gern Jensen
142 sn: Jensen
143 uid: gjensen
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
147 drink: Coffee
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
157 changetype: delete
158 # TRAILING COMMENT AND WHITE SPACE
160 dn: ou=People,dc=example,dc=com
161 changetype: modify
162 increment: uidNumber
163 uidNumber: 1
165 increment: gidNumber
166 gidNumber: -1
168 dn: dc=example,dc=com
169 changetype: modify
170 # EMPTY SEQUENCE OF CHANGE
172 EOMODS
174 RC=$?
175 if test $RC != 0 ; then
176 echo "ldapmodify failed ($RC)!"
177 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 exit $RC
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
185 changetype: add
186 # EMPTY SEQUENCE OF ATTRS
187 EOMODS
189 RC=$?
190 case $RC in
192 echo " ldapmodify failed ($RC)"
195 echo " ldapmodify should have failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
197 exit -1
200 echo " ldapmodify failed ($RC)!"
201 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 exit $RC
204 esac
206 echo "Using ldapsearch to retrieve all the entries..."
207 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
208 'objectClass=*' > $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
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"
227 exit 1
230 echo ">>>>> Test succeeded"
232 test $KILLSERVERS != no && wait
234 exit 0