docker-mailserver/test/mail_dhparams_default.bats

79 lines
2.9 KiB
Plaintext
Raw Normal View History

2020-04-26 19:36:03 +00:00
load 'test_helper/common'
2020-04-27 07:57:36 +00:00
# Test case
# ---------
# By default, this image is using audited FFDHE groups (https://github.com/tomav/docker-mailserver/pull/1463)
#
# This test suite cover the described situation for ONE_DIR=1 and for ONE_DIR=0.
#
# Description:
# - when using a default DHE parameters:
# ~ repo FFDHE4096 file is unchanged.
# ~ ffdhe4096 params file is copied in postfix and dovecot configuration.
2020-04-26 19:36:03 +00:00
function setup() {
run_setup_file_if_necessary
}
function teardown() {
run_teardown_file_if_necessary
}
function setup_file() {
docker run -d --name mail_default_dhparams_one_dir \
-v "`pwd`/test/config":/tmp/docker-mailserver \
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
-e DMS_DEBUG=0 \
-e ONE_DIR=1 \
-h mail.my-domain.com -t ${NAME}
2020-04-27 08:28:05 +00:00
wait_for_finished_setup_in_container mail_default_dhparams_one_dir
2020-04-26 19:36:03 +00:00
docker run -d --name mail_default_dhparams_not_one_dir \
-v "`pwd`/test/config":/tmp/docker-mailserver \
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
-e DMS_DEBUG=0 \
-e ONE_DIR=0 \
-h mail.my-domain.com -t ${NAME}
wait_for_finished_setup_in_container mail_default_dhparams_not_one_dir
}
function teardown_file() {
docker rm -f mail_default_dhparams_one_dir
docker rm -f mail_default_dhparams_not_one_dir
}
@test "first" {
skip 'this test must come first to reliably identify when to run setup_file'
}
@test "checking ssl: checking dhe params are sufficient" {
# reference used: (22/04/2020) https://english.ncsc.nl/publications/publications/2019/juni/01/it-security-guidelines-for-transport-layer-security-tls
# check ffdhe params are inchanged
repo_checksum=$(sha512sum "$(pwd)/target/shared/ffdhe4096.pem" | awk '{print $1}')
mozilla_checksum=$(curl https://ssl-config.mozilla.org/ffdhe4096.txt -s | sha512sum | awk '{print $1}')
assert_equal "$repo_checksum" "$mozilla_checksum"
run echo "$repo_checksum"
refute_output '' # checksum must not be empty
# by default, ffdhe4096 should be used
# ONE_DIR=1
docker_dovecot_checksum_one_dir=$(docker exec mail_default_dhparams_one_dir sha512sum /etc/dovecot/dh.pem | awk '{print $1}')
docker_postfix_checksum_one_dir=$(docker exec mail_default_dhparams_one_dir sha512sum /etc/postfix/dhparams.pem | awk '{print $1}')
assert_equal "$docker_dovecot_checksum_one_dir" "$repo_checksum"
assert_equal "$docker_postfix_checksum_one_dir" "$repo_checksum"
# ONE_DIR=0
docker_dovecot_checksum_not_one_dir=$(docker exec mail_default_dhparams_not_one_dir sha512sum /etc/dovecot/dh.pem | awk '{print $1}')
docker_postfix_checksum_not_one_dir=$(docker exec mail_default_dhparams_not_one_dir sha512sum /etc/postfix/dhparams.pem | awk '{print $1}')
assert_equal "$docker_dovecot_checksum_not_one_dir" "$repo_checksum"
assert_equal "$docker_postfix_checksum_not_one_dir" "$repo_checksum"
}
@test "last" {
skip 'this test is only there to reliably mark the end for the teardown_file'
}