]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:tests: Add kerberos test for smbget
authorAndreas Schneider <asn@samba.org>
Fri, 31 Mar 2023 07:46:02 +0000 (09:46 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 5 Apr 2023 01:06:29 +0000 (01:06 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/script/tests/test_smbget.sh

index 9afbe240138889ce460b3e2558c53f0f83eda738..2465ce634dccebc761a87969c39e47efc47d40d7 100755 (executable)
@@ -24,6 +24,9 @@ TMPDIR="$SELFTEST_TMPDIR"
 
 incdir=$(dirname $0)/../../../testprogs/blackbox
 . $incdir/subunit.sh
+. "${incdir}/common_test_fns.inc"
+
+samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
 
 create_test_data()
 {
@@ -404,6 +407,35 @@ test_encrypt()
        return 0
 }
 
+test_kerberos()
+{
+       clear_download_area
+
+       KRB5CCNAME_PATH="$PREFIX/smget_krb5ccache"
+       rm -f "${KRB5CCNAME_PATH}"
+
+       KRB5CCNAME="FILE:${KRB5CCNAME_PATH}"
+       export KRB5CCNAME
+       kerberos_kinit "${samba_kinit}" \
+               "${DC_USERNAME}@${REALM}" "${DC_PASSWORD}"
+
+       $SMBGET --verbose --use-krb5-ccache="${KRB5CCNAME}" \
+               smb://$SERVER/smbget/testfile
+       if [ $? -ne 0 ]; then
+               echo 'ERROR: RC does not match, expected: 0'
+               return 1
+       fi
+
+       cmp --silent $WORKDIR/testfile ./testfile
+       if [ $? -ne 0 ]; then
+               echo 'ERROR: file content does not match'
+               return 1
+       fi
+
+       rm -f "${KRB5CCNAME_PATH}"
+
+       return 0
+}
 
 create_test_data
 
@@ -461,6 +493,9 @@ testit "limit rate" test_limit_rate ||
 testit "encrypt" test_encrypt ||
        failed=$((failed + 1))
 
+testit "kerberos" test_kerberos ||
+       failed=$((failed + 1))
+
 clear_download_area
 
 popd # TMPDIR