From 628e90223359534168ec9157637e09c78099edfd Mon Sep 17 00:00:00 2001 From: Casper Date: Thu, 5 May 2022 10:28:38 +0200 Subject: [PATCH] Remove unnecessary quotes from command substitutions (#2561) --- Dockerfile | 4 +- setup.sh | 6 +-- target/bin/addmailuser | 2 +- target/bin/updatemailuser | 2 +- target/scripts/check-for-changes.sh | 2 +- target/scripts/helpers/dns.sh | 2 +- target/scripts/helpers/lock.sh | 4 +- target/scripts/helpers/ssl.sh | 4 +- target/scripts/startup/daemons-stack.sh | 2 +- target/scripts/startup/setup-stack.sh | 4 +- test/default_relay_host.bats | 2 +- test/dovecot_inet_protocol.bats | 2 +- test/helper-functions.bats | 2 +- test/linting/lint.sh | 10 ++--- test/mail_changedetector.bats | 2 +- test/mail_disabled_clamav_spamassassin.bats | 2 +- test/mail_dnsbl.bats | 2 +- test/mail_fail2ban.bats | 2 +- test/mail_fetchmail.bats | 2 +- test/mail_fetchmail_parallel.bats | 2 +- test/mail_hostname.bats | 8 ++-- test/mail_lmtp_ip.bats | 4 +- test/mail_pop3.bats | 2 +- test/mail_postfix_inet.bats | 8 ++-- test/mail_postscreen.bats | 2 +- test/mail_privacy.bats | 2 +- test/mail_quotas_disabled.bats | 2 +- test/mail_smtponly.bats | 2 +- test/mail_spam_junk_folder.bats | 4 +- test/mail_special_use_folders.bats | 2 +- test/mail_ssl_manual.bats | 2 +- test/mail_time.bats | 2 +- test/mail_tls_dhparams.bats | 14 +++---- test/mail_undef_spam_subject.bats | 4 +- test/mail_with_imap.bats | 2 +- test/mail_with_ldap.bats | 2 +- test/mail_with_mdbox.bats | 2 +- test/mail_with_postgrey.bats | 2 +- ...ail_with_postgrey_disabled_by_default.bats | 2 +- test/mail_with_sdbox.bats | 2 +- test/open_dkim.bats | 20 +++++----- test/permit_docker.bats | 4 +- test/security_tls_cipherlists.bats | 2 +- test/test_helper.bats | 38 +++++++++---------- test/test_helper/common.bash | 8 ++-- test/tests.bats | 2 +- 46 files changed, 102 insertions(+), 102 deletions(-) diff --git a/Dockerfile b/Dockerfile index d2c9e922..ad1b048f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,9 +69,9 @@ RUN \ --recv-keys ${FAIL2BAN_GPG_PUBLIC_KEY_ID} 2>&1 && \ curl -Lkso fail2ban.deb ${FAIL2BAN_DEB_URL} && \ curl -Lkso fail2ban.deb.asc ${FAIL2BAN_DEB_ASC_URL} && \ - FINGERPRINT="$(LANG=C gpg --verify \ + FINGERPRINT=$(LANG=C gpg --verify \ fail2ban.deb.asc fail2ban.deb 2>&1 \ - | sed -n 's#Primary key fingerprint: \(.*\)#\1#p')" && \ + | sed -n 's#Primary key fingerprint: \(.*\)#\1#p') && \ if [[ -z ${FINGERPRINT} ]]; then \ echo "ERROR: Invalid GPG signature!" >&2; exit 1; fi && \ if [[ ${FINGERPRINT} != "${FAIL2BAN_GPG_FINGERPRINT}" ]]; then \ diff --git a/setup.sh b/setup.sh index 62dfd3e7..e0dd8aef 100755 --- a/setup.sh +++ b/setup.sh @@ -9,7 +9,7 @@ CONTAINER_NAME= CRI= DEFAULT_CONFIG_PATH= DESIRED_CONFIG_PATH= -DIR="$(pwd)" +DIR=$(pwd) DMS_CONFIG='/tmp/docker-mailserver' IMAGE_NAME= DEFAULT_IMAGE_NAME='docker.io/mailserver/docker-mailserver:latest' @@ -90,10 +90,10 @@ function _get_absolute_script_directory { if dirname "$(readlink -f "${0}")" &>/dev/null then - DIR="$(dirname "$(readlink -f "${0}")")" + DIR=$(dirname "$(readlink -f "${0}")") elif realpath -e -L "${0}" &>/dev/null then - DIR="$(realpath -e -L "${0}")" + DIR=$(realpath -e -L "${0}") DIR="${DIR%/setup.sh}" fi } diff --git a/target/bin/addmailuser b/target/bin/addmailuser index 4882dbc8..069a0f57 100755 --- a/target/bin/addmailuser +++ b/target/bin/addmailuser @@ -56,7 +56,7 @@ then [[ -z ${PASSWD} ]] && _exit_with_error "Password must not be empty" fi -HASH="$(doveadm pw -s SHA512-CRYPT -u "${FULL_EMAIL}" -p "${PASSWD}")" +HASH=$(doveadm pw -s SHA512-CRYPT -u "${FULL_EMAIL}" -p "${PASSWD}") echo "${FULL_EMAIL}|${HASH}" >> "${DATABASE}" USER="${FULL_EMAIL%@*}" diff --git a/target/bin/updatemailuser b/target/bin/updatemailuser index f07d6f1e..d43999c4 100755 --- a/target/bin/updatemailuser +++ b/target/bin/updatemailuser @@ -25,7 +25,7 @@ then [[ -z ${PASSWD} ]] && _exit_with_error 'Password must not be empty' fi -HASH="$(doveadm pw -s SHA512-CRYPT -u "${USER}" -p "${PASSWD}")" +HASH=$(doveadm pw -s SHA512-CRYPT -u "${USER}" -p "${PASSWD}") touch "${DATABASE}" _create_lock # Protect config file with lock to avoid race conditions diff --git a/target/scripts/check-for-changes.sh b/target/scripts/check-for-changes.sh index daeaf590..9d0b8ff4 100755 --- a/target/scripts/check-for-changes.sh +++ b/target/scripts/check-for-changes.sh @@ -94,7 +94,7 @@ function _check_for_changes # Prevent an unnecessary change detection from the newly extracted cert files by updating their hashes in advance: local CERT_DOMAIN - CERT_DOMAIN="$(_find_letsencrypt_domain)" + CERT_DOMAIN=$(_find_letsencrypt_domain) ACME_CERT_DIR="/etc/letsencrypt/live/${CERT_DOMAIN}" sed -i "\|${ACME_CERT_DIR}|d" "${CHKSUM_FILE}.new" diff --git a/target/scripts/helpers/dns.sh b/target/scripts/helpers/dns.sh index 2237c601..d47ab204 100644 --- a/target/scripts/helpers/dns.sh +++ b/target/scripts/helpers/dns.sh @@ -52,7 +52,7 @@ function _obtain_hostname_and_domainname # going forward. In future our docs should drop any mention of it. #shellcheck disable=SC2034 - DOMAINNAME="$(hostname -d)" + DOMAINNAME=$(hostname -d) fi fi diff --git a/target/scripts/helpers/lock.sh b/target/scripts/helpers/lock.sh index a8fef039..80e74aa0 100644 --- a/target/scripts/helpers/lock.sh +++ b/target/scripts/helpers/lock.sh @@ -2,10 +2,10 @@ # This becomes the sourcing script name # (example: check-for-changes.sh) -SCRIPT_NAME="$(basename "$0")" +SCRIPT_NAME=$(basename "$0") # Used inside of lock files to identify them and # prevent removal by other instances of docker-mailserver -LOCK_ID="$(uuid)" +LOCK_ID=$(uuid) function _create_lock { diff --git a/target/scripts/helpers/ssl.sh b/target/scripts/helpers/ssl.sh index daca4b6d..28a907b8 100644 --- a/target/scripts/helpers/ssl.sh +++ b/target/scripts/helpers/ssl.sh @@ -187,8 +187,8 @@ function _setup_ssl # checks folders in /etc/letsencrypt/live to identify which one to implicitly use: local LETSENCRYPT_DOMAIN LETSENCRYPT_KEY - LETSENCRYPT_DOMAIN="$(_find_letsencrypt_domain)" - LETSENCRYPT_KEY="$(_find_letsencrypt_key "${LETSENCRYPT_DOMAIN}")" + LETSENCRYPT_DOMAIN=$(_find_letsencrypt_domain) + LETSENCRYPT_KEY=$(_find_letsencrypt_key "${LETSENCRYPT_DOMAIN}") # Update relevant config for Postfix and Dovecot _log 'trace' "Adding ${LETSENCRYPT_DOMAIN} SSL certificate to the postfix and dovecot configuration" diff --git a/target/scripts/startup/daemons-stack.sh b/target/scripts/startup/daemons-stack.sh index cdfcbd82..8215ff83 100644 --- a/target/scripts/startup/daemons-stack.sh +++ b/target/scripts/startup/daemons-stack.sh @@ -15,7 +15,7 @@ function _default_start_daemon _log 'debug' "Starting ${1:?}" local RESULT - RESULT="$(supervisorctl start "${1}" 2>&1)" + RESULT=$(supervisorctl start "${1}" 2>&1) # shellcheck disable=SC2181 if [[ ${?} -ne 0 ]] diff --git a/target/scripts/startup/setup-stack.sh b/target/scripts/startup/setup-stack.sh index 21607296..d6e7159d 100644 --- a/target/scripts/startup/setup-stack.sh +++ b/target/scripts/startup/setup-stack.sh @@ -714,7 +714,7 @@ function _setup_docker_permit CONTAINER_IP=$(ip addr show "${NETWORK_INTERFACE}" | \ grep 'inet ' | sed 's|[^0-9\.\/]*||g' | cut -d '/' -f 1) - CONTAINER_NETWORK="$(echo "${CONTAINER_IP}" | cut -d '.' -f1-2).0.0" + CONTAINER_NETWORK=$(echo "${CONTAINER_IP}" | cut -d '.' -f1-2).0.0 if [[ -z ${CONTAINER_IP} ]] then @@ -955,7 +955,7 @@ function _setup_security_stack cat >"${SPAMASSASSIN_KAM_CRON_FILE}" <<"EOM" #! /bin/bash -RESULT="$(sa-update --gpgkey 24C063D8 --channel kam.sa-channels.mcgrail.com 2>&1)" +RESULT=$(sa-update --gpgkey 24C063D8 --channel kam.sa-channels.mcgrail.com 2>&1) EXIT_CODE=${?} # see https://spamassassin.apache.org/full/3.1.x/doc/sa-update.html#exit_codes diff --git a/test/default_relay_host.bats b/test/default_relay_host.bats index ee38d529..be8008c2 100644 --- a/test/default_relay_host.bats +++ b/test/default_relay_host.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container relay-hosts)" + PRIVATE_CONFIG=$(duplicate_config_for_container relay-hosts) docker run -d --name mail_with_default_relay \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/dovecot_inet_protocol.bats b/test/dovecot_inet_protocol.bats index 7b0c21cd..dfb63c8b 100644 --- a/test/dovecot_inet_protocol.bats +++ b/test/dovecot_inet_protocol.bats @@ -4,7 +4,7 @@ function setup_file() { local PRIVATE_CONFIG export ALL IPV4 IPV6 - PRIVATE_CONFIG="$(duplicate_config_for_container . "${IPV4}")" + PRIVATE_CONFIG=$(duplicate_config_for_container . "${IPV4}") ALL="mail_dovecot_all_protocols" IPV4="mail_dovecot_ipv4" IPV6="mail_dovecot_ipv6" diff --git a/test/helper-functions.bats b/test/helper-functions.bats index bd48c1d4..2145a1d7 100644 --- a/test/helper-functions.bats +++ b/test/helper-functions.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_helper_functions \ --cap-add=NET_ADMIN \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ diff --git a/test/linting/lint.sh b/test/linting/lint.sh index c7e125f8..191313c2 100755 --- a/test/linting/lint.sh +++ b/test/linting/lint.sh @@ -7,7 +7,7 @@ SCRIPT="lint.sh" SCRIPT_DIR=$(dirname "$(readlink -f "$0")") -REPO_ROOT="$(realpath "${SCRIPT_DIR}"/../../)" +REPO_ROOT=$(realpath "${SCRIPT_DIR}"/../../) HADOLINT_VERSION=2.8.0 ECLINT_VERSION=2.3.5 @@ -93,14 +93,14 @@ function _shellcheck local SCRIPT='SHELLCHECK' # File paths for shellcheck: - F_SH="$(find . -type f -iname '*.sh' \ + F_SH=$(find . -type f -iname '*.sh' \ -not -path './test/bats/*' \ -not -path './test/test_helper/*' \ -not -path './target/docker-configomat/*' - )" + ) # shellcheck disable=SC2248 - F_BIN="$(find 'target/bin' -type f -not -name '*.py')" - F_BATS="$(find 'test' -maxdepth 1 -type f -iname '*.bats')" + F_BIN=$(find 'target/bin' -type f -not -name '*.py') + F_BATS=$(find 'test' -maxdepth 1 -type f -iname '*.bats') # This command is a bit easier to grok as multi-line. # There is a `.shellcheckrc` file, but it's only supports half of the options below, thus kept as CLI: diff --git a/test/mail_changedetector.bats b/test/mail_changedetector.bats index 536c28e2..7e6f73dc 100644 --- a/test/mail_changedetector.bats +++ b/test/mail_changedetector.bats @@ -6,7 +6,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_changedetector_one)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_changedetector_one) docker run -d --name mail_changedetector_one \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ diff --git a/test/mail_disabled_clamav_spamassassin.bats b/test/mail_disabled_clamav_spamassassin.bats index 37018357..79190462 100644 --- a/test/mail_disabled_clamav_spamassassin.bats +++ b/test/mail_disabled_clamav_spamassassin.bats @@ -2,7 +2,7 @@ load 'test_helper/common' setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run --rm -d --name mail_disabled_clamav_spamassassin \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_dnsbl.bats b/test/mail_dnsbl.bats index 08d6ad51..c1043154 100644 --- a/test/mail_dnsbl.bats +++ b/test/mail_dnsbl.bats @@ -5,7 +5,7 @@ CONTAINER2="mail_dnsbl_disabled" function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . "${CONTAINER}")" + PRIVATE_CONFIG=$(duplicate_config_for_container . "${CONTAINER}") docker run --rm -d --name "${CONTAINER}" \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ diff --git a/test/mail_fail2ban.bats b/test/mail_fail2ban.bats index 44768c68..fa5ce29f 100644 --- a/test/mail_fail2ban.bats +++ b/test/mail_fail2ban.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run --rm -d --name mail_fail2ban \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_fetchmail.bats b/test/mail_fetchmail.bats index 49aa7e6c..07f2fb07 100644 --- a/test/mail_fetchmail.bats +++ b/test/mail_fetchmail.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_fetchmail \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_fetchmail_parallel.bats b/test/mail_fetchmail_parallel.bats index dec6f4a3..a1d87d86 100644 --- a/test/mail_fetchmail_parallel.bats +++ b/test/mail_fetchmail_parallel.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_fetchmail_parallel \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_hostname.bats b/test/mail_hostname.bats index 1cf135b7..caa5b08f 100644 --- a/test/mail_hostname.bats +++ b/test/mail_hostname.bats @@ -3,7 +3,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_override_hostname)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_override_hostname) docker run --rm -d --name mail_override_hostname \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -13,7 +13,7 @@ function setup_file() { -h unknown.domain.tld \ -t "${NAME}" - PRIVATE_CONFIG_TWO="$(duplicate_config_for_container . mail_non_subdomain_hostname)" + PRIVATE_CONFIG_TWO=$(duplicate_config_for_container . mail_non_subdomain_hostname) docker run --rm -d --name mail_non_subdomain_hostname \ -v "${PRIVATE_CONFIG_TWO}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -23,7 +23,7 @@ function setup_file() { --domainname domain.com \ -t "${NAME}" - PRIVATE_CONFIG_THREE="$(duplicate_config_for_container . mail_srs_domainname)" + PRIVATE_CONFIG_THREE=$(duplicate_config_for_container . mail_srs_domainname) docker run --rm -d --name mail_srs_domainname \ -v "${PRIVATE_CONFIG_THREE}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -34,7 +34,7 @@ function setup_file() { --hostname 'mail' \ -t "${NAME}" - PRIVATE_CONFIG_FOUR="$(duplicate_config_for_container . mail_domainname)" + PRIVATE_CONFIG_FOUR=$(duplicate_config_for_container . mail_domainname) docker run --rm -d --name mail_domainname \ -v "${PRIVATE_CONFIG_FOUR}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_lmtp_ip.bats b/test/mail_lmtp_ip.bats index 8b95dadd..341bd553 100644 --- a/test/mail_lmtp_ip.bats +++ b/test/mail_lmtp_ip.bats @@ -2,8 +2,8 @@ load 'test_helper/common' setup_file() { local PRIVATE_CONFIG PRIVATE_ETC - PRIVATE_CONFIG="$(duplicate_config_for_container .)" - PRIVATE_ETC="$(duplicate_config_for_container dovecot-lmtp/ mail_lmtp_ip_dovecot-lmtp)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) + PRIVATE_ETC=$(duplicate_config_for_container dovecot-lmtp/ mail_lmtp_ip_dovecot-lmtp) docker run -d --name mail_lmtp_ip \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "${PRIVATE_ETC}":/etc/dovecot \ diff --git a/test/mail_pop3.bats b/test/mail_pop3.bats index 93f8a3ae..fb397658 100644 --- a/test/mail_pop3.bats +++ b/test/mail_pop3.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_pop3 \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_postfix_inet.bats b/test/mail_postfix_inet.bats index 14977e0a..3f90b735 100644 --- a/test/mail_postfix_inet.bats +++ b/test/mail_postfix_inet.bats @@ -6,7 +6,7 @@ load 'test_helper/common' @test "checking postfix: inet default" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . )" + PRIVATE_CONFIG=$(duplicate_config_for_container . ) docker run -d --name mail_postfix_inet_default \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -23,7 +23,7 @@ load 'test_helper/common' @test "checking postfix: inet all" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . )" + PRIVATE_CONFIG=$(duplicate_config_for_container . ) docker run -d --name mail_postfix_inet_all \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -41,7 +41,7 @@ load 'test_helper/common' @test "checking postfix: inet ipv4" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . )" + PRIVATE_CONFIG=$(duplicate_config_for_container . ) docker run -d --name mail_postfix_inet_ipv4 \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -59,7 +59,7 @@ load 'test_helper/common' @test "checking postfix: inet ipv6" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . )" + PRIVATE_CONFIG=$(duplicate_config_for_container . ) docker run -d --name mail_postfix_inet_ipv6 \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_postscreen.bats b/test/mail_postscreen.bats index 3c25d14b..166f4d38 100644 --- a/test/mail_postscreen.bats +++ b/test/mail_postscreen.bats @@ -7,7 +7,7 @@ setup() { setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_postscreen \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_privacy.bats b/test/mail_privacy.bats index d21c0dfc..a09a3f32 100644 --- a/test/mail_privacy.bats +++ b/test/mail_privacy.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_privacy \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_quotas_disabled.bats b/test/mail_quotas_disabled.bats index 56cedad5..27577178 100644 --- a/test/mail_quotas_disabled.bats +++ b/test/mail_quotas_disabled.bats @@ -7,7 +7,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_no_quotas \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_smtponly.bats b/test/mail_smtponly.bats index 62990345..083a4245 100644 --- a/test/mail_smtponly.bats +++ b/test/mail_smtponly.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run --rm -d --name mail_smtponly \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_spam_junk_folder.bats b/test/mail_spam_junk_folder.bats index 6f0fd03e..23d64c8e 100644 --- a/test/mail_spam_junk_folder.bats +++ b/test/mail_spam_junk_folder.bats @@ -6,7 +6,7 @@ load 'test_helper/common' @test "checking amavis: spam message is delivered and moved to the Junk folder (MOVE_SPAM_TO_JUNK=1)" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_spam_moved_junk)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_spam_moved_junk) docker run -d --name mail_spam_moved_junk \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -35,7 +35,7 @@ load 'test_helper/common' @test "checking amavis: spam message is delivered to INBOX (MOVE_SPAM_TO_JUNK=0)" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_spam_moved_new)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_spam_moved_new) docker run -d --name mail_spam_moved_new \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_special_use_folders.bats b/test/mail_special_use_folders.bats index 9cdf21b4..7c141c71 100644 --- a/test/mail_special_use_folders.bats +++ b/test/mail_special_use_folders.bats @@ -2,7 +2,7 @@ load 'test_helper/common' setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_special_use_folders \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_ssl_manual.bats b/test/mail_ssl_manual.bats index 9171494a..81e326a0 100644 --- a/test/mail_ssl_manual.bats +++ b/test/mail_ssl_manual.bats @@ -16,7 +16,7 @@ function setup_file() { local PRIVATE_CONFIG export DOMAIN_SSL_MANUAL='example.test' - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_manual_ssl \ --volume "${PRIVATE_CONFIG}/:/tmp/docker-mailserver/" \ diff --git a/test/mail_time.bats b/test/mail_time.bats index 4fb5e9bc..52407a59 100644 --- a/test/mail_time.bats +++ b/test/mail_time.bats @@ -2,7 +2,7 @@ load 'test_helper/common' setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_time \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ diff --git a/test/mail_tls_dhparams.bats b/test/mail_tls_dhparams.bats index 12f53994..05e5f608 100644 --- a/test/mail_tls_dhparams.bats +++ b/test/mail_tls_dhparams.bats @@ -35,10 +35,10 @@ function setup_file() { DH_DEFAULT_PARAMS="$(pwd)/target/shared/ffdhe4096.pem" - DH_DEFAULT_CHECKSUM="$(sha512sum "${DH_DEFAULT_PARAMS}" | awk '{print $1}')" + DH_DEFAULT_CHECKSUM=$(sha512sum "${DH_DEFAULT_PARAMS}" | awk '{print $1}') DH_CUSTOM_PARAMS="$(pwd)/test/test-files/ssl/custom-dhe-params.pem" - DH_CUSTOM_CHECKSUM="$(sha512sum "${DH_CUSTOM_PARAMS}" | awk '{print $1}')" + DH_CUSTOM_CHECKSUM=$(sha512sum "${DH_CUSTOM_PARAMS}" | awk '{print $1}') } # Not used @@ -54,12 +54,12 @@ function setup_file() { # Verify the FFDHE params file has not been modified (equivalent to `target/shared/ffdhe4096.pem.sha512sum`): local DH_MOZILLA_CHECKSUM - DH_MOZILLA_CHECKSUM="$(curl https://ssl-config.mozilla.org/ffdhe4096.txt -s | sha512sum | awk '{print $1}')" + DH_MOZILLA_CHECKSUM=$(curl https://ssl-config.mozilla.org/ffdhe4096.txt -s | sha512sum | awk '{print $1}') assert_equal "${DH_DEFAULT_CHECKSUM}" "${DH_MOZILLA_CHECKSUM}" } @test "testing tls: DH Parameters - Default [ONE_DIR=0]" { - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dhparams_default_0)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_dhparams_default_0) DMS_ONE_DIR=0 common_container_setup @@ -67,14 +67,14 @@ function setup_file() { } @test "testing tls: DH Parameters - Default [ONE_DIR=1]" { - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dhparams_default_1)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_dhparams_default_1) common_container_setup should_have_valid_checksum "${DH_DEFAULT_CHECKSUM}" } @test "testing tls: DH Parameters - Custom [ONE_DIR=0]" { - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dhparams_custom_0)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_dhparams_custom_0) # shellcheck disable=SC2030 DMS_ONE_DIR=0 @@ -87,7 +87,7 @@ function setup_file() { @test "testing tls: DH Parameters - Custom [ONE_DIR=1]" { # shellcheck disable=SC2030 - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dhparams_custom_1)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_dhparams_custom_1) cp "${DH_CUSTOM_PARAMS}" "${PRIVATE_CONFIG}/dhparams.pem" diff --git a/test/mail_undef_spam_subject.bats b/test/mail_undef_spam_subject.bats index 31728965..4f44ebfd 100644 --- a/test/mail_undef_spam_subject.bats +++ b/test/mail_undef_spam_subject.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_undef_spam_subject \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -10,7 +10,7 @@ function setup() { -e SA_SPAM_SUBJECT="undef" \ -h mail.my-domain.com -t "${NAME}" - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_undef_spam_subject_2)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_undef_spam_subject_2) CONTAINER=$(docker run -d \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_with_imap.bats b/test/mail_with_imap.bats index 04ce3052..74ae5cd6 100644 --- a/test/mail_with_imap.bats +++ b/test/mail_with_imap.bats @@ -3,7 +3,7 @@ load 'test_helper/common' setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_with_imap \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_with_ldap.bats b/test/mail_with_ldap.bats index 5f8a6b50..137ecf17 100644 --- a/test/mail_with_ldap.bats +++ b/test/mail_with_ldap.bats @@ -25,7 +25,7 @@ function setup_file() { # _setup_ldap uses configomat with .ext files and ENV vars like DOVECOT_TLS with a prefix (eg DOVECOT_ or LDAP_) local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_with_ldap \ -v "${PRIVATE_CONFIG}:/tmp/docker-mailserver" \ -v "$(pwd)/test/test-files:/tmp/docker-mailserver-test:ro" \ diff --git a/test/mail_with_mdbox.bats b/test/mail_with_mdbox.bats index d0925879..a607f35a 100644 --- a/test/mail_with_mdbox.bats +++ b/test/mail_with_mdbox.bats @@ -2,7 +2,7 @@ load 'test_helper/common' setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_with_mdbox_format \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_with_postgrey.bats b/test/mail_with_postgrey.bats index d81c38d1..660a508a 100644 --- a/test/mail_with_postgrey.bats +++ b/test/mail_with_postgrey.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_with_postgrey \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_with_postgrey_disabled_by_default.bats b/test/mail_with_postgrey_disabled_by_default.bats index 28249544..23c5e6da 100644 --- a/test/mail_with_postgrey_disabled_by_default.bats +++ b/test/mail_with_postgrey_disabled_by_default.bats @@ -2,7 +2,7 @@ load 'test_helper/common' function setup() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) CONTAINER=$(docker run -d \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/mail_with_sdbox.bats b/test/mail_with_sdbox.bats index 696ecbca..6167daae 100644 --- a/test/mail_with_sdbox.bats +++ b/test/mail_with_sdbox.bats @@ -2,7 +2,7 @@ load 'test_helper/common' setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) docker run -d --name mail_with_sdbox_format \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/open_dkim.bats b/test/open_dkim.bats index d8937032..e4fc3616 100644 --- a/test/open_dkim.bats +++ b/test/open_dkim.bats @@ -10,7 +10,7 @@ TEST_FILE='checking OpenDKIM: ' function setup_file { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . "${CONTAINER_NAME}")" + PRIVATE_CONFIG=$(duplicate_config_for_container . "${CONTAINER_NAME}") docker run -d \ --name "${CONTAINER_NAME}" \ @@ -62,7 +62,7 @@ function teardown_file # TODO Needs complete re-write @test "${TEST_FILE}generator creates default keys size" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_default_key_size)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_default_key_size) # Prepare default key size 4096 rm -rf "${PRIVATE_CONFIG}/keyDefault" @@ -93,7 +93,7 @@ function teardown_file # TODO Needs complete re-write @test "${TEST_FILE}generator creates key size 4096" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_4096)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_key_size_4096) rm -rf "${PRIVATE_CONFIG}/key4096" mkdir -p "${PRIVATE_CONFIG}/config/key4096" @@ -122,7 +122,7 @@ function teardown_file # TODO Needs complete re-write @test "${TEST_FILE}generator creates key size 2048" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_2048)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_key_size_2048) rm -rf "${PRIVATE_CONFIG}/key2048" mkdir -p "${PRIVATE_CONFIG}/config/key2048" @@ -151,7 +151,7 @@ function teardown_file # TODO Needs complete re-write @test "${TEST_FILE}generator creates key size 1024" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_1024)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_key_size_1024) rm -rf "${PRIVATE_CONFIG}/key1024" mkdir -p "${PRIVATE_CONFIG}/key1024" @@ -176,7 +176,7 @@ function teardown_file @test "${TEST_FILE}generator creates keys, tables and TrustedHosts" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts) rm -rf "${PRIVATE_CONFIG}/empty" mkdir -p "${PRIVATE_CONFIG}/empty" run docker run --rm \ @@ -212,7 +212,7 @@ function teardown_file @test "${TEST_FILE}generator creates keys, tables and TrustedHosts without postfix-accounts.cf" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . )" + PRIVATE_CONFIG=$(duplicate_config_for_container . ) rm -rf "${PRIVATE_CONFIG}/without-accounts" mkdir -p "${PRIVATE_CONFIG}/without-accounts" run docker run --rm \ @@ -248,7 +248,7 @@ function teardown_file @test "${TEST_FILE}generator creates keys, tables and TrustedHosts without postfix-virtual.cf" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . "${BATS_TEST_NAME}")" + PRIVATE_CONFIG=$(duplicate_config_for_container . "${BATS_TEST_NAME}") rm -rf "${PRIVATE_CONFIG}/without-virtual" mkdir -p "${PRIVATE_CONFIG}/without-virtual" run docker run --rm \ @@ -286,7 +286,7 @@ function teardown_file @test "${TEST_FILE}generator creates keys, tables and TrustedHosts using manual provided domain name" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . "${BATS_TEST_NAME}")" + PRIVATE_CONFIG=$(duplicate_config_for_container . "${BATS_TEST_NAME}") rm -rf "${PRIVATE_CONFIG}/with-domain" && mkdir -p "${PRIVATE_CONFIG}/with-domain" # generate first key @@ -374,7 +374,7 @@ function teardown_file @test "${TEST_FILE}generator creates keys, tables and TrustedHosts using manual provided selector name" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . "${BATS_TEST_NAME}")" + PRIVATE_CONFIG=$(duplicate_config_for_container . "${BATS_TEST_NAME}") rm -rf "${PRIVATE_CONFIG}/with-selector" && mkdir -p "${PRIVATE_CONFIG}/with-selector" # Generate first key diff --git a/test/permit_docker.bats b/test/permit_docker.bats index ef7fb1b5..5ba4d9fb 100644 --- a/test/permit_docker.bats +++ b/test/permit_docker.bats @@ -8,7 +8,7 @@ setup_file() { # currently we cannot use --network in `docker run` multiple times, it will just use the last one # instead we need to use create, network connect and start (see https://success.docker.com/article/multiple-docker-networks) local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_smtponly_second_network)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_smtponly_second_network) docker create --name mail_smtponly_second_network \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ @@ -19,7 +19,7 @@ setup_file() { -t "${NAME}" docker network connect "${NON_DEFAULT_DOCKER_MAIL_NETWORK_NAME}2" mail_smtponly_second_network docker start mail_smtponly_second_network - PRIVATE_CONFIG="$(duplicate_config_for_container . mail_smtponly_second_network_sender)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail_smtponly_second_network_sender) docker run -d --name mail_smtponly_second_network_sender \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ diff --git a/test/security_tls_cipherlists.bats b/test/security_tls_cipherlists.bats index fabe1a03..5c2b3b45 100644 --- a/test/security_tls_cipherlists.bats +++ b/test/security_tls_cipherlists.bats @@ -23,7 +23,7 @@ function setup_file() { # Copies all of `./test/config/` to specific directory for testing # `${PRIVATE_CONFIG}` becomes `$(pwd)/test/duplicate_configs/` export PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) # Pull `testssl.sh` image in advance to avoid it interfering with the `run` captured output. # Only interferes (potential test failure) with `assert_output` not `assert_success`? diff --git a/test/test_helper.bats b/test/test_helper.bats index 86317652..57d54967 100644 --- a/test/test_helper.bats +++ b/test/test_helper.bats @@ -99,11 +99,11 @@ load 'test_helper/common' @test "wait_for_finished_setup_in_container" { # variable not local to make visible to teardown local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" - CONTAINER_NAME="$(docker run -d --rm \ + PRIVATE_CONFIG=$(duplicate_config_for_container .) + CONTAINER_NAME=$(docker run -d --rm \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -h mail.my-domain.com \ - -t "${NAME}")" + -t "${NAME}") teardown() { docker rm -f "${CONTAINER_NAME}"; } # the setup should not be finished immediately after starting @@ -117,7 +117,7 @@ load 'test_helper/common' @test "duplicate_config_for_container" { local path - path="$(duplicate_config_for_container duplicate_config_test)" + path=$(duplicate_config_for_container duplicate_config_test) run cat "${path}/marker" assert_line "This marker file is there to identify the correct config being copied" @@ -128,12 +128,12 @@ load 'test_helper/common' @test "container_has_service_running/wait_for_service" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) # variable not local to make visible to teardown - CONTAINER_NAME="$(docker run -d --rm \ + CONTAINER_NAME=$(docker run -d --rm \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -h mail.my-domain.com \ - -t "${NAME}")" + -t "${NAME}") teardown() { docker rm -f "${CONTAINER_NAME}"; } # pick a service that was not started @@ -154,12 +154,12 @@ load 'test_helper/common' @test "wait_for_changes_to_be_detected_in_container fails when timeout is reached" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) # variable not local to make visible to teardown - CONTAINER_NAME="$(docker run -d --rm \ + CONTAINER_NAME=$(docker run -d --rm \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -h mail.my-domain.com \ - -t "${NAME}")" + -t "${NAME}") teardown() { docker rm -f "${CONTAINER_NAME}"; } # wait for the initial checksum detection to complete @@ -177,12 +177,12 @@ load 'test_helper/common' @test "wait_for_changes_to_be_detected_in_container succeeds within timeout" { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) # variable not local to make visible to teardown - CONTAINER_NAME="$(docker run -d --rm \ + CONTAINER_NAME=$(docker run -d --rm \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -h mail.my-domain.com \ - -t "${NAME}")" + -t "${NAME}") teardown() { docker rm -f "${CONTAINER_NAME}"; } # wait for the initial checksum detection to complete @@ -202,15 +202,15 @@ load 'test_helper/common' skip 'disabled as it fails randomly: https://github.com/docker-mailserver/docker-mailserver/pull/2177' local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) # variable not local to make visible to teardown # enable ClamAV to make message delivery slower, so we can detect it - CONTAINER_NAME="$(docker run -d --rm \ + CONTAINER_NAME=$(docker run -d --rm \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_CLAMAV=1 \ -h mail.my-domain.com \ - -t "${NAME}")" + -t "${NAME}") teardown() { docker rm -f "${CONTAINER_NAME}"; } @@ -233,15 +233,15 @@ load 'test_helper/common' skip 'disabled as it fails randomly: https://github.com/docker-mailserver/docker-mailserver/pull/2177' local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container .)" + PRIVATE_CONFIG=$(duplicate_config_for_container .) # variable not local to make visible to teardown # enable ClamAV to make message delivery slower, so we can detect it - CONTAINER_NAME="$(docker run -d --rm \ + CONTAINER_NAME=$(docker run -d --rm \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \ -v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \ -e ENABLE_CLAMAV=1 \ -h mail.my-domain.com \ - -t "${NAME}")" + -t "${NAME}") teardown() { docker rm -f "${CONTAINER_NAME}"; } diff --git a/test/test_helper/common.bash b/test/test_helper/common.bash index 72497276..514a387f 100644 --- a/test/test_helper/common.bash +++ b/test/test_helper/common.bash @@ -128,7 +128,7 @@ function private_config_path() { # @return path to the folder where the config is duplicated function duplicate_config_for_container() { local OUTPUT_FOLDER - OUTPUT_FOLDER="$(private_config_path "${2}")" || return $? + OUTPUT_FOLDER=$(private_config_path "${2}") || return $? rm -rf "${OUTPUT_FOLDER:?}/" || return $? # cleanup mkdir -p "${OUTPUT_FOLDER}" || return $? cp -r "${PWD}/test/config/${1:?}/." "${OUTPUT_FOLDER}" || return $? @@ -169,16 +169,16 @@ function wait_for_empty_mail_queue_in_container() { # For individual test override the var via `local` var instead. # # For example, if you need an immutable config volume that can't be affected by other tests -# in the file, then use `local TEST_TMP_CONFIG="$(duplicate_config_for_container . "${UNIQUE_ID_HERE}")"` +# in the file, then use `local TEST_TMP_CONFIG=$(duplicate_config_for_container . "${UNIQUE_ID_HERE}")` function init_with_defaults() { export TEST_NAME TEST_TMP_CONFIG # In `setup_file()` the default name to use for the currently tested docker container # is `${TEST_NAME}` global defined here. It derives the name from the test filename: # `basename` to ignore absolute dir path and file extension, only extract filename. - TEST_NAME="$(basename "${BATS_TEST_FILENAME}" '.bats')" + TEST_NAME=$(basename "${BATS_TEST_FILENAME}" '.bats') # In `setup_file()` creates a single copy of the test config folder to use for an entire test file: - TEST_TMP_CONFIG="$(duplicate_config_for_container . "${TEST_NAME}")" + TEST_TMP_CONFIG=$(duplicate_config_for_container . "${TEST_NAME}") # Common complimentary test files, read-only safe to share across containers: export TEST_FILES_CONTAINER_PATH='/tmp/docker-mailserver-test' diff --git a/test/tests.bats b/test/tests.bats index 38a34e8d..0766e2a3 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -7,7 +7,7 @@ IMAGE_NAME="${NAME}" setup_file() { local PRIVATE_CONFIG - PRIVATE_CONFIG="$(duplicate_config_for_container . mail)" + PRIVATE_CONFIG=$(duplicate_config_for_container . mail) mv "${PRIVATE_CONFIG}/user-patches/user-patches.sh" "${PRIVATE_CONFIG}/user-patches.sh" docker run --rm -d --name mail \ -v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \