Show delivered mails with more details in test

This commit is contained in:
Erik Wramner 2020-01-20 21:59:34 +01:00
parent 1c73290ba0
commit 881ac71601
16 changed files with 42 additions and 20 deletions

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <user1@localhost.localdomain>
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

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <user1@localhost.localdomain>
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

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <added@localhost.localdomain>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
Subject: Test Message existing-added.txt
This is a test mail.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <alias1@localhost.localdomain>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
Subject: Test Message existing-alias-external.txt
This is a test mail.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local Alias <alias2@localhost.localdomain>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
Subject: Test Message existing-alias-local.txt
This is a test mail.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local Alias With Delimiter <alias1+test@localhost.localdomain>
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.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <wildcard@localdomain2.com>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
Subject: Test Message existing-catchall-local.txt
This is a test mail.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <bounce-always@localhost.localdomain>
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.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <test123@localhost.localdomain>
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.
.

View File

@ -6,7 +6,7 @@ From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <user1@localhost.localdomain>
Cc: Existing Local Alias <alias2@localhost.localdomain>
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.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <user1@localhost.localdomain>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
Subject: Test Message existing-user1.txt
This is a test mail.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <user2@otherdomain.tld>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
Subject: Test Message existing-user2.txt
This is a test mail.
.

View File

@ -5,7 +5,7 @@ DATA
From: Docker Mail Server <dockermailserver@external.tld>
To: Existing Local User <user1@localhost.localdomain>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
Subject: Test Message non-existing-user.txt
This is a test mail.
.

View File

@ -5,7 +5,7 @@ DATA
From: Spambot <spam@spam.com>
To: Existing Local User <alias2@localhost.localdomain>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
Subject: Test Message sieve-spam-folder.txt
This is a test mail.
.

View File

@ -1,3 +1,3 @@
Subject: Test Message
Subject: Test Message test-email.txt
This is a test mail.

View File

@ -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=</</g' | sed 's/, relay.*//g' | sort | uniq -c | tr -s \" \" | tr '\n' ';'"
#run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | sed 's/.* to=</</g' | sed 's/, relay.*//g' | sort | uniq -c | tr -s \" \" | tr '\n' ';'"
run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | sed 's/.* to=</</g' | sed 's/, relay.*//g' | sort | uniq -c | tr -s \" \""
assert_success
assert_output " 1 <added@localhost.localdomain>; 6 <user1@localhost.localdomain>; 1 <user1@localhost.localdomain>, orig_to=<postmaster@my-domain.com>; 1 <user1@localhost.localdomain>, orig_to=<root>; 1 <user1~test@localhost.localdomain>; 2 <user2@otherdomain.tld>;"
#assert_output " 1 <added@localhost.localdomain>; 6 <user1@localhost.localdomain>; 1 <user1@localhost.localdomain>, orig_to=<postmaster@my-domain.com>; 1 <user1@localhost.localdomain>, orig_to=<root>; 1 <user1~test@localhost.localdomain>; 2 <user2@otherdomain.tld>;"
cat <<'EOF' | assert_output
1 <added@localhost.localdomain>
6 <user1@localhost.localdomain>
1 <user1@localhost.localdomain>, orig_to=<postmaster@my-domain.com>
1 <user1@localhost.localdomain>, orig_to=<root>
1 <user1~test@localhost.localdomain>
2 <user2@otherdomain.tld>
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
}