docker-postfix/unit-tests/000_test-multi-comment.bats

73 lines
2.1 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env bats
load /code/scripts/common.sh
load /code/scripts/common-run.sh
postconf daemon_directory=/usr/libexec/postfix
if [[ ! -f /etc/postfix/main.test-multi-comment ]]; then
cp /etc/postfix/main.cf /etc/postfix/main.test-multi-comment
fi
@test "make sure #myhostname appears four times in main.cf (default)" {
result=$(grep -E "^#myhostname" /etc/postfix/main.cf | wc -l)
[[ "$result" -gt 1 ]]
}
@test "make sure commenting out #myhostname does not incrase count" {
COMMENT_COUNT=$(grep -E "^#myhostname" /etc/postfix/main.test-multi-comment | wc -l)
do_postconf -# myhostname
2020-10-23 19:20:31 +08:00
postfix check
result=$(grep -E "^#myhostname" /etc/postfix/main.cf | wc -l)
[ "$result" == "$COMMENT_COUNT" ]
}
@test "make sure adding myhostname does not incrase count" {
COMMENT_COUNT=$(grep -E "^#myhostname" /etc/postfix/main.test-multi-comment | wc -l)
do_postconf -e myhostname=localhost
2020-10-23 19:20:31 +08:00
postfix check
result=$(grep -E "^#myhostname" /etc/postfix/main.cf | wc -l)
[ "$result" == "$COMMENT_COUNT" ]
}
@test "make sure adding myhostname is added only once" {
do_postconf -e myhostname=localhost
2020-10-23 19:20:31 +08:00
postfix check
result=$(grep -E "^myhostname" /etc/postfix/main.cf | wc -l)
[ "$result" == "1" ]
}
@test "make sure deleting myhostname does not incrase count" {
COMMENT_COUNT=$(grep -E "^#myhostname" /etc/postfix/main.test-multi-comment | wc -l)
do_postconf -# myhostname
2020-10-23 19:20:31 +08:00
postfix check
result=$(grep -E "^#myhostname" /etc/postfix/main.cf | wc -l)
[ "$result" == "$COMMENT_COUNT" ]
}
2020-10-23 19:20:31 +08:00
@test "test removing relayhost" {
do_postconf -# relayhost
grep -q -E "^#relayhost" /etc/postfix/main.cf
! grep -q -E "^relayhost" /etc/postfix/main.cf
postfix check
}
@test "spaces in parameters" {
do_postconf -e "smtpd_recipient_restrictions=reject_non_fqdn_recipient, reject_unknown_recipient_domain, check_sender_access lmdb:example.org, reject"
2020-10-23 19:20:31 +08:00
postfix check
}
@test "no sasl password duplications" {
local RELAYHOST="demo"
local RELAYHOST_USERNAME="foo"
local RELAYHOST_PASSWORD="bar"
postfix_setup_relayhost
postfix_setup_relayhost
2020-10-23 19:20:31 +08:00
postfix check
result=$(grep -E "^demo" /etc/postfix/sasl_passwd | wc -l)
[ "$result" == "1" ]
}