tests: Adjust for change in logs
This commit is contained in:
parent
b67dad5bf9
commit
b7352754df
|
@ -78,7 +78,7 @@ function _parse_arguments() {
|
|||
( 'keysize' )
|
||||
if [[ -n ${2+set} ]]; then
|
||||
KEYSIZE="${2}"
|
||||
_log 'debug' "Keysize set to '${KEYSIZE}'"
|
||||
_log 'trace' "Keysize set to '${KEYSIZE}'"
|
||||
else
|
||||
_exit_with_error "No keysize provided after 'keysize' argument"
|
||||
fi
|
||||
|
@ -87,7 +87,7 @@ function _parse_arguments() {
|
|||
( 'selector' )
|
||||
if [[ -n ${2+set} ]]; then
|
||||
SELECTOR="${2}"
|
||||
_log 'debug' "Selector set to '${SELECTOR}'"
|
||||
_log 'trace' "Selector set to '${SELECTOR}'"
|
||||
else
|
||||
_exit_with_error "No selector provided after 'selector' argument"
|
||||
fi
|
||||
|
@ -96,7 +96,7 @@ function _parse_arguments() {
|
|||
( 'domain' )
|
||||
if [[ -n ${2+set} ]]; then
|
||||
DMS_DOMAINS="${2}"
|
||||
_log 'debug' "Domain(s) set to '${DMS_DOMAINS}'"
|
||||
_log 'trace' "Domain(s) set to '${DMS_DOMAINS}'"
|
||||
else
|
||||
_exit_with_error "No domain(s) provided after 'domain' argument"
|
||||
fi
|
||||
|
@ -209,8 +209,6 @@ SIGNING_TABLE_FILE="${OPENDKIM_BASE_DIR}/SigningTable"
|
|||
TRUSTED_HOSTS_FILE="${OPENDKIM_BASE_DIR}/TrustedHosts"
|
||||
# Create configs if missing:
|
||||
function _create_opendkim_configs() {
|
||||
_log 'debug' 'Creating any missing OpenDKIM configs'
|
||||
|
||||
mkdir -p "${OPENDKIM_BASE_DIR}"
|
||||
local OPENDKIM_CONFIGS=(
|
||||
"${KEY_TABLE_FILE}"
|
||||
|
@ -219,8 +217,11 @@ function _create_opendkim_configs() {
|
|||
)
|
||||
|
||||
# Only create if the file doesn't exist (avoids modifying mtime):
|
||||
for FILE in ${OPENDKIM_CONFIGS[@]}; do
|
||||
[[ ! -f "${FILE}" ]] && touch "${FILE}"
|
||||
for FILE in "${OPENDKIM_CONFIGS[@]}"; do
|
||||
if [[ ! -f "${FILE}" ]]; then
|
||||
_log 'debug' "Creating OpenDKIM config '${FILE}'"
|
||||
touch "${FILE}"
|
||||
fi
|
||||
done
|
||||
|
||||
# If file exists but is empty, add default hosts to trust:
|
||||
|
|
|
@ -23,7 +23,11 @@ function _setup_opendkim() {
|
|||
# check if any keys are available
|
||||
if [[ -e /tmp/docker-mailserver/opendkim/KeyTable ]]; then
|
||||
cp -a /tmp/docker-mailserver/opendkim/* /etc/opendkim/
|
||||
_log 'trace' "DKIM keys added for: $(find /etc/opendkim/keys/ -maxdepth 1 -type f -printf '%f ')"
|
||||
|
||||
local DKIM_DOMAINS
|
||||
DKIM_DOMAINS=$(find /etc/opendkim/keys/ -maxdepth 1 -type f -printf '%f ')
|
||||
_log 'trace' "DKIM keys added for: ${DKIM_DOMAINS}"
|
||||
|
||||
chown -R opendkim:opendkim /etc/opendkim/
|
||||
chmod -R 0700 /etc/opendkim/keys/
|
||||
else
|
||||
|
|
|
@ -62,7 +62,7 @@ function teardown() { _default_teardown ; }
|
|||
|
||||
__init_container_without_waiting
|
||||
|
||||
__should_generate_dkim_key 6
|
||||
__should_generate_dkim_key 7
|
||||
__assert_outputs_common_dkim_logs
|
||||
|
||||
__should_have_tables_trustedhosts_for_domain
|
||||
|
@ -78,7 +78,7 @@ function teardown() { _default_teardown ; }
|
|||
# Only mount single config file (postfix-virtual.cf):
|
||||
__init_container_without_waiting "${PWD}/test/config/postfix-virtual.cf:/tmp/docker-mailserver/postfix-virtual.cf:ro"
|
||||
|
||||
__should_generate_dkim_key 5
|
||||
__should_generate_dkim_key 6
|
||||
__assert_outputs_common_dkim_logs
|
||||
|
||||
__should_have_tables_trustedhosts_for_domain
|
||||
|
@ -95,7 +95,7 @@ function teardown() { _default_teardown ; }
|
|||
# Only mount single config file (postfix-accounts.cf):
|
||||
__init_container_without_waiting "${PWD}/test/config/postfix-accounts.cf:/tmp/docker-mailserver/postfix-accounts.cf:ro"
|
||||
|
||||
__should_generate_dkim_key 5
|
||||
__should_generate_dkim_key 6
|
||||
__assert_outputs_common_dkim_logs
|
||||
|
||||
__should_have_tables_trustedhosts_for_domain
|
||||
|
@ -113,7 +113,7 @@ function teardown() { _default_teardown ; }
|
|||
__init_container_without_waiting '/tmp/docker-mailserver'
|
||||
|
||||
# generate first key (with a custom selector)
|
||||
__should_generate_dkim_key 4 '1024' 'domain1.tld' 'mailer'
|
||||
__should_generate_dkim_key 5 '1024' 'domain1.tld' 'mailer'
|
||||
__assert_outputs_common_dkim_logs
|
||||
# generate two additional keys different to the previous one
|
||||
__should_generate_dkim_key 2 '1024' 'domain2.tld,domain3.tld'
|
||||
|
@ -183,15 +183,15 @@ function __assert_logged_dkim_creation() {
|
|||
|
||||
function __assert_outputs_common_dkim_logs() {
|
||||
refute_output --partial 'No entries found, no keys to make'
|
||||
assert_output --partial 'Creating DKIM KeyTable'
|
||||
assert_output --partial 'Creating DKIM SigningTable'
|
||||
assert_output --partial 'Creating DKIM TrustedHosts'
|
||||
assert_output --partial "Creating OpenDKIM config '/tmp/docker-mailserver/opendkim/KeyTable'"
|
||||
assert_output --partial "Creating OpenDKIM config '/tmp/docker-mailserver/opendkim/SigningTable'"
|
||||
assert_output --partial "Creating OpenDKIM config '/tmp/docker-mailserver/opendkim/TrustedHosts'"
|
||||
}
|
||||
|
||||
function __should_support_creating_key_of_size() {
|
||||
local EXPECTED_KEYSIZE=${1:-}
|
||||
|
||||
__should_generate_dkim_key 6 "${EXPECTED_KEYSIZE}"
|
||||
__should_generate_dkim_key 7 "${EXPECTED_KEYSIZE}"
|
||||
__assert_outputs_common_dkim_logs
|
||||
__assert_logged_dkim_creation 'localdomain2.com'
|
||||
__assert_logged_dkim_creation 'localhost.localdomain'
|
||||
|
|
Loading…
Reference in New Issue