docker-mailserver/test/tests/parallel/set1/dovecot/dovecot_sieve.bats
Georg Lauterbach 7453bc096b
Dovecot: make home dir distinct from mail dir (#3335)
* add new home dir for Dovecot

I tried changing the mail dir, but this is a _very_ disruptive change,
so I took approach 3 on
<https://doc.dovecot.org/configuration_manual/home_directories_for_virtual_users/>,
whereby the home directory is now inside the mail directory.

The MDBOX/SDBOX formats are not touched by this change. The change
itself could be considered breaking though.

* adjust Sieve tests accordingly

* Update target/dovecot/10-mail.conf

* Update target/dovecot/auth-passwdfile.inc

---------

Co-authored-by: Casper <casperklein@users.noreply.github.com>
2023-05-15 20:10:29 +02:00

61 lines
2.3 KiB
Bash

load "${REPOSITORY_ROOT}/test/helper/common"
load "${REPOSITORY_ROOT}/test/helper/setup"
# Docs:
# https://docker-mailserver.github.io/docker-mailserver/edge/config/advanced/mail-sieve/
BATS_TEST_NAME_PREFIX='[Dovecot] (Sieve support) '
CONTAINER_NAME='dms-test_dovecot-sieve'
function setup_file() {
_init_with_defaults
# Move sieve configs into main `/tmp/docker-mailserver` config location:
mv "${TEST_TMP_CONFIG}/dovecot-sieve/"* "${TEST_TMP_CONFIG}/"
local CONTAINER_ARGS_ENV_CUSTOM=(
--env ENABLE_MANAGESIEVE=1
# Required for mail delivery via nc:
--env PERMIT_DOCKER=container
# Mount into home dir for user1 to treat as a user-sieve:
# NOTE: Cannot use ':ro', 'start-mailserver.sh' attempts to 'chown -R' /var/mail:
--volume "${TEST_TMP_CONFIG}/dovecot.sieve:/var/mail/localhost.localdomain/user1/home/.dovecot.sieve"
)
_common_container_setup 'CONTAINER_ARGS_ENV_CUSTOM'
_wait_for_smtp_port_in_container
# Single mail sent from 'spam@spam.com' that is handled by User (relocate) and Global (copy) sieves for user1:
_send_email 'email-templates/sieve-spam-folder'
# Mail for user2 triggers the sieve-pipe:
_send_email 'email-templates/sieve-pipe'
_wait_for_empty_mail_queue_in_container
}
function teardown_file() { _default_teardown ; }
# dovecot-sieve/dovecot.sieve
@test "User Sieve - should store mail from 'spam@spam.com' into recipient (user1) mailbox 'INBOX.spam'" {
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/.INBOX.spam/new 1
}
# dovecot-sieve/before.dovecot.sieve
@test "Global Sieve - should have copied mail from 'spam@spam.com' to recipient (user1) inbox" {
_run_in_container grep -R 'Spambot <spam@spam.com>' /var/mail/localhost.localdomain/user1/new/
assert_success
}
# dovecot-sieve/sieve-pipe + dovecot-sieve/user2@otherdomain.tld.dovecot.sieve
@test "Sieve Pipe - should pipe mail received for user2 into '/tmp/pipe-test.out'" {
_run_in_container_bash '[[ -f /tmp/pipe-test.out ]]'
assert_success
}
# Only test coverage for feature is to check that the service is listening on the expected port:
# https://doc.dovecot.org/admin_manual/pigeonhole_managesieve_server/
@test "ENV 'ENABLE_MANAGESIEVE' - should have enabled service on port 4190" {
_run_in_container nc -z 0.0.0.0 4190
assert_success
}