From 3720dbafc072ebb7c82274e5be1c7b7962d37660 Mon Sep 17 00:00:00 2001 From: Georg Lauterbach Date: Mon, 19 Oct 2020 15:19:34 +0200 Subject: [PATCH] removed `local VAR=$(...)` assignments --- test/mail_dhparams_manual_not_one_dir.bats | 3 ++- test/test_helper.bats | 12 ++++++---- test/tests.bats | 27 ++++++++++++++-------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/test/mail_dhparams_manual_not_one_dir.bats b/test/mail_dhparams_manual_not_one_dir.bats index e8b76efe..1569f67c 100644 --- a/test/mail_dhparams_manual_not_one_dir.bats +++ b/test/mail_dhparams_manual_not_one_dir.bats @@ -21,7 +21,8 @@ function teardown() { } function setup_file() { - local PRIVATE_CONFIG=$(duplicate_config_for_container .) + local PRIVATE_CONFIG + PRIVATE_CONFIG=$(duplicate_config_for_container .) # copy the custom DHE params in local config cp "$(pwd)/test/test-files/ssl/custom-dhe-params.pem" "${PRIVATE_CONFIG}/dhparams.pem" diff --git a/test/test_helper.bats b/test/test_helper.bats index f69b368b..82ff8a0f 100644 --- a/test/test_helper.bats +++ b/test/test_helper.bats @@ -56,7 +56,8 @@ load 'test_helper/common' } @test "repeat_in_container_until_success_or_timeout run command in container" { - local CONTAINER_NAME=$(docker run --rm -d alpine sleep 100) + local CONTAINER_NAME + CONTAINER_NAME=$(docker run --rm -d alpine sleep 100) SECONDS=0 ! repeat_in_container_until_success_or_timeout 10 "${CONTAINER_NAME}" sh -c "echo '${CONTAINER_NAME}' > /tmp/marker" [[ ${SECONDS} -le 1 ]] @@ -65,14 +66,16 @@ load 'test_helper/common' } @test "container_is_running" { - local CONTAINER_NAME=$(docker run --rm -d alpine sleep 100) + local CONTAINER_NAME + CONTAINER_NAME=$(docker run --rm -d alpine sleep 100) container_is_running "${CONTAINER_NAME}" docker rm -f "${CONTAINER_NAME}" ! container_is_running "${CONTAINER_NAME}" } @test "wait_for_smtp_port_in_container aborts wait after timeout" { - local CONTAINER_NAME=$(docker run --rm -d alpine sleep 100) + local CONTAINER_NAME + CONTAINER_NAME=$(docker run --rm -d alpine sleep 100) SECONDS=0 TEST_TIMEOUT_IN_SECONDS=2 run wait_for_smtp_port_in_container "${CONTAINER_NAME}" [[ ${SECONDS} -ge 2 ]] @@ -81,7 +84,8 @@ load 'test_helper/common' } @test "wait_for_smtp_port_in_container returns immediately when port found" { - local CONTAINER_NAME=$(docker run --rm -d alpine sh -c "sleep 10") + local CONTAINER_NAME + CONTAINER_NAME=$(docker run --rm -d alpine sh -c "sleep 10") docker exec "${CONTAINER_NAME}" apk add netcat-openbsd docker exec "${CONTAINER_NAME}" nc -l 25 & diff --git a/test/tests.bats b/test/tests.bats index e6219606..528fcfc0 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -10,7 +10,8 @@ setup() { } setup_file() { - local PRIVATE_CONFIG="$(duplicate_config_for_container . mail)" + local PRIVATE_CONFIG + 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 \ @@ -460,7 +461,8 @@ EOF # Instead it tests the file-size (here 511) - which may differ with a different domain names # This test may be re-used as a global test to provide better test coverage. @test "checking opendkim: generator creates default keys size" { - local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_default_key_size)" + local PRIVATE_CONFIG + PRIVATE_CONFIG="$(duplicate_config_for_container . mail_default_key_size)" # Prepare default key size 2048 rm -rf "${PRIVATE_CONFIG}/keyDefault" mkdir -p "${PRIVATE_CONFIG}/keyDefault" @@ -486,7 +488,8 @@ EOF # Instead it tests the file-size (here 511) - which may differ with a different domain names # This test may be re-used as a global test to provide better test coverage. @test "checking opendkim: generator creates key size 2048" { - local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_2048)" + local PRIVATE_CONFIG + PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_2048)" # Prepare set key size 2048 rm -rf "${PRIVATE_CONFIG}/key2048" mkdir -p "${PRIVATE_CONFIG}/config/key2048" @@ -511,7 +514,8 @@ EOF # Instead it tests the file-size (here 329) - which may differ with a different domain names # This test may be re-used as a global test to provide better test coverage. @test "checking opendkim: generator creates key size 1024" { - local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_1024)" + local PRIVATE_CONFIG + PRIVATE_CONFIG="$(duplicate_config_for_container . mail_key_size_1024)" # Prepare set key size 1024 rm -rf "${PRIVATE_CONFIG}/key1024" mkdir -p "${PRIVATE_CONFIG}/key1024" @@ -533,7 +537,8 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts" { - local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts)" + local PRIVATE_CONFIG + 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 \ @@ -564,7 +569,8 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-accounts.cf" { - local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_accounts.cf)" + local PRIVATE_CONFIG + PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_accounts.cf)" rm -rf "${PRIVATE_CONFIG}/without-accounts" mkdir -p "${PRIVATE_CONFIG}/without-accounts" run docker run --rm \ @@ -594,7 +600,8 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts without postfix-virtual.cf" { - local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_virtual.cf)" + local PRIVATE_CONFIG + PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_virtual.cf)" rm -rf "${PRIVATE_CONFIG}/without-virtual" mkdir -p "${PRIVATE_CONFIG}/without-virtual" run docker run --rm \ @@ -624,7 +631,8 @@ EOF } @test "checking opendkim: generator creates keys, tables and TrustedHosts using domain name" { - local PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_virtual.cf)" + local PRIVATE_CONFIG + PRIVATE_CONFIG="$(duplicate_config_for_container . mail_dkim_generator_creates_keys_tables_TrustedHosts_without_postfix_virtual.cf)" rm -rf "${PRIVATE_CONFIG}/with-domain" && mkdir -p "${PRIVATE_CONFIG}/with-domain" run docker run --rm \ -v "${PRIVATE_CONFIG}/with-domain/":/tmp/docker-mailserver/ \ @@ -932,7 +940,8 @@ EOF } @test "checking accounts: user3 should have been added to /tmp/docker-mailserver/postfix-accounts.cf even when that file does not exist" { - local PRIVATE_CONFIG=$(duplicate_config_for_container without-accounts/ without-accounts_file_does_not_exist) + local PRIVATE_CONFIG + PRIVATE_CONFIG=$(duplicate_config_for_container without-accounts/ without-accounts_file_does_not_exist) run docker run --rm \ -v "${PRIVATE_CONFIG}/without-accounts/":/tmp/docker-mailserver/ \ "${IMAGE_NAME:?}" /bin/sh -c 'addmailuser user3@domain.tld mypassword'