mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2026-05-05 12:16:33 +02:00
tests: update tests associated with Postgrey
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
parent
ab680c8e75
commit
e7cdb97f7b
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user