Fixed tests for #143

This commit is contained in:
Thomas VIAL 2016-04-21 12:15:34 +02:00
parent f5f6637233
commit bc7b42e4bc
2 changed files with 7 additions and 10 deletions

View file

@ -1,5 +1,4 @@
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) NAME = tvial/docker-mailserver:testing
NAME = tvial/docker-mailserver:$(BRANCH)
all: build-no-cache run fixtures tests clean all: build-no-cache run fixtures tests clean
all-fast: build run fixtures tests clean all-fast: build run fixtures tests clean
@ -51,7 +50,7 @@ fixtures:
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-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 /bin/sh -c "nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/non-existing-user.txt"
# Wait for mails to be analyzed # Wait for mails to be analyzed
sleep 10 sleep 20
tests: tests:
# Start tests # Start tests
@ -60,4 +59,3 @@ tests:
clean: clean:
# Remove running test containers # Remove running test containers
docker rm -f mail mail_pop3 mail_smtponly mail_fail2ban fail-auth-mailer docker rm -f mail mail_pop3 mail_smtponly mail_fail2ban fail-auth-mailer
rm -rf "$(pwd)/test/config/empty" && mkdir -p "$(pwd)/test/config/empty"

View file

@ -255,28 +255,27 @@
-v "$(pwd)/test/config/empty/":/tmp/docker-mailserver/ \ -v "$(pwd)/test/config/empty/":/tmp/docker-mailserver/ \
-v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \ -v "$(pwd)/test/config/postfix-accounts.cf":/tmp/docker-mailserver/postfix-accounts.cf \
-v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \ -v "$(pwd)/test/config/postfix-virtual.cf":/tmp/docker-mailserver/postfix-virtual.cf \
tvial/docker-mailserver:v2 /bin/sh -c 'generate-dkim-config | wc -l' tvial/docker-mailserver:testing /bin/sh -c 'generate-dkim-config | wc -l'
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" -eq 5 ] [ "$output" -eq 5 ]
# Check keys for localhost.localdomain # Check keys for localhost.localdomain
run docker run --rm \ run docker run --rm \
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \ -v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
tvial/docker-mailserver:v2 /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l' tvial/docker-mailserver:testing /bin/sh -c 'ls -1 /etc/opendkim/keys/localhost.localdomain/ | wc -l'
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" -eq 2 ] [ "$output" -eq 2 ]
# Check keys for otherdomain.tld # Check keys for otherdomain.tld
run docker run --rm \ run docker run --rm \
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \ -v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
tvial/docker-mailserver:v2 /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l' tvial/docker-mailserver:testing /bin/sh -c 'ls -1 /etc/opendkim/keys/otherdomain.tld | wc -l'
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" -eq 2 ] [ "$output" -eq 2 ]
# Check presence of tables and TrustedHosts # Check presence of tables and TrustedHosts
run docker run --rm \ run docker run --rm \
-v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \ -v "$(pwd)/test/config/empty/opendkim":/etc/opendkim \
tvial/docker-mailserver:v2 /bin/sh -c "ls -1 etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l" tvial/docker-mailserver:testing /bin/sh -c "ls -1 etc/opendkim | grep -E 'KeyTable|SigningTable|TrustedHosts|keys'|wc -l"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" -eq 4 ] [ "$output" -eq 4 ]
rm -rf "$(pwd)/test/config/empty" && mkdir -p "$(pwd)/test/config/empty"
} }
# #
@ -333,7 +332,7 @@
# Getting mail_fail2ban container IP # Getting mail_fail2ban container IP
MAIL_FAIL2BAN_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' mail_fail2ban) MAIL_FAIL2BAN_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' mail_fail2ban)
# Create a container which will send wront authentications and should banned # Create a container which will send wront authentications and should banned
docker run --name fail-auth-mailer -e MAIL_FAIL2BAN_IP=$MAIL_FAIL2BAN_IP -v "$(pwd)/test":/tmp/docker-mailserver-test -d tvial/docker-mailserver:v2 tail -f /var/log/faillog docker run --name fail-auth-mailer -e MAIL_FAIL2BAN_IP=$MAIL_FAIL2BAN_IP -v "$(pwd)/test":/tmp/docker-mailserver-test -d tvial/docker-mailserver:testing tail -f /var/log/faillog
docker exec fail-auth-mailer /bin/sh -c 'nc $MAIL_FAIL2BAN_IP 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt' docker exec fail-auth-mailer /bin/sh -c 'nc $MAIL_FAIL2BAN_IP 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt'
docker exec fail-auth-mailer /bin/sh -c 'nc $MAIL_FAIL2BAN_IP 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt' docker exec fail-auth-mailer /bin/sh -c 'nc $MAIL_FAIL2BAN_IP 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt'
docker exec fail-auth-mailer /bin/sh -c 'nc $MAIL_FAIL2BAN_IP 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt' docker exec fail-auth-mailer /bin/sh -c 'nc $MAIL_FAIL2BAN_IP 25 < /tmp/docker-mailserver-test/auth/smtp-auth-login-wrong.txt'