From 349b0523d9daf7119571fc1da7a84540984fee7c 2021-01-12 21:35:48 From: Branko Majic Date: 2021-01-12 21:35:48 Subject: [PATCH] MAR-163: Deduplicate test for certificate validity check configuration in mail_server role: - Tests are already identical, they were probably kept separate by mistake. --- diff --git a/roles/mail_server/molecule/default/tests/test_default.py b/roles/mail_server/molecule/default/tests/test_default.py index a5b326464d00b337affc86214325e78c8ff31802..a33dffced78cc85db3c081b8c361bc80627b909b 100644 --- a/roles/mail_server/molecule/default/tests/test_default.py +++ b/roles/mail_server/molecule/default/tests/test_default.py @@ -562,3 +562,26 @@ def test_postfix_sends_mails_over_tls_when_available(host): pattern = r"postfix/smtp\[\d+\]: %s: to=, relay=smtp-server-requiring-tls.*, status=sent" % queue_id match_result = re.search(pattern, mail_log.content_string) assert match_result is not None, queue_id + + +def test_certificate_validity_check_configuration(host): + """ + Tests if certificate validity check configuration file has been deployed + correctly. + """ + + hostname = host.run('hostname').stdout.strip() + + config = host.file('/etc/check_certificate/%s_smtp.conf' % hostname) + assert config.is_file + assert config.user == 'root' + assert config.group == 'root' + assert config.mode == 0o644 + assert config.content_string == "/etc/ssl/certs/%s_smtp.pem" % hostname + + config = host.file('/etc/check_certificate/%s_imap.conf' % hostname) + assert config.is_file + assert config.user == 'root' + assert config.group == 'root' + assert config.mode == 0o644 + assert config.content_string == "/etc/ssl/certs/%s_imap.pem" % hostname diff --git a/roles/mail_server/molecule/default/tests/test_mandatory.py b/roles/mail_server/molecule/default/tests/test_mandatory.py index 2d70358d9df57a9817fe10e5873bc5f8146ff83b..85998b126fdeaaee07b53c638999009ff6f41ceb 100644 --- a/roles/mail_server/molecule/default/tests/test_mandatory.py +++ b/roles/mail_server/molecule/default/tests/test_mandatory.py @@ -11,29 +11,6 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-mandatory') -def test_certificate_validity_check_configuration(host): - """ - Tests if certificate validity check configuration file has been deployed - correctly. - """ - - hostname = host.run('hostname').stdout.strip() - - config = host.file('/etc/check_certificate/%s_smtp.conf' % hostname) - assert config.is_file - assert config.user == 'root' - assert config.group == 'root' - assert config.mode == 0o644 - assert config.content_string == "/etc/ssl/certs/%s_smtp.pem" % hostname - - config = host.file('/etc/check_certificate/%s_imap.conf' % hostname) - assert config.is_file - assert config.user == 'root' - assert config.group == 'root' - assert config.mode == 0o644 - assert config.content_string == "/etc/ssl/certs/%s_imap.pem" % hostname - - def test_mailname_file_content(host): """ Tests the system mail name file content. diff --git a/roles/mail_server/molecule/default/tests/test_optional.py b/roles/mail_server/molecule/default/tests/test_optional.py index 4fd6e1eda3f02fb88b4079c58ada9d42d58b6874..405fa457e7a34347e023125e10f74d66519ba1b1 100644 --- a/roles/mail_server/molecule/default/tests/test_optional.py +++ b/roles/mail_server/molecule/default/tests/test_optional.py @@ -14,29 +14,6 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-optional') -def test_certificate_validity_check_configuration(host): - """ - Tests if certificate validity check configuration file has been deployed - correctly. - """ - - hostname = host.run('hostname').stdout.strip() - - config = host.file('/etc/check_certificate/%s_smtp.conf' % hostname) - assert config.is_file - assert config.user == 'root' - assert config.group == 'root' - assert config.mode == 0o644 - assert config.content_string == "/etc/ssl/certs/%s_smtp.pem" % hostname - - config = host.file('/etc/check_certificate/%s_imap.conf' % hostname) - assert config.is_file - assert config.user == 'root' - assert config.group == 'root' - assert config.mode == 0o644 - assert config.content_string == "/etc/ssl/certs/%s_imap.pem" % hostname - - def test_mailname_file_content(host): """ Tests the system mail name file content.