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