Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test
[ira/wip.git] / testprogs / blackbox / test_kinit.sh
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-2007 Andrew Bartlett <abartlet@samba.org>
5
6 if [ $# -lt 5 ]; then
7 cat <<EOF
8 Usage: test_kinit.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
9 EOF
10 exit 1;
11 fi
12
13 SERVER=$1
14 USERNAME=$2
15 PASSWORD=$3
16 REALM=$4
17 DOMAIN=$5
18 PREFIX=$6
19 shift 6
20 failed=0
21
22 samba4bindir=`dirname $0`/../../source/bin
23 smbclient=$samba4bindir/smbclient
24 samba4kinit=$samba4bindir/samba4kinit
25 net=$samba4bindir/net
26 enableaccount="$samba4bindir/smbpython `dirname $0`/../../source/setup/enableaccount"
27
28 . `dirname $0`/subunit.sh
29
30 test_smbclient() {
31         name="$1"
32         cmd="$2"
33         shift
34         shift
35         echo "test: $name"
36         $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@
37         status=$?
38         if [ x$status = x0 ]; then
39                 echo "success: $name"
40         else
41                 echo "failure: $name"
42         fi
43         return $status
44 }
45
46 KRB5CCNAME="$PREFIX/tmpccache"
47 export KRB5CCNAME
48
49 echo $PASSWORD > ./tmppassfile
50 #testit "kinit with keytab" $samba4kinit --keytab=$PREFIX/dc/private/secrets.keytab $SERVER\$@$REALM   || failed=`expr $failed + 1`
51 testit "kinit with password" $samba4kinit --password-file=./tmppassfile --request-pac $USERNAME@$REALM   || failed=`expr $failed + 1`
52 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`
53 testit "kinit renew ticket" $samba4kinit --request-pac -R
54
55 test_smbclient "Test login with kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
56
57 testit "domain join with kerberos ccache" $VALGRIND $net join $DOMAIN $CONFIGURATION  -W "$DOMAIN" -k yes $@ || failed=`expr $failed + 1`
58 testit "check time with kerberos ccache" $VALGRIND $net time $SERVER $CONFIGURATION  -W "$DOMAIN" -k yes $@ || failed=`expr $failed + 1`
59
60 testit "add user with kerberos ccache" $VALGRIND $net user add nettestuser $CONFIGURATION  -k yes $@ || failed=`expr $failed + 1`
61 USERPASS=testPass@12%
62 echo $USERPASS > ./tmpuserpassfile
63
64 testit "set user password with kerberos ccache" $VALGRIND $net password set $DOMAIN\\nettestuser $USERPASS $CONFIGURATION  -k yes $@ || failed=`expr $failed + 1`
65
66 testit "enable user with kerberos cache" $VALGRIND $enableaccount nettestuser -H ldap://$SERVER -k yes $@ || failed=`expr $failed + 1`
67
68 KRB5CCNAME="$PREFIX/tmpuserccache"
69 export KRB5CCNAME
70
71 testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM   || failed=`expr $failed + 1`
72
73 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
74
75 NEWUSERPASS=testPaSS@34%
76 testit "change user password" $VALGRIND $net password change -W$DOMAIN -U$DOMAIN\\nettestuser%$USERPASS $CONFIGURATION  -k no $NEWUSERPASS $@ || failed=`expr $failed + 1`
77
78 echo $NEWUSERPASS > ./tmpuserpassfile
79 testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM   || failed=`expr $failed + 1`
80
81 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
82
83 KRB5CCNAME="$PREFIX/tmpccache"
84 export KRB5CCNAME
85
86 testit "del user with kerberos ccache" $VALGRIND $net user delete nettestuser $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
87
88 rm -f tmpccfile tmppassfile tmpuserpassfile tmpuserccache
89 exit $failed