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