Changeset - 349b0523d9da
[Not reviewed]
0 3 0
Branko Majic (branko) - 3 years ago 2021-01-12 21:35:48
branko@majic.rs
MAR-163: Deduplicate test for certificate validity check configuration in mail_server role:

- Tests are already identical, they were probably kept separate by
mistake.
3 files changed with 23 insertions and 46 deletions:
0 comments (0 inline, 0 general)
roles/mail_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -562,3 +562,26 @@ def test_postfix_sends_mails_over_tls_when_available(host):
 
        pattern = r"postfix/smtp\[\d+\]: %s: to=<root@smtp-server-requiring-tls>, 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
roles/mail_server/molecule/default/tests/test_mandatory.py
Show inline comments
 
@@ -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.
roles/mail_server/molecule/default/tests/test_optional.py
Show inline comments
 
@@ -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.
0 comments (0 inline, 0 general)