From e57724befd58af3d78dd3ddb39c89bc139fe9fed Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Tue, 16 Aug 2016 19:44:46 +0200 Subject: [PATCH] Refactored. --- Makefile | 9 +-------- test/ENABLE_POP3_0.bats | 9 --------- test/ENABLE_POP3_1.bats | 14 -------------- test/SASL_PASSWD.bats | 43 +++++++++++++++++++++++++++++++++++++++++ test/SASL_PASSWD_0.bats | 4 ---- test/SASL_PASSWD_1.bats | 14 -------------- 6 files changed, 44 insertions(+), 49 deletions(-) delete mode 100644 test/ENABLE_POP3_0.bats delete mode 100644 test/ENABLE_POP3_1.bats create mode 100644 test/SASL_PASSWD.bats delete mode 100644 test/SASL_PASSWD_0.bats delete mode 100644 test/SASL_PASSWD_1.bats diff --git a/Makefile b/Makefile index 6fa91aa7..3979a268 100644 --- a/Makefile +++ b/Makefile @@ -55,15 +55,8 @@ fixtures: tests: # Start tests -# ifdef ENABLE_POP3 -# @echo "ENABLE_POP3 => $(ENABLE_POP3)" -# ./test/bats/bats test/ENABLE_POP3_$(ENABLE_POP3).bats -# endif -# ifdef SASL_PASSWD -# @echo "SASL_PASSWD => $(SASL_PASSWD)" -# ./test/bats/bats test/SASL_PASSWD_$(SASL_PASSWD_).bats -# endif ./test/bats/bats test/ENABLE_POP3.bats + ./test/bats/bats test/SASL_PASSWD.bats clean: # Remove running test container diff --git a/test/ENABLE_POP3_0.bats b/test/ENABLE_POP3_0.bats deleted file mode 100644 index 30229bd1..00000000 --- a/test/ENABLE_POP3_0.bats +++ /dev/null @@ -1,9 +0,0 @@ -@test "checking process: process is not running" { - run docker exec mail /bin/bash -c "ps aux | grep 'dovecot/pop'" - [ "$status" -eq 1 ] -} - -@test "checking pop: server does not respond on port 110" { - run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 110" - [ "$status" -eq 1 ] -} diff --git a/test/ENABLE_POP3_1.bats b/test/ENABLE_POP3_1.bats deleted file mode 100644 index 03eec3b3..00000000 --- a/test/ENABLE_POP3_1.bats +++ /dev/null @@ -1,14 +0,0 @@ -@test "checking pop: process is running" { - run docker exec mail /bin/bash -c "ps aux | grep 'dovecot/pop'" - [ "$status" -eq 0 ] -} - -@test "checking pop: server responds on port 110" { - run docker exec mail /bin/bash -c "nc -w 1 0.0.0.0 110 | grep '+OK'" - [ "$status" -eq 0 ] -} - -@test "checking pop: authentication works" { - run docker exec mail /bin/sh -c "nc -w 1 0.0.0.0 110 < /tmp/docker-mailserver-test/auth/pop3-auth.txt" - [ "$status" -eq 0 ] -} diff --git a/test/SASL_PASSWD.bats b/test/SASL_PASSWD.bats new file mode 100644 index 00000000..ac7111eb --- /dev/null +++ b/test/SASL_PASSWD.bats @@ -0,0 +1,43 @@ +#################################################################################################### +# +# SASL_PASSWD provided +# +#################################################################################################### + +@test "checking sasl: doveadm auth test works with good password" { + if [ -z "$SASL_PASSWD" ]; then + skip + fi + run docker exec mail /bin/sh -c "doveadm auth test -x service=smtp user2@otherdomain.tld mypassword | grep 'auth succeeded'" + [ "$status" -eq 0 ] +} + +@test "checking sasl: doveadm auth test fails with bad password" { + if [ -z "$SASL_PASSWD" ]; then + skip + fi + run docker exec mail /bin/sh -c "doveadm auth test -x service=smtp user2@otherdomain.tld BADPASSWORD | grep 'auth failed'" + [ "$status" -eq 0 ] +} + +@test "checking sasl: sasl_passwd.db exists" { + if [ -z "$SASL_PASSWD" ]; then + skip + fi + run docker exec mail [ -f /etc/postfix/sasl_passwd.db ] + [ "$status" -eq 0 ] +} + +#################################################################################################### +# +# SASL_PASSWD not provided +# +#################################################################################################### + +@test "checking sasl: sasl_passwd.db should not exist" { + if [ -n "$SASL_PASSWD" ]; then + skip + fi + run docker exec mail [ -f /etc/postfix/sasl_passwd.db ] + [ "$status" -eq 1 ] +} diff --git a/test/SASL_PASSWD_0.bats b/test/SASL_PASSWD_0.bats deleted file mode 100644 index 10c2971e..00000000 --- a/test/SASL_PASSWD_0.bats +++ /dev/null @@ -1,4 +0,0 @@ -@test "checking sasl: sasl_passwd.db should not exist" { - run docker exec mail [ -f /etc/postfix/sasl_passwd.db ] - [ "$status" -eq 1 ] -} diff --git a/test/SASL_PASSWD_1.bats b/test/SASL_PASSWD_1.bats deleted file mode 100644 index 7c472850..00000000 --- a/test/SASL_PASSWD_1.bats +++ /dev/null @@ -1,14 +0,0 @@ -@test "checking sasl: doveadm auth test works with good password" { - run docker exec mail /bin/sh -c "doveadm auth test -x service=smtp user2@otherdomain.tld mypassword | grep 'auth succeeded'" - [ "$status" -eq 0 ] -} - -@test "checking sasl: doveadm auth test fails with bad password" { - run docker exec mail /bin/sh -c "doveadm auth test -x service=smtp user2@otherdomain.tld BADPASSWORD | grep 'auth failed'" - [ "$status" -eq 0 ] -} - -@test "checking sasl: sasl_passwd.db exists" { - run docker exec mail [ -f /etc/postfix/sasl_passwd.db ] - [ "$status" -eq 0 ] -}