auth/credentials_krb5: fix memory leak in cli_credentials_failed_kerberos_login().
[Samba.git] / testprogs / blackbox / test_pkinit.sh
blobb727c0c668901c5c3ef227b49198f28745e4a06a
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 ENCTYPE SMBCLINET
9 EOF
10 exit 1;
13 SERVER=$1
14 USERNAME=$2
15 PASSWORD=$3
16 REALM=$4
17 DOMAIN=$5
18 PREFIX=$6
19 ENCTYPE=$7
20 smbclient=$8
21 shift 8
22 failed=0
24 samba4bindir="$BINDIR"
25 samba4srcdir="$SRCDIR/source4"
26 samba4kinit=kinit
27 if test -x $BINDIR/samba4kinit; then
28 samba4kinit=$BINDIR/samba4kinit
31 samba_tool="$samba4bindir/samba-tool"
32 samba4kpasswd=kpasswd
33 if test -x $BINDIR/samba4kpasswd; then
34 samba4passwd=$BINDIR/samba4kpasswd
37 enableaccount="$samba_tool user enable"
38 machineaccountccache="$samba4srcdir/scripting/bin/machineaccountccache"
40 ldbmodify="ldbmodify"
41 if [ -x "$samba4bindir/ldbmodify" ]; then
42 ldbmodify="$samba4bindir/ldbmodify"
45 ldbsearch="ldbsearch"
46 if [ -x "$samba4bindir/ldbsearch" ]; then
47 ldbsearch="$samba4bindir/ldbsearch"
50 . `dirname $0`/subunit.sh
52 test_smbclient() {
53 name="$1"
54 cmd="$2"
55 shift
56 shift
57 echo "test: $name"
58 $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" $@
59 status=$?
60 if [ x$status = x0 ]; then
61 echo "success: $name"
62 else
63 echo "failure: $name"
65 return $status
68 enctype="-e $ENCTYPE"
70 KRB5CCNAME="$PREFIX/tmpccache"
71 export KRB5CCNAME
73 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`
74 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`
75 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`
76 testit "kinit renew ticket" $samba4kinit --request-pac -R
78 test_smbclient "Test login with kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
80 rm -f $PREFIX/tmpccache
81 exit $failed