s3:tests: Add interactive smbget test for password entry
authorAndreas Schneider <asn@samba.org>
Wed, 6 Dec 2023 14:58:08 +0000 (15:58 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 10 Dec 2023 21:24:38 +0000 (21:24 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15532

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/script/tests/test_smbget.sh

index 0af28c6ff89f303a016c4ac76f2456f041dce253..74050f6951acdc082bfca512b0aaeb0fe4b9d762 100755 (executable)
@@ -29,6 +29,7 @@ incdir=$(dirname $0)/../../../testprogs/blackbox
 . "${incdir}/common_test_fns.inc"
 
 samba_kinit=$(system_or_builddir_binary kinit "${BINDIR}" samba4kinit)
+samba_texpect="${BINDIR}/texpect"
 
 create_test_data()
 {
@@ -163,6 +164,33 @@ test_singlefile_smburl2()
        return 0
 }
 
+test_singlefile_smburl_interactive()
+{
+       clear_download_area
+
+       tmpfile="$(mktemp --tmpdir="${TMPDIR}" expect_XXXXXXXXXX)"
+
+       cat >"${tmpfile}" <<EOF
+expect Password for
+send ${DOMAIN_USER_PASSWORD}\n
+EOF
+
+       USER="hanswurst" ${samba_texpect} "${tmpfile}" ${SMBGET} "smb://${DOMAIN};${DOMAIN_USER}@${SERVER_IP}/smbget/testfile"
+       ret=$?
+       rm -f "${tmpfile}"
+       if [ ${ret} -ne 0 ]; then
+               echo 'ERROR: RC does not match, expected: 0'
+               return 1
+       fi
+       cmp --silent $WORKDIR/testfile ./testfile
+       ret=$?
+       if [ ${ret} -ne 0 ]; then
+               echo 'ERROR: file content does not match'
+               return 1
+       fi
+       return 0
+}
+
 test_singlefile_authfile()
 {
        clear_download_area
@@ -533,6 +561,10 @@ testit "download single file with smb URL including domain" \
        test_singlefile_smburl2 ||
        failed=$(expr $failed + 1)
 
+testit "download single file with smb URL interactive" \
+       test_singlefile_smburl_interactive ||
+       failed=$(expr $failed + 1)
+
 testit "download single file with authfile" test_singlefile_authfile ||
        failed=$(expr $failed + 1)