From ad0be553d8546c7f1be2b7b9d66e8c1f9adb81a0 Mon Sep 17 00:00:00 2001 From: Martin Schulze Date: Thu, 17 Sep 2020 23:46:31 +0200 Subject: [PATCH] Extract SRS DOMAINNAME tests/container into own file --- Makefile | 21 --------------------- test/mail_srs_domainname.bats | 34 ++++++++++++++++++++++++++++++++++ test/tests.bats | 10 +--------- 3 files changed, 35 insertions(+), 30 deletions(-) create mode 100644 test/mail_srs_domainname.bats diff --git a/Makefile b/Makefile index 68f9c4a7..50d2e492 100644 --- a/Makefile +++ b/Makefile @@ -71,27 +71,6 @@ run: -h unknown.domain.tld \ -t $(NAME) -@ sleep $(SLEEP) - docker run --rm -d --name mail_domainname \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ - -e PERMIT_DOCKER=network \ - -e DMS_DEBUG=0 \ - -e ENABLE_SRS=1 \ - -e DOMAINNAME=my-domain.com \ - -h unknown.domain.tld \ - -t $(NAME) - -@ sleep $(SLEEP) - docker run --rm -d --name mail_srs_domainname \ - -v "`pwd`/test/config":/tmp/docker-mailserver \ - -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ - -e PERMIT_DOCKER=network \ - -e DMS_DEBUG=0 \ - -e ENABLE_SRS=1 \ - -e SRS_DOMAINNAME=srs.my-domain.com \ - -e DOMAINNAME=my-domain.com \ - -h unknown.domain.tld \ - -t $(NAME) - -@ sleep $(SLEEP) generate-accounts-after-run: @ docker run --rm -e MAIL_USER=added@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s SHA512-CRYPT -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf diff --git a/test/mail_srs_domainname.bats b/test/mail_srs_domainname.bats new file mode 100644 index 00000000..8047df79 --- /dev/null +++ b/test/mail_srs_domainname.bats @@ -0,0 +1,34 @@ +load 'test_helper/common' + +@test "checking SRS: SRS_DOMAINNAME is used correctly" { + docker run --rm -d --name mail_srs_domainname \ + -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -e PERMIT_DOCKER=network \ + -e DMS_DEBUG=0 \ + -e ENABLE_SRS=1 \ + -e SRS_DOMAINNAME=srs.my-domain.com \ + -e DOMAINNAME=my-domain.com \ + -h unknown.domain.tld \ + -t ${NAME} + + teardown() { docker rm -f mail_srs_domainname; } + + repeat_until_success_or_timeout 15 docker exec mail_srs_domainname grep "SRS_DOMAIN=srs.my-domain.com" /etc/default/postsrsd +} + +@test "checking SRS: DOMAINNAME is handled correctly" { + docker run --rm -d --name mail_domainname \ + -v "`pwd`/test/config":/tmp/docker-mailserver \ + -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ + -e PERMIT_DOCKER=network \ + -e DMS_DEBUG=0 \ + -e ENABLE_SRS=1 \ + -e DOMAINNAME=my-domain.com \ + -h unknown.domain.tld \ + -t ${NAME} + + teardown() { docker rm -f mail_domainname; } + + repeat_until_success_or_timeout 15 docker exec mail_domainname grep "SRS_DOMAIN=my-domain.com" /etc/default/postsrsd +} \ No newline at end of file diff --git a/test/tests.bats b/test/tests.bats index fa4a4752..e582add6 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -667,20 +667,12 @@ EOF assert_success } -@test "checking SRS: SRS_DOMAINNAME is used correctly" { - run docker exec mail_srs_domainname grep "SRS_DOMAIN=srs.my-domain.com" /etc/default/postsrsd - assert_success -} - @test "checking SRS: OVERRIDE_HOSTNAME is handled correctly" { run docker exec mail_override_hostname grep "SRS_DOMAIN=my-domain.com" /etc/default/postsrsd assert_success } -@test "checking SRS: DOMAINNAME is handled correctly" { - run docker exec mail_domainname grep "SRS_DOMAIN=my-domain.com" /etc/default/postsrsd - assert_success -} + @test "checking SRS: fallback to hostname is handled correctly" { run docker exec mail grep "SRS_DOMAIN=my-domain.com" /etc/default/postsrsd assert_success