3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $PPOLICY = ppolicyno; then
20 echo "Password policy overlay not available, test skipped"
24 if test "$BACKEND" = "ldbm" ; then
25 echo "Test does not support $BACKEND"
29 mkdir -p $TESTDIR $DBDIR1
31 echo "Starting slapd on TCP/IP port $PORT1..."
32 . $CONFFILTER $BACKEND $MONITORDB < $PPOLICYCONF > $CONF1
33 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
35 if test $WAIT != 0 ; then
41 USER="uid=nd, ou=People, o=University of Michigan, c=US"
44 echo "Using ldapsearch to check that slapd is running..."
45 for i in 0 1 2 3 4 5; do
46 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
47 'objectclass=*' > /dev/null 2>&1
49 if test $RC = 0 ; then
52 echo "Waiting 5 seconds for slapd to start..."
55 if test $RC != 0 ; then
56 echo "ldapsearch failed $(RC)!"
57 test $KILLSERVERS != no && kill -HUP $KILLPIDS
61 echo "Using ldapadd to populate the database..."
62 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
63 $LDIFPPOLICY > $TESTOUT 2>&1
65 if test $RC != 0 ; then
66 echo "ldapadd failed ($RC)!"
67 test $KILLSERVERS != no && kill -HUP $KILLPIDS
71 echo "Testing account lockout..."
72 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -D "$USER" -w wrongpw >$SEARCHOUT 2>&1
74 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -D "$USER" -w wrongpw >>$SEARCHOUT 2>&1
76 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -D "$USER" -w wrongpw >>$SEARCHOUT 2>&1
78 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w wrongpw >> $SEARCHOUT 2>&1
79 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS >> $SEARCHOUT 2>&1
80 COUNT=`grep "Account locked" $SEARCHOUT | wc -l`
81 if test $COUNT != 2 ; then
82 echo "Account lockout test failed"
83 test $KILLSERVERS != no && kill -HUP $KILLPIDS
87 echo "Waiting 30 seconds for lockout to reset..."
90 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
91 -b "$BASEDN" -s base >> $SEARCHOUT 2>&1
93 if test $RC != 0 ; then
94 echo "ldapsearch failed ($RC)!"
95 test $KILLSERVERS != no && kill -HUP $KILLPIDS
99 echo "Testing password expiration..."
100 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
101 $TESTOUT 2>&1 << EOMODS
102 dn: uid=nd, ou=People, o=University of Michigan, c=US
104 replace: pwdChangedTime
105 pwdChangedTime: 20031231000001Z
109 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS > $SEARCHOUT 2>&1
111 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS >> $SEARCHOUT 2>&1
113 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS >> $SEARCHOUT 2>&1
115 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS >> $SEARCHOUT 2>&1
117 if test $RC = 0 ; then
118 echo "Password expiration failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 COUNT=`grep "grace logins" $SEARCHOUT | wc -l`
124 if test $COUNT != 3 ; then
125 echo "Password expiration test failed"
126 test $KILLSERVERS != no && kill -HUP $KILLPIDS
130 echo "Resetting password to clear expired status"
131 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
133 -D "$MANAGERDN" "$USER" >> $TESTOUT 2>&1
135 if test $RC != 0 ; then
136 echo "ldappasswd failed ($RC)!"
137 test $KILLSERVERS != no && kill -HUP $KILLPIDS
141 echo "Filling password history..."
142 $LDAPMODIFY -v -D "$USER" -h $LOCALHOST -p $PORT1 -w $PASS > \
143 $TESTOUT 2>&1 << EOMODS
144 dn: uid=nd, ou=People, o=University of Michigan,c=US
147 userpassword: testpassword
149 replace: userpassword
150 userpassword: 20urgle12-1
152 dn: uid=nd, ou=People, o=University of Michigan,c=US
155 userpassword: 20urgle12-1
157 replace: userpassword
158 userpassword: 20urgle12-2
160 dn: uid=nd, ou=People, o=University of Michigan,c=US
163 userpassword: 20urgle12-2
165 replace: userpassword
166 userpassword: 20urgle12-3
168 dn: uid=nd, ou=People, o=University of Michigan,c=US
171 userpassword: 20urgle12-3
173 replace: userpassword
174 userpassword: 20urgle12-4
176 dn: uid=nd, ou=People, o=University of Michigan,c=US
179 userpassword: 20urgle12-4
181 replace: userpassword
182 userpassword: 20urgle12-5
184 dn: uid=nd, ou=People, o=University of Michigan,c=US
187 userpassword: 20urgle12-5
189 replace: userpassword
190 userpassword: 20urgle12-6
194 if test $RC != 0 ; then
195 echo "ldapmodify failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
199 echo "Testing password history..."
200 $LDAPMODIFY -v -D "$USER" -h $LOCALHOST -p $PORT1 -w 20urgle12-6 > \
201 $TESTOUT 2>&1 << EOMODS
202 dn: uid=nd, ou=People, o=University of Michigan, c=US
205 userPassword: 20urgle12-6
207 replace: userPassword
208 userPassword: 20urgle12-2
212 if test $RC = 0 ; then
213 echo "ldapmodify failed ($RC)!"
214 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218 echo "Testing forced reset..."
220 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
221 $TESTOUT 2>&1 << EOMODS
222 dn: uid=nd, ou=People, o=University of Michigan, c=US
224 replace: userPassword
225 userPassword: testpassword
232 if test $RC != 0 ; then
233 echo "ldapmodify failed ($RC)!"
234 test $KILLSERVERS != no && kill -HUP $KILLPIDS
238 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
239 -b "$BASEDN" -s base > $SEARCHOUT 2>&1
241 if test $RC = 0 ; then
242 echo "Forced reset failed ($RC)!"
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
247 COUNT=`grep "Operations are restricted" $SEARCHOUT | wc -l`
248 if test $COUNT != 1 ; then
249 echo "Forced reset test failed"
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
254 echo "Clearing forced reset..."
256 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
257 $TESTOUT 2>&1 << EOMODS
258 dn: uid=nd, ou=People, o=University of Michigan, c=US
264 if test $RC != 0 ; then
265 echo "ldapmodify failed ($RC)!"
266 test $KILLSERVERS != no && kill -HUP $KILLPIDS
270 $LDAPSEARCH -e ppolicy -h $LOCALHOST -p $PORT1 -D "$USER" -w $PASS \
271 -b "$BASEDN" -s base > $SEARCHOUT 2>&1
273 if test $RC != 0 ; then
274 echo "Clearing forced reset failed ($RC)!"
275 test $KILLSERVERS != no && kill -HUP $KILLPIDS
279 echo "Testing Safe modify..."
281 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
282 -w $PASS -s failexpect \
283 -D "$USER" > $TESTOUT 2>&1
285 if test $RC = 0 ; then
286 echo "Safe modify test 1 failed ($RC)!"
287 test $KILLSERVERS != no && kill -HUP $KILLPIDS
293 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
294 -w $PASS -s failexpect -a $PASS \
295 -D "$USER" > $TESTOUT 2>&1
297 if test $RC != 0 ; then
298 echo "Safe modify test 2 failed ($RC)!"
299 test $KILLSERVERS != no && kill -HUP $KILLPIDS
303 echo "Testing length requirement..."
305 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
306 -w failexpect -a failexpect -s spw \
307 -D "$USER" > $TESTOUT 2>&1
309 if test $RC = 0 ; then
310 echo "Length requirement test failed ($RC)!"
311 test $KILLSERVERS != no && kill -HUP $KILLPIDS
314 COUNT=`grep "Password fails quality" $TESTOUT | wc -l`
315 if test $COUNT != 1 ; then
316 echo "Length requirement test failed"
317 test $KILLSERVERS != no && kill -HUP $KILLPIDS
321 test $KILLSERVERS != no && kill -HUP $KILLPIDS
323 echo ">>>>> Test succeeded"