]> git.sur5r.net Git - openldap/blob - tests/scripts/test004-modify
ce05f26d479b3497babd4041d02f36efa7c3bdf6
[openldap] / tests / scripts / test004-modify
1 #! /bin/sh
2 # $OpenLDAP$
3
4 echo "running defines.sh"
5 . $SRCDIR/scripts/defines.sh
6
7 mkdir $DBDIR
8
9 echo "Running slapadd to build slapd database..."
10 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $DBCONF
11 $SLAPADD -f $DBCONF -l $LDIFORDERED
12 RC=$?
13 if test $RC != 0 ; then
14         echo "slapadd failed ($RC)!"
15         exit $RC
16 fi
17
18 echo "Starting slapd on TCP/IP port $PORT..."
19 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
20 PID=$!
21 if test $WAIT != 0 ; then
22     echo PID $PID
23     read foo
24 fi
25
26 echo "Testing slapd modify operations..."
27 for i in 0 1 2 3 4 5; do
28         $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
29                 'objectclass=*' > /dev/null 2>&1
30         RC=$?
31         if test $RC = 0 ; then
32                 break
33         fi
34         echo "Waiting 5 seconds for slapd to start..."
35         sleep 5
36 done
37
38 if test $RC != 0 ; then
39         echo "ldapsearch failed ($RC)!"
40         kill -HUP $PID
41         exit $RC
42 fi
43
44 echo "Testing modify, add, and delete..."
45 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
46         $TESTOUT 2>&1 << EOMODS
47 version: 1
48
49 # LEADING COMMENT AND WHITE SPACE
50
51 dn: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Michigan,c=US
52 # EMBEDDED COMMENT
53 changetype: modify
54 add: drink
55 drink: Pils
56 -
57 add: drink
58 drink: Orange Juice
59 -
60 delete: drink
61 drink: Pils
62 -
63 delete: sn
64 sn: Jones
65 -
66 add: sn
67 sn: Jones
68
69 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US
70 changetype: modify
71 # EMBEDDED COMMENT
72  CONTINUED
73 replace: description
74 description: The replaced multiLineDescription $ Blah Woof.
75 -
76 replace: drink
77 drink: Iced Tea
78 drink: Mad Dog 20/20
79
80 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
81 changetype: modify
82 delete: uniquemember
83 uniquemember: cn=James A Jones 2,ou=Information Technology Division,
84  ou=People,o=University of Michigan,c=US
85 uniquemember: cn=Bjorn Jensen,ou=Information Technology Division,
86  ou=People,o=University of Michigan,c=US
87 -
88 add: uniquemember
89 uniquemember: cn=Dorothy Stevens,ou=Alumni Association,
90  ou=People,o=University of Michigan,c=US
91 uniquemember: cn=James A Jones 1,ou=Alumni Association,
92  ou=People,o=University of Michigan,c=US
93
94 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
95 changetype: modify
96 delete: member
97 -
98 add: member
99 member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,o=University of Michigan,c=US
100 -
101 delete: description
102
103 dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US
104 changetype: add
105 objectclass: OpenLDAPperson
106 cn: Gern Jensen
107 sn: Jensen
108 uid: gjensen
109 title: Chief Investigator, ITD
110 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
111 seealso: cn=All Staff,ou=Groups,o=University of Michigan,c=US
112 drink: Coffee
113 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
114 description: Very odd
115 facsimiletelephonenumber: +1 313 555 7557
116 telephonenumber: +1 313 555 8343
117 mail: gjensen@mailgw.example.com
118 homephone: +1 313 555 8844
119
120 dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=University of Michigan,c=US
121 changetype: delete
122 # TRAILING COMMENT AND WHITE SPACE
123
124 dn: ou=People,o=University of Michigan,c=US
125 changetype: modify
126 increment: uidNumber
127 uidNumber: 1
128 -
129 increment: gidNumber
130 gidNumber: -1
131
132 EOMODS
133
134 RC=$?
135 if test $RC != 0 ; then
136         echo "ldapmodify failed ($RC)!"
137         kill -HUP $PID
138         exit $RC
139 fi
140
141 echo "Using ldapsearch to retrieve all the entries..."
142 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
143             'objectClass=*' > $SEARCHOUT 2>&1
144 RC=$?
145 kill -HUP $PID
146 if test $RC != 0 ; then
147         echo "ldapsearch failed ($RC)!"
148         exit $RC
149 fi
150
151 LDIF=$MODIFYOUTMASTER
152
153 echo "Filtering ldapsearch results..."
154 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
155 echo "Filtering original ldif used to create database..."
156 . $LDIFFILTER < $LDIF > $LDIFFLT
157 echo "Comparing filter output..."
158 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
159
160 if test $? != 0 ; then
161         echo "comparison failed - modify operations did not complete correctly"
162         exit 1
163 fi
164
165 echo ">>>>> Test succeeded"
166 exit 0