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