diff --git a/roles/mail_forwarder/molecule/default/tests/test_default.py b/roles/mail_forwarder/molecule/default/tests/test_default.py index 0a33b106ca3b33d7ab85d7576cab5a9b38bcfb39..397fd500065cc4dcad49846b79c2c249fb7a9e18 100644 --- a/roles/mail_forwarder/molecule/default/tests/test_default.py +++ b/roles/mail_forwarder/molecule/default/tests/test_default.py @@ -1,4 +1,5 @@ import os +import re import testinfra.utils.ansible_runner @@ -64,6 +65,22 @@ def test_postfix_main_cf_file(host): assert config.mode == 0o644 +def test_postfix_main_configuration_is_valid(host): + """ + Tests if Postfix main configuration is valid and not producing any + warnings. + """ + + postconf = host.run('/usr/sbin/postconf') + + # Clean-up the SSH warning from the beginning of stderr if + # present. + stderr = re.sub("^Warning: Permanently added.*?\r\n", "", postconf.stderr) + + assert postconf.rc == 0 + assert stderr == "" + + def test_services(host): """ Tests if all the necessary services are enabled and running.