]> git.sur5r.net Git - openldap/blob - tests/scripts/test005-modrdn
Update test005-modrdn to handle success without entries
[openldap] / tests / scripts / test005-modrdn
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 slapadd to build slapd database..."
20 $LDIF2LDBM -f $CONF -l $LDIF
21 RC=$?
22 if test $RC != 0 ; then
23         echo "slapadd 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 echo "Testing slapd modrdn operations..."
31
32 # Make sure we can search the database
33 for i in 0 1 2 3 4 5; do
34         $LDAPSEARCH -s base -b "$MONITOR" -h localhost -p $PORT \
35                 'objectclass=*' > /dev/null 2>&1
36         RC=$?
37         if test $RC = 1 ; then
38                 echo "Waiting 5 seconds for slapd to start..."
39                 sleep 5
40         fi
41 done
42
43 if test $RC != 0 ; then
44         echo "ldapsearch failed!"
45         kill -HUP $PID
46         exit $RC
47 fi
48
49 # -r used to do remove of old rdn
50
51 echo "Testing modrdn(deleteoldrdn=0)..."
52 $LDAPMODRDN -v -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD > \
53         $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones III'
54
55 RC=$?
56 if test $RC != 0 ; then
57         echo "ldapmodrdn failed!"
58         kill -HUP $PID
59         exit $RC
60 fi
61
62 echo "Testing modrdn(deleteoldrdn=1)..."
63 $LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD >> \
64         $TESTOUT 2>&1 'cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US' 'cn=James A Jones II'
65
66 RC=$?
67 if test $RC != 0 ; then
68         echo "ldapmodrdn failed!"
69         kill -HUP $PID
70         exit $RC
71 fi
72
73 # Ensure the new rdn's can be found
74
75 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones III)..."
76 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
77             'cn=James A Jones III' > $SEARCHOUT 2>&1
78 RC=$?
79 if test $RC != 0 ; then
80         echo "ldapsearch failed!"
81         kill -HUP $PID
82         exit $RC
83 fi
84
85
86 LDIF=$MODRDNOUTMASTER1
87
88 echo "Filtering ldapsearch results..."
89 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
90 echo "Filtering original ldif used to create database..."
91 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
92 echo "Comparing filter output..."
93 cmp $SEARCHFLT $LDIFFLT
94
95 if test $? != 0 ; then
96         echo "comparison failed - modrdn operations did not complete correctly"
97         kill -HUP $PID
98         exit 1
99 fi
100
101
102 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones II)..."
103 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
104             'cn=James A Jones II' > $SEARCHOUT 2>&1
105 RC=$?
106 if test $RC != 0 ; then
107         echo "ldapsearch failed!"
108         kill -HUP $PID
109         exit $RC
110 fi
111
112
113 LDIF=$MODRDNOUTMASTER2
114
115 echo "Filtering ldapsearch results..."
116 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
117 echo "Filtering original ldif used to create database..."
118 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
119 echo "Comparing filter output..."
120 cmp $SEARCHFLT $LDIFFLT
121
122 if test $? != 0 ; then
123         echo "comparison failed - modrdn operations did not complete correctly"
124         kill -HUP $PID
125         exit 1
126 fi
127
128 # Ensure that you cannot find the entry for which the rdn was deleted as
129 # an attribute.
130
131 echo "Using ldapsearch to retrieve entries using removed rdn (cn=James A Jones 2)..."
132 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
133             'cn=James A Jones 2' > $SEARCHOUT 2>&1
134 RC=$?
135 if test $RC != 0 ; then
136         kill -HUP $PID
137         echo "ldapsearch failed!"
138         exit $RC
139 fi
140 cmp $SEARCHOUT /dev/null
141 if test $? != 0 ; then
142         echo "failure: ldapsearch found attribute that was to be removed!"
143         kill -HUP $PID
144         exit 1
145 fi
146
147 echo "Using ldapsearch to retrieve all the entries..."
148 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
149             'objectClass=*' > $SEARCHOUT 2>&1
150 RC=$?
151 if test $RC != 0 ; then
152         kill -HUP $PID
153         echo "ldapsearch failed!"
154         exit $RC
155 fi
156
157 LDIF=$MODRDNOUTMASTER0
158
159 echo "Filtering ldapsearch results..."
160 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
161 echo "Filtering original ldif used to create database..."
162 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
163 echo "Comparing filter output..."
164 cmp $SEARCHFLT $LDIFFLT
165
166 if test $? != 0 ; then
167         echo "comparison failed - modrdn operations did not complete correctly"
168         kill -HUP $PID
169         exit 1
170 fi
171
172
173 echo "Testing modrdn(deleteoldrdn=1), modrdn with new rdn already an att val..."
174 $LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD > \
175         /dev/null 2>&1 'cn=James A Jones III, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones 1'
176
177 RC=$?
178 if test $RC != 0 ; then
179         echo "ldapmodrdn failed!"
180         kill -HUP $PID
181         exit $RC
182 fi
183
184 # Test that you can use modrdn with an attribute value which was previously
185 # present
186
187 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones 1)..."
188 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
189             'cn=James A Jones 1' > $SEARCHOUT 2>&1
190 RC=$?
191 if test $RC != 0 ; then
192         echo "ldapsearch failed!"
193         kill -HUP $PID
194         exit $RC
195 fi
196
197
198 LDIF=$MODRDNOUTMASTER3
199
200 echo "Filtering ldapsearch results..."
201 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
202 echo "Filtering original ldif used to create database..."
203 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
204 echo "Comparing filter output..."
205 cmp $SEARCHFLT $LDIFFLT
206
207 kill -HUP $PID
208 if test $? != 0 ; then
209         echo "comparison failed - modrdn operations did not complete correctly"
210         exit 1
211 fi
212
213 echo ">>>>> Test succeeded"
214
215
216
217 # echo "modrdn test not yet written"
218
219 exit 0