s4:torture/rpc/samr.c - make some argument of function "test_SamLogon_with_creds...
[Samba/nascimento.git] / testprogs / blackbox / test_kinit.sh
blob1ee4e1c9b6889736919aca0e608d49566ce3fcde
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="$samba4bindir/net enableaccount"
29 machineaccountccache="$BUILDDIR/scripting/bin/machineaccountccache"
31 . `dirname $0`/subunit.sh
33 test_smbclient() {
34 name="$1"
35 cmd="$2"
36 shift
37 shift
38 echo "test: $name"
39 $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" -W "$DOMAIN" $@
40 status=$?
41 if [ x$status = x0 ]; then
42 echo "success: $name"
43 else
44 echo "failure: $name"
46 return $status
49 KRB5CCNAME="$PREFIX/tmpccache"
50 export KRB5CCNAME
52 echo $PASSWORD > ./tmppassfile
53 #testit "kinit with keytab" $samba4kinit --keytab=$PREFIX/dc/private/secrets.keytab $SERVER\$@$REALM || failed=`expr $failed + 1`
54 testit "kinit with password" $samba4kinit --password-file=./tmppassfile --request-pac $USERNAME@$REALM || failed=`expr $failed + 1`
55 testit "kinit with password (enterprise style)" $samba4kinit --enterprise --password-file=./tmppassfile --request-pac $USERNAME@$REALM || failed=`expr $failed + 1`
56 testit "kinit with password (windows style)" $samba4kinit --windows --password-file=./tmppassfile --request-pac $USERNAME@$REALM || failed=`expr $failed + 1`
57 testit "kinit with pkinit (name specified)" $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`
58 testit "kinit with pkinit (enterprise name specified)" $samba4kinit --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`
59 testit "kinit with pkinit (enterprise name in cert)" $samba4kinit --request-pac --renewable --pk-user=FILE:$PREFIX/dc/private/tls/admincertupn.pem,$PREFIX/dc/private/tls/adminkey.pem --pk-enterprise || failed=`expr $failed + 1`
60 testit "kinit renew ticket" $samba4kinit --request-pac -R
62 test_smbclient "Test login with kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
64 testit "domain join with kerberos ccache" $VALGRIND $net join $DOMAIN $CONFIGURATION -W "$DOMAIN" -k yes $@ || failed=`expr $failed + 1`
65 testit "check time with kerberos ccache" $VALGRIND $net time $SERVER $CONFIGURATION -W "$DOMAIN" -k yes $@ || failed=`expr $failed + 1`
67 testit "add user with kerberos ccache" $VALGRIND $net user add nettestuser $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
68 USERPASS=testPass@12%
69 echo $USERPASS > ./tmpuserpassfile
71 testit "set user password with kerberos ccache" $VALGRIND $net password set $DOMAIN\\nettestuser $USERPASS $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
73 testit "enable user with kerberos cache" $VALGRIND $enableaccount nettestuser -H ldap://$SERVER -k yes $@ || failed=`expr $failed + 1`
75 KRB5CCNAME="$PREFIX/tmpuserccache"
76 export KRB5CCNAME
78 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
80 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
82 NEWUSERPASS=testPaSS@34%
83 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`
85 echo $NEWUSERPASS > ./tmpuserpassfile
86 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
88 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
91 USERPASS=$NEWUSERPASS
92 NEWUSERPASS=testPaSS@56%
93 echo $NEWUSERPASS > ./tmpuserpassfile
95 cat > ./tmpkpasswdscript <<EOF
96 expect Password
97 password ${USERPASS}\n
98 expect New password
99 send ${NEWUSERPASS}\n
100 expect New password
101 send ${NEWUSERPASS}\n
102 expect Success
105 testit "change user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd nettestuser@$REALM || failed=`expr $failed + 1`
107 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
109 NEWUSERPASS=testPaSS@78%
110 echo $NEWUSERPASS > ./tmpuserpassfile
112 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
114 cat > ./tmpkpasswdscript <<EOF
115 expect New password
116 send ${NEWUSERPASS}\n
117 expect New password
118 send ${NEWUSERPASS}\n
119 expect Success
122 testit "set user password with kpasswd" $rkpty ./tmpkpasswdscript $samba4kpasswd --cache=$PREFIX/tmpccache nettestuser@$REALM || failed=`expr $failed + 1`
124 testit "kinit with user password" $samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
126 test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
128 KRB5CCNAME="$PREFIX/tmpccache"
129 export KRB5CCNAME
131 testit "del user with kerberos ccache" $VALGRIND $net user delete nettestuser $CONFIGURATION -k yes $@ || failed=`expr $failed + 1`
133 rm -f $KRB5CCNAME
134 testit "kinit with machineaccountccache script" $machineaccountccache $CONFIGURATTION $KRB5CCNAME || failed=`expr $failed + 1`
135 test_smbclient "Test machine account login with kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
137 rm -f $PREFIX/tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript
138 exit $failed