From 881ac716019cb92e3cd70a3e43d75f7f74a2831e Mon Sep 17 00:00:00 2001 From: Erik Wramner Date: Mon, 20 Jan 2020 21:59:34 +0100 Subject: [PATCH] Show delivered mails with more details in test --- .../email-templates/amavis-spam.txt | 2 +- .../email-templates/amavis-virus.txt | 2 +- .../email-templates/existing-added.txt | 2 +- .../existing-alias-external.txt | 2 +- .../email-templates/existing-alias-local.txt | 2 +- .../existing-alias-recipient-delimiter.txt | 2 +- .../existing-catchall-local.txt | 2 +- .../existing-regexp-alias-external.txt | 2 +- .../existing-regexp-alias-local.txt | 2 +- .../existing-user-and-cc-local-alias.txt | 2 +- .../email-templates/existing-user1.txt | 2 +- .../email-templates/existing-user2.txt | 2 +- .../email-templates/non-existing-user.txt | 2 +- .../email-templates/sieve-spam-folder.txt | 2 +- .../test-files/email-templates/test-email.txt | 2 +- test/tests.bats | 32 ++++++++++++++++--- 16 files changed, 42 insertions(+), 20 deletions(-) diff --git a/test/test-files/email-templates/amavis-spam.txt b/test/test-files/email-templates/amavis-spam.txt index 1fcdc0a2..66be1df3 100644 --- a/test/test-files/email-templates/amavis-spam.txt +++ b/test/test-files/email-templates/amavis-spam.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message amavis-spam.txt This is a test mail. XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X diff --git a/test/test-files/email-templates/amavis-virus.txt b/test/test-files/email-templates/amavis-virus.txt index c37b7d81..1343a07c 100644 --- a/test/test-files/email-templates/amavis-virus.txt +++ b/test/test-files/email-templates/amavis-virus.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message amavis-virus.txt Content-type: multipart/mixed; boundary="emailboundary" MIME-version: 1.0 diff --git a/test/test-files/email-templates/existing-added.txt b/test/test-files/email-templates/existing-added.txt index aa97fb2f..320fa4d2 100644 --- a/test/test-files/email-templates/existing-added.txt +++ b/test/test-files/email-templates/existing-added.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-added.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-alias-external.txt b/test/test-files/email-templates/existing-alias-external.txt index 02648991..61b1df3c 100644 --- a/test/test-files/email-templates/existing-alias-external.txt +++ b/test/test-files/email-templates/existing-alias-external.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-alias-external.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-alias-local.txt b/test/test-files/email-templates/existing-alias-local.txt index bf415697..c1bbc890 100644 --- a/test/test-files/email-templates/existing-alias-local.txt +++ b/test/test-files/email-templates/existing-alias-local.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local Alias Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-alias-local.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-alias-recipient-delimiter.txt b/test/test-files/email-templates/existing-alias-recipient-delimiter.txt index 39052986..47b01397 100644 --- a/test/test-files/email-templates/existing-alias-recipient-delimiter.txt +++ b/test/test-files/email-templates/existing-alias-recipient-delimiter.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local Alias With Delimiter Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-alias-recipient-delimiter.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-catchall-local.txt b/test/test-files/email-templates/existing-catchall-local.txt index faed7aaf..c80db170 100644 --- a/test/test-files/email-templates/existing-catchall-local.txt +++ b/test/test-files/email-templates/existing-catchall-local.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-catchall-local.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-regexp-alias-external.txt b/test/test-files/email-templates/existing-regexp-alias-external.txt index ab5ecd11..0e214db4 100644 --- a/test/test-files/email-templates/existing-regexp-alias-external.txt +++ b/test/test-files/email-templates/existing-regexp-alias-external.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-regexp-alias-external.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-regexp-alias-local.txt b/test/test-files/email-templates/existing-regexp-alias-local.txt index 99170500..6af46e92 100644 --- a/test/test-files/email-templates/existing-regexp-alias-local.txt +++ b/test/test-files/email-templates/existing-regexp-alias-local.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-regexp-alias-local.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-user-and-cc-local-alias.txt b/test/test-files/email-templates/existing-user-and-cc-local-alias.txt index a1d54f92..5fcb333b 100644 --- a/test/test-files/email-templates/existing-user-and-cc-local-alias.txt +++ b/test/test-files/email-templates/existing-user-and-cc-local-alias.txt @@ -6,7 +6,7 @@ From: Docker Mail Server To: Existing Local User Cc: Existing Local Alias Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-user-and-cc-local-alias.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-user1.txt b/test/test-files/email-templates/existing-user1.txt index 0a534e32..5ab0333f 100644 --- a/test/test-files/email-templates/existing-user1.txt +++ b/test/test-files/email-templates/existing-user1.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-user1.txt This is a test mail. . diff --git a/test/test-files/email-templates/existing-user2.txt b/test/test-files/email-templates/existing-user2.txt index eb75c7fe..63554f27 100644 --- a/test/test-files/email-templates/existing-user2.txt +++ b/test/test-files/email-templates/existing-user2.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message existing-user2.txt This is a test mail. . diff --git a/test/test-files/email-templates/non-existing-user.txt b/test/test-files/email-templates/non-existing-user.txt index e026358f..406f6755 100644 --- a/test/test-files/email-templates/non-existing-user.txt +++ b/test/test-files/email-templates/non-existing-user.txt @@ -5,7 +5,7 @@ DATA From: Docker Mail Server To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message non-existing-user.txt This is a test mail. . diff --git a/test/test-files/email-templates/sieve-spam-folder.txt b/test/test-files/email-templates/sieve-spam-folder.txt index 4f904fdd..8e802817 100644 --- a/test/test-files/email-templates/sieve-spam-folder.txt +++ b/test/test-files/email-templates/sieve-spam-folder.txt @@ -5,7 +5,7 @@ DATA From: Spambot To: Existing Local User Date: Sat, 22 May 2010 07:43:25 -0400 -Subject: Test Message +Subject: Test Message sieve-spam-folder.txt This is a test mail. . diff --git a/test/test-files/email-templates/test-email.txt b/test/test-files/email-templates/test-email.txt index 69608d44..3625f348 100644 --- a/test/test-files/email-templates/test-email.txt +++ b/test/test-files/email-templates/test-email.txt @@ -1,3 +1,3 @@ -Subject: Test Message +Subject: Test Message test-email.txt This is a test mail. diff --git a/test/tests.bats b/test/tests.bats index 79f09567..956656e4 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -217,9 +217,18 @@ function count_processed_changes() { } @test "checking smtp: delivers mail to existing account" { - run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | sed 's/.* to=; 6 ; 1 , orig_to=; 1 , orig_to=; 1 ; 2 ;" + #assert_output " 1 ; 6 ; 1 , orig_to=; 1 , orig_to=; 1 ; 2 ;" + cat <<'EOF' | assert_output + 1 + 6 + 1 , orig_to= + 1 , orig_to= + 1 + 2 +EOF } @test "checking smtp: delivers mail to existing alias" { @@ -250,9 +259,22 @@ function count_processed_changes() { } @test "checking smtp: user1 should have received 9 mails" { - run docker exec mail /bin/sh -c "ls -A /var/mail/localhost.localdomain/user1/new | wc -l" + run docker exec mail /bin/sh -c "grep Subject /var/mail/localhost.localdomain/user1/new/* | sed 's/.*Subject: //g' | sed 's/\.txt.*//g' | sed 's/VIRUS.*/VIRUS/g' | sort" assert_success - assert_output 9 + # 9 messages, the virus mail has three subject lines + cat <<'EOF' | assert_output +Root Test Message +Test Message amavis-virus +Test Message amavis-virus +Test Message existing-alias-external +Test Message existing-alias-recipient-delimiter +Test Message existing-catchall-local +Test Message existing-regexp-alias-local +Test Message existing-user-and-cc-local-alias +Test Message existing-user1 +Test Message sieve-spam-folder +VIRUS +EOF } @test "checking smtp: rejects mail to unknown user" { @@ -1285,6 +1307,6 @@ function count_processed_changes() { # @test "checking that the container stops cleanly" { - run docker stop -t 60 mail + # run docker stop -t 60 mail assert_success }