mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-05 02:27:15 +02:00
tests: refactor POP3, IMAP (actually SASLauthd + RIMAP) & relay (#3062)
* refactor `mail_pop3.bats` * refactor `mail_with_imap.bats` * refactor `mail_with_relays.bats` * moved test that that did not belong into POP3 test * slightly clean up `no_container.bats` Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
parent
4efbbbe571
commit
2caec2cdf6
6 changed files with 134 additions and 156 deletions
|
@ -1,85 +1,46 @@
|
|||
load "${REPOSITORY_ROOT}/test/test_helper/common"
|
||||
load "${REPOSITORY_ROOT}/test/helper/common"
|
||||
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||
|
||||
BATS_TEST_NAME_PREFIX='[POP3] '
|
||||
CONTAINER_NAME='dms-test_pop3'
|
||||
|
||||
function setup_file() {
|
||||
local PRIVATE_CONFIG
|
||||
PRIVATE_CONFIG=$(duplicate_config_for_container .)
|
||||
_init_with_defaults
|
||||
|
||||
docker run -d --name mail_pop3 \
|
||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e ENABLE_POP3=1 \
|
||||
-e PERMIT_DOCKER=container \
|
||||
-h mail.my-domain.com -t "${NAME}"
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_POP3=1
|
||||
--env PERMIT_DOCKER=container
|
||||
)
|
||||
|
||||
wait_for_finished_setup_in_container mail_pop3
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
}
|
||||
|
||||
function teardown_file() {
|
||||
docker rm -f mail_pop3
|
||||
function teardown_file() { _default_teardown ; }
|
||||
|
||||
@test 'server is ready' {
|
||||
_run_in_container nc -w 1 0.0.0.0 110
|
||||
assert_success
|
||||
assert_output --partial '+OK'
|
||||
}
|
||||
|
||||
#
|
||||
# pop
|
||||
#
|
||||
|
||||
@test "checking pop: server is ready" {
|
||||
run docker exec mail_pop3 /bin/bash -c "nc -w 1 0.0.0.0 110 | grep '+OK'"
|
||||
@test 'authentication works' {
|
||||
_run_in_container_bash 'nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/pop3-auth.txt'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking pop: authentication works" {
|
||||
run docker exec mail_pop3 /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/pop3-auth.txt"
|
||||
@test 'added user authentication works' {
|
||||
_run_in_container_bash 'nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/added-pop3-auth.txt'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking pop: added user authentication works" {
|
||||
run docker exec mail_pop3 /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/added-pop3-auth.txt"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#
|
||||
# spamassassin
|
||||
#
|
||||
|
||||
@test "checking spamassassin: docker env variables are set correctly (default)" {
|
||||
run docker exec mail_pop3 /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
||||
assert_success
|
||||
|
||||
run docker exec mail_pop3 /bin/sh -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'"
|
||||
assert_success
|
||||
|
||||
run docker exec mail_pop3 /bin/sh -c "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'"
|
||||
assert_success
|
||||
|
||||
run docker exec mail_pop3 /bin/sh -c "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= .\*\*\*SPAM\*\*\* .'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#
|
||||
# system
|
||||
#
|
||||
|
||||
@test "checking system: /var/log/mail/mail.log is error free" {
|
||||
run docker exec mail_pop3 grep 'non-null host address bits in' /var/log/mail/mail.log
|
||||
@test '/var/log/mail/mail.log is error-free' {
|
||||
_run_in_container grep 'non-null host address bits in' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
|
||||
run docker exec mail_pop3 grep ': error:' /var/log/mail/mail.log
|
||||
_run_in_container grep ': error:' /var/log/mail/mail.log
|
||||
assert_failure
|
||||
}
|
||||
|
||||
#
|
||||
# sieve
|
||||
#
|
||||
|
||||
@test "checking manage sieve: disabled per default" {
|
||||
run docker exec mail_pop3 /bin/bash -c "nc -z 0.0.0.0 4190"
|
||||
@test '(Manage Sieve) disabled per default' {
|
||||
_run_in_container nc -z 0.0.0.0 4190
|
||||
assert_failure
|
||||
}
|
||||
|
||||
#
|
||||
# PERMIT_DOCKER mynetworks
|
||||
#
|
||||
@test "checking PERMIT_DOCKER: my network value" {
|
||||
run docker exec mail_pop3 /bin/sh -c "postconf | grep '^mynetworks =' | egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}/32'"
|
||||
assert_success
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue