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