diff --git a/Makefile b/Makefile index 01d7ffd6..05029946 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,12 @@ run: -v "`pwd`/test":/tmp/test \ -e ENABLE_POP3=1 \ -h mail.my-domain.com -t $(NAME) + docker run -d --name mail_smtponly \ + -v "`pwd`/postfix":/tmp/postfix \ + -v "`pwd`/spamassassin":/tmp/spamassassin \ + -v "`pwd`/test":/tmp/test \ + -e SMTP_ONLY=1 \ + -h mail.my-domain.com -t $(NAME) # Wait for containers to fully start sleep 60 @@ -47,4 +53,4 @@ clean: # Get default files back git checkout postfix/accounts.cf postfix/virtual # Remove running test containers - docker rm -f mail mail_pop3 \ No newline at end of file + docker rm -f mail mail_pop3 mail_smtponly diff --git a/start-mailserver.sh b/start-mailserver.sh index 43eb12a6..e8668a36 100644 --- a/start-mailserver.sh +++ b/start-mailserver.sh @@ -229,11 +229,15 @@ echo "Starting daemons" cron /etc/init.d/rsyslog start /etc/init.d/saslauthd start + +if [ "$SMTP_ONLY" != 1 ]; then + /etc/init.d/courier-authdaemon start /etc/init.d/courier-imap start /etc/init.d/courier-imap-ssl start -if [ "$ENABLE_POP3" = 1 ]; then +fi +if [ "$ENABLE_POP3" = 1 -a "$SMTP_ONLY" != 1 ]; then echo "Starting POP3 services" /etc/init.d/courier-pop start /etc/init.d/courier-pop-ssl start diff --git a/test/tests.bats b/test/tests.bats index 7eeed0ce..be681fb1 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -47,10 +47,26 @@ [ "$status" -eq 0 ] } +@test "checking process: courierpop3d (disabled using SMTP_ONLY)" { + run docker exec mail_smtponly /bin/bash -c "ps aux --forest | grep -v grep | grep '/usr/lib/courier/courier/courierpop3d'" + [ "$status" -eq 1 ] +} + + # # 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'" + [ "$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'" + [ "$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'" [ "$status" -eq 0 ]