You've already forked docker-mailserver
mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-07 23:03:10 +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:
@ -1,49 +1,42 @@
|
||||
load "${REPOSITORY_ROOT}/test/test_helper/common"
|
||||
load "${REPOSITORY_ROOT}/test/helper/common"
|
||||
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||
|
||||
setup_file() {
|
||||
local PRIVATE_CONFIG
|
||||
PRIVATE_CONFIG=$(duplicate_config_for_container .)
|
||||
BATS_TEST_NAME_PREFIX='[SASLauthd + RIMAP] '
|
||||
CONTAINER_NAME='dms-test_saslauthd_and_rimap'
|
||||
|
||||
docker run -d --name mail_with_imap \
|
||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e ENABLE_SASLAUTHD=1 \
|
||||
-e POSTMASTER_ADDRESS=postmaster@localhost.localdomain \
|
||||
-e SASLAUTHD_MECH_OPTIONS=127.0.0.1 \
|
||||
-e SASLAUTHD_MECHANISMS=rimap \
|
||||
-e PERMIT_DOCKER=container \
|
||||
-h mail.my-domain.com -t "${NAME}"
|
||||
function setup_file() {
|
||||
_init_with_defaults
|
||||
|
||||
wait_for_smtp_port_in_container mail_with_imap
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env ENABLE_SASLAUTHD=1
|
||||
--env SASLAUTHD_MECH_OPTIONS=127.0.0.1
|
||||
--env SASLAUTHD_MECHANISMS=rimap
|
||||
--env PERMIT_DOCKER=container
|
||||
)
|
||||
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
_wait_for_smtp_port_in_container mail_with_imap
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
docker rm -f mail_with_imap
|
||||
}
|
||||
function teardown_file() { _default_teardown ; }
|
||||
|
||||
#
|
||||
# RIMAP
|
||||
#
|
||||
|
||||
# dovecot
|
||||
@test "checking dovecot: ldap rimap connection and authentication works" {
|
||||
run docker exec mail_with_imap /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-auth.txt"
|
||||
@test '(Dovecot) LDAP RIMAP connection and authentication works' {
|
||||
_run_in_container_bash "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver-test/auth/imap-auth.txt"
|
||||
assert_success
|
||||
}
|
||||
|
||||
# saslauthd
|
||||
@test "checking saslauthd: sasl rimap authentication works" {
|
||||
run docker exec mail_with_imap bash -c "testsaslauthd -u user1@localhost.localdomain -p mypassword"
|
||||
@test '(SASLauthd) SASL RIMAP authentication works' {
|
||||
_run_in_container testsaslauthd -u 'user1@localhost.localdomain' -p 'mypassword'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking saslauthd: rimap smtp authentication" {
|
||||
run docker exec mail_with_imap /bin/sh -c "nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt | grep 'Authentication successful'"
|
||||
@test '(SASLauthd) RIMAP SMTP authentication works' {
|
||||
_run_in_container_bash 'nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login.txt'
|
||||
assert_success
|
||||
assert_output --partial 'Authentication successful'
|
||||
}
|
||||
|
||||
# master account
|
||||
@test "checking dovecot: master account can login" {
|
||||
run docker exec mail_with_imap bash -c "testsaslauthd -u user1@localhost.localdomain*masterusername -p masterpassword"
|
||||
@test '(Dovecot) master account can login' {
|
||||
_run_in_container testsaslauthd -u 'user1@localhost.localdomain*masterusername' -p 'masterpassword'
|
||||
assert_success
|
||||
}
|
||||
|
Reference in New Issue
Block a user