8d5c799403950919807a02e5c22ca848e835d12f
[ira/wip.git] / testprogs / blackbox / test_pkinit.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-2008 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 ENCTYPE=$7
20 shift 7
21 failed=0
22
23 samba4bindir="$BINDIR"
24 samba4srcdir="$SRCDIR/source4"
25 smbclient="$samba4bindir/smbclient$EXEEXT"
26 samba4kinit="$samba4bindir/samba4kinit$EXEEXT"
27 samba_tool="$samba4bindir/samba-tool$EXEEXT"
28 ldbmodify="$samba4bindir/ldbmodify$EXEEXT"
29 ldbsearch="$samba4bindir/ldbsearch$EXEEXT"
30 rkpty="$samba4bindir/rkpty$EXEEXT"
31 samba4kpasswd="$samba4bindir/samba4kpasswd$EXEEXT"
32 enableaccount="$samba_tool enableaccount"
33 machineaccountccache="$samba4srcdir/scripting/bin/machineaccountccache"
34
35 . `dirname $0`/subunit.sh
36
37 test_smbclient() {
38         name="$1"
39         cmd="$2"
40         shift
41         shift
42         echo "test: $name"
43         $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" -W "$DOMAIN" $@
44         status=$?
45         if [ x$status = x0 ]; then
46                 echo "success: $name"
47         else
48                 echo "failure: $name"
49         fi
50         return $status
51 }
52
53 enctype="-e $ENCTYPE"
54
55 KRB5CCNAME="$PREFIX/tmpccache"
56 export KRB5CCNAME
57
58 testit "kinit with pkinit (name specified)" $samba4kinit $enctype --request-pac --renewable --pk-user=FILE:$PREFIX/dc/private/tls/admincert.pem,$PREFIX/dc/private/tls/adminkey.pem $USERNAME@$REALM || failed=`expr $failed + 1`
59 testit "kinit with pkinit (enterprise name specified)" $samba4kinit $enctype --request-pac --renewable --pk-user=FILE:$PREFIX/dc/private/tls/admincert.pem,$PREFIX/dc/private/tls/adminkey.pem --enterprise $USERNAME@$REALM || failed=`expr $failed + 1`
60 testit "kinit with pkinit (enterprise name in cert)" $samba4kinit $enctype --request-pac --renewable --pk-user=FILE:$PREFIX/dc/private/tls/admincertupn.pem,$PREFIX/dc/private/tls/adminkey.pem --pk-enterprise || failed=`expr $failed + 1`
61 testit "kinit renew ticket" $samba4kinit --request-pac -R
62
63 test_smbclient "Test login with kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
64
65 rm -f $PREFIX/tmpccache
66 exit $failed