]> git.sur5r.net Git - openldap/blob - tests/scripts/test004-modify
Don't muck with OpenLDAPperson or openldap.schema.
[openldap] / tests / scripts / test004-modify
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2005 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 echo "Testing slapd modify operations..."
40 for i in 0 1 2 3 4 5; do
41         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
42                 'objectclass=*' > /dev/null 2>&1
43         RC=$?
44         if test $RC = 0 ; then
45                 break
46         fi
47         echo "Waiting 5 seconds for slapd to start..."
48         sleep 5
49 done
50
51 if test $RC != 0 ; then
52         echo "ldapsearch failed ($RC)!"
53         test $KILLSERVERS != no && kill -HUP $KILLPIDS
54         exit $RC
55 fi
56
57 echo "Testing modify, add, and delete..."
58 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
59         $TESTOUT 2>&1 << EOMODS
60 version: 1
61
62 # LEADING COMMENT AND WHITE SPACE
63
64 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,dc=example,dc=com
65 # EMBEDDED COMMENT
66 changetype: modify
67 add: drink
68 drink: Pils
69 -
70 add: drink
71 drink: Orange Juice
72 -
73 delete: drink
74 drink: Pils
75 -
76 delete: sn
77 sn: Jones
78 -
79 add: sn
80 sn: Jones
81
82 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
83 changetype: modify
84 # EMBEDDED COMMENT
85  CONTINUED
86 replace: description
87 description: The replaced multiLineDescription $ Blah Woof.
88 -
89 replace: drink
90 drink: Iced Tea
91 drink: Mad Dog 20/20
92
93 dn: cn=ITD Staff,ou=Groups,dc=example,dc=com
94 changetype: modify
95 delete: uniquemember
96 uniquemember: cn=James A Jones 2,ou=Information Technology Division,
97  ou=People,dc=example,dc=com
98 uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,
99  ou=People,dc=example,dc=com
100 -
101 add: uniquemember
102 uniquemember: cn=Dorothy Stevens,ou=Alumni Association,
103  ou=People,dc=example,dc=com
104 uniquemember: cn=James A Jones 1,ou=Alumni Association,
105  ou=People,dc=example,dc=com
106 -
107 add: objectClass
108 objectClass: OpenLDAPdisplayableObject
109 objectClass: pkiUser
110 objectClass: userSecurityInformation
111 -
112 delete: objectClass
113 objectClass: userSecurityInformation
114 objectClass: pkiUser
115 objectClass: OpenLDAPdisplayableObject
116
117 dn: cn=All Staff,ou=Groups,dc=example,dc=com
118 changetype: modify
119 delete: member
120 -
121 add: member
122 member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,dc=example,dc=com
123 -
124 delete: description
125 -
126 add: objectClass
127 objectClass: OpenLDAPdisplayableObject
128 objectClass: pkiUser
129 objectClass: userSecurityInformation
130 -
131 delete: objectClass
132 objectClass: OpenLDAPdisplayableObject
133 objectClass: pkiUser
134 objectClass: userSecurityInformation
135
136 dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
137 changetype: add
138 objectclass: testPerson
139 cn: Gern Jensen
140 sn: Jensen
141 uid: gjensen
142 title: Chief Investigator, ITD
143 postaladdress: ITD $ 535 W. William St $ Anytown, MI 48103
144 seealso: cn=All Staff,ou=Groups,dc=example,dc=com
145 drink: Coffee
146 homepostaladdress: 844 Brown St. Apt. 4 $ Anytown, MI 48104
147 description: Very odd
148 facsimiletelephonenumber: +1 313 555 7557
149 telephonenumber: +1 313 555 8343
150 mail: gjensen@mailgw.example.com
151 homephone: +1 313 555 8844
152 testTime: 20050304001801.234Z
153
154 dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=example,dc=com
155 changetype: delete
156 # TRAILING COMMENT AND WHITE SPACE
157
158 dn: ou=People,dc=example,dc=com
159 changetype: modify
160 increment: uidNumber
161 uidNumber: 1
162 -
163 increment: gidNumber
164 gidNumber: -1
165
166 EOMODS
167
168 RC=$?
169 if test $RC != 0 ; then
170         echo "ldapmodify failed ($RC)!"
171         test $KILLSERVERS != no && kill -HUP $KILLPIDS
172         exit $RC
173 fi
174
175 echo "Using ldapsearch to retrieve all the entries..."
176 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
177             'objectClass=*' > $SEARCHOUT 2>&1
178 RC=$?
179 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 if test $RC != 0 ; then
181         echo "ldapsearch failed ($RC)!"
182         exit $RC
183 fi
184
185 LDIF=$MODIFYOUTMASTER
186
187 echo "Filtering ldapsearch results..."
188 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
189 echo "Filtering original ldif used to create database..."
190 . $LDIFFILTER < $LDIF > $LDIFFLT
191 echo "Comparing filter output..."
192 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
193
194 if test $? != 0 ; then
195         echo "comparison failed - modify operations did not complete correctly"
196         exit 1
197 fi
198
199 echo ">>>>> Test succeeded"
200 exit 0