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