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