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>
8 Usage: test_passwords.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
22 samba4bindir
="$BUILDDIR/bin"
23 smbclient
="$samba4bindir/smbclient$EXEEXT"
24 samba4kinit
="$samba4bindir/samba4kinit$EXEEXT"
25 net
="$samba4bindir/net$EXEEXT"
26 rkpty
="$samba4bindir/rkpty$EXEEXT"
27 samba4kpasswd
="$samba4bindir/samba4kpasswd$EXEEXT"
28 newuser
="$net newuser"
30 .
`dirname $0`/subunit.sh
38 $VALGRIND $smbclient //$SERVER/tmp
-c "$cmd" -W "$DOMAIN" $@
40 if [ x
$status = x0
]; then
48 CONFIG
="--configfile=$PREFIX/dc/etc/smb.conf"
53 testit
"create user locally" $VALGRIND $newuser $CONFIG nettestuser
$USERPASS $@ || failed
=`expr $failed + 1`
55 KRB5CCNAME
="$PREFIX/tmpuserccache"
58 echo $USERPASS > $PREFIX/tmpuserpassfile
60 testit
"kinit with user password" $samba4kinit --password-file=$PREFIX/tmpuserpassfile
--request-pac nettestuser@
$REALM || failed
=`expr $failed + 1`
62 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
64 NEWUSERPASS
=testPaSS@
02%
65 testit
"change user password with 'net password change' (unforced)" $VALGRIND $net password change
-W$DOMAIN -U$DOMAIN/nettestuser
%$USERPASS -k no
$NEWUSERPASS $@ || failed
=`expr $failed + 1`
67 echo $NEWUSERPASS > .
/tmpuserpassfile
68 testit
"kinit with user password" $samba4kinit --password-file=.
/tmpuserpassfile
--request-pac nettestuser@
$REALM || failed
=`expr $failed + 1`
70 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
74 NEWUSERPASS
=testPaSS@
03%
76 cat > .
/tmpkpasswdscript
<<EOF
78 password ${USERPASS}\n
86 testit
"change user password with kpasswd" $rkpty .
/tmpkpasswdscript
$samba4kpasswd nettestuser@
$REALM || failed
=`expr $failed + 1`
88 test_smbclient
"Test login with user kerberos (unforced)" 'ls' -k yes -Unettestuser@
$REALM%$NEWUSERPASS || failed
=`expr $failed + 1`
91 NEWUSERPASS
=testPaSS@
04%
92 testit
"set password on user locally" $VALGRIND $net setpassword
$CONFIG nettestuser
--newpassword=$NEWUSERPASS --must-change-at-next-login $@ || failed
=`expr $failed + 1`
95 NEWUSERPASS
=testPaSS@
05%
96 testit
"change user password with 'net password change' (after must change flag set)" $VALGRIND $net password change
-W$DOMAIN -U$DOMAIN/nettestuser
%$USERPASS -k no
$NEWUSERPASS $@ || failed
=`expr $failed + 1`
99 NEWUSERPASS
=testPaSS@
06%
100 testit
"set password on user locally" $VALGRIND $net setpassword
$CONFIG nettestuser
--newpassword=$NEWUSERPASS --must-change-at-next-login $@ || failed
=`expr $failed + 1`
101 USERPASS
=$NEWUSERPASS
103 NEWUSERPASS
=testPaSS@
07%
105 cat > .
/tmpkpasswdscript
<<EOF
107 password ${USERPASS}\n
109 send ${NEWUSERPASS}\n
111 send ${NEWUSERPASS}\n
115 testit
"change user password with kpasswd (after must change flag set)" $rkpty .
/tmpkpasswdscript
$samba4kpasswd nettestuser@
$REALM || failed
=`expr $failed + 1`
116 USERPASS
=$NEWUSERPASS
118 test_smbclient
"Test login with user kerberos" 'ls' -k yes -Unettestuser@
$REALM%$NEWUSERPASS || failed
=`expr $failed + 1`
120 testit
"reset password policies" $VALGRIND $net pwsettings
set $CONFIG --complexity=default
--history-length=default
--min-pwd-length=default
--min-pwd-age=default
--max-pwd-age=default || failed
=`expr $failed + 1`
123 testit_expect_failure
"try to set a non-complex password (command should not succeed)" $VALGRIND $net password change
-W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no
"$NEWUSERPASS" $@
&& failed
=`expr $failed + 1`
125 testit
"allow non-complex passwords" $VALGRIND $net pwsettings
set $CONFIG --complexity=off || failed
=`expr $failed + 1`
127 testit
"try to set a non-complex password (command should succeed)" $VALGRIND $net password change
-W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no
"$NEWUSERPASS" $@ || failed
=`expr $failed + 1`
128 USERPASS
=$NEWUSERPASS
130 test_smbclient
"test login with non-complex password" 'ls' -k no
-Unettestuser@
$REALM%$USERPASS || failed
=`expr $failed + 1`
133 testit_expect_failure
"try to set a short password (command should not succeed)" $VALGRIND $net password change
-W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no
"$NEWUSERPASS" $@
&& failed
=`expr $failed + 1`
135 testit
"allow short passwords (length 1)" $VALGRIND $net pwsettings
$CONFIG set --min-pwd-length=1 || failed
=`expr $failed + 1`
137 testit
"try to set a short password (command should succeed)" $VALGRIND $net password change
-W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no
"$NEWUSERPASS" $@ || failed
=`expr $failed + 1`
138 USERPASS
="$NEWUSERPASS"
140 testit
"require minimum password age of 1 day" $VALGRIND $net pwsettings
$CONFIG set --min-pwd-age=1 || failed
=`expr $failed + 1`
142 testit
"show password settings" $VALGRIND $net pwsettings
$CONFIG show || failed
=`expr $failed + 1`
144 NEWUSERPASS
="testPaSS@08%"
145 testit_expect_failure
"try to change password too quickly (command should not succeed)" $VALGRIND $net password change
-W$DOMAIN "-U$DOMAIN/nettestuser%$USERPASS" -k no
"$NEWUSERPASS" $@
&& failed
=`expr $failed + 1`
147 testit
"reset password policies" $VALGRIND $net pwsettings
$CONFIG set --complexity=default
--history-length=default
--min-pwd-length=default
--min-pwd-age=default
--max-pwd-age=default || failed
=`expr $failed + 1`
149 testit
"del user" $VALGRIND $net user delete nettestuser
-U"$USERNAME%$PASSWORD" -k no $@ || failed
=`expr $failed + 1`
151 rm -f tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript