From 9415c099ccf8994b4e9332591c40559ec69df822 Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Mon, 25 Apr 2016 16:00:39 +0200 Subject: [PATCH] Fixed #159: postfix-accounts.cf now generated with script + fixed line endings using sed in start-mailserver.sh --- .gitignore | 1 + Makefile | 10 +++++++--- target/start-mailserver.sh | 2 ++ test/config/example.postfix-accounts.cf | 2 ++ test/config/postfix-accounts.cf | 4 ++-- test/tests.bats | 5 +++++ 6 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 test/config/example.postfix-accounts.cf diff --git a/.gitignore b/.gitignore index 357344b5..7354a227 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ docker-compose.yml .idea test/config/empty/ +test/config/postfix-accounts.cf diff --git a/Makefile b/Makefile index cdce19db..9e039e2f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ NAME = tvial/docker-mailserver:testing -all: build-no-cache run fixtures tests clean -all-fast: build run fixtures tests clean -no-build: run fixtures tests clean +all: build-no-cache generate-accounts run fixtures tests clean +all-fast: build generate-accounts run fixtures tests clean +no-build: generate-accounts run fixtures tests clean build-no-cache: docker build --no-cache -t $(NAME) . @@ -10,6 +10,10 @@ build-no-cache: build: docker build -t $(NAME) . +generate-accounts: + docker run --rm -e MAIL_USER=user1@localhost.localdomain -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s CRAM-MD5 -u $$MAIL_USER -p $$MAIL_PASS)"' > test/config/postfix-accounts.cf + docker run --rm -e MAIL_USER=user2@otherdomain.tld -e MAIL_PASS=mypassword -t $(NAME) /bin/sh -c 'echo "$$MAIL_USER|$$(doveadm pw -s CRAM-MD5 -u $$MAIL_USER -p $$MAIL_PASS)"' >> test/config/postfix-accounts.cf + run: # Run containers docker run -d --name mail \ diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 46a80c76..19f5f90b 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -9,6 +9,8 @@ die () { # Users # if [ -f /tmp/docker-mailserver/postfix-accounts.cf ]; then + echo "Checking file line endings" + sed -i 's/\r//g' /tmp/docker-mailserver/postfix-accounts.cf echo "Regenerating postfix 'vmailbox' and 'virtual' for given users" echo "# WARNING: this file is auto-generated. Modify config/postfix-accounts.cf to edit user list." > /etc/postfix/vmailbox diff --git a/test/config/example.postfix-accounts.cf b/test/config/example.postfix-accounts.cf new file mode 100644 index 00000000..200b6331 --- /dev/null +++ b/test/config/example.postfix-accounts.cf @@ -0,0 +1,2 @@ +user1@localhost.localdomain|{CRAM-MD5}de5924752ad74e36bc271a8dc7fad4b2d341f21f05382f20dedf1fdfbd5a1717 +user2@otherdomain.tld|{CRAM-MD5}de5924752ad74e36bc271a8dc7fad4b2d341f21f05382f20dedf1fdfbd5a1717 diff --git a/test/config/postfix-accounts.cf b/test/config/postfix-accounts.cf index f1ec3b3d..200b6331 100644 --- a/test/config/postfix-accounts.cf +++ b/test/config/postfix-accounts.cf @@ -1,2 +1,2 @@ -user1@localhost.localdomain|{MD5-CRYPT}$1$agWCql3M$ATBimsiJ4EETYnG/yLWwr. -user2@otherdomain.tld|{MD5-CRYPT}$1$31q82qPz$vprzqppi3chSsK8SgWT8d/ +user1@localhost.localdomain|{CRAM-MD5}de5924752ad74e36bc271a8dc7fad4b2d341f21f05382f20dedf1fdfbd5a1717 +user2@otherdomain.tld|{CRAM-MD5}de5924752ad74e36bc271a8dc7fad4b2d341f21f05382f20dedf1fdfbd5a1717 diff --git a/test/tests.bats b/test/tests.bats index 1c836e51..da487521 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -174,6 +174,11 @@ # accounts # +@test "checking accounts: generated 'postfix-accounts.cf' matches template" { + run diff test/config/example.postfix-accounts.cf test/config/postfix-accounts.cf + [ "$status" -eq 0 ] +} + @test "checking accounts: user accounts" { run docker exec mail doveadm user '*' [ "$status" -eq 0 ]