mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
tests: Migrate and combine ENV tests for *_INET_PROTOCOLS
(#3052)
* tests: Migrate and combine ENV tests for `*_INET_PROTOCOLS` These two features + tests were introduced years apart but serve the same purpose for both Postfix and Dovecot.
This commit is contained in:
parent
ed6917ff22
commit
7a61214aa5
|
@ -1,45 +0,0 @@
|
|||
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||
load "${REPOSITORY_ROOT}/test/helper/common"
|
||||
|
||||
BATS_TEST_NAME_PREFIX='[Dovecot] (protocols) '
|
||||
CONTAINER1_NAME='dms-test_dovecot_protocols_all'
|
||||
CONTAINER2_NAME='dms-test_dovecot_protocols_ipv4'
|
||||
CONTAINER3_NAME='dms-test_dovecot_protocols_ipv6'
|
||||
|
||||
function teardown() { _default_teardown ; }
|
||||
|
||||
@test "dual-stack IP configuration" {
|
||||
export CONTAINER_NAME=${CONTAINER1_NAME}
|
||||
local CUSTOM_SETUP_ARGUMENTS=(--env DOVECOT_INET_PROTOCOLS=)
|
||||
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
_run_in_container grep '^#listen = \*, ::' /etc/dovecot/dovecot.conf
|
||||
assert_success
|
||||
assert_output '#listen = *, ::'
|
||||
}
|
||||
|
||||
@test "IPv4 configuration" {
|
||||
export CONTAINER_NAME=${CONTAINER2_NAME}
|
||||
local CUSTOM_SETUP_ARGUMENTS=(--env DOVECOT_INET_PROTOCOLS=ipv4)
|
||||
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
_run_in_container grep '^listen = \*$' /etc/dovecot/dovecot.conf
|
||||
assert_success
|
||||
assert_output 'listen = *'
|
||||
}
|
||||
|
||||
@test "IPv6 configuration" {
|
||||
export CONTAINER_NAME=${CONTAINER3_NAME}
|
||||
local CUSTOM_SETUP_ARGUMENTS=(--env DOVECOT_INET_PROTOCOLS=ipv6)
|
||||
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
_run_in_container grep '^listen = \[::\]$' /etc/dovecot/dovecot.conf
|
||||
assert_success
|
||||
assert_output 'listen = [::]'
|
||||
}
|
76
test/tests/parallel/set1/network_inet_protocols.bats
Normal file
76
test/tests/parallel/set1/network_inet_protocols.bats
Normal file
|
@ -0,0 +1,76 @@
|
|||
load "${REPOSITORY_ROOT}/test/helper/setup"
|
||||
load "${REPOSITORY_ROOT}/test/helper/common"
|
||||
|
||||
# ENV support for restricting network types that Dovecot and Postfix listen on/
|
||||
# PRs:
|
||||
# DOVECOT_INET_PROTOCOLS: https://github.com/docker-mailserver/docker-mailserver/pull/2358
|
||||
# POSTFIX_INET_PROTOCOLS: https://github.com/docker-mailserver/docker-mailserver/pull/1505
|
||||
|
||||
# Docs (upstream):
|
||||
# https://doc.dovecot.org/settings/core/#core_setting-listen
|
||||
# https://www.postfix.org/postconf.5.html#inet_protocols
|
||||
|
||||
BATS_TEST_NAME_PREFIX='[Network] (ENV *_INET_PROTOCOLS) '
|
||||
CONTAINER1_NAME='dms-test_inet-protocols_all'
|
||||
CONTAINER2_NAME='dms-test_inet-protocols_ipv4'
|
||||
CONTAINER3_NAME='dms-test_inet-protocols_ipv6'
|
||||
|
||||
function teardown() { _default_teardown ; }
|
||||
|
||||
@test "should configure for dual-stack IP by default" {
|
||||
export CONTAINER_NAME=${CONTAINER1_NAME}
|
||||
# Unset (default) should be equivalent to 'all':
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env DOVECOT_INET_PROTOCOLS=''
|
||||
--env POSTFIX_INET_PROTOCOLS=''
|
||||
)
|
||||
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
_run_in_container grep '^#listen =' /etc/dovecot/dovecot.conf
|
||||
assert_success
|
||||
assert_output '#listen = *, ::'
|
||||
|
||||
_run_in_container postconf inet_protocols
|
||||
assert_success
|
||||
assert_output 'inet_protocols = all'
|
||||
}
|
||||
|
||||
@test "should configure for IPv4-only" {
|
||||
export CONTAINER_NAME=${CONTAINER2_NAME}
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env DOVECOT_INET_PROTOCOLS='ipv4'
|
||||
--env POSTFIX_INET_PROTOCOLS='ipv4'
|
||||
)
|
||||
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
_run_in_container grep '^listen =' /etc/dovecot/dovecot.conf
|
||||
assert_success
|
||||
assert_output 'listen = *'
|
||||
|
||||
_run_in_container postconf inet_protocols
|
||||
assert_success
|
||||
assert_output 'inet_protocols = ipv4'
|
||||
}
|
||||
|
||||
@test "should configure for IPv6-only networks" {
|
||||
export CONTAINER_NAME=${CONTAINER3_NAME}
|
||||
local CUSTOM_SETUP_ARGUMENTS=(
|
||||
--env DOVECOT_INET_PROTOCOLS='ipv6'
|
||||
--env POSTFIX_INET_PROTOCOLS='ipv6'
|
||||
)
|
||||
|
||||
_init_with_defaults
|
||||
_common_container_setup 'CUSTOM_SETUP_ARGUMENTS'
|
||||
|
||||
_run_in_container grep '^listen =' /etc/dovecot/dovecot.conf
|
||||
assert_success
|
||||
assert_output 'listen = [::]'
|
||||
|
||||
_run_in_container postconf inet_protocols
|
||||
assert_success
|
||||
assert_output 'inet_protocols = ipv6'
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
load "${REPOSITORY_ROOT}/test/test_helper/common"
|
||||
|
||||
# Test case
|
||||
# ---------
|
||||
# POSTFIX_INET_PROTOCOLS value is set
|
||||
|
||||
@test "checking postfix: inet default" {
|
||||
local PRIVATE_CONFIG
|
||||
PRIVATE_CONFIG=$(duplicate_config_for_container . )
|
||||
|
||||
docker run -d --name mail_postfix_inet_default \
|
||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-h mail.my-domain.com -t "${NAME}"
|
||||
|
||||
teardown() { docker rm -f mail_postfix_inet_default; }
|
||||
|
||||
wait_for_finished_setup_in_container mail_postfix_inet_default
|
||||
|
||||
run docker exec mail_postfix_inet_default postconf inet_protocols
|
||||
assert_output "inet_protocols = all"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking postfix: inet all" {
|
||||
local PRIVATE_CONFIG
|
||||
PRIVATE_CONFIG=$(duplicate_config_for_container . )
|
||||
|
||||
docker run -d --name mail_postfix_inet_all \
|
||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e POSTFIX_INET_PROTOCOLS=all \
|
||||
-h mail.my-domain.com -t "${NAME}"
|
||||
|
||||
teardown() { docker rm -f mail_postfix_inet_all; }
|
||||
|
||||
wait_for_finished_setup_in_container mail_postfix_inet_all
|
||||
|
||||
run docker exec mail_postfix_inet_all postconf inet_protocols
|
||||
assert_output "inet_protocols = all"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking postfix: inet ipv4" {
|
||||
local PRIVATE_CONFIG
|
||||
PRIVATE_CONFIG=$(duplicate_config_for_container . )
|
||||
|
||||
docker run -d --name mail_postfix_inet_ipv4 \
|
||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e POSTFIX_INET_PROTOCOLS=ipv4 \
|
||||
-h mail.my-domain.com -t "${NAME}"
|
||||
|
||||
teardown() { docker rm -f mail_postfix_inet_ipv4; }
|
||||
|
||||
wait_for_finished_setup_in_container mail_postfix_inet_ipv4
|
||||
|
||||
run docker exec mail_postfix_inet_ipv4 postconf inet_protocols
|
||||
assert_output "inet_protocols = ipv4"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking postfix: inet ipv6" {
|
||||
local PRIVATE_CONFIG
|
||||
PRIVATE_CONFIG=$(duplicate_config_for_container . )
|
||||
|
||||
docker run -d --name mail_postfix_inet_ipv6 \
|
||||
-v "${PRIVATE_CONFIG}":/tmp/docker-mailserver \
|
||||
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
||||
-e POSTFIX_INET_PROTOCOLS=ipv6 \
|
||||
-h mail.my-domain.com -t "${NAME}"
|
||||
|
||||
teardown() { docker rm -f mail_postfix_inet_ipv6; }
|
||||
|
||||
wait_for_finished_setup_in_container mail_postfix_inet_ipv6
|
||||
|
||||
run docker exec mail_postfix_inet_ipv6 postconf inet_protocols
|
||||
assert_output "inet_protocols = ipv6"
|
||||
assert_success
|
||||
}
|
Loading…
Reference in a new issue