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_kinit.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 enableaccount="$PYTHON `dirname $0`/../../source4/setup/enableaccount"
29 setpassword="$PYTHON `dirname $0`/../../source4/setup/setpassword"
30 newuser="$PYTHON `dirname $0`/../../source4/setup/newuser"
32 . `dirname $0`/subunit.sh
40 $VALGRIND $smbclient //$SERVER/tmp -c "$cmd" -W "$DOMAIN" $@
42 if [ x$status = x0 ]; then
52 testit "create user locally" $VALGRIND $newuser nettestuser $USERPASS $@ || failed=`expr $failed + 1`
54 KRB5CCNAME="$PREFIX/tmpuserccache"
57 echo $USERPASS > $PREFIX/tmpuserpassfile
59 testit "kinit with user password" $samba4kinit --password-file=$PREFIX/tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
61 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
63 NEWUSERPASS=testPaSS@02%
64 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`
66 echo $NEWUSERPASS > ./tmpuserpassfile
67 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
69 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
73 NEWUSERPASS=testPaSS@03%
75 cat > ./tmpkpasswdscript <<EOF
77 password ${USERPASS}\n
85 testit "change user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
87 test_smbclient "Test login with user kerberos (unforced)" 'ls' -k yes -Unettestuser@$REALM%$NEWUSERPASS || failed=`expr $failed + 1`
90 NEWUSERPASS=testPaSS@04%
91 testit "set password on user locally" $VALGRIND $setpassword nettestuser --newpassword=$NEWUSERPASS --must-change-at-next-login $@ || failed=`expr $failed + 1`
94 NEWUSERPASS=testPaSS@05%
95 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`
98 NEWUSERPASS=testPaSS@06%
99 testit "set password on user locally" $VALGRIND $setpassword nettestuser --newpassword=$NEWUSERPASS --must-change-at-next-login $@ || failed=`expr $failed + 1`
100 USERPASS=$NEWUSERPASS
102 NEWUSERPASS=testPaSS@07%
104 cat > ./tmpkpasswdscript <<EOF
106 password ${USERPASS}\n
108 send ${NEWUSERPASS}\n
110 send ${NEWUSERPASS}\n
114 testit "change user password with kpasswd (after must change flag set)" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
116 test_smbclient "Test login with user kerberos" 'ls' -k yes -Unettestuser@$REALM%$NEWUSERPASS || failed=`expr $failed + 1`
118 testit "del user" $VALGRIND $net user delete nettestuser -U"$USERNAME%$PASSWORD" -k no $@ || failed=`expr $failed + 1`
120 rm -f tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript