]> git.sur5r.net Git - openldap/blob - tests/scripts/test004-modify
Happy New Year!
[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: OpenLDAPperson
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
153 dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,dc=example,dc=com
154 changetype: delete
155 # TRAILING COMMENT AND WHITE SPACE
156
157 dn: ou=People,dc=example,dc=com
158 changetype: modify
159 increment: uidNumber
160 uidNumber: 1
161 -
162 increment: gidNumber
163 gidNumber: -1
164
165 EOMODS
166
167 RC=$?
168 if test $RC != 0 ; then
169         echo "ldapmodify failed ($RC)!"
170         test $KILLSERVERS != no && kill -HUP $KILLPIDS
171         exit $RC
172 fi
173
174 echo "Using ldapsearch to retrieve all the entries..."
175 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
176             'objectClass=*' > $SEARCHOUT 2>&1
177 RC=$?
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 if test $RC != 0 ; then
180         echo "ldapsearch failed ($RC)!"
181         exit $RC
182 fi
183
184 LDIF=$MODIFYOUTMASTER
185
186 echo "Filtering ldapsearch results..."
187 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
188 echo "Filtering original ldif used to create database..."
189 . $LDIFFILTER < $LDIF > $LDIFFLT
190 echo "Comparing filter output..."
191 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
192
193 if test $? != 0 ; then
194         echo "comparison failed - modify operations did not complete correctly"
195         exit 1
196 fi
197
198 echo ">>>>> Test succeeded"
199 exit 0