mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
tests(refactor): Migrate mail_privacy.bats
to new format and helpers (#3014)
This commit is contained in:
parent
94a9d2af44
commit
efeb93e094
|
@ -1,39 +1,38 @@
|
||||||
load "${REPOSITORY_ROOT}/test/test_helper/common"
|
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||||
|
load "${REPOSITORY_ROOT}/test/helper/common"
|
||||||
|
|
||||||
|
BATS_TEST_NAME_PREFIX='[Privacy] '
|
||||||
|
CONTAINER_NAME='dms-test_privacy'
|
||||||
|
|
||||||
function setup_file() {
|
function setup_file() {
|
||||||
local PRIVATE_CONFIG
|
_init_with_defaults
|
||||||
PRIVATE_CONFIG=$(duplicate_config_for_container .)
|
|
||||||
|
|
||||||
docker run -d --name mail_privacy \
|
local CUSTOM_SETUP_ARGUMENTS=(
|
||||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
--env ENABLE_AMAVIS=1
|
||||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
--env ENABLE_MANAGESIEVE=1
|
||||||
-e ENABLE_MANAGESIEVE=1 \
|
--env PERMIT_DOCKER=host
|
||||||
-e PERMIT_DOCKER=host \
|
--env SSL_TYPE='snakeoil'
|
||||||
-h mail.my-domain.com \
|
)
|
||||||
-e SSL_TYPE='snakeoil' \
|
|
||||||
--tty \
|
|
||||||
"${NAME}" # Image name
|
|
||||||
|
|
||||||
wait_for_amavis_port_in_container mail_privacy
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||||
wait_for_smtp_port_in_container mail_privacy
|
|
||||||
|
# Port 10024 (Amavis)
|
||||||
|
_wait_for_tcp_port_in_container 10024
|
||||||
|
_wait_for_smtp_port_in_container
|
||||||
}
|
}
|
||||||
|
|
||||||
function teardown_file() {
|
function teardown_file() { _default_teardown ; }
|
||||||
docker rm -f mail_privacy
|
|
||||||
}
|
|
||||||
|
|
||||||
# What this test should cover: https://github.com/docker-mailserver/docker-mailserver/issues/681
|
# this test covers https://github.com/docker-mailserver/docker-mailserver/issues/681
|
||||||
@test "checking postfix: remove privacy details of the sender" {
|
@test "(Postfix) remove privacy details of the sender" {
|
||||||
docker exec mail_privacy /bin/sh -c "openssl s_client -quiet -starttls smtp -connect 0.0.0.0:587 < /tmp/docker-mailserver-test/email-templates/send-privacy-email.txt"
|
_run_in_container_bash "openssl s_client -quiet -starttls smtp -connect 0.0.0.0:587 < /tmp/docker-mailserver-test/email-templates/send-privacy-email.txt"
|
||||||
# shellcheck disable=SC2016
|
|
||||||
repeat_until_success_or_timeout 120 docker exec mail_privacy /bin/bash -c '[[ $(ls /var/mail/localhost.localdomain/user1/new | wc -l) -eq 1 ]]'
|
|
||||||
docker logs mail_privacy
|
|
||||||
|
|
||||||
run docker exec mail_privacy /bin/sh -c "ls /var/mail/localhost.localdomain/user1/new | wc -l"
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_output 1
|
|
||||||
|
|
||||||
run docker exec mail_privacy /bin/sh -c 'grep -rE "^User-Agent:" /var/mail/localhost.localdomain/user1/new | wc -l'
|
_run_until_success_or_timeout 120 _exec_in_container_bash '[[ -d /var/mail/localhost.localdomain/user1/new ]]'
|
||||||
assert_success
|
assert_success
|
||||||
assert_output 0
|
|
||||||
|
_count_files_in_directory_in_container '/var/mail/localhost.localdomain/user1/new/' '1'
|
||||||
|
|
||||||
|
_run_in_container_bash 'grep -rE "^User-Agent:" /var/mail/localhost.localdomain/user1/new'
|
||||||
|
_should_output_number_of_lines 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue