mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
* Fixes #496 enabling all domains to get spam headers and spam checks (integration tests included)
This commit is contained in:
parent
4e842c75f8
commit
62f6fbbaae
|
@ -77,7 +77,7 @@ COPY target/postfix/ldap-users.cf target/postfix/ldap-groups.cf target/postfix/l
|
||||||
# Enables Spamassassin CRON updates
|
# Enables Spamassassin CRON updates
|
||||||
RUN sed -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin
|
RUN sed -i -r 's/^(CRON)=0/\1=1/g' /etc/default/spamassassin
|
||||||
|
|
||||||
#Enables Postgrey
|
# Enables Postgrey
|
||||||
COPY target/postgrey/postgrey /etc/default/postgrey
|
COPY target/postgrey/postgrey /etc/default/postgrey
|
||||||
COPY target/postgrey/postgrey.init /etc/init.d/postgrey
|
COPY target/postgrey/postgrey.init /etc/init.d/postgrey
|
||||||
RUN chmod 755 /etc/init.d/postgrey
|
RUN chmod 755 /etc/init.d/postgrey
|
||||||
|
@ -86,6 +86,7 @@ RUN chown postgrey:postgrey /var/run/postgrey
|
||||||
|
|
||||||
# Enables Amavis
|
# Enables Amavis
|
||||||
RUN sed -i -r 's/#(@| \\%)bypass/\1bypass/g' /etc/amavis/conf.d/15-content_filter_mode
|
RUN sed -i -r 's/#(@| \\%)bypass/\1bypass/g' /etc/amavis/conf.d/15-content_filter_mode
|
||||||
|
COPY target/amavis/conf.d/60-dms_default_config /etc/amavis/conf.d/
|
||||||
RUN adduser clamav amavis && adduser amavis clamav
|
RUN adduser clamav amavis && adduser amavis clamav
|
||||||
RUN useradd -u 5000 -d /home/docker -s /bin/bash -p $(echo docker | openssl passwd -1 -stdin) docker
|
RUN useradd -u 5000 -d /home/docker -s /bin/bash -p $(echo docker | openssl passwd -1 -stdin) docker
|
||||||
RUN (echo "0 4 * * * /usr/local/bin/virus-wiper" ; crontab -l) | crontab -
|
RUN (echo "0 4 * * * /usr/local/bin/virus-wiper" ; crontab -l) | crontab -
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -24,7 +24,7 @@ run:
|
||||||
-v "`pwd`/test/onedir":/var/mail-state \
|
-v "`pwd`/test/onedir":/var/mail-state \
|
||||||
-e ENABLE_CLAMAV=1 \
|
-e ENABLE_CLAMAV=1 \
|
||||||
-e ENABLE_SPAMASSASSIN=1 \
|
-e ENABLE_SPAMASSASSIN=1 \
|
||||||
-e SA_TAG=1.0 \
|
-e SA_TAG=-5.0 \
|
||||||
-e SA_TAG2=2.0 \
|
-e SA_TAG2=2.0 \
|
||||||
-e SA_KILL=3.0 \
|
-e SA_KILL=3.0 \
|
||||||
-e VIRUSMAILS_DELETE_DELAY=7 \
|
-e VIRUSMAILS_DELETE_DELAY=7 \
|
||||||
|
@ -150,18 +150,19 @@ fixtures:
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-external.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-external.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-local.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-local.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-recipient-delimiter.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-alias-recipient-delimiter.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||||
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user2.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user-and-cc-local-alias.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user-and-cc-local-alias.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-regexp-alias-external.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-regexp-alias-external.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-regexp-alias-local.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-regexp-alias-local.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-catchall-local.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-catchall-local.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/sieve-spam-folder.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/sieve-spam-folder.txt"
|
||||||
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/non-existing-user.txt"
|
docker exec mail /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/non-existing-user.txt"
|
||||||
docker exec mail_disabled_clamav_spamassassin /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt"
|
docker exec mail_disabled_clamav_spamassassin /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||||
# postfix virtual transport lmtp
|
# postfix virtual transport lmtp
|
||||||
docker exec mail_lmtp_ip /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt"
|
docker exec mail_lmtp_ip /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||||
|
|
||||||
docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user.txt"
|
docker exec mail_override_hostname /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/existing-user1.txt"
|
||||||
# Wait for mails to be analyzed
|
# Wait for mails to be analyzed
|
||||||
sleep 20
|
sleep 20
|
||||||
|
|
||||||
|
|
7
target/amavis/conf.d/60-dms_default_config
Normal file
7
target/amavis/conf.d/60-dms_default_config
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
@local_domains_maps = (
|
||||||
|
read_hash('/etc/postfix/vhost')
|
||||||
|
);
|
||||||
|
|
||||||
|
1; # ensure a defined return
|
|
@ -860,7 +860,7 @@ function _setup_security_stack() {
|
||||||
notify 'task' "Setting up Security Stack"
|
notify 'task' "Setting up Security Stack"
|
||||||
|
|
||||||
# recreate auto-generated file
|
# recreate auto-generated file
|
||||||
dms_amavis_file="/etc/amavis/conf.d/51-dms_auto_generated"
|
dms_amavis_file="/etc/amavis/conf.d/61-dms_auto_generated"
|
||||||
echo "# WARNING: this file is auto-generated." > $dms_amavis_file
|
echo "# WARNING: this file is auto-generated." > $dms_amavis_file
|
||||||
echo "use strict;" >> $dms_amavis_file
|
echo "use strict;" >> $dms_amavis_file
|
||||||
|
|
||||||
|
|
12
test/email-templates/existing-user2.txt
Normal file
12
test/email-templates/existing-user2.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
HELO mail.external.tld
|
||||||
|
MAIL FROM: user@external.tld
|
||||||
|
RCPT TO: user2@otherdomain.tld
|
||||||
|
DATA
|
||||||
|
From: Docker Mail Server <dockermailserver@external.tld>
|
||||||
|
To: Existing Local User <user2@otherdomain.tld>
|
||||||
|
Date: Sat, 22 May 2010 07:43:25 -0400
|
||||||
|
Subject: Test Message
|
||||||
|
This is a test mail.
|
||||||
|
|
||||||
|
.
|
||||||
|
QUIT
|
|
@ -271,7 +271,7 @@ load 'test_helper/bats-assert/load'
|
||||||
@test "checking smtp: delivers mail to existing account" {
|
@test "checking smtp: delivers mail to existing account" {
|
||||||
run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | wc -l"
|
run docker exec mail /bin/sh -c "grep 'postfix/lmtp' /var/log/mail/mail.log | grep 'status=sent' | grep ' Saved)' | wc -l"
|
||||||
assert_success
|
assert_success
|
||||||
assert_output 7
|
assert_output 8
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking smtp: delivers mail to existing alias" {
|
@test "checking smtp: delivers mail to existing alias" {
|
||||||
|
@ -414,7 +414,7 @@ load 'test_helper/bats-assert/load'
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "checking spamassassin: docker env variables are set correctly (custom)" {
|
@test "checking spamassassin: docker env variables are set correctly (custom)" {
|
||||||
run docker exec mail /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 1.0'"
|
run docker exec mail /bin/sh -c "grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= -5.0'"
|
||||||
assert_success
|
assert_success
|
||||||
run docker exec mail /bin/sh -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
run docker exec mail /bin/sh -c "grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'"
|
||||||
assert_success
|
assert_success
|
||||||
|
@ -422,6 +422,14 @@ load 'test_helper/bats-assert/load'
|
||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "checking spamassassin: all registered domains should see spam headers" {
|
||||||
|
run docker exec mail /bin/sh -c "grep -ir 'X-Spam-' /var/mail/localhost.localdomain/user1/new"
|
||||||
|
assert_success
|
||||||
|
run docker exec mail /bin/sh -c "grep -ir 'X-Spam-' /var/mail/otherdomain.tld/user2/new"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# clamav
|
# clamav
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue