mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Change 'for' style (#3368)
This commit is contained in:
parent
8512dba8ad
commit
8bfe8424fc
|
@ -14,7 +14,6 @@ else
|
||||||
GETMAILDIR=/tmp/docker-mailserver/getmail
|
GETMAILDIR=/tmp/docker-mailserver/getmail
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for FILE in /etc/getmailrc.d/getmailrc*
|
for FILE in /etc/getmailrc.d/getmailrc*; do
|
||||||
do
|
|
||||||
/usr/local/bin/getmail --getmaildir "${GETMAILDIR}" --rcfile "${FILE}" --dump | tail -n +7
|
/usr/local/bin/getmail --getmaildir "${GETMAILDIR}" --rcfile "${FILE}" --dump | tail -n +7
|
||||||
done
|
done
|
||||||
|
|
|
@ -7,8 +7,7 @@ function _main() {
|
||||||
_require_n_parameters_or_print_usage 1 "${@}"
|
_require_n_parameters_or_print_usage 1 "${@}"
|
||||||
|
|
||||||
# Actual command to perform:
|
# Actual command to perform:
|
||||||
for MAIL_ACCOUNT in "${@}"
|
for MAIL_ACCOUNT in "${@}"; do
|
||||||
do
|
|
||||||
_manage_accounts_dovecotmaster_delete "${MAIL_ACCOUNT}" \
|
_manage_accounts_dovecotmaster_delete "${MAIL_ACCOUNT}" \
|
||||||
|| _exit_with_error "'${MAIL_ACCOUNT}' could not be deleted"
|
|| _exit_with_error "'${MAIL_ACCOUNT}' could not be deleted"
|
||||||
done
|
done
|
||||||
|
|
|
@ -16,8 +16,7 @@ function _main() {
|
||||||
_create_lock
|
_create_lock
|
||||||
|
|
||||||
# Actual command to perform:
|
# Actual command to perform:
|
||||||
for MAIL_ACCOUNT in "${@}"
|
for MAIL_ACCOUNT in "${@}"; do
|
||||||
do
|
|
||||||
_account_should_already_exist
|
_account_should_already_exist
|
||||||
|
|
||||||
[[ ${MAILDEL} -eq 1 ]] && _remove_maildir "${MAIL_ACCOUNT}"
|
[[ ${MAILDEL} -eq 1 ]] && _remove_maildir "${MAIL_ACCOUNT}"
|
||||||
|
|
|
@ -13,16 +13,14 @@ fail2ban-client ping &>/dev/null || _exit_with_error "Fail2ban not running"
|
||||||
unset JAILS
|
unset JAILS
|
||||||
declare -a JAILS
|
declare -a JAILS
|
||||||
|
|
||||||
for LIST in $(fail2ban-client status | grep "Jail list" | cut -f2- | sed 's/,/ /g')
|
for LIST in $(fail2ban-client status | grep "Jail list" | cut -f2- | sed 's/,/ /g'); do
|
||||||
do
|
|
||||||
JAILS+=("${LIST}")
|
JAILS+=("${LIST}")
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z ${1} ]]; then
|
if [[ -z ${1} ]]; then
|
||||||
IPS_BANNED=0
|
IPS_BANNED=0
|
||||||
|
|
||||||
for JAIL in "${JAILS[@]}"
|
for JAIL in "${JAILS[@]}"; do
|
||||||
do
|
|
||||||
BANNED_IPS=$(fail2ban-client status "${JAIL}" | grep -oP '(?<=Banned IP list:\s).+')
|
BANNED_IPS=$(fail2ban-client status "${JAIL}" | grep -oP '(?<=Banned IP list:\s).+')
|
||||||
|
|
||||||
if [[ -n ${BANNED_IPS} ]]; then
|
if [[ -n ${BANNED_IPS} ]]; then
|
||||||
|
@ -58,8 +56,7 @@ else
|
||||||
shift
|
shift
|
||||||
if [[ -n ${1} ]]; then
|
if [[ -n ${1} ]]; then
|
||||||
|
|
||||||
for JAIL in "${JAILS[@]}"
|
for JAIL in "${JAILS[@]}"; do
|
||||||
do
|
|
||||||
RESULT=$(fail2ban-client set "${JAIL}" unbanip "${@}" 2>&1)
|
RESULT=$(fail2ban-client set "${JAIL}" unbanip "${@}" 2>&1)
|
||||||
|
|
||||||
[[ ${RESULT} != *"is not banned"* ]] && [[ ${RESULT} != *"NOK"* ]] && echo "Unbanned IP from ${JAIL}: ${RESULT}"
|
[[ ${RESULT} != *"is not banned"* ]] && [[ ${RESULT} != *"NOK"* ]] && echo "Unbanned IP from ${JAIL}: ${RESULT}"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
for FILE in /etc/getmailrc.d/getmailrc*
|
for FILE in /etc/getmailrc.d/getmailrc*; do
|
||||||
do
|
|
||||||
if ! pgrep -f "${FILE}$" &>/dev/null; then
|
if ! pgrep -f "${FILE}$" &>/dev/null; then
|
||||||
/usr/local/bin/getmail --getmaildir /var/lib/getmail --rcfile "${FILE}"
|
/usr/local/bin/getmail --getmaildir /var/lib/getmail --rcfile "${FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -64,8 +64,7 @@ function _monitored_files_checksums() {
|
||||||
|
|
||||||
# If the file actually exists, add to CHANGED_FILES
|
# If the file actually exists, add to CHANGED_FILES
|
||||||
# and generate a content hash entry:
|
# and generate a content hash entry:
|
||||||
for FILE in "${STAGING_FILES[@]}"
|
for FILE in "${STAGING_FILES[@]}"; do
|
||||||
do
|
|
||||||
[[ -f "${FILE}" ]] && CHANGED_FILES+=("${FILE}")
|
[[ -f "${FILE}" ]] && CHANGED_FILES+=("${FILE}")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,7 @@ function _sanitize_ipv4_to_subnet_cidr() {
|
||||||
declare -a MASKED_DIGITS DIGITS
|
declare -a MASKED_DIGITS DIGITS
|
||||||
IFS='.' ; read -r -a DIGITS < <(echo "${1%%/*}") ; unset IFS
|
IFS='.' ; read -r -a DIGITS < <(echo "${1%%/*}") ; unset IFS
|
||||||
|
|
||||||
for ((i = 0 ; i < 4 ; i++))
|
for ((i = 0 ; i < 4 ; i++)); do
|
||||||
do
|
|
||||||
MASKED_DIGITS[i]=$(_mask_ip_digit "${DIGIT_PREFIX_LENGTH}" "${DIGITS[i]}")
|
MASKED_DIGITS[i]=$(_mask_ip_digit "${DIGIT_PREFIX_LENGTH}" "${DIGITS[i]}")
|
||||||
DIGIT_PREFIX_LENGTH=$((DIGIT_PREFIX_LENGTH - 8))
|
DIGIT_PREFIX_LENGTH=$((DIGIT_PREFIX_LENGTH - 8))
|
||||||
done
|
done
|
||||||
|
|
|
@ -9,8 +9,7 @@ function _register_check_function() {
|
||||||
|
|
||||||
function _check() {
|
function _check() {
|
||||||
_log 'info' 'Checking configuration'
|
_log 'info' 'Checking configuration'
|
||||||
for FUNC in "${FUNCS_CHECK[@]}"
|
for FUNC in "${FUNCS_CHECK[@]}"; do
|
||||||
do
|
|
||||||
${FUNC}
|
${FUNC}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,7 @@ function _register_start_daemon() {
|
||||||
function _start_daemons() {
|
function _start_daemons() {
|
||||||
_log 'info' 'Starting daemons'
|
_log 'info' 'Starting daemons'
|
||||||
|
|
||||||
for FUNCTION in "${DAEMONS_START[@]}"
|
for FUNCTION in "${DAEMONS_START[@]}"; do
|
||||||
do
|
|
||||||
${FUNCTION}
|
${FUNCTION}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -56,8 +55,7 @@ function _start_daemon_postfix() {
|
||||||
function _start_daemon_fetchmail() {
|
function _start_daemon_fetchmail() {
|
||||||
if [[ ${FETCHMAIL_PARALLEL} -eq 1 ]]; then
|
if [[ ${FETCHMAIL_PARALLEL} -eq 1 ]]; then
|
||||||
local COUNTER=0
|
local COUNTER=0
|
||||||
for _ in /etc/fetchmailrc.d/fetchmail-*.rc
|
for _ in /etc/fetchmailrc.d/fetchmail-*.rc; do
|
||||||
do
|
|
||||||
COUNTER=$(( COUNTER + 1 ))
|
COUNTER=$(( COUNTER + 1 ))
|
||||||
_default_start_daemon "fetchmail-${COUNTER}"
|
_default_start_daemon "fetchmail-${COUNTER}"
|
||||||
done
|
done
|
||||||
|
|
|
@ -10,15 +10,13 @@ function _register_setup_function() {
|
||||||
function _setup() {
|
function _setup() {
|
||||||
# Requires `shopt -s globstar` because of `**` which in
|
# Requires `shopt -s globstar` because of `**` which in
|
||||||
# turn is required as we're decending through directories
|
# turn is required as we're decending through directories
|
||||||
for FILE in /usr/local/bin/setup.d/**/*.sh
|
for FILE in /usr/local/bin/setup.d/**/*.sh; do
|
||||||
do
|
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "${FILE}"
|
source "${FILE}"
|
||||||
done
|
done
|
||||||
|
|
||||||
_log 'info' 'Configuring mail server'
|
_log 'info' 'Configuring mail server'
|
||||||
for FUNC in "${FUNCS_SETUP[@]}"
|
for FUNC in "${FUNCS_SETUP[@]}"; do
|
||||||
do
|
|
||||||
${FUNC}
|
${FUNC}
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -146,8 +146,7 @@ function _setup_dovecot_local_user() {
|
||||||
function __wait_until_an_account_is_added_or_shutdown() {
|
function __wait_until_an_account_is_added_or_shutdown() {
|
||||||
local SLEEP_PERIOD='10'
|
local SLEEP_PERIOD='10'
|
||||||
|
|
||||||
for (( COUNTER = 11 ; COUNTER >= 0 ; COUNTER-- ))
|
for (( COUNTER = 11 ; COUNTER >= 0 ; COUNTER-- )); do
|
||||||
do
|
|
||||||
if [[ $(grep -cE '.+@.+\|' /tmp/docker-mailserver/postfix-accounts.cf 2>/dev/null || printf '%s' '0') -ge 1 ]]; then
|
if [[ $(grep -cE '.+@.+\|' /tmp/docker-mailserver/postfix-accounts.cf 2>/dev/null || printf '%s' '0') -ge 1 ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
|
|
@ -76,8 +76,7 @@ function _setup_fetchmail_parallel() {
|
||||||
_fetchmailrc_split
|
_fetchmailrc_split
|
||||||
|
|
||||||
local COUNTER=0
|
local COUNTER=0
|
||||||
for RC in /etc/fetchmailrc.d/fetchmail-*.rc
|
for RC in /etc/fetchmailrc.d/fetchmail-*.rc; do
|
||||||
do
|
|
||||||
COUNTER=$(( COUNTER + 1 ))
|
COUNTER=$(( COUNTER + 1 ))
|
||||||
cat >"/etc/supervisor/conf.d/fetchmail-${COUNTER}.conf" << EOF
|
cat >"/etc/supervisor/conf.d/fetchmail-${COUNTER}.conf" << EOF
|
||||||
[program:fetchmail-${COUNTER}]
|
[program:fetchmail-${COUNTER}]
|
||||||
|
|
|
@ -13,8 +13,7 @@ function _setup_getmail() {
|
||||||
|
|
||||||
# Generate getmailrc configs, starting with the `/etc/getmailrc_general` base config,
|
# Generate getmailrc configs, starting with the `/etc/getmailrc_general` base config,
|
||||||
# Add a unique `message_log` config, then append users own config to the end.
|
# Add a unique `message_log` config, then append users own config to the end.
|
||||||
for FILE in /tmp/docker-mailserver/getmail-*.cf
|
for FILE in /tmp/docker-mailserver/getmail-*.cf; do
|
||||||
do
|
|
||||||
if [[ -f ${FILE} ]]; then
|
if [[ -f ${FILE} ]]; then
|
||||||
CONFIGS=1
|
CONFIGS=1
|
||||||
ID=$(cut -d '-' -f 3 <<< "${FILE}" | cut -d '.' -f 1)
|
ID=$(cut -d '-' -f 3 <<< "${FILE}" | cut -d '.' -f 1)
|
||||||
|
|
|
@ -4,8 +4,7 @@ function _setup_ldap() {
|
||||||
_log 'debug' 'Setting up LDAP'
|
_log 'debug' 'Setting up LDAP'
|
||||||
_log 'trace' 'Checking for custom configs'
|
_log 'trace' 'Checking for custom configs'
|
||||||
|
|
||||||
for i in 'users' 'groups' 'aliases' 'domains'
|
for i in 'users' 'groups' 'aliases' 'domains'; do
|
||||||
do
|
|
||||||
local FPATH="/tmp/docker-mailserver/ldap-${i}.cf"
|
local FPATH="/tmp/docker-mailserver/ldap-${i}.cf"
|
||||||
if [[ -f ${FPATH} ]]; then
|
if [[ -f ${FPATH} ]]; then
|
||||||
cp "${FPATH}" "/etc/postfix/ldap-${i}.cf"
|
cp "${FPATH}" "/etc/postfix/ldap-${i}.cf"
|
||||||
|
@ -23,8 +22,7 @@ function _setup_ldap() {
|
||||||
/etc/postfix/maps/sender_login_maps.ldap
|
/etc/postfix/maps/sender_login_maps.ldap
|
||||||
)
|
)
|
||||||
|
|
||||||
for FILE in "${FILES[@]}"
|
for FILE in "${FILES[@]}"; do
|
||||||
do
|
|
||||||
[[ ${FILE} =~ ldap-user ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_USER}"
|
[[ ${FILE} =~ ldap-user ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_USER}"
|
||||||
[[ ${FILE} =~ ldap-group ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_GROUP}"
|
[[ ${FILE} =~ ldap-group ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_GROUP}"
|
||||||
[[ ${FILE} =~ ldap-aliases ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_ALIAS}"
|
[[ ${FILE} =~ ldap-aliases ]] && export LDAP_QUERY_FILTER="${LDAP_QUERY_FILTER_ALIAS}"
|
||||||
|
@ -51,8 +49,7 @@ function _setup_ldap() {
|
||||||
# Default DOVECOT_PASS_FILTER to the same value as DOVECOT_USER_FILTER
|
# Default DOVECOT_PASS_FILTER to the same value as DOVECOT_USER_FILTER
|
||||||
DOVECOT_LDAP_MAPPING['DOVECOT_PASS_FILTER']="${DOVECOT_PASS_FILTER:="${DOVECOT_USER_FILTER}"}"
|
DOVECOT_LDAP_MAPPING['DOVECOT_PASS_FILTER']="${DOVECOT_PASS_FILTER:="${DOVECOT_USER_FILTER}"}"
|
||||||
|
|
||||||
for VAR in "${!DOVECOT_LDAP_MAPPING[@]}"
|
for VAR in "${!DOVECOT_LDAP_MAPPING[@]}"; do
|
||||||
do
|
|
||||||
export "${VAR}=${DOVECOT_LDAP_MAPPING[${VAR}]}"
|
export "${VAR}=${DOVECOT_LDAP_MAPPING[${VAR}]}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@ function _setup_save_states() {
|
||||||
# Single service files
|
# Single service files
|
||||||
[[ ${ENABLE_SRS} -eq 1 ]] && SERVICEFILES+=('/etc/postsrsd.secret')
|
[[ ${ENABLE_SRS} -eq 1 ]] && SERVICEFILES+=('/etc/postsrsd.secret')
|
||||||
|
|
||||||
for SERVICEFILE in "${SERVICEFILES[@]}";
|
for SERVICEFILE in "${SERVICEFILES[@]}"; do
|
||||||
do
|
|
||||||
DEST="${STATEDIR}/${SERVICEFILE}"
|
DEST="${STATEDIR}/${SERVICEFILE}"
|
||||||
DESTDIR="${DEST%/*}"
|
DESTDIR="${DEST%/*}"
|
||||||
|
|
||||||
|
@ -55,8 +54,7 @@ function _setup_save_states() {
|
||||||
ln -s "${DEST}" "${SERVICEFILE}"
|
ln -s "${DEST}" "${SERVICEFILE}"
|
||||||
done
|
done
|
||||||
|
|
||||||
for SERVICEDIR in "${SERVICEDIRS[@]}"
|
for SERVICEDIR in "${SERVICEDIRS[@]}"; do
|
||||||
do
|
|
||||||
DEST="${STATEDIR}/${SERVICEDIR//\//-}"
|
DEST="${STATEDIR}/${SERVICEDIR//\//-}"
|
||||||
SERVICEDIR="/var/${SERVICEDIR}"
|
SERVICEDIR="/var/${SERVICEDIR}"
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ function _setup_docker_permit() {
|
||||||
;;
|
;;
|
||||||
|
|
||||||
( 'connected-networks' )
|
( 'connected-networks' )
|
||||||
for CONTAINER_NETWORK in "${CONTAINER_NETWORKS[@]}"
|
for CONTAINER_NETWORK in "${CONTAINER_NETWORKS[@]}"; do
|
||||||
do
|
|
||||||
CONTAINER_NETWORK=$(_sanitize_ipv4_to_subnet_cidr "${CONTAINER_NETWORK}")
|
CONTAINER_NETWORK=$(_sanitize_ipv4_to_subnet_cidr "${CONTAINER_NETWORK}")
|
||||||
__add_to_postfix_mynetworks 'Docker Network' "${CONTAINER_NETWORK}"
|
__add_to_postfix_mynetworks 'Docker Network' "${CONTAINER_NETWORK}"
|
||||||
done
|
done
|
||||||
|
|
|
@ -158,8 +158,7 @@ function __setup__security__clamav() {
|
||||||
_log 'debug' 'Enabling and configuring ClamAV'
|
_log 'debug' 'Enabling and configuring ClamAV'
|
||||||
|
|
||||||
local FILE
|
local FILE
|
||||||
for FILE in /var/log/mail/{clamav,freshclam}.log
|
for FILE in /var/log/mail/{clamav,freshclam}.log; do
|
||||||
do
|
|
||||||
touch "${FILE}"
|
touch "${FILE}"
|
||||||
chown clamav:adm "${FILE}"
|
chown clamav:adm "${FILE}"
|
||||||
chmod 640 "${FILE}"
|
chmod 640 "${FILE}"
|
||||||
|
|
|
@ -179,8 +179,7 @@ function __rspamd__setup_default_modules() {
|
||||||
metric_exporter
|
metric_exporter
|
||||||
)
|
)
|
||||||
|
|
||||||
for MODULE in "${DISABLE_MODULES[@]}"
|
for MODULE in "${DISABLE_MODULES[@]}"; do
|
||||||
do
|
|
||||||
__rspamd__helper__enable_disable_module "${MODULE}" 'false'
|
__rspamd__helper__enable_disable_module "${MODULE}" 'false'
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,8 +212,7 @@ function _environment_variables_export() {
|
||||||
: >/etc/dms-settings # this file can be sourced by other scripts
|
: >/etc/dms-settings # this file can be sourced by other scripts
|
||||||
|
|
||||||
local VAR
|
local VAR
|
||||||
for VAR in "${!VARS[@]}"
|
for VAR in "${!VARS[@]}"; do
|
||||||
do
|
|
||||||
echo "export ${VAR}='${VARS[${VAR}]}'" >>/root/.bashrc
|
echo "export ${VAR}='${VARS[${VAR}]}'" >>/root/.bashrc
|
||||||
echo "${VAR}='${VARS[${VAR}]}'" >>/etc/dms-settings
|
echo "${VAR}='${VARS[${VAR}]}'" >>/etc/dms-settings
|
||||||
done
|
done
|
||||||
|
|
|
@ -29,8 +29,7 @@ function __initialize_variables() {
|
||||||
'CONTAINER_NAME'
|
'CONTAINER_NAME'
|
||||||
)
|
)
|
||||||
|
|
||||||
for VARIABLE in "${REQUIRED_VARIABLES_FOR_TESTS[@]}"
|
for VARIABLE in "${REQUIRED_VARIABLES_FOR_TESTS[@]}"; do
|
||||||
do
|
|
||||||
__check_if_set "${VARIABLE}"
|
__check_if_set "${VARIABLE}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,7 @@ function _should_succesfully_negotiate_tls() {
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
local PORTS=(25 587 465 143 993)
|
local PORTS=(25 587 465 143 993)
|
||||||
for PORT in "${PORTS[@]}"
|
for PORT in "${PORTS[@]}"; do
|
||||||
do
|
|
||||||
_negotiate_tls "${FQDN}" "${PORT}"
|
_negotiate_tls "${FQDN}" "${PORT}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,7 @@ function teardown_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "fail2ban-jail.cf overrides" {
|
@test "fail2ban-jail.cf overrides" {
|
||||||
for FILTER in 'dovecot' 'postfix' 'postfix-sasl'
|
for FILTER in 'dovecot' 'postfix' 'postfix-sasl'; do
|
||||||
do
|
|
||||||
_run_in_container fail2ban-client get "${FILTER}" bantime
|
_run_in_container fail2ban-client get "${FILTER}" bantime
|
||||||
assert_output 1234
|
assert_output 1234
|
||||||
|
|
||||||
|
|
|
@ -89,8 +89,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "argument 'domain' is applied correctly" {
|
@test "argument 'domain' is applied correctly" {
|
||||||
for DOMAIN in 'blabla.org' 'someother.com' 'random.de'
|
for DOMAIN in 'blabla.org' 'someother.com' 'random.de'; do
|
||||||
do
|
|
||||||
_run_in_container setup config dkim domain "${DOMAIN}"
|
_run_in_container setup config dkim domain "${DOMAIN}"
|
||||||
assert_success
|
assert_success
|
||||||
assert_line --partial "Domain set to '${DOMAIN}'"
|
assert_line --partial "Domain set to '${DOMAIN}'"
|
||||||
|
@ -107,8 +106,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
assert_failure
|
assert_failure
|
||||||
assert_line --partial "Unknown keytype 'foobar'"
|
assert_line --partial "Unknown keytype 'foobar'"
|
||||||
|
|
||||||
for KEYTYPE in 'rsa' 'ed25519'
|
for KEYTYPE in 'rsa' 'ed25519'; do
|
||||||
do
|
|
||||||
_run_in_container setup config dkim keytype "${KEYTYPE}"
|
_run_in_container setup config dkim keytype "${KEYTYPE}"
|
||||||
assert_success
|
assert_success
|
||||||
assert_line --partial "Keytype set to '${KEYTYPE}'"
|
assert_line --partial "Keytype set to '${KEYTYPE}'"
|
||||||
|
@ -127,8 +125,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "argument 'selector' is applied correctly" {
|
@test "argument 'selector' is applied correctly" {
|
||||||
for SELECTOR in 'foo' 'bar' 'baz'
|
for SELECTOR in 'foo' 'bar' 'baz'; do
|
||||||
do
|
|
||||||
__create_key 'rsa' "${SELECTOR}"
|
__create_key 'rsa' "${SELECTOR}"
|
||||||
assert_success
|
assert_success
|
||||||
assert_line --partial "Selector set to '${SELECTOR}'"
|
assert_line --partial "Selector set to '${SELECTOR}'"
|
||||||
|
@ -146,8 +143,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "argument 'keysize' is applied correctly for RSA keys" {
|
@test "argument 'keysize' is applied correctly for RSA keys" {
|
||||||
for KEYSIZE in 512 1024 2048 4096
|
for KEYSIZE in 512 1024 2048 4096; do
|
||||||
do
|
|
||||||
__create_key 'rsa' 'mail' "${DOMAIN_NAME}" "${KEYSIZE}"
|
__create_key 'rsa' 'mail' "${DOMAIN_NAME}" "${KEYSIZE}"
|
||||||
assert_success
|
assert_success
|
||||||
__log_is_free_of_warnings_and_errors
|
__log_is_free_of_warnings_and_errors
|
||||||
|
@ -234,8 +230,7 @@ function __check_rsa_keys() {
|
||||||
# @param ${1} = base file name that all DKIM key files have
|
# @param ${1} = base file name that all DKIM key files have
|
||||||
function __check_key_files_are_present() {
|
function __check_key_files_are_present() {
|
||||||
local BASE_FILE_NAME="${1:?Base file name must be supplied to __check_key_files_are_present}"
|
local BASE_FILE_NAME="${1:?Base file name must be supplied to __check_key_files_are_present}"
|
||||||
for FILE in ${BASE_FILE_NAME}.{public.txt,public.dns.txt,private.txt}
|
for FILE in ${BASE_FILE_NAME}.{public.txt,public.dns.txt,private.txt}; do
|
||||||
do
|
|
||||||
_run_in_container_bash "[[ -f ${FILE} ]]"
|
_run_in_container_bash "[[ -f ${FILE} ]]"
|
||||||
assert_success
|
assert_success
|
||||||
done
|
done
|
||||||
|
|
|
@ -49,8 +49,7 @@ function setup_file() {
|
||||||
export MAIL_ID3=$(_send_email_and_get_id 'email-templates/rspamd-virus')
|
export MAIL_ID3=$(_send_email_and_get_id 'email-templates/rspamd-virus')
|
||||||
export MAIL_ID4=$(_send_email_and_get_id 'email-templates/rspamd-spam-header')
|
export MAIL_ID4=$(_send_email_and_get_id 'email-templates/rspamd-spam-header')
|
||||||
|
|
||||||
for ID in MAIL_ID{1,2,3,4}
|
for ID in MAIL_ID{1,2,3,4}; do
|
||||||
do
|
|
||||||
[[ -n ${!ID} ]] || { echo "${ID} is empty - aborting!" ; return 1 ; }
|
[[ -n ${!ID} ]] || { echo "${ID} is empty - aborting!" ; return 1 ; }
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -225,8 +224,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'RSPAMD_LEARN works' {
|
@test 'RSPAMD_LEARN works' {
|
||||||
for FILE in learn-{ham,spam}.{sieve,svbin}
|
for FILE in learn-{ham,spam}.{sieve,svbin}; do
|
||||||
do
|
|
||||||
_run_in_container_bash "[[ -f /usr/lib/dovecot/sieve-pipe/${FILE} ]]"
|
_run_in_container_bash "[[ -f /usr/lib/dovecot/sieve-pipe/${FILE} ]]"
|
||||||
assert_success
|
assert_success
|
||||||
done
|
done
|
||||||
|
@ -267,8 +265,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial 'imapsieve: Matched static mailbox rule [1]'
|
assert_output --partial 'imapsieve: Matched static mailbox rule [1]'
|
||||||
refute_output --partial 'imapsieve: Matched static mailbox rule [2]'
|
refute_output --partial 'imapsieve: Matched static mailbox rule [2]'
|
||||||
for LINE in "${LEARN_SPAM_LINES[@]}"
|
for LINE in "${LEARN_SPAM_LINES[@]}"; do
|
||||||
do
|
|
||||||
assert_output --partial "${LINE}"
|
assert_output --partial "${LINE}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -281,8 +278,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
_run_in_container cat /var/log/mail/mail.log
|
_run_in_container cat /var/log/mail/mail.log
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial 'imapsieve: Matched static mailbox rule [2]'
|
assert_output --partial 'imapsieve: Matched static mailbox rule [2]'
|
||||||
for LINE in "${LEARN_HAM_LINES[@]}"
|
for LINE in "${LEARN_HAM_LINES[@]}"; do
|
||||||
do
|
|
||||||
assert_output --partial "${LINE}"
|
assert_output --partial "${LINE}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
@test "log warns about interfering features" {
|
@test "log warns about interfering features" {
|
||||||
run docker logs "${CONTAINER_NAME}"
|
run docker logs "${CONTAINER_NAME}"
|
||||||
assert_success
|
assert_success
|
||||||
for SERVICE in 'Amavis/SA' 'OpenDKIM' 'OpenDMARC' 'policyd-spf'
|
for SERVICE in 'Amavis/SA' 'OpenDKIM' 'OpenDMARC' 'policyd-spf'; do
|
||||||
do
|
|
||||||
assert_output --regexp ".*WARNING.*Running ${SERVICE} & Rspamd at the same time is discouraged"
|
assert_output --regexp ".*WARNING.*Running ${SERVICE} & Rspamd at the same time is discouraged"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -63,8 +62,7 @@ function teardown_file() { _default_teardown ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@test 'learning is properly disabled' {
|
@test 'learning is properly disabled' {
|
||||||
for FILE in learn-{ham,spam}.{sieve,svbin}
|
for FILE in learn-{ham,spam}.{sieve,svbin}; do
|
||||||
do
|
|
||||||
_run_in_container_bash "[[ -f /usr/lib/dovecot/sieve-pipe/${FILE} ]]"
|
_run_in_container_bash "[[ -f /usr/lib/dovecot/sieve-pipe/${FILE} ]]"
|
||||||
assert_failure
|
assert_failure
|
||||||
done
|
done
|
||||||
|
|
|
@ -72,16 +72,14 @@ ENV_PROCESS_LIST=(
|
||||||
# Required for Postfix (when launched by wrapper script which is slow to start)
|
# Required for Postfix (when launched by wrapper script which is slow to start)
|
||||||
_wait_for_smtp_port_in_container
|
_wait_for_smtp_port_in_container
|
||||||
|
|
||||||
for PROCESS in "${CORE_PROCESS_LIST[@]}"
|
for PROCESS in "${CORE_PROCESS_LIST[@]}"; do
|
||||||
do
|
|
||||||
run _check_if_process_is_running "${PROCESS}"
|
run _check_if_process_is_running "${PROCESS}"
|
||||||
assert_success
|
assert_success
|
||||||
assert_output --partial "${PROCESS}"
|
assert_output --partial "${PROCESS}"
|
||||||
refute_output --partial "is not running"
|
refute_output --partial "is not running"
|
||||||
done
|
done
|
||||||
|
|
||||||
for PROCESS in "${ENV_PROCESS_LIST[@]}" clamd
|
for PROCESS in "${ENV_PROCESS_LIST[@]}" clamd; do
|
||||||
do
|
|
||||||
run _check_if_process_is_running "${PROCESS}"
|
run _check_if_process_is_running "${PROCESS}"
|
||||||
assert_failure
|
assert_failure
|
||||||
assert_output --partial "'${PROCESS}' is not running"
|
assert_output --partial "'${PROCESS}' is not running"
|
||||||
|
@ -116,8 +114,7 @@ ENV_PROCESS_LIST=(
|
||||||
"${ENV_PROCESS_LIST[@]}"
|
"${ENV_PROCESS_LIST[@]}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for PROCESS in "${ENABLED_PROCESS_LIST[@]}"
|
for PROCESS in "${ENABLED_PROCESS_LIST[@]}"; do
|
||||||
do
|
|
||||||
_should_restart_when_killed "${PROCESS}"
|
_should_restart_when_killed "${PROCESS}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue