2022-11-25 22:37:58 +00:00
|
|
|
load "${REPOSITORY_ROOT}/test/test_helper/common"
|
2019-10-08 20:15:27 +00:00
|
|
|
|
|
|
|
function setup_file() {
|
2022-05-30 00:53:30 +00:00
|
|
|
docker run --rm -d --name mail_smtponly \
|
|
|
|
-v "$(pwd)/test/test-files":/tmp/docker-mailserver-test:ro \
|
|
|
|
-e SMTP_ONLY=1 \
|
|
|
|
-e PERMIT_DOCKER=network \
|
|
|
|
-e OVERRIDE_HOSTNAME=mail.my-domain.com \
|
|
|
|
-t "${NAME}"
|
|
|
|
|
|
|
|
wait_for_finished_setup_in_container mail_smtponly
|
2019-10-08 20:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function teardown_file() {
|
2022-05-30 00:53:30 +00:00
|
|
|
docker rm -f mail_smtponly
|
2019-10-08 20:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# configuration checks
|
|
|
|
#
|
|
|
|
|
|
|
|
@test "checking configuration: hostname/domainname override" {
|
|
|
|
run docker exec mail_smtponly /bin/bash -c "cat /etc/mailname | grep my-domain.com"
|
|
|
|
assert_success
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# imap
|
|
|
|
#
|
|
|
|
|
|
|
|
@test "checking process: dovecot imaplogin (disabled using SMTP_ONLY)" {
|
|
|
|
run docker exec mail_smtponly /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/dovecot'"
|
|
|
|
assert_failure
|
|
|
|
}
|
|
|
|
|
2020-04-24 12:55:32 +00:00
|
|
|
@test "checking configuration: dovecot quota absent in postconf (disabled using SMTP_ONLY)" {
|
|
|
|
run docker exec mail_smtponly /bin/bash -c "postconf | grep 'check_policy_service inet:localhost:65265'"
|
|
|
|
assert_failure
|
|
|
|
}
|
|
|
|
|
2019-10-08 20:15:27 +00:00
|
|
|
#
|
|
|
|
# smtp
|
|
|
|
#
|
|
|
|
|
|
|
|
@test "checking smtp_only: mail send should work" {
|
2022-08-29 11:26:44 +00:00
|
|
|
run docker exec mail_smtponly /bin/sh -c "postconf smtp_host_lookup=no"
|
2019-10-08 20:15:27 +00:00
|
|
|
assert_success
|
|
|
|
run docker exec mail_smtponly /bin/sh -c "/etc/init.d/postfix reload"
|
|
|
|
assert_success
|
2020-11-06 13:11:42 +00:00
|
|
|
|
|
|
|
wait_for_smtp_port_in_container mail_smtponly
|
2019-10-08 20:15:27 +00:00
|
|
|
run docker exec mail_smtponly /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/smtp-only.txt"
|
|
|
|
assert_success
|
|
|
|
run docker exec mail_smtponly /bin/sh -c 'grep -cE "to=<user2\@external.tld>.*status\=sent" /var/log/mail/mail.log'
|
2021-12-19 10:56:22 +00:00
|
|
|
[[ ${status} -ge 0 ]]
|
2019-10-08 20:15:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# PERMIT_DOCKER=network
|
|
|
|
#
|
|
|
|
|
|
|
|
@test "checking PERMIT_DOCKER=network: opendmarc/opendkim config" {
|
|
|
|
run docker exec mail_smtponly /bin/sh -c "cat /etc/opendmarc/ignore.hosts | grep '172.16.0.0/12'"
|
|
|
|
assert_success
|
2022-05-30 00:53:30 +00:00
|
|
|
|
2019-10-08 20:15:27 +00:00
|
|
|
run docker exec mail_smtponly /bin/sh -c "cat /etc/opendkim/TrustedHosts | grep '172.16.0.0/12'"
|
|
|
|
assert_success
|
|
|
|
}
|