mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
tests: small adjustments (#3772)
This commit is contained in:
parent
f794f65caa
commit
3a142f9726
|
@ -20,7 +20,7 @@ All notable changes to this project will be documented in this file. The format
|
|||
### Updates
|
||||
|
||||
- **Tests**:
|
||||
- Refactored mail sending ([#3747](https://github.com/docker-mailserver/docker-mailserver/pull/3747)):
|
||||
- Refactored mail sending ([#3747](https://github.com/docker-mailserver/docker-mailserver/pull/3747) & [#3772](https://github.com/docker-mailserver/docker-mailserver/pull/3772)):
|
||||
- This change is a follow-up to [#3732](https://github.com/docker-mailserver/docker-mailserver/pull/3732) from DMS v13.2.
|
||||
- `swaks` version is now the latest from Github releases instead of the Debian package.
|
||||
- `_nc_wrapper`, `_send_mail` and related helpers expect the `.txt` filepath extension again.
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
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 amavis/spam.txt
|
||||
This is a test mail.
|
||||
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
|
|
@ -141,14 +141,12 @@ function _send_email_and_get_id() {
|
|||
# Get rid of ${1} so only the arguments for swaks remain
|
||||
shift 1
|
||||
|
||||
local QUEUE_ID
|
||||
# The unique ID Postfix (and other services) use may be different in length
|
||||
# on different systems (e.g. amd64 (11) vs aarch64 (10)). Hence, we use a
|
||||
# range to safely capture it.
|
||||
# on different systems. Hence, we use a range to safely capture it.
|
||||
local QUEUE_ID_REGEX='[A-Z0-9]{9,12}'
|
||||
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
local OUTPUT=$(_send_email "${@}" --header "Message-Id: ${MID}")
|
||||
_send_email "${@}" --header "Message-Id: ${MID}"
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
|
||||
# We store Postfix's queue ID first
|
||||
|
@ -164,3 +162,12 @@ function _send_email_and_get_id() {
|
|||
run echo "${ID_ENV_VAR_REF}"
|
||||
assert_line --regexp "^${QUEUE_ID_REGEX}\|${MID}$"
|
||||
}
|
||||
|
||||
# Send a spam e-mail by utilizing GTUBE.
|
||||
#
|
||||
# Extra arguments given to this function will be supplied by `_send_email_and_get_id` directly.
|
||||
function _send_spam() {
|
||||
_send_email_and_get_id MAIL_ID_SPAM "${@}" \
|
||||
--from 'spam@external.tld' \
|
||||
--body 'XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X'
|
||||
}
|
||||
|
|
|
@ -43,20 +43,18 @@ function setup_file() {
|
|||
_wait_for_service postfix
|
||||
_wait_for_smtp_port_in_container
|
||||
|
||||
# ref: https://rspamd.com/doc/gtube_patterns.html
|
||||
local GTUBE_SUFFIX='*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X'
|
||||
|
||||
# We will send 4 emails:
|
||||
# 1. The first one should pass just fine
|
||||
# 1. The first one should pass just fine
|
||||
_send_email_and_get_id MAIL_ID_PASS
|
||||
# 2. The second one should be rejected (GTUBE pattern)
|
||||
_send_email_and_get_id MAIL_ID_REJECT --expect-rejection --body "XJS${GTUBE_SUFFIX}"
|
||||
# 3. The third one should be rejected due to a virus (ClamAV EICAR pattern)
|
||||
# 2. The second one should be rejected (Rspamd-specific GTUBE pattern for rejection)
|
||||
_send_spam --expect-rejection
|
||||
# 3. The third one should be rejected due to a virus (ClamAV EICAR pattern)
|
||||
# shellcheck disable=SC2016
|
||||
_send_email_and_get_id MAIL_ID_VIRUS --expect-rejection \
|
||||
--body 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*'
|
||||
# 4. The fourth one will receive an added header (GTUBE pattern)
|
||||
_send_email_and_get_id MAIL_ID_HEADER --body "YJS${GTUBE_SUFFIX}"
|
||||
# 4. The fourth one will receive an added header (Rspamd-specific GTUBE pattern for adding a spam header)
|
||||
# ref: https://rspamd.com/doc/gtube_patterns.html
|
||||
_send_email_and_get_id MAIL_ID_HEADER --body "YJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"
|
||||
|
||||
_run_in_container cat /var/log/mail.log
|
||||
assert_success
|
||||
|
@ -122,7 +120,7 @@ function teardown_file() { _default_teardown ; }
|
|||
_service_log_should_contain_string 'rspamd' 'S \(reject\)'
|
||||
_service_log_should_contain_string 'rspamd' 'reject "Gtube pattern"'
|
||||
|
||||
_print_mail_log_for_id "${MAIL_ID_REJECT}"
|
||||
_print_mail_log_for_id "${MAIL_ID_SPAM}"
|
||||
assert_output --partial 'milter-reject'
|
||||
assert_output --partial '5.7.1 Gtube pattern'
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ function teardown() { _default_teardown ; }
|
|||
function _should_send_spam_message() {
|
||||
_wait_for_smtp_port_in_container
|
||||
_wait_for_tcp_port_in_container 10024 # port 10024 is for Amavis
|
||||
_send_email --from 'spam@external.tld' --data 'amavis/spam.txt'
|
||||
_send_spam
|
||||
}
|
||||
|
||||
function _should_be_received_by_amavis() {
|
||||
|
|
|
@ -81,7 +81,7 @@ function setup_file() {
|
|||
_send_email --to bounce-always@localhost.localdomain
|
||||
_send_email --to alias2@localhost.localdomain
|
||||
# Required for 'rejects spam':
|
||||
_send_email --from 'spam@external.tld' --data 'amavis/spam.txt'
|
||||
_send_spam
|
||||
|
||||
# Required for 'delivers mail to existing account':
|
||||
_send_email --header 'Subject: Test Message existing-user1'
|
||||
|
|
Loading…
Reference in a new issue