]> git.sur5r.net Git - openldap/blob - tests/scripts/test004-modify
c9fbd0902911656b562b31eb14f43a093f519613
[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 -l $LDIF
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 version: 1
52
53 # LEADING COMMENT AND WHITE SPACE
54
55 dn: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
56 # EMBEDDED COMMENT
57 changetype: modify
58 add: drink
59 drink: Orange Juice
60
61 dn: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
62 changetype: modify
63 # EMBEDDED COMMENT
64  CONTINUED
65 replace: multilinedescription
66 multilinedescription: The replaced multiLineDescription $ Blah Woof.
67 -
68 replace: drink
69 drink: Iced Tea
70 drink: Mad Dog 20/20
71
72 dn: cn=ITD Staff,ou=Groups,o=University of Michigan,c=US
73 delete: member
74 member: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
75 member: cn=Bjorn Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
76 -
77 add: member
78 member: cn=Dorothy Stevens, ou=Alumni Association, ou=People, o=University of Michigan, c=US
79 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
80
81 dn: cn=All Staff,ou=Groups,o=University of Michigan,c=US
82 changetype: modify
83 delete: member
84
85 dn: cn=Gern Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
86 changetype: add
87 objectclass: top
88 objectclass: person
89 objectclass: organizationalPerson
90 objectclass: newPilotPerson
91 objectclass: umichPerson
92 cn: Gern Jensen
93 title: Chief Investigator, ITD
94 postaladdress: ITD $ 535 W. William St $ Ann Arbor, MI 48103
95 seealso: cn=All Staff, ou=Groups, o=University of Michigan, c=US
96 uid: gjensen
97 krbname: gjensen@umich.edu
98 nobatchupdates: TRUE
99 onvacation: FALSE
100 drink: Coffee
101 homepostaladdress: 844 Brown St. Apt. 4 $ Ann Arbor, MI 48104
102 multilinedescription: Very odd
103 facsimiletelephonenumber: +1 313 555 7557
104 telephonenumber: +1 313 555 8343
105 mail: gjensen@mailgw.umich.edu
106 homephone: +1 313 555 8844
107
108 dn: cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
109 changetype: delete
110 # TRAILING COMMENT AND WHITE SPACE
111
112 EOMODS
113
114 RC=$?
115 if test $RC != 0 ; then
116         echo "ldapmodify failed!"
117         kill -HUP $PID
118         exit $RC
119 fi
120
121 echo "Using ldapsearch to retrieve all the entries..."
122 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
123             'objectClass=*' > $SEARCHOUT 2>&1
124 RC=$?
125 kill -HUP $PID
126 if test $RC != 0 ; then
127         echo "ldapsearch failed!"
128         exit $RC
129 fi
130
131 LDIF=$MODIFYOUTMASTER
132
133 echo "Filtering ldapsearch results..."
134 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
135 echo "Filtering original ldif used to create database..."
136 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
137 echo "Comparing filter output..."
138 cmp $SEARCHFLT $LDIFFLT
139
140 if test $? != 0 ; then
141         echo "comparison failed - modify operations did not complete correctly"
142         exit 1
143 fi
144
145 echo ">>>>> Test succeeded"
146
147 exit 0