From 8daa83a594a2e98f39d764422bfbdbc62c9efd44 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 19:20:00 +0200 Subject: Adding upstream version 2:4.20.0+dfsg. Signed-off-by: Daniel Baumann --- source3/script/tests/test_virus_scanner.sh | 135 +++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100755 source3/script/tests/test_virus_scanner.sh (limited to 'source3/script/tests/test_virus_scanner.sh') diff --git a/source3/script/tests/test_virus_scanner.sh b/source3/script/tests/test_virus_scanner.sh new file mode 100755 index 0000000..83b50df --- /dev/null +++ b/source3/script/tests/test_virus_scanner.sh @@ -0,0 +1,135 @@ +#!/bin/sh +# Copyright (c) 2022 Pavel Filipenský +# shellcheck disable=1091 + +if [ $# -lt 4 ]; then + cat <fsp_flags.modified + if ! echo "Hello Virus!" >"${sharedir}/infected.txt"; then + echo "ERROR: Cannot create ${sharedir}/infected.txt" + return 1 + fi + + ${SMBCLIENT} "//${SERVER_IP}/${SHARE}" -U"${USER}"%"${PASSWORD}" -c "put ${sharedir}/infected.txt ${smbfile}" + + # check that virusfilter:rename prefix/suffix was added + if [ ! -f "${sharedir}/${smbfilerenamed}" ]; then + echo "ERROR: ${sharedir}/${smbfilerenamed} is missing." + return 1 + fi + + # check that file was not uploaded + if [ -f "${sharedir}/infected.upload.txt" ]; then + echo "ERROR: {sharedir}/${smbfile} should not exist." + return 1 + fi + + return 0 +} + +check_healthy_read() +{ + rm -rf "${sharedir:?}"/* + + if ! echo "Hello Samba!" >"${sharedir}/healthy.txt"; then + echo "ERROR: Cannot create ${sharedir}/healthy.txt" + return 1 + fi + + ${SMBCLIENT} //"${SERVER_IP}"/"${SHARE}" -U"${USER}"%"${PASSWORD}" -c "get healthy.txt ${sharedir}/healthy.download.txt" + + if ! cmp "${sharedir}/healthy.txt" "${sharedir}/healthy.download.txt"; then + echo "ERROR: cmp ${sharedir}/healthy.txt ${sharedir}/healthy.download.txt FAILED" + return 1 + fi + + return 0 +} + +check_healthy_write() +{ + rm -rf "${sharedir:?}"/* + + if ! echo "Hello Samba!" >"${sharedir}/healthy.txt"; then + echo "ERROR: Cannot create ${sharedir}/healthy.txt" + return 1 + fi + + ${SMBCLIENT} //"${SERVER_IP}"/"${SHARE}" -U"${USER}"%"${PASSWORD}" -c "put ${sharedir}/healthy.txt healthy.upload.txt" + + if ! cmp "${sharedir}/healthy.txt" "${sharedir}/healthy.upload.txt"; then + echo "ERROR: cmp ${sharedir}/healthy.txt ${sharedir}/healthy.upload.txt FAILED" + return 1 + fi + + return 0 +} + +testit "check_infected_read" check_infected_read || failed=$((failed + 1)) +testit "check_infected_write" check_infected_write || failed=$((failed + 1)) +testit "check_healthy_read" check_healthy_read || failed=$((failed + 1)) +testit "check_healthy_write" check_healthy_write || failed=$((failed + 1)) + +testok "$0" "$failed" -- cgit v1.2.3