diff --git a/Makefile b/Makefile index 422a653e..4439fa31 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,10 @@ ifdef ENABLE_POP3 @echo "ENABLE_POP3 => $(ENABLE_POP3)" ./test/bats/bats test/ENABLE_POP3.bats endif +ifdef SASL_PASSWD + @echo "SASL_PASSWD => $(SASL_PASSWD)" + ./test/bats/bats test/SASL_PASSWD.bats +endif clean: # Remove running test container diff --git a/test/SASL_PASSWD.bats b/test/SASL_PASSWD.bats new file mode 100644 index 00000000..e01cc2f0 --- /dev/null +++ b/test/SASL_PASSWD.bats @@ -0,0 +1,29 @@ +@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'" + + if [ -n "$SASL_PASSWD" ]; then + [ "$status" -eq 0 ] + else + [ "$status" -eq 1 ] + fi +} + +@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'" + + if [ -n "$SASL_PASSWD" ]; then + [ "$status" -eq 0 ] + else + [ "$status" -eq 1 ] + fi +} + +@test "checking sasl: sasl_passwd.db exists" { + run docker exec mail [ -f /etc/postfix/sasl_passwd.db ] + + if [ -n "$SASL_PASSWD" ]; then + [ "$status" -eq 0 ] + else + [ "$status" -eq 1 ] + fi +} diff --git a/test/tests.bats b/test/tests.bats index fe8b9b07..27cbf331 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -84,29 +84,6 @@ fi [ "$status" -eq 0 ] } -# -# sasl -# - -if [ $SASL_PASSWD == "external-domain.com username:password" ]; then - - @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 ] - } - -fi - # # logs #