s3/i18n: Add Russian translation for SWAT messages.
[Samba/gebeck_regimport.git] / testprogs / blackbox / test_kinit.sh
blobb19edfbb3803a3602aa5e70ef193f49c7475e0c4
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>
6 if [ $# -lt 5 ]; then
7 cat <<EOF
8 Usage: test_kinit.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
9 EOF
10 exit 1;
13 SERVER=$1
14 USERNAME=$2
15 PASSWORD=$3
16 REALM=$4
17 DOMAIN=$5
18 PREFIX=$6
19 shift 6
20 failed=0
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"
30 . `dirname $0`/subunit.sh
32 test_smbclient() {
33 name="$1"
34 cmd="$2"
35 shift
36 shift
37 echo "test: $name"
38 $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@
39 status=$?
40 if [ x$status = x0 ]; then
41 echo "success: $name"
42 else
43 echo "failure: $name"
45 return $status
48 KRB5CCNAME="$PREFIX/tmpccache"
49 export KRB5CCNAME
51 echo $PASSWORD > ./tmppassfile
52 #testit "kinit with keytab" $samba4kinit --keytab=$PREFIX/dc/private/secrets.keytab $SERVER\$@$REALM || failed=`expr $failed + 1`
53 testit "kinit with password" $samba4kinit --password-file=./tmppassfile --request-pac $USERNAME@$REALM || failed=`expr $failed + 1`
54 testit "kinit with pkinit" $samba4kinit --request-pac --renewable --pk-user=FILE:$PREFIX/dc/private/tls/admincert.pem,$PREFIX/dc/private/tls/adminkey.pem $USERNAME@$REALM || failed=`expr $failed + 1`
55 testit "kinit renew ticket" $samba4kinit --request-pac -R
57 test_smbclient "Test login with kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
59 testit "domain join with kerberos ccache" $VALGRIND $net join $DOMAIN $CONFIGURATION -W "$DOMAIN" -k yes $@ || failed=`expr $failed + 1`
60 testit "check time with kerberos ccache" $VALGRIND $net time $SERVER $CONFIGURATION -W "$DOMAIN" -k yes $@ || failed=`expr $failed + 1`
62 testit "add user with kerberos ccache" $VALGRIND $net user add nettestuser $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
63 USERPASS=testPass@12%
64 echo $USERPASS > ./tmpuserpassfile
66 testit "set user password with kerberos ccache" $VALGRIND $net password set $DOMAIN\\nettestuser $USERPASS $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
68 testit "enable user with kerberos cache" $VALGRIND $enableaccount nettestuser -H ldap://$SERVER -k yes $@ || failed=`expr $failed + 1`
70 KRB5CCNAME="$PREFIX/tmpuserccache"
71 export KRB5CCNAME
73 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
75 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
77 NEWUSERPASS=testPaSS@34%
78 testit "change user password with 'net password change' (rpc)" $VALGRIND $net password change -W$DOMAIN -U$DOMAIN\\nettestuser%$USERPASS $CONFIGURATION -k no $NEWUSERPASS $@ || failed=`expr $failed + 1`
80 echo $NEWUSERPASS > ./tmpuserpassfile
81 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
83 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
86 USERPASS=$NEWUSERPASS
87 NEWUSERPASS=testPaSS@56%
88 echo $NEWUSERPASS > ./tmpuserpassfile
90 cat > ./tmpkpasswdscript <<EOF
91 expect Password
92 password ${USERPASS}\n
93 expect New password
94 send ${NEWUSERPASS}\n
95 expect New password
96 send ${NEWUSERPASS}\n
97 expect Success
98 EOF
100 testit "change user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
102 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
104 NEWUSERPASS=testPaSS@78%
105 echo $NEWUSERPASS > ./tmpuserpassfile
107 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
109 cat > ./tmpkpasswdscript <<EOF
110 expect New password
111 send ${NEWUSERPASS}\n
112 expect New password
113 send ${NEWUSERPASS}\n
114 expect Success
117 testit "set user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd --cache=$PREFIX/tmpccache nettestuser@$REALM || failed=`expr $failed + 1`
119 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
121 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
123 KRB5CCNAME="$PREFIX/tmpccache"
124 export KRB5CCNAME
126 testit "del user with kerberos ccache" $VALGRIND $net user delete nettestuser $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
128 rm -f tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript
129 exit $failed