From e7cdb97f7b04b3c4e6b47e234330627712705c5b Mon Sep 17 00:00:00 2001 From: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> Date: Sat, 28 Mar 2026 22:26:26 +0100 Subject: [PATCH] tests: update tests associated with Postgrey Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> --- test/helper/common.bash | 11 +++++++++++ .../parallel/set1/spam_virus/postgrey_enabled.bats | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/test/helper/common.bash b/test/helper/common.bash index 8f2fa218..c48b54e4 100644 --- a/test/helper/common.bash +++ b/test/helper/common.bash @@ -442,6 +442,17 @@ function _nc_wrapper() { _run_in_container_bash "while read -r LINE; do sleep 0.5s; echo \"\${LINE}\"; done < /tmp/docker-mailserver-test/${FILE} | nc ${NC_PARAMETERS}" } +# Like _nc_wrapper, but without additional "buffering" after each line; +# this function sends the given file via `nc` as a whole immediately. +function _nc_wrapper_plain() { + local FILE=${1:?Must provide name of template file} + local NC_PARAMETERS=${2:-0.0.0.0 25} + + [[ -v CONTAINER_NAME ]] || return 1 + + _run_in_container_bash "nc ${NC_PARAMETERS} < /tmp/docker-mailserver-test/${FILE}" +} + # A simple wrapper for a test that checks whether a file exists. # # @param ${1} = the path to the file inside the container diff --git a/test/tests/parallel/set1/spam_virus/postgrey_enabled.bats b/test/tests/parallel/set1/spam_virus/postgrey_enabled.bats index 2609812e..87cd5f53 100644 --- a/test/tests/parallel/set1/spam_virus/postgrey_enabled.bats +++ b/test/tests/parallel/set1/spam_virus/postgrey_enabled.bats @@ -86,7 +86,7 @@ function teardown_file() { _default_teardown ; } # - It'd also cause the earlier greylist test to fail. # - TODO: Actually confirm whitelist feature works correctly as these test cases are using a workaround: @test "should whitelist sender 'user@whitelist.tld'" { - _nc_wrapper 'nc/postgrey_whitelist.txt' '-w 0 0.0.0.0 10023' + _nc_wrapper_plain 'nc/postgrey_whitelist.txt' '-w 0 0.0.0.0 10023' _should_have_log_entry \ 'action=pass' \ @@ -95,7 +95,7 @@ function teardown_file() { _default_teardown ; } } @test "should whitelist recipient 'user2@otherdomain.tld'" { - _nc_wrapper 'nc/postgrey_whitelist_recipients.txt' '-w 0 0.0.0.0 10023' + _nc_wrapper_plain 'nc/postgrey_whitelist_recipients.txt' '-w 0 0.0.0.0 10023' _should_have_log_entry \ 'action=pass' \ @@ -109,7 +109,7 @@ function _should_have_log_entry() { local TRIPLET=${3} # Allow some extra time for logs to update to avoids a false-positive failure: - _run_until_success_or_timeout 10 _exec_in_container grep \ + _run_until_success_or_timeout 25 _exec_in_container grep \ "${ACTION}, ${REASON}," \ /var/log/supervisor/postgrey.log