test022-ppolicy revision 1.1.1.2 1 1.1 lukem #! /bin/sh
2 1.1.1.2 lukem # OpenLDAP: pkg/ldap/tests/scripts/test022-ppolicy,v 1.17.2.8 2009/07/01 21:01:41 quanah Exp
3 1.1 lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 1.1 lukem ##
5 1.1.1.2 lukem ## Copyright 1998-2009 The OpenLDAP Foundation.
6 1.1 lukem ## All rights reserved.
7 1.1 lukem ##
8 1.1 lukem ## Redistribution and use in source and binary forms, with or without
9 1.1 lukem ## modification, are permitted only as authorized by the OpenLDAP
10 1.1 lukem ## Public License.
11 1.1 lukem ##
12 1.1 lukem ## A copy of this license is available in the file LICENSE in the
13 1.1 lukem ## top-level directory of the distribution or, alternatively, at
14 1.1 lukem ## <http://www.OpenLDAP.org/license.html>.
15 1.1 lukem
16 1.1 lukem echo "running defines.sh"
17 1.1 lukem . $SRCDIR/scripts/defines.sh
18 1.1 lukem
19 1.1 lukem if test $PPOLICY = ppolicyno; then
20 1.1 lukem echo "Password policy overlay not available, test skipped"
21 1.1 lukem exit 0
22 1.1 lukem fi
23 1.1 lukem
24 1.1 lukem mkdir -p $TESTDIR $DBDIR1
25 1.1 lukem
26 1.1.1.2 lukem $SLAPPASSWD -g -n >$CONFIGPWF
27 1.1.1.2 lukem echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
28 1.1.1.2 lukem
29 1.1 lukem echo "Starting slapd on TCP/IP port $PORT1..."
30 1.1 lukem . $CONFFILTER $BACKEND $MONITORDB < $PPOLICYCONF > $CONF1
31 1.1 lukem $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
32 1.1 lukem PID=$!
33 1.1 lukem if test $WAIT != 0 ; then
34 1.1 lukem echo PID $PID
35 1.1 lukem read foo
36 1.1 lukem fi
37 1.1 lukem KILLPIDS="$PID"
38 1.1 lukem
39 1.1 lukem USER="uid=nd, ou=People, dc=example, dc=com"
40 1.1 lukem PASS=testpassword
41 1.1 lukem
42 1.1 lukem sleep 1
43 1.1 lukem
44 1.1 lukem echo "Using ldapsearch to check that slapd is running..."
45 1.1 lukem for i in 0 1 2 3 4 5; do
46 1.1 lukem $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
47 1.1 lukem 'objectclass=*' > /dev/null 2>&1
48 1.1 lukem RC=$?
49 1.1 lukem if test $RC = 0 ; then
50 1.1 lukem break
51 1.1 lukem fi
52 1.1 lukem echo "Waiting 5 seconds for slapd to start..."
53 1.1 lukem sleep 5
54 1.1 lukem done
55 1.1 lukem if test $RC != 0 ; then
56 1.1 lukem echo "ldapsearch failed ($RC)!"
57 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
58 1.1 lukem exit $RC
59 1.1 lukem fi
60 1.1 lukem
61 1.1 lukem echo /dev/null > $TESTOUT
62 1.1 lukem
63 1.1 lukem echo "Using ldapadd to populate the database..."
64 1.1 lukem # may need "-e relax" for draft 09, but not yet.
65 1.1 lukem $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
66 1.1 lukem $LDIFPPOLICY >> $TESTOUT 2>&1
67 1.1 lukem RC=$?
68 1.1 lukem if test $RC != 0 ; then
69 1.1 lukem echo "ldapadd failed ($RC)!"
70 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
71 1.1 lukem exit $RC
72 1.1 lukem fi
73 1.1 lukem
74 1.1 lukem echo "Testing account lockout..."
75 1.1 lukem $LDAPSEARCH -h $LOCALHOST -p $PORT1 -D "$USER" -w wrongpw >$SEARCHOUT 2>&1
76 1.1 lukem sleep 2
77 1.1 lukem $LDAPSEARCH -h $LOCALHOST -p $PORT1 -D "$USER" -w wrongpw >>$SEARCHOUT 2>&1
78 1.1 lukem sleep 2
79 1.1 lukem $LDAPSEARCH -h $LOCALHOST -p $PORT1 -D "$USER" -w wrongpw >>$SEARCHOUT 2>&1
80 1.1 lukem sleep 2
81 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w wrongpw >> $SEARCHOUT 2>&1
82 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS >> $SEARCHOUT 2>&1
83 1.1 lukem COUNT=`grep "Account locked" $SEARCHOUT | wc -l`
84 1.1 lukem if test $COUNT != 2 ; then
85 1.1 lukem echo "Account lockout test failed"
86 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
87 1.1 lukem exit 1
88 1.1 lukem fi
89 1.1 lukem
90 1.1 lukem echo "Waiting 20 seconds for lockout to reset..."
91 1.1 lukem sleep 20
92 1.1 lukem
93 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
94 1.1 lukem -b "$BASEDN" -s base >> $SEARCHOUT 2>&1
95 1.1 lukem RC=$?
96 1.1 lukem if test $RC != 0 ; then
97 1.1 lukem echo "ldapsearch failed ($RC)!"
98 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
99 1.1 lukem exit $RC
100 1.1 lukem fi
101 1.1 lukem
102 1.1 lukem echo "Testing password expiration"
103 1.1 lukem echo "Waiting 20 seconds for password to expire..."
104 1.1 lukem sleep 20
105 1.1 lukem
106 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
107 1.1 lukem -b "$BASEDN" -s base > $SEARCHOUT 2>&1
108 1.1 lukem sleep 2
109 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
110 1.1 lukem -b "$BASEDN" -s base >> $SEARCHOUT 2>&1
111 1.1 lukem sleep 2
112 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
113 1.1 lukem -b "$BASEDN" -s base >> $SEARCHOUT 2>&1
114 1.1 lukem sleep 2
115 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
116 1.1 lukem -b "$BASEDN" -s base >> $SEARCHOUT 2>&1
117 1.1 lukem RC=$?
118 1.1 lukem if test $RC = 0 ; then
119 1.1 lukem echo "Password expiration failed ($RC)!"
120 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 1.1 lukem exit 1
122 1.1 lukem fi
123 1.1 lukem
124 1.1 lukem COUNT=`grep "grace logins" $SEARCHOUT | wc -l`
125 1.1 lukem if test $COUNT != 3 ; then
126 1.1 lukem echo "Password expiration test failed"
127 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 1.1 lukem exit 1
129 1.1 lukem fi
130 1.1 lukem
131 1.1 lukem echo "Resetting password to clear expired status"
132 1.1 lukem $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
133 1.1 lukem -w secret -s $PASS \
134 1.1 lukem -D "$MANAGERDN" "$USER" >> $TESTOUT 2>&1
135 1.1 lukem RC=$?
136 1.1 lukem if test $RC != 0 ; then
137 1.1 lukem echo "ldappasswd failed ($RC)!"
138 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
139 1.1 lukem exit $RC
140 1.1 lukem fi
141 1.1 lukem
142 1.1 lukem echo "Filling password history..."
143 1.1 lukem $LDAPMODIFY -v -D "$USER" -h $LOCALHOST -p $PORT1 -w $PASS >> \
144 1.1 lukem $TESTOUT 2>&1 << EOMODS
145 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
146 1.1 lukem changetype: modify
147 1.1 lukem delete: userpassword
148 1.1.1.2 lukem userpassword: $PASS
149 1.1 lukem -
150 1.1 lukem replace: userpassword
151 1.1 lukem userpassword: 20urgle12-1
152 1.1 lukem
153 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
154 1.1 lukem changetype: modify
155 1.1 lukem delete: userpassword
156 1.1 lukem userpassword: 20urgle12-1
157 1.1 lukem -
158 1.1 lukem replace: userpassword
159 1.1 lukem userpassword: 20urgle12-2
160 1.1 lukem
161 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
162 1.1 lukem changetype: modify
163 1.1 lukem delete: userpassword
164 1.1 lukem userpassword: 20urgle12-2
165 1.1 lukem -
166 1.1 lukem replace: userpassword
167 1.1 lukem userpassword: 20urgle12-3
168 1.1 lukem
169 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
170 1.1 lukem changetype: modify
171 1.1 lukem delete: userpassword
172 1.1 lukem userpassword: 20urgle12-3
173 1.1 lukem -
174 1.1 lukem replace: userpassword
175 1.1 lukem userpassword: 20urgle12-4
176 1.1 lukem
177 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
178 1.1 lukem changetype: modify
179 1.1 lukem delete: userpassword
180 1.1 lukem userpassword: 20urgle12-4
181 1.1 lukem -
182 1.1 lukem replace: userpassword
183 1.1 lukem userpassword: 20urgle12-5
184 1.1 lukem
185 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
186 1.1 lukem changetype: modify
187 1.1 lukem delete: userpassword
188 1.1 lukem userpassword: 20urgle12-5
189 1.1 lukem -
190 1.1 lukem replace: userpassword
191 1.1 lukem userpassword: 20urgle12-6
192 1.1 lukem
193 1.1 lukem EOMODS
194 1.1 lukem RC=$?
195 1.1 lukem if test $RC != 0 ; then
196 1.1 lukem echo "ldapmodify failed ($RC)!"
197 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
198 1.1 lukem exit $RC
199 1.1 lukem fi
200 1.1 lukem echo "Testing password history..."
201 1.1 lukem $LDAPMODIFY -v -D "$USER" -h $LOCALHOST -p $PORT1 -w 20urgle12-6 >> \
202 1.1 lukem $TESTOUT 2>&1 << EOMODS
203 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
204 1.1 lukem changetype: modify
205 1.1 lukem delete: userPassword
206 1.1 lukem userPassword: 20urgle12-6
207 1.1 lukem -
208 1.1 lukem replace: userPassword
209 1.1 lukem userPassword: 20urgle12-2
210 1.1 lukem
211 1.1 lukem EOMODS
212 1.1 lukem RC=$?
213 1.1 lukem if test $RC = 0 ; then
214 1.1 lukem echo "ldapmodify failed ($RC)!"
215 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
216 1.1 lukem exit 1
217 1.1 lukem fi
218 1.1 lukem
219 1.1 lukem echo "Testing forced reset..."
220 1.1 lukem
221 1.1 lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
222 1.1 lukem $TESTOUT 2>&1 << EOMODS
223 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
224 1.1 lukem changetype: modify
225 1.1 lukem replace: userPassword
226 1.1.1.2 lukem userPassword: $PASS
227 1.1 lukem -
228 1.1 lukem replace: pwdReset
229 1.1 lukem pwdReset: TRUE
230 1.1 lukem
231 1.1 lukem EOMODS
232 1.1 lukem RC=$?
233 1.1 lukem if test $RC != 0 ; then
234 1.1 lukem echo "ldapmodify failed ($RC)!"
235 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
236 1.1 lukem exit $RC
237 1.1 lukem fi
238 1.1 lukem
239 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
240 1.1 lukem -b "$BASEDN" -s base > $SEARCHOUT 2>&1
241 1.1 lukem RC=$?
242 1.1 lukem if test $RC = 0 ; then
243 1.1 lukem echo "Forced reset failed ($RC)!"
244 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 1.1 lukem exit 1
246 1.1 lukem fi
247 1.1 lukem
248 1.1 lukem COUNT=`grep "Operations are restricted" $SEARCHOUT | wc -l`
249 1.1 lukem if test $COUNT != 1 ; then
250 1.1 lukem echo "Forced reset test failed"
251 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
252 1.1 lukem exit 1
253 1.1 lukem fi
254 1.1 lukem
255 1.1 lukem echo "Clearing forced reset..."
256 1.1 lukem
257 1.1 lukem $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
258 1.1 lukem $TESTOUT 2>&1 << EOMODS
259 1.1 lukem dn: uid=nd, ou=People, dc=example, dc=com
260 1.1 lukem changetype: modify
261 1.1 lukem delete: pwdReset
262 1.1 lukem
263 1.1 lukem EOMODS
264 1.1 lukem RC=$?
265 1.1 lukem if test $RC != 0 ; then
266 1.1 lukem echo "ldapmodify failed ($RC)!"
267 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 1.1 lukem exit $RC
269 1.1 lukem fi
270 1.1 lukem
271 1.1 lukem $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
272 1.1 lukem -b "$BASEDN" -s base > $SEARCHOUT 2>&1
273 1.1 lukem RC=$?
274 1.1 lukem if test $RC != 0 ; then
275 1.1 lukem echo "Clearing forced reset failed ($RC)!"
276 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
277 1.1 lukem exit $RC
278 1.1 lukem fi
279 1.1 lukem
280 1.1 lukem echo "Testing Safe modify..."
281 1.1 lukem
282 1.1 lukem $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
283 1.1 lukem -w $PASS -s failexpect \
284 1.1 lukem -D "$USER" >> $TESTOUT 2>&1
285 1.1 lukem RC=$?
286 1.1 lukem if test $RC = 0 ; then
287 1.1 lukem echo "Safe modify test 1 failed ($RC)!"
288 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
289 1.1 lukem exit 1
290 1.1 lukem fi
291 1.1 lukem
292 1.1 lukem sleep 2
293 1.1 lukem
294 1.1.1.2 lukem OLDPASS=$PASS
295 1.1.1.2 lukem PASS=successexpect
296 1.1.1.2 lukem
297 1.1 lukem $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
298 1.1.1.2 lukem -w $OLDPASS -s $PASS -a $OLDPASS \
299 1.1 lukem -D "$USER" >> $TESTOUT 2>&1
300 1.1 lukem RC=$?
301 1.1 lukem if test $RC != 0 ; then
302 1.1 lukem echo "Safe modify test 2 failed ($RC)!"
303 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
304 1.1 lukem exit $RC
305 1.1 lukem fi
306 1.1 lukem
307 1.1 lukem echo "Testing length requirement..."
308 1.1.1.2 lukem # check control in response (ITS#5711)
309 1.1 lukem $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
310 1.1.1.2 lukem -w $PASS -a $PASS -s 2shr \
311 1.1.1.2 lukem -D "$USER" -e ppolicy > ${TESTOUT}.2 2>&1
312 1.1 lukem RC=$?
313 1.1 lukem cat ${TESTOUT}.2 >> $TESTOUT
314 1.1 lukem if test $RC = 0 ; then
315 1.1 lukem echo "Length requirement test failed ($RC)!"
316 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
317 1.1 lukem exit 1
318 1.1 lukem fi
319 1.1 lukem COUNT=`grep "Password fails quality" ${TESTOUT}.2 | wc -l`
320 1.1 lukem if test $COUNT != 1 ; then
321 1.1 lukem echo "Length requirement test failed"
322 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
323 1.1 lukem exit 1
324 1.1 lukem fi
325 1.1.1.2 lukem COUNT=`grep "Password is too short for policy" ${TESTOUT}.2 | wc -l`
326 1.1.1.2 lukem if test $COUNT != 1 ; then
327 1.1.1.2 lukem echo "Control not returned in response"
328 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
329 1.1.1.2 lukem exit 1
330 1.1.1.2 lukem fi
331 1.1 lukem
332 1.1 lukem echo "Testing hashed length requirement..."
333 1.1 lukem
334 1.1.1.2 lukem $LDAPMODIFY -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS > \
335 1.1 lukem ${TESTOUT}.2 2>&1 << EOMODS
336 1.1 lukem dn: $USER
337 1.1 lukem changetype: modify
338 1.1 lukem delete: userPassword
339 1.1.1.2 lukem userPassword: $PASS
340 1.1 lukem -
341 1.1 lukem add: userPassword
342 1.1 lukem userPassword: {MD5}xxxxxx
343 1.1 lukem
344 1.1 lukem EOMODS
345 1.1 lukem RC=$?
346 1.1 lukem cat ${TESTOUT}.2 >> $TESTOUT
347 1.1 lukem if test $RC = 0 ; then
348 1.1 lukem echo "Hashed length requirement test failed ($RC)!"
349 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
350 1.1 lukem exit 1
351 1.1 lukem fi
352 1.1 lukem COUNT=`grep "Password fails quality" ${TESTOUT}.2 | wc -l`
353 1.1 lukem if test $COUNT != 1 ; then
354 1.1 lukem echo "Hashed length requirement test failed"
355 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
356 1.1 lukem exit 1
357 1.1 lukem fi
358 1.1 lukem
359 1.1 lukem echo "Testing multiple password add/modify checks..."
360 1.1 lukem
361 1.1 lukem $LDAPMODIFY -h $LOCALHOST -p $PORT1 -D "$MANAGERDN" -w $PASSWD >> \
362 1.1 lukem $TESTOUT 2>&1 << EOMODS
363 1.1 lukem dn: cn=Add Should Fail, ou=People, dc=example, dc=com
364 1.1 lukem changetype: add
365 1.1 lukem objectClass: inetOrgPerson
366 1.1 lukem cn: Add Should Fail
367 1.1 lukem sn: Fail
368 1.1 lukem userPassword: firstpw
369 1.1 lukem userPassword: secondpw
370 1.1 lukem EOMODS
371 1.1 lukem RC=$?
372 1.1 lukem if test $RC = 0 ; then
373 1.1 lukem echo "Multiple password add test failed ($RC)!"
374 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
375 1.1 lukem exit 1
376 1.1 lukem fi
377 1.1 lukem
378 1.1 lukem $LDAPMODIFY -h $LOCALHOST -p $PORT1 -D "$MANAGERDN" -w $PASSWD >> \
379 1.1 lukem $TESTOUT 2>&1 << EOMODS
380 1.1 lukem dn: $USER
381 1.1 lukem changetype: modify
382 1.1 lukem add: userPassword
383 1.1 lukem userPassword: firstpw
384 1.1 lukem userPassword: secondpw
385 1.1 lukem EOMODS
386 1.1 lukem RC=$?
387 1.1 lukem if test $RC = 0 ; then
388 1.1 lukem echo "Multiple password modify add test failed ($RC)!"
389 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
390 1.1 lukem exit 1
391 1.1 lukem fi
392 1.1 lukem
393 1.1 lukem $LDAPMODIFY -h $LOCALHOST -p $PORT1 -D "$MANAGERDN" -w $PASSWD >> \
394 1.1 lukem $TESTOUT 2>&1 << EOMODS
395 1.1 lukem dn: $USER
396 1.1 lukem changetype: modify
397 1.1 lukem replace: userPassword
398 1.1 lukem userPassword: firstpw
399 1.1 lukem userPassword: secondpw
400 1.1 lukem EOMODS
401 1.1 lukem RC=$?
402 1.1 lukem if test $RC = 0 ; then
403 1.1 lukem echo "Multiple password modify replace test failed ($RC)!"
404 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
405 1.1 lukem exit 1
406 1.1 lukem fi
407 1.1 lukem
408 1.1.1.2 lukem if test "$BACKLDAP" != "ldapno" && test "$SYNCPROV" != "syncprovno" ; then
409 1.1.1.2 lukem echo ""
410 1.1.1.2 lukem echo "Setting up policy state forwarding test..."
411 1.1.1.2 lukem
412 1.1.1.2 lukem mkdir $DBDIR2
413 1.1.1.2 lukem sed -e "s,$DBDIR1,$DBDIR2," < $CONF1 > $CONF2
414 1.1.1.2 lukem echo "Starting slapd consumer on TCP/IP port $PORT2..."
415 1.1.1.2 lukem $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
416 1.1.1.2 lukem PID=$!
417 1.1.1.2 lukem if test $WAIT != 0 ; then
418 1.1.1.2 lukem echo PID $PID
419 1.1.1.2 lukem read foo
420 1.1.1.2 lukem fi
421 1.1.1.2 lukem KILLPIDS="$KILLPIDS $PID"
422 1.1.1.2 lukem
423 1.1.1.2 lukem echo "Configuring syncprov on provider..."
424 1.1.1.2 lukem if [ "$SYNCPROV" = syncprovmod ]; then
425 1.1.1.2 lukem $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
426 1.1.1.2 lukem dn: cn=module,cn=config
427 1.1.1.2 lukem objectclass: olcModuleList
428 1.1.1.2 lukem cn: module
429 1.1.1.2 lukem olcModulePath: $TESTWD/../servers/slapd/overlays
430 1.1.1.2 lukem olcModuleLoad: syncprov.la
431 1.1.1.2 lukem
432 1.1.1.2 lukem EOF
433 1.1.1.2 lukem RC=$?
434 1.1.1.2 lukem if test $RC != 0 ; then
435 1.1.1.2 lukem echo "ldapadd failed for moduleLoad ($RC)!"
436 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
437 1.1.1.2 lukem exit $RC
438 1.1.1.2 lukem fi
439 1.1.1.2 lukem fi
440 1.1.1.2 lukem
441 1.1.1.2 lukem $LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
442 1.1.1.2 lukem dn: olcOverlay={1}syncprov,olcDatabase={1}$BACKEND,cn=config
443 1.1.1.2 lukem objectClass: olcOverlayConfig
444 1.1.1.2 lukem objectClass: olcSyncProvConfig
445 1.1.1.2 lukem olcOverlay: {1}syncprov
446 1.1.1.2 lukem
447 1.1.1.2 lukem EOF
448 1.1.1.2 lukem RC=$?
449 1.1.1.2 lukem if test $RC != 0 ; then
450 1.1.1.2 lukem echo "ldapadd failed for provider database config ($RC)!"
451 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
452 1.1.1.2 lukem exit $RC
453 1.1.1.2 lukem fi
454 1.1.1.2 lukem
455 1.1.1.2 lukem echo "Using ldapsearch to check that slapd is running..."
456 1.1.1.2 lukem for i in 0 1 2 3 4 5; do
457 1.1.1.2 lukem $LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \
458 1.1.1.2 lukem 'objectclass=*' > /dev/null 2>&1
459 1.1.1.2 lukem RC=$?
460 1.1.1.2 lukem if test $RC = 0 ; then
461 1.1.1.2 lukem break
462 1.1.1.2 lukem fi
463 1.1.1.2 lukem echo "Waiting 5 seconds for slapd to start..."
464 1.1.1.2 lukem sleep 5
465 1.1.1.2 lukem done
466 1.1.1.2 lukem if test $RC != 0 ; then
467 1.1.1.2 lukem echo "ldapsearch failed ($RC)!"
468 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
469 1.1.1.2 lukem exit $RC
470 1.1.1.2 lukem fi
471 1.1.1.2 lukem
472 1.1.1.2 lukem echo "Configuring syncrepl on consumer..."
473 1.1.1.2 lukem if [ "$BACKLDAP" = ldapmod ]; then
474 1.1.1.2 lukem $LDAPADD -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
475 1.1.1.2 lukem dn: cn=module,cn=config
476 1.1.1.2 lukem objectclass: olcModuleList
477 1.1.1.2 lukem cn: module
478 1.1.1.2 lukem olcModulePath: $TESTWD/../servers/slapd/back-ldap
479 1.1.1.2 lukem olcModuleLoad: back_ldap.la
480 1.1.1.2 lukem
481 1.1.1.2 lukem EOF
482 1.1.1.2 lukem RC=$?
483 1.1.1.2 lukem if test $RC != 0 ; then
484 1.1.1.2 lukem echo "ldapadd failed for moduleLoad ($RC)!"
485 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
486 1.1.1.2 lukem exit $RC
487 1.1.1.2 lukem fi
488 1.1.1.2 lukem fi
489 1.1.1.2 lukem $LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >> $TESTOUT 2>&1
490 1.1.1.2 lukem dn: olcOverlay={0}chain,olcDatabase={-1}frontend,cn=config
491 1.1.1.2 lukem changetype: add
492 1.1.1.2 lukem objectClass: olcOverlayConfig
493 1.1.1.2 lukem objectClass: olcChainConfig
494 1.1.1.2 lukem olcOverlay: {0}chain
495 1.1.1.2 lukem
496 1.1.1.2 lukem dn: olcDatabase=ldap,olcOverlay={0}chain,olcDatabase={-1}frontend,cn=config
497 1.1.1.2 lukem changetype: add
498 1.1.1.2 lukem objectClass: olcLDAPConfig
499 1.1.1.2 lukem objectClass: olcChainDatabase
500 1.1.1.2 lukem olcDBURI: $URI1
501 1.1.1.2 lukem olcDbIDAssertBind: bindmethod=simple
502 1.1.1.2 lukem binddn="cn=manager,dc=example,dc=com"
503 1.1.1.2 lukem credentials=secret
504 1.1.1.2 lukem mode=self
505 1.1.1.2 lukem
506 1.1.1.2 lukem dn: olcDatabase={1}$BACKEND,cn=config
507 1.1.1.2 lukem changetype: modify
508 1.1.1.2 lukem add: olcSyncrepl
509 1.1.1.2 lukem olcSyncrepl: rid=1
510 1.1.1.2 lukem provider=$URI1
511 1.1.1.2 lukem binddn="cn=manager,dc=example,dc=com"
512 1.1.1.2 lukem bindmethod=simple
513 1.1.1.2 lukem credentials=secret
514 1.1.1.2 lukem searchbase="dc=example,dc=com"
515 1.1.1.2 lukem type=refreshAndPersist
516 1.1.1.2 lukem retry="3 5 300 5"
517 1.1.1.2 lukem -
518 1.1.1.2 lukem add: olcUpdateref
519 1.1.1.2 lukem olcUpdateref: $URI1
520 1.1.1.2 lukem -
521 1.1.1.2 lukem
522 1.1.1.2 lukem dn: olcOverlay={0}ppolicy,olcDatabase={1}$BACKEND,cn=config
523 1.1.1.2 lukem changetype: modify
524 1.1.1.2 lukem replace: olcPPolicyForwardUpdates
525 1.1.1.2 lukem olcPPolicyForwardUpdates: TRUE
526 1.1.1.2 lukem -
527 1.1.1.2 lukem
528 1.1.1.2 lukem EOF
529 1.1.1.2 lukem RC=$?
530 1.1.1.2 lukem if test $RC != 0 ; then
531 1.1.1.2 lukem echo "ldapmodify failed ($RC)!"
532 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
533 1.1.1.2 lukem exit $RC
534 1.1.1.2 lukem fi
535 1.1.1.2 lukem
536 1.1.1.2 lukem echo "Waiting for consumer to sync..."
537 1.1.1.2 lukem sleep $SLEEP1
538 1.1.1.2 lukem
539 1.1.1.2 lukem echo "Testing policy state forwarding..."
540 1.1.1.2 lukem $LDAPSEARCH -H $URI2 -D "$USER" -w wrongpw >$SEARCHOUT 2>&1
541 1.1.1.2 lukem $LDAPSEARCH -H $URI1 -D "$MANAGERDN" -w $PASSWD -b "$USER" \* \+ >> $SEARCHOUT 2>&1
542 1.1.1.2 lukem COUNT=`grep "pwdFailureTime" $SEARCHOUT | wc -l`
543 1.1.1.2 lukem if test $COUNT != 1 ; then
544 1.1.1.2 lukem echo "Policy state forwarding failed"
545 1.1.1.2 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
546 1.1.1.2 lukem exit 1
547 1.1.1.2 lukem fi
548 1.1.1.2 lukem
549 1.1.1.2 lukem # End of chaining test
550 1.1.1.2 lukem
551 1.1.1.2 lukem fi
552 1.1.1.2 lukem
553 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
554 1.1 lukem
555 1.1 lukem echo ">>>>> Test succeeded"
556 1.1 lukem
557 1.1 lukem test $KILLSERVERS != no && wait
558 1.1 lukem
559 1.1 lukem exit 0
560