mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
use new filters (and sending) functions
This commit is contained in:
parent
74d63af683
commit
745e59dbc2
|
@ -122,9 +122,9 @@ function _send_email_with_mid() {
|
||||||
|
|
||||||
# Send a spam e-mail by utilizing GTUBE.
|
# Send a spam e-mail by utilizing GTUBE.
|
||||||
#
|
#
|
||||||
# Extra arguments given to this function will be supplied by `_send_email_and_get_id` directly.
|
# Extra arguments given to this function will be supplied by `_send_email_with_mid` directly.
|
||||||
function _send_spam() {
|
function _send_spam() {
|
||||||
_send_email_and_get_id MAIL_ID_SPAM "${@}" \
|
_send_email_with_mid 'spam' "${@}" \
|
||||||
--from 'spam@external.tld' \
|
--from 'spam@external.tld' \
|
||||||
--body 'XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X'
|
--body 'XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X'
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,12 +56,11 @@ function teardown_file() {
|
||||||
@test "should successfully pass postscreen and get postfix greeting message (respecting postscreen_greet_wait time)" {
|
@test "should successfully pass postscreen and get postfix greeting message (respecting postscreen_greet_wait time)" {
|
||||||
# Configure `send_email()` to send from the mail client container (CONTAINER2_NAME) via ENV override,
|
# Configure `send_email()` to send from the mail client container (CONTAINER2_NAME) via ENV override,
|
||||||
# mail is sent to the DMS server container (CONTAINER1_NAME) via `--server` parameter:
|
# mail is sent to the DMS server container (CONTAINER1_NAME) via `--server` parameter:
|
||||||
# TODO: Use _send_email_and_get_id when proper resolution of domain names is possible:
|
|
||||||
CONTAINER_NAME=${CONTAINER2_NAME} _send_email --expect-rejection --server "${CONTAINER1_IP}" --port 25 --data 'postscreen.txt'
|
CONTAINER_NAME=${CONTAINER2_NAME} _send_email --expect-rejection --server "${CONTAINER1_IP}" --port 25 --data 'postscreen.txt'
|
||||||
# CONTAINER_NAME=${CONTAINER2_NAME} _send_email_and_get_id MAIL_ID_POSTSCREEN --server "${CONTAINER1_IP}" --data 'postscreen.txt'
|
# TODO: Use _send_email_with_mid when proper resolution of domain names is possible:
|
||||||
# _print_mail_log_for_id "${MAIL_ID_POSTSCREEN}"
|
# CONTAINER_NAME=${CONTAINER2_NAME} _send_email_with_mid 'postscreen' --server "${CONTAINER1_IP}" --data 'postscreen.txt'
|
||||||
|
# _print_mail_log_for_msgid 'postscreen'
|
||||||
# assert_output --partial "stored mail into mailbox 'INBOX'"
|
# assert_output --partial "stored mail into mailbox 'INBOX'"
|
||||||
|
|
||||||
_run_in_container cat /var/log/mail.log
|
_service_log_should_contain_string 'mail' 'PASS NEW'
|
||||||
assert_output --partial 'PASS NEW'
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,16 +45,16 @@ function setup_file() {
|
||||||
|
|
||||||
# We will send 4 emails:
|
# 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
|
_send_email_with_mid 'pass'
|
||||||
# 2. The second one should be rejected (Rspamd-specific GTUBE pattern for rejection)
|
# 2. The second one should be rejected (Rspamd-specific GTUBE pattern for rejection)
|
||||||
_send_spam --expect-rejection
|
_send_spam --expect-rejection
|
||||||
# 3. The third one should be rejected due to a virus (ClamAV EICAR pattern)
|
# 3. The third one should be rejected due to a virus (ClamAV EICAR pattern)
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
_send_email_and_get_id MAIL_ID_VIRUS --expect-rejection \
|
_send_email_with_mid 'virus' --expect-rejection \
|
||||||
--body 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*'
|
--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 (Rspamd-specific GTUBE pattern for adding a spam header)
|
# 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
|
# 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"
|
_send_email_with_mid 'header' --body "YJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"
|
||||||
|
|
||||||
_run_in_container cat /var/log/mail.log
|
_run_in_container cat /var/log/mail.log
|
||||||
assert_success
|
assert_success
|
||||||
|
@ -110,7 +110,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
@test 'normal mail passes fine' {
|
@test 'normal mail passes fine' {
|
||||||
_service_log_should_contain_string 'rspamd' 'F \(no action\)'
|
_service_log_should_contain_string 'rspamd' 'F \(no action\)'
|
||||||
|
|
||||||
_print_mail_log_for_id "${MAIL_ID_PASS}"
|
_print_mail_log_for_msgid 'pass'
|
||||||
assert_output --partial "stored mail into mailbox 'INBOX'"
|
assert_output --partial "stored mail into mailbox 'INBOX'"
|
||||||
|
|
||||||
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 1
|
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 1
|
||||||
|
@ -120,9 +120,13 @@ function teardown_file() { _default_teardown ; }
|
||||||
_service_log_should_contain_string 'rspamd' 'S \(reject\)'
|
_service_log_should_contain_string 'rspamd' 'S \(reject\)'
|
||||||
_service_log_should_contain_string 'rspamd' 'reject "Gtube pattern"'
|
_service_log_should_contain_string 'rspamd' 'reject "Gtube pattern"'
|
||||||
|
|
||||||
_print_mail_log_for_id "${MAIL_ID_SPAM}"
|
_print_mail_log_of_queue_id_from_mid 'spam'
|
||||||
assert_output --partial 'milter-reject'
|
assert_output --partial 'milter-reject'
|
||||||
assert_output --partial '5.7.1 Gtube pattern'
|
assert_output --partial '5.7.1 Gtube pattern'
|
||||||
|
refute_output --partial "stored mail into mailbox 'INBOX'"
|
||||||
|
|
||||||
|
_print_mail_log_for_msgid 'spam'
|
||||||
|
assert_failure
|
||||||
|
|
||||||
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 1
|
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 1
|
||||||
}
|
}
|
||||||
|
@ -131,11 +135,14 @@ function teardown_file() { _default_teardown ; }
|
||||||
_service_log_should_contain_string 'rspamd' 'T \(reject\)'
|
_service_log_should_contain_string 'rspamd' 'T \(reject\)'
|
||||||
_service_log_should_contain_string 'rspamd' 'reject "ClamAV FOUND VIRUS "Eicar-Signature"'
|
_service_log_should_contain_string 'rspamd' 'reject "ClamAV FOUND VIRUS "Eicar-Signature"'
|
||||||
|
|
||||||
_print_mail_log_for_id "${MAIL_ID_VIRUS}"
|
_print_mail_log_of_queue_id_from_mid 'virus'
|
||||||
assert_output --partial 'milter-reject'
|
assert_output --partial 'milter-reject'
|
||||||
assert_output --partial '5.7.1 ClamAV FOUND VIRUS "Eicar-Signature"'
|
assert_output --partial '5.7.1 ClamAV FOUND VIRUS "Eicar-Signature"'
|
||||||
refute_output --partial "stored mail into mailbox 'INBOX'"
|
refute_output --partial "stored mail into mailbox 'INBOX'"
|
||||||
|
|
||||||
|
_print_mail_log_for_msgid 'spam'
|
||||||
|
assert_failure
|
||||||
|
|
||||||
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 1
|
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +227,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
_service_log_should_contain_string 'rspamd' 'S \(add header\)'
|
_service_log_should_contain_string 'rspamd' 'S \(add header\)'
|
||||||
_service_log_should_contain_string 'rspamd' 'add header "Gtube pattern"'
|
_service_log_should_contain_string 'rspamd' 'add header "Gtube pattern"'
|
||||||
|
|
||||||
_print_mail_log_for_id "${MAIL_ID_HEADER}"
|
_print_mail_log_for_msgid 'header'
|
||||||
assert_output --partial "fileinto action: stored mail into mailbox 'Junk'"
|
assert_output --partial "fileinto action: stored mail into mailbox 'Junk'"
|
||||||
|
|
||||||
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 1
|
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 1
|
||||||
|
|
Loading…
Reference in a new issue