source: trunk/server/testprogs/blackbox/test_passwords.sh

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 7.5 KB
Line 
1#!/bin/sh
2# Blackbox tests for kinit and kerberos integration with smbclient etc
3# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
4# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
5
6if [ $# -lt 5 ]; then
7cat <<EOF
8Usage: test_passwords.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
9EOF
10exit 1;
11fi
12
13SERVER=$1
14USERNAME=$2
15PASSWORD=$3
16REALM=$4
17DOMAIN=$5
18PREFIX=$6
19shift 6
20failed=0
21
22samba4bindir="$BUILDDIR/bin"
23smbclient="$samba4bindir/smbclient$EXEEXT"
24samba4kinit="$samba4bindir/samba4kinit$EXEEXT"
25samba_tool="$samba4bindir/samba-tool$EXEEXT"
26rkpty="$samba4bindir/rkpty$EXEEXT"
27samba4kpasswd="$samba4bindir/samba4kpasswd$EXEEXT"
28newuser="$samba_tool newuser"
29
30. `dirname $0`/subunit.sh
31
32test_smbclient() {
33 name="$1"
34 cmd="$2"
35 shift
36 shift
37 echo "test: $name"
38 $VALGRIND $smbclient //$SERVER/tmp -c "$cmd" -W "$DOMAIN" $@
39 status=$?
40 if [ x$status = x0 ]; then
41 echo "success: $name"
42 else
43 echo "failure: $name"
44 fi
45 return $status
46}
47
48CONFIG="--configfile=$PREFIX/dc/etc/smb.conf"
49export CONFIG
50
51testit "reset password policies beside of minimum password age of 0 days" $VALGRIND $samba_tool pwsettings $CONFIG set --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=0 --max-pwd-age=default || failed=`expr $failed + 1`
52
53USERPASS=testPaSS@01%
54
55testit "create user locally" $VALGRIND $newuser $CONFIG nettestuser $USERPASS $@ || failed=`expr $failed + 1`
56
57KRB5CCNAME="$PREFIX/tmpuserccache"
58export KRB5CCNAME
59
60echo $USERPASS > $PREFIX/tmpuserpassfile
61
62testit "kinit with user password" $samba4kinit --password-file=$PREFIX/tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
63
64test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
65
66NEWUSERPASS=testPaSS@02%
67testit "change user password with 'samba-tool password change' (unforced)" $VALGRIND $samba_tool password change -W$DOMAIN -U$DOMAIN/nettestuser%$USERPASS -k no $NEWUSERPASS $@ || failed=`expr $failed + 1`
68
69echo $NEWUSERPASS > ./tmpuserpassfile
70testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
71
72test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
73
74
75USERPASS=$NEWUSERPASS
76WEAKPASS=testpass1
77NEWUSERPASS=testPaSS@03%
78
79# password mismatch check doesn't work yet (kpasswd bug, reported to Love)
80#echo "check that password mismatch gives the right error"
81#cat > ./tmpkpasswdscript <<EOF
82#expect Password
83#password ${USERPASS}\n
84#expect New password
85#send ${WEAKPASS}\n
86#expect New password
87#send ${NEWUSERPASS}\n
88#expect password mismatch
89#EOF
90#
91#testit "change user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
92
93
94echo "check that a weak password is rejected"
95cat > ./tmpkpasswdscript <<EOF
96expect Password
97password ${USERPASS}\n
98expect New password
99send ${WEAKPASS}\n
100expect New password
101send ${WEAKPASS}\n
102expect Password does not meet complexity requirements
103EOF
104
105testit "change to weak user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
106
107echo "check that a short password is rejected"
108cat > ./tmpkpasswdscript <<EOF
109expect Password
110password ${USERPASS}\n
111expect New password
112send xx1\n
113expect New password
114send xx1\n
115expect Password too short
116EOF
117
118testit "change to short user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
119
120
121echo "check that a strong new password is accepted"
122cat > ./tmpkpasswdscript <<EOF
123expect Password
124password ${USERPASS}\n
125expect New password
126send ${NEWUSERPASS}\n
127expect New password
128send ${NEWUSERPASS}\n
129expect Success
130EOF
131
132testit "change user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
133
134test_smbclient "Test login with user kerberos (unforced)" 'ls' -k yes -Unettestuser@$REALM%$NEWUSERPASS || failed=`expr $failed + 1`
135
136
137NEWUSERPASS=testPaSS@04%
138testit "set password on user locally" $VALGRIND $samba_tool setpassword $CONFIG nettestuser --newpassword=$NEWUSERPASS --must-change-at-next-login $@ || failed=`expr $failed + 1`
139USERPASS=$NEWUSERPASS
140
141NEWUSERPASS=testPaSS@05%
142testit "change user password with 'samba-tool password change' (after must change flag set)" $VALGRIND $samba_tool password change -W$DOMAIN -U$DOMAIN/nettestuser%$USERPASS -k no $NEWUSERPASS $@ || failed=`expr $failed + 1`
143USERPASS=$NEWUSERPASS
144
145NEWUSERPASS=testPaSS@06%
146testit "set password on user locally" $VALGRIND $samba_tool setpassword $CONFIG nettestuser --newpassword=$NEWUSERPASS --must-change-at-next-login $@ || failed=`expr $failed + 1`
147USERPASS=$NEWUSERPASS
148
149NEWUSERPASS=testPaSS@07%
150
151cat > ./tmpkpasswdscript <<EOF
152expect Password
153password ${USERPASS}\n
154expect New password
155send ${NEWUSERPASS}\n
156expect New password
157send ${NEWUSERPASS}\n
158expect Success
159EOF
160
161testit "change user password with kpasswd (after must change flag set)" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
162USERPASS=$NEWUSERPASS
163
164test_smbclient "Test login with user kerberos" 'ls' -k yes -Unettestuser@$REALM%$NEWUSERPASS || failed=`expr $failed + 1`
165
166NEWUSERPASS=abcdefg
167testit_expect_failure "try to set a non-complex password (command should not succeed)" $VALGRIND $samba_tool password change -W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no "$NEWUSERPASS" $@ && failed=`expr $failed + 1`
168
169testit "allow non-complex passwords" $VALGRIND $samba_tool pwsettings set $CONFIG --complexity=off || failed=`expr $failed + 1`
170
171testit "try to set a non-complex password (command should succeed)" $VALGRIND $samba_tool password change -W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no "$NEWUSERPASS" $@ || failed=`expr $failed + 1`
172USERPASS=$NEWUSERPASS
173
174test_smbclient "test login with non-complex password" 'ls' -k no -Unettestuser@$REALM%$USERPASS || failed=`expr $failed + 1`
175
176NEWUSERPASS=abc
177testit_expect_failure "try to set a short password (command should not succeed)" $VALGRIND $samba_tool password change -W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no "$NEWUSERPASS" $@ && failed=`expr $failed + 1`
178
179testit "allow short passwords (length 1)" $VALGRIND $samba_tool pwsettings $CONFIG set --min-pwd-length=1 || failed=`expr $failed + 1`
180
181testit "try to set a short password (command should succeed)" $VALGRIND $samba_tool password change -W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no "$NEWUSERPASS" $@ || failed=`expr $failed + 1`
182USERPASS="$NEWUSERPASS"
183
184testit "require minimum password age of 1 day" $VALGRIND $samba_tool pwsettings $CONFIG set --min-pwd-age=1 || failed=`expr $failed + 1`
185
186testit "show password settings" $VALGRIND $samba_tool pwsettings $CONFIG show || failed=`expr $failed + 1`
187
188NEWUSERPASS="testPaSS@08%"
189testit_expect_failure "try to change password too quickly (command should not succeed)" $VALGRIND $samba_tool password change -W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no "$NEWUSERPASS" $@ && failed=`expr $failed + 1`
190
191testit "reset password policies" $VALGRIND $samba_tool pwsettings $CONFIG set --complexity=default --history-length=default --min-pwd-length=default --min-pwd-age=default --max-pwd-age=default || failed=`expr $failed + 1`
192
193testit "del user" $VALGRIND $samba_tool user delete nettestuser -U"$USERNAME%$PASSWORD" -k no $@ || failed=`expr $failed + 1`
194
195rm -f tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript
196exit $failed
Note: See TracBrowser for help on using the repository browser.