]> git.sur5r.net Git - openldap/blob - tests/scripts/test004-modify
d56a72389d914250317ac9a3269bad1d0c0e538b
[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: Orange Juice
78
79 dn: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US
80 changetype: modify
81 # EMBEDDED COMMENT
82  CONTINUED
83 replace: description
84 description: The replaced multiLineDescription $ Blah Woof.
85 -
86 replace: drink
87 drink: Iced Tea
88 drink: Mad Dog 20/20
89
90 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
91 delete: member
92 member: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=University of Michigan,c=US
93 member: cn=Bjorn Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US
94 -
95 add: member
96 member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,o=University of Michigan,c=US
97 member: cn=James A Jones 1,ou=Alumni Association,ou=People,o=University of Michigan,c=US
98
99 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
100 changetype: modify
101 delete: member
102 -
103 add: member
104 member: cn=Dorothy Stevens,ou=Alumni Association,ou=People,o=University of Michigan,c=US
105
106 dn: cn=Gern Jensen,ou=Information Technology Division,ou=People,o=University of Michigan,c=US
107 changetype: add
108 objectclass: OpenLDAPperson
109 cn: Gern Jensen
110 sn: Jensen
111 uid: gjensen
112 title: Chief Investigator, ITD
113 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
114 seealso: cn=All Staff,ou=Groups,o=University of Michigan,c=US
115 drink: Coffee
116 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
117 description: Very odd
118 facsimiletelephonenumber: +1 313 555 7557
119 telephonenumber: +1 313 555 8343
120 mail: gjensen@mailgw.umich.edu
121 homephone: +1 313 555 8844
122
123 dn: cn=James A Jones 2,ou=Information Technology Division,ou=People,o=University of Michigan,c=US
124 changetype: delete
125 # TRAILING COMMENT AND WHITE SPACE
126
127 EOMODS
128
129 RC=$?
130 if test $RC != 0 ; then
131         echo "ldapmodify failed ($RC)!"
132         kill -HUP $PID
133         exit $RC
134 fi
135
136 echo "Using ldapsearch to retrieve all the entries..."
137 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
138             'objectClass=*' > $SEARCHOUT 2>&1
139 RC=$?
140 kill -HUP $PID
141 if test $RC != 0 ; then
142         echo "ldapsearch failed ($RC)!"
143         exit $RC
144 fi
145
146 LDIF=$MODIFYOUTMASTER
147
148 echo "Filtering ldapsearch results..."
149 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
150 echo "Filtering original ldif used to create database..."
151 . $LDIFFILTER < $LDIF > $LDIFFLT
152 echo "Comparing filter output..."
153 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
154
155 if test $? != 0 ; then
156         echo "comparison failed - modify operations did not complete correctly"
157         exit 1
158 fi
159
160 echo ">>>>> Test succeeded"
161
162 exit 0