tests: Fix white-space difference
- `packages.sh` + `utils.sh` lint fix. - `.tmpl` + `.base` files column aligned. - `mail_with_ldap.bats` updated to ignore white-space between key/value entries being checked.
This commit is contained in:
parent
1ec1853528
commit
4968f4a51d
|
@ -99,7 +99,8 @@ function _install_feature_config_templates() {
|
||||||
apt-get "${QUIET}" --no-install-recommends install gettext-base
|
apt-get "${QUIET}" --no-install-recommends install gettext-base
|
||||||
|
|
||||||
# zenv:
|
# zenv:
|
||||||
local URL_ZENV="https://github.com/numToStr/zenv/releases/download/0.8.0/zenv-0.8.0-$(uname --machine)-unknown-linux-gnu.tar.gz"
|
local URL_ZENV
|
||||||
|
URL_ZENV="https://github.com/numToStr/zenv/releases/download/0.8.0/zenv-0.8.0-$(uname --machine)-unknown-linux-gnu.tar.gz"
|
||||||
# Download from GH releases to stdout, then extract the zenv file to make available via PATH:
|
# Download from GH releases to stdout, then extract the zenv file to make available via PATH:
|
||||||
curl -L "${URL_ZENV}" -o - | tar --gzip --extract --directory /usr/local/bin --file - zenv
|
curl -L "${URL_ZENV}" -o - | tar --gzip --extract --directory /usr/local/bin --file - zenv
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,6 +186,6 @@ function _cleanse_config() {
|
||||||
local KV_DELIMITER=${1:?KV Delimiter is required}
|
local KV_DELIMITER=${1:?KV Delimiter is required}
|
||||||
local INPUT_FILE=${2?:Input file is required}
|
local INPUT_FILE=${2?:Input file is required}
|
||||||
|
|
||||||
sed "/^[^${KV_DELIMITER}]*${KV_DELIMITER}\s*$/d" ${INPUT_FILE} \
|
sed "/^[^${KV_DELIMITER}]*${KV_DELIMITER}\s*$/d" "${INPUT_FILE}" \
|
||||||
| tac | sort -u -t"${KV_DELIMITER}" -k1,1
|
| tac | sort -u -t"${KV_DELIMITER}" -k1,1
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,19 +229,9 @@ function teardown() {
|
||||||
)
|
)
|
||||||
|
|
||||||
for LDAP_SETTING in "${LDAP_SETTINGS_POSTFIX[@]}"; do
|
for LDAP_SETTING in "${LDAP_SETTINGS_POSTFIX[@]}"; do
|
||||||
# "${LDAP_SETTING%=*}" is to match only the key portion of the var (helpful for assert_output error messages)
|
_should_have_matching_setting "${LDAP_SETTING}" /etc/postfix/ldap/users.cf
|
||||||
# NOTE: `start_tls = no` is a default setting, but the white-space differs when ENV `LDAP_START_TLS` is not set explicitly.
|
_should_have_matching_setting "${LDAP_SETTING}" /etc/postfix/ldap/groups.cf
|
||||||
_run_in_container grep "${LDAP_SETTING%=*}" /etc/postfix/ldap/users.cf
|
_should_have_matching_setting "${LDAP_SETTING}" /etc/postfix/ldap/aliases.cf
|
||||||
assert_output "${LDAP_SETTING}"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
_run_in_container grep "${LDAP_SETTING%=*}" /etc/postfix/ldap/groups.cf
|
|
||||||
assert_output "${LDAP_SETTING}"
|
|
||||||
assert_success
|
|
||||||
|
|
||||||
_run_in_container grep "${LDAP_SETTING%=*}" /etc/postfix/ldap/aliases.cf
|
|
||||||
assert_output "${LDAP_SETTING}"
|
|
||||||
assert_success
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,9 +259,7 @@ function teardown() {
|
||||||
)
|
)
|
||||||
|
|
||||||
for LDAP_SETTING in "${LDAP_SETTINGS_DOVECOT[@]}"; do
|
for LDAP_SETTING in "${LDAP_SETTINGS_DOVECOT[@]}"; do
|
||||||
_run_in_container grep "${LDAP_SETTING%=*}" /etc/dovecot/dovecot-ldap.conf.ext
|
_should_have_matching_setting "${LDAP_SETTING}" /etc/dovecot/dovecot-ldap.conf.ext
|
||||||
assert_output "${LDAP_SETTING}"
|
|
||||||
assert_success
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,3 +425,21 @@ function _should_successfully_deliver_mail_to() {
|
||||||
# NOTE: Prevents compatibility for running testcases in parallel (for same container) when the count could become racey:
|
# NOTE: Prevents compatibility for running testcases in parallel (for same container) when the count could become racey:
|
||||||
_count_files_in_directory_in_container "${MAIL_STORAGE_RECIPIENT}" 1
|
_count_files_in_directory_in_container "${MAIL_STORAGE_RECIPIENT}" 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _should_have_matching_setting() {
|
||||||
|
local KEY_VALUE=${1}
|
||||||
|
local CONFIG_FILE=${2}
|
||||||
|
|
||||||
|
function __trim_whitespace() {
|
||||||
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<< "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
local KEY VALUE
|
||||||
|
# Split string into key/value vars and trim white-space:
|
||||||
|
KEY=$(__trim_whitespace "${KEY_VALUE%=*}")
|
||||||
|
VALUE=$(__trim_whitespace "${KEY_VALUE#*=}")
|
||||||
|
|
||||||
|
_run_in_container grep "${KEY}" "${CONFIG_FILE}"
|
||||||
|
assert_output --regexp "^${KEY}\s*=\s*${VALUE}$"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue