From d6f9ffe9a6eefdfbb8a8d78bd3fb6f99dbda9575 Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Wed, 13 Apr 2016 23:16:46 +0200 Subject: [PATCH] Fixed some tests for #109 --- target/start-mailserver.sh | 3 ++- test/tests.bats | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index e7012ea9..0a05db27 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -322,7 +322,7 @@ cron if [ "$SMTP_ONLY" != 1 ]; then # Here we are starting sasl and imap, not pop3 because it's disabled by default echo " * Starting dovecot services" - /usr/sbin/dovecot -F -c /etc/dovecot/dovecot.conf & + /usr/sbin/dovecot -c /etc/dovecot/dovecot.conf fi if [ "$ENABLE_POP3" = 1 -a "$SMTP_ONLY" != 1 ]; then @@ -340,6 +340,7 @@ fi if [ "$ENABLE_FAIL2BAN" = 1 ]; then echo "Starting fail2ban service" + touch /var/log/auth.log /etc/init.d/fail2ban start fi diff --git a/test/tests.bats b/test/tests.bats index 58a381c7..b2ec5176 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -41,23 +41,23 @@ # imap # -@test "checking process: courier imaplogin (enabled in default configuration)" { - run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/lib/courier/courier/imaplogin'" +@test "checking process: dovecot imaplogin (enabled in default configuration)" { + run docker exec mail /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/sbin/dovecot'" [ "$status" -eq 0 ] } -@test "checking process: courier imaplogin (disabled using SMTP_ONLY)" { - run docker exec mail_smtponly /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/lib/courier/courier/imaplogin'" +@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'" [ "$status" -eq 1 ] } @test "checking imap: server is ready with STARTTLS" { - run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 143 | grep '* OK' | grep 'STARTTLS' | grep 'Courier-IMAP ready'" + run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 143 | grep '* OK' | grep 'STARTTLS' | grep 'ready'" [ "$status" -eq 0 ] } @test "checking imap: authentication works" { - run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/test/auth/imap-auth.txt" + run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 143 < /tmp/docker-mailserver/test/auth/imap-auth.txt" [ "$status" -eq 0 ] } @@ -71,7 +71,7 @@ } @test "checking pop: authentication works" { - run docker exec mail_pop3 /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/test/auth/pop3-auth.txt" + run docker exec mail_pop3 /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver/test/auth/pop3-auth.txt" [ "$status" -eq 0 ] } @@ -109,22 +109,22 @@ # @test "checking smtp: authentication works with good password (plain)" { - run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 25 < /tmp/test/auth/smtp-auth-plain.txt | grep 'Authentication successful'" + run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 25 < /tmp/docker-mailserver/test/auth/smtp-auth-plain.txt | grep 'Authentication successful'" [ "$status" -eq 0 ] } @test "checking smtp: authentication fails with wrong password (plain)" { - run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 25 < /tmp/test/auth/smtp-auth-plain-wrong.txt | grep 'authentication failed'" + run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 25 < /tmp/docker-mailserver/test/auth/smtp-auth-plain-wrong.txt | grep 'authentication failed'" [ "$status" -eq 0 ] } @test "checking smtp: authentication works with good password (login)" { - run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 25 < /tmp/test/auth/smtp-auth-login.txt | grep 'Authentication successful'" + run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 25 < /tmp/docker-mailserver/test/auth/smtp-auth-login.txt | grep 'Authentication successful'" [ "$status" -eq 0 ] } @test "checking smtp: authentication fails with wrong password (login)" { - run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 25 < /tmp/test/auth/smtp-auth-login-wrong.txt | grep 'authentication failed'" + run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 25 < /tmp/docker-mailserver/test/auth/smtp-auth-login-wrong.txt | grep 'authentication failed'" [ "$status" -eq 0 ] } @@ -312,9 +312,9 @@ @test "checking fail2ban: ban ip on multiple failed login" { docker exec mail_fail2ban fail2ban-client status sasl docker exec mail_fail2ban fail2ban-client set sasl delignoreip 127.0.0.1/8 - docker exec mail_fail2ban /bin/sh -c 'nc -w 1 0.0.0.0 25 < /tmp/test/auth/smtp-auth-login-wrong.txt' - docker exec mail_fail2ban /bin/sh -c 'nc -w 1 0.0.0.0 25 < /tmp/test/auth/smtp-auth-login-wrong.txt' - docker exec mail_fail2ban /bin/sh -c 'nc -w 1 0.0.0.0 25 < /tmp/test/auth/smtp-auth-login-wrong.txt' + docker exec mail_fail2ban /bin/sh -c 'nc -w 1 0.0.0.0 25 < /tmp/docker-mailserver/test/auth/smtp-auth-login-wrong.txt' + docker exec mail_fail2ban /bin/sh -c 'nc -w 1 0.0.0.0 25 < /tmp/docker-mailserver/test/auth/smtp-auth-login-wrong.txt' + docker exec mail_fail2ban /bin/sh -c 'nc -w 1 0.0.0.0 25 < /tmp/docker-mailserver/test/auth/smtp-auth-login-wrong.txt' sleep 5 run docker exec mail_fail2ban /bin/sh -c "fail2ban-client status sasl | grep 'IP list:.*127.0.0.1'" [ "$status" -eq 0 ]