Fix for #24 + some new integration tests

This commit is contained in:
Bojan Čekrlić 2020-07-01 14:12:04 +02:00
parent ff2d080279
commit c460941b90
4 changed files with 50 additions and 3 deletions

View file

@ -24,4 +24,7 @@ services:
- "../tester:/code"
build:
context: ../tester
command: "/"
command: "/"
environment:
FROM: "demo@example.org"
TO: "test@gmail.com"

View file

@ -0,0 +1,32 @@
version: '3.7'
services:
postfix_test_587:
hostname: "postfix"
image: "boky/postfix"
build:
context: ../..
restart: always
healthcheck:
test: [ "CMD", "sh", "-c", "netstat -an | fgrep 587 | fgrep -q LISTEN" ]
interval: 10s
timeout: 5s
start_period: 10s
retries: 2
environment:
MASQUERADED_DOMAINS: "postfix"
ALLOWED_SENDER_DOMAINS: ""
ALLOW_EMPTY_SENDER_DOMAINS: "true"
POSTFIX_smtpd_end_of_data_restrictions: "check_client_access static:discard"
LOG_FORMAT: "json"
tests:
image: "boky/postfix-integration-test"
restart: "no"
volumes:
- "../tester:/code"
build:
context: ../tester
command: "/"
environment:
FROM: "demo@example.org"
TO: "test@gmail.com"
SKIP_INVALID_DOMAIN_SEND: "1"

View file

@ -37,3 +37,17 @@ SMTP_DATA="-smtp postfix_test_587 -port 587"
attach \
-file "/usr/local/bin/mailsend"
}
@test "Send mail from non-supported sender" {
if [[ "$SKIP_INVALID_DOMAIN_SEND" == "1" ]]; then
skip
fi
if mailsend \
-sub "Test email 1" $SMTP_DATA \
-from "test@gmail.com" -to "$TO" \
body \
-msg "Hello world!\nThis is a simple test message!"; then
return 1
fi
}

View file

@ -166,8 +166,6 @@ postfix_setup_sender_domains() {
echo
postmap $allowed_senders
postconf -e "smtpd_restriction_classes=allowed_domains_only"
postconf -e "allowed_domains_only=permit_mynetworks, reject_non_fqdn_sender reject"
postconf -e "smtpd_recipient_restrictions=reject_non_fqdn_recipient, reject_unknown_recipient_domain, check_sender_access hash:$allowed_senders, reject"
# Since we are behind closed doors, let's just permit all relays.