mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
tests: Migrate Dovecot DBox tests (sdbox + mdbox) (#3051)
* tests: Migrate Dovecot DBox tests to new testing format * tests: Group Dovecot related tests into subfolder
This commit is contained in:
parent
adb30178ae
commit
ed6917ff22
|
@ -410,8 +410,9 @@ function _count_files_in_directory_in_container()
|
||||||
_run_in_container_bash "[[ -d ${DIRECTORY} ]]"
|
_run_in_container_bash "[[ -d ${DIRECTORY} ]]"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
_run_in_container_bash "find ${DIRECTORY} -maxdepth 1 -type f -printf 'x\n'"
|
_run_in_container_bash "find ${DIRECTORY} -maxdepth 1 -type f"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
_should_output_number_of_lines "${NUMBER_OF_LINES}"
|
_should_output_number_of_lines "${NUMBER_OF_LINES}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
59
test/tests/parallel/set1/dovecot/mailbox_format_dbox.bats
Normal file
59
test/tests/parallel/set1/dovecot/mailbox_format_dbox.bats
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
load "${REPOSITORY_ROOT}/test/helper/common"
|
||||||
|
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||||
|
|
||||||
|
# Feature (ENV DOVECOT_MAILBOX_FORMAT) - Logic in `setup-stack:_setup_dovecot()`
|
||||||
|
# - Configures mail_location in 10-mail.conf to a supported dbox type
|
||||||
|
# - Then adds a cron task to purge dbox for freeing disk space (see upstream docs)
|
||||||
|
|
||||||
|
# PR: https://github.com/docker-mailserver/docker-mailserver/pull/1314
|
||||||
|
# Docs (upstream): https://doc.dovecot.org/configuration_manual/mail_location/dbox/#dbox-settings
|
||||||
|
|
||||||
|
BATS_TEST_NAME_PREFIX='[Dovecot] '
|
||||||
|
|
||||||
|
CONTAINER1_NAME='dms-test_dovecot-dbox_sdbox'
|
||||||
|
CONTAINER2_NAME='dms-test_dovecot-dbox_mdbox'
|
||||||
|
|
||||||
|
function teardown() { _default_teardown ; }
|
||||||
|
|
||||||
|
@test "(ENV DOVECOT_MAILBOX_FORMAT=sdbox) should store received mail at expected location" {
|
||||||
|
export CONTAINER_NAME=${CONTAINER1_NAME}
|
||||||
|
local CUSTOM_SETUP_ARGUMENTS=(
|
||||||
|
--env DOVECOT_MAILBOX_FORMAT=sdbox
|
||||||
|
--env PERMIT_DOCKER=container
|
||||||
|
)
|
||||||
|
|
||||||
|
_init_with_defaults
|
||||||
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||||
|
_wait_for_smtp_port_in_container
|
||||||
|
|
||||||
|
_send_email 'existing-user1'
|
||||||
|
_wait_for_empty_mail_queue_in_container
|
||||||
|
|
||||||
|
# Mail received should be stored as `u.1` (one file per message)
|
||||||
|
local MAILBOX_STORAGE='/var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails'
|
||||||
|
_count_files_in_directory_in_container "${MAILBOX_STORAGE}" 3
|
||||||
|
assert_output --partial "${MAILBOX_STORAGE}/dovecot.index.log"
|
||||||
|
assert_output --partial "${MAILBOX_STORAGE}/u.1"
|
||||||
|
assert_output --partial "${MAILBOX_STORAGE}/dovecot.index.cache"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(ENV DOVECOT_MAILBOX_FORMAT=mdbox) should store received mail at expected location" {
|
||||||
|
export CONTAINER_NAME=${CONTAINER2_NAME}
|
||||||
|
local CUSTOM_SETUP_ARGUMENTS=(
|
||||||
|
--env DOVECOT_MAILBOX_FORMAT=mdbox
|
||||||
|
--env PERMIT_DOCKER=container
|
||||||
|
)
|
||||||
|
|
||||||
|
_init_with_defaults
|
||||||
|
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||||
|
_wait_for_smtp_port_in_container
|
||||||
|
|
||||||
|
_send_email 'existing-user1'
|
||||||
|
_wait_for_empty_mail_queue_in_container
|
||||||
|
|
||||||
|
# Mail received should be stored in `m.1` (1 or more messages)
|
||||||
|
local MAILBOX_STORAGE='/var/mail/localhost.localdomain/user1/storage'
|
||||||
|
_count_files_in_directory_in_container "${MAILBOX_STORAGE}" 2
|
||||||
|
assert_output --partial "${MAILBOX_STORAGE}/dovecot.map.index.log"
|
||||||
|
assert_output --partial "${MAILBOX_STORAGE}/m.1"
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
load "${REPOSITORY_ROOT}/test/test_helper/common"
|
|
||||||
|
|
||||||
setup_file() {
|
|
||||||
local PRIVATE_CONFIG
|
|
||||||
PRIVATE_CONFIG=$(duplicate_config_for_container .)
|
|
||||||
|
|
||||||
docker run -d --name mail_with_mdbox_format \
|
|
||||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
|
||||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
|
||||||
-e ENABLE_CLAMAV=0 \
|
|
||||||
-e ENABLE_SPAMASSASSIN=0 \
|
|
||||||
-e DOVECOT_MAILBOX_FORMAT=mdbox \
|
|
||||||
-e PERMIT_DOCKER=host \
|
|
||||||
-h mail.my-domain.com -t "${NAME}"
|
|
||||||
|
|
||||||
wait_for_smtp_port_in_container mail_with_mdbox_format
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown_file() {
|
|
||||||
docker rm -f mail_with_mdbox_format
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "checking dovecot mailbox format: mdbox file created" {
|
|
||||||
run docker exec mail_with_mdbox_format /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
# shellcheck disable=SC2016
|
|
||||||
repeat_until_success_or_timeout 30 docker exec mail_with_mdbox_format /bin/sh -c '[ $(ls /var/mail/localhost.localdomain/user1/storage/m.1 | wc -l) -eq 1 ]'
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
load "${REPOSITORY_ROOT}/test/test_helper/common"
|
|
||||||
|
|
||||||
setup_file() {
|
|
||||||
local PRIVATE_CONFIG
|
|
||||||
PRIVATE_CONFIG=$(duplicate_config_for_container .)
|
|
||||||
|
|
||||||
docker run -d --name mail_with_sdbox_format \
|
|
||||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
|
||||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
|
||||||
-e ENABLE_CLAMAV=0 \
|
|
||||||
-e ENABLE_SPAMASSASSIN=0 \
|
|
||||||
-e DOVECOT_MAILBOX_FORMAT=sdbox \
|
|
||||||
-e PERMIT_DOCKER=host \
|
|
||||||
-h mail.my-domain.com -t "${NAME}"
|
|
||||||
|
|
||||||
wait_for_smtp_port_in_container mail_with_sdbox_format
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown_file() {
|
|
||||||
docker rm -f mail_with_sdbox_format
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "checking dovecot mailbox format: sdbox file created" {
|
|
||||||
run docker exec mail_with_sdbox_format /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
# shellcheck disable=SC2016
|
|
||||||
repeat_until_success_or_timeout 30 docker exec mail_with_sdbox_format /bin/sh -c '[ $(ls /var/mail/localhost.localdomain/user1/mailboxes/INBOX/dbox-Mails/u.1 | wc -l) -eq 1 ]'
|
|
||||||
}
|
|
Loading…
Reference in a new issue