2 # Blackbox tests for kerberos client options
3 # Copyright (c) 2019 Andreas Schneider <asn@samba.org>
7 Usage: test_client_kerberos.sh DOMAIN REALM USERNAME PASSWORD SERVER PREFIX CONFIGURATION
23 . $
(dirname $0)/subunit.sh
24 . $
(dirname $0)/common_test_fns.inc
26 samba_bindir
="$BINDIR"
27 samba_rpcclient
="$samba_bindir/rpcclient"
28 samba_smbclient
="$samba_bindir/smbclient"
29 samba_smbtorture
="$samba_bindir/smbtorture"
32 if test -x ${samba_bindir}/samba4kinit
; then
33 samba_kinit
=${samba_bindir}/samba4kinit
36 samba_kdestroy
=kdestroy
37 if test -x ${samba_bindir}/samba4kdestroy
; then
38 samba_kinit
=${samba_bindir}/samba4kdestroy
41 test_rpc_getusername_legacy
() {
45 if [ $ret -ne 0 ] ; then
46 echo "Failed to connect! Error: $ret"
51 echo "$out" |
grep -q "Account Name: $USERNAME, Authority Name: $DOMAIN"
53 if [ $ret -ne 0 ] ; then
54 echo "Incorrect account/authority name! Error: $ret"
62 test_smbclient_legacy
() {
66 if [ $ret -ne 0 ] ; then
67 echo "Failed to connect! Error: $ret"
77 cmd
='$samba_rpcclient ncacn_np:${SERVER} -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} -c getusername 2>&1'
78 testit
"test rpcclient legacy ntlm" \
79 test_rpc_getusername_legacy || \
80 failed
=$
(expr $failed + 1)
82 cmd
='echo ${PASSWORD} | USER=${USERNAME} $samba_rpcclient ncacn_np:${SERVER} --configfile=${CONFIGURATION} -c getusername 2>&1'
83 testit
"test rpcclient legacy ntlm interactive" \
84 test_rpc_getusername_legacy || \
85 failed
=$
(expr $failed + 1)
87 cmd
='echo ${PASSWORD} | $samba_rpcclient ncacn_np:${SERVER} -U${USERNAME} --configfile=${CONFIGURATION} -c getusername 2>&1'
88 testit
"test rpcclient legacy ntlm interactive with -U" \
89 test_rpc_getusername_legacy || \
90 failed
=$
(expr $failed + 1)
92 cmd
='$samba_rpcclient ncacn_np:${SERVER} -U${USERNAME}%${PASSWORD} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
93 testit
"test rpcclient legacy kerberos" \
94 test_rpc_getusername_legacy || \
95 failed
=$
(expr $failed + 1)
97 cmd
='echo ${PASSWORD} | $samba_rpcclient ncacn_np:${SERVER} -U${USERNAME} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
98 testit_expect_failure
"test rpcclient legacy kerberos interactive (negative test)" \
99 test_rpc_getusername_legacy || \
100 failed
=$
(expr $failed + 1)
102 kerberos_kinit
$samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
103 cmd
='$samba_rpcclient ncacn_np:${SERVER} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
104 testit
"test rpcclient legacy kerberos ccache" \
105 test_rpc_getusername_legacy || \
106 failed
=$
(expr $failed + 1)
111 cmd
='$samba_smbtorture -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
112 testit
"test smbtorture legacy default" \
113 test_rpc_getusername_legacy || \
114 failed
=$
(expr $failed + 1)
116 cmd
='$samba_smbtorture -U${USERNAME}%${PASSWORD} -k no --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
117 testit
"test smbtorture legacy ntlm (kerberos=no)" \
118 test_rpc_getusername_legacy || \
119 failed
=$
(expr $failed + 1)
121 cmd
='$samba_smbtorture -U${USERNAME}%${PASSWORD} -k yes --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
122 testit
"test smbtorture legacy kerberos=yes" \
123 test_rpc_getusername_legacy || \
124 failed
=$
(expr $failed + 1)
126 kerberos_kinit
$samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
127 cmd
='$samba_smbtorture -k yes --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
128 testit
"test smbtorture legacy kerberos=yes ccache" \
129 test_rpc_getusername_legacy || \
130 failed
=$
(expr $failed + 1)
133 kerberos_kinit
$samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
134 cmd
='$samba_smbtorture -k no --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
135 testit_expect_failure
"test smbtorture legacy kerberos=no ccache (negative test)" \
136 test_rpc_getusername_legacy || \
137 failed
=$
(expr $failed + 1)
141 cmd
='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} -c "ls; quit"'
142 testit
"test smbclient legacy ntlm" \
143 test_smbclient_legacy || \
144 failed
=$
(expr $failed + 1)
146 cmd
='echo ${PASSWORD} | USER=$USERNAME $samba_smbclient //${SERVER}/tmp -W ${DOMAIN} --configfile=${CONFIGURATION} -c "ls; quit"'
147 testit
"test smbclient legacy ntlm interactive" \
148 test_smbclient_legacy || \
149 failed
=$
(expr $failed + 1)
151 cmd
='echo ${PASSWORD} | $samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME} --configfile=${CONFIGURATION} -c "ls; quit"'
152 testit
"test smbclient legacy ntlm interactive with -U" \
153 test_smbclient_legacy || \
154 failed
=$
(expr $failed + 1)
156 cmd
='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} -k --configfile=${CONFIGURATION} -c "ls; quit"'
157 testit
"test smbclient legacy kerberos" \
158 test_smbclient_legacy || \
159 failed
=$
(expr $failed + 1)
161 kerberos_kinit
$samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
162 cmd
='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -k --configfile=${CONFIGURATION} -c "ls; quit"'
163 testit
"test smbclient legacy kerberos ccache" \
164 test_smbclient_legacy || \
165 failed
=$
(expr $failed + 1)