From 1ae235d7a1712e4cd6b6e193ad4197ede2509e3b Mon Sep 17 00:00:00 2001 From: georglauterbach <44545919+georglauterbach@users.noreply.github.com> Date: Fri, 5 Jan 2024 09:31:37 +0100 Subject: [PATCH] correct hostname.bats Thanks to @polarathene for helping me here! I also noticed the logic of `_send_email_unchecked` was not 100% sound when supplying the `--data` argument - this has also been fixed. --- test/helper/sending.bash | 7 ++++++- .../parallel/set3/container_configuration/hostname.bats | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/helper/sending.bash b/test/helper/sending.bash index ed29a98a..12a3d260 100644 --- a/test/helper/sending.bash +++ b/test/helper/sending.bash @@ -48,7 +48,12 @@ function _send_email_unchecked() { ( '--port' ) PORT=${2:?--port given but no argument} ; shift 2 ;; ( '--data' ) ADDITIONAL_SWAKS_OPTIONS+=('--data') - ADDITIONAL_SWAKS_OPTIONS+=("@/tmp/docker-mailserver-test/emails/${2:?--data given but no argument provided}") + local FILE_PATH="/tmp/docker-mailserver-test/emails/${2:?--data given but no argument provided}" + if _exec_in_container_bash "[[ -e ${FILE_PATH} ]]"; then + ADDITIONAL_SWAKS_OPTIONS+=("@${FILE_PATH}") + else + ADDITIONAL_SWAKS_OPTIONS+=("'${2}'") + fi shift 2 ;; ( * ) ADDITIONAL_SWAKS_OPTIONS+=("'${1}'") ; shift 1 ;; diff --git a/test/tests/parallel/set3/container_configuration/hostname.bats b/test/tests/parallel/set3/container_configuration/hostname.bats index a525ecb2..c0a23b19 100644 --- a/test/tests/parallel/set3/container_configuration/hostname.bats +++ b/test/tests/parallel/set3/container_configuration/hostname.bats @@ -207,7 +207,7 @@ function _should_have_correct_mail_headers() { # (eg: OVERRIDE_HOSTNAME or `--hostname mail --domainname example.test`) local EXPECTED_HOSTNAME=${3:-${EXPECTED_FQDN}} - _send_email --from 'user@external.tld' + _send_email --from 'user@external.tld' --data "Date: %DATE%\nTo: %TO_ADDRESS%\nFrom: %FROM_ADDRESS%\nSubject: test %DATE%\n%NEW_HEADERS%\n%BODY%\n" _wait_for_empty_mail_queue_in_container _count_files_in_directory_in_container '/var/mail/localhost.localdomain/user1/new/' '1'