mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-02 09:05:14 +02:00
* Add new configuration for multi-domain relay hosts (#922) * Creates new environment variables (replacing existing AWS_SES variables) * Optionally allows more advanced setups using config files * Update relay hosts during change detection (#922) * Add helper scripts for adding relay hosts and per-domain auth * Allow the possibility to deliver some mail directly * adding a domain with no destination will exclude it from the relayhost_map and so Postfix will attempt to deliver the mail directly * tests for setup.sh script * tests for relay host configuration * these tests cover the code in `start-mailserver.sh` dealing with both the env vars and the configuration files
This commit is contained in:
parent
86ea0bbae1
commit
f28e9843ce
13 changed files with 388 additions and 11 deletions
|
@ -1310,6 +1310,46 @@ load 'test_helper/bats-assert/load'
|
|||
assert_output --partial "You need to specify an IP address. Run"
|
||||
}
|
||||
|
||||
@test "checking setup.sh: setup.sh relay add-domain" {
|
||||
echo -n > ./config/postfix-relaymap.cf
|
||||
./setup.sh -c mail relay add-domain example1.org smtp.relay1.com 2525
|
||||
./setup.sh -c mail relay add-domain example2.org smtp.relay2.com
|
||||
./setup.sh -c mail relay add-domain example3.org smtp.relay3.com 2525
|
||||
./setup.sh -c mail relay add-domain example3.org smtp.relay.com 587
|
||||
|
||||
# check adding
|
||||
run /bin/sh -c 'cat ./config/postfix-relaymap.cf | grep -e "^@example1.org\s\+\[smtp.relay1.com\]:2525" | wc -l | grep 1'
|
||||
assert_success
|
||||
# test default port
|
||||
run /bin/sh -c 'cat ./config/postfix-relaymap.cf | grep -e "^@example2.org\s\+\[smtp.relay2.com\]:25" | wc -l | grep 1'
|
||||
assert_success
|
||||
# test modifying
|
||||
run /bin/sh -c 'cat ./config/postfix-relaymap.cf | grep -e "^@example3.org\s\+\[smtp.relay.com\]:587" | wc -l | grep 1'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking setup.sh: setup.sh relay add-auth" {
|
||||
echo -n > ./config/postfix-sasl-password.cf
|
||||
./setup.sh -c mail relay add-auth example.org smtp_user smtp_pass
|
||||
./setup.sh -c mail relay add-auth example2.org smtp_user2 smtp_pass2
|
||||
./setup.sh -c mail relay add-auth example2.org smtp_user2 smtp_pass_new
|
||||
|
||||
# test adding
|
||||
run /bin/sh -c 'cat ./config/postfix-sasl-password.cf | grep -e "^@example.org\s\+smtp_user:smtp_pass" | wc -l | grep 1'
|
||||
assert_success
|
||||
# test updating
|
||||
run /bin/sh -c 'cat ./config/postfix-sasl-password.cf | grep -e "^@example2.org\s\+smtp_user2:smtp_pass_new" | wc -l | grep 1'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking setup.sh: setup.sh relay exclude-domain" {
|
||||
echo -n > ./config/postfix-relaymap.cf
|
||||
./setup.sh -c mail relay exclude-domain example.org
|
||||
|
||||
run /bin/sh -c 'cat ./config/postfix-relaymap.cf | grep -e "^@example.org\s*$" | wc -l | grep 1'
|
||||
assert_success
|
||||
}
|
||||
|
||||
#
|
||||
# LDAP
|
||||
#
|
||||
|
@ -1617,3 +1657,32 @@ load 'test_helper/bats-assert/load'
|
|||
run docker exec mail_with_ldap /bin/bash -c "pkill saslauthd && sleep 10 && ps aux --forest | grep -v grep | grep '/usr/sbin/saslauthd'"
|
||||
assert_success
|
||||
}
|
||||
|
||||
#
|
||||
# relay hosts
|
||||
#
|
||||
|
||||
@test "checking relay hosts: default mapping is added from env vars" {
|
||||
run docker exec mail_with_relays /bin/sh -c 'cat /etc/postfix/relayhost_map | grep -e "^@domainone.tld\s\+\[default.relay.com\]:2525" | wc -l | grep 1'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking relay hosts: custom mapping is added from file" {
|
||||
run docker exec mail_with_relays /bin/sh -c 'cat /etc/postfix/relayhost_map | grep -e "^@domaintwo.tld\s\+\[other.relay.com\]:587" | wc -l | grep 1'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking relay hosts: ignored domain is not added" {
|
||||
run docker exec mail_with_relays /bin/sh -c 'cat /etc/postfix/relayhost_map | grep -e "^@domainthree.tld\s\+\[any.relay.com\]:25" | wc -l | grep 0'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking relay hosts: auth entry is added" {
|
||||
run docker exec mail_with_relays /bin/sh -c 'cat /etc/postfix/sasl_passwd | grep -e "^@domaintwo.tld\s\+smtp_user_2:smtp_password_2" | wc -l | grep 1'
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "checking relay hosts: default auth entry is added" {
|
||||
run docker exec mail_with_relays /bin/sh -c 'cat /etc/postfix/sasl_passwd | grep -e "^\[default.relay.com\]:2525\s\+smtp_user:smtp_password" | wc -l | grep 1'
|
||||
assert_success
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue