docker-postfix/unit-tests/000_test-multi-comment.bats
Bojan Čekrlić b358d71454 Fix for #192: Automatically add domains to provided usernames for SASL
So, according to the documentation, usernames must always include a
domain for SASL.

In other words. User cannot be `johhny` but `johhny@example.org`.
Further info can be found on this ticket: https://github.com/bokysan/docker-postfix/issues/192

This commit will automatically append domain if one is not provided in
`SMTPD_SASL_USERS`.
2024-04-16 22:11:34 +02:00

73 lines
2.1 KiB
Bash

#!/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
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
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
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
postfix check
result=$(grep -E "^#myhostname" /etc/postfix/main.cf | wc -l)
[ "$result" == "$COMMENT_COUNT" ]
}
@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"
postfix check
}
@test "no sasl password duplications" {
local RELAYHOST="demo"
local RELAYHOST_USERNAME="foo"
local RELAYHOST_PASSWORD="bar"
postfix_setup_relayhost
postfix_setup_relayhost
postfix check
result=$(grep -E "^demo" /etc/postfix/sasl_passwd | wc -l)
[ "$result" == "1" ]
}