diff --git a/roles/mail_server/molecule/default/tests/test_default.py b/roles/mail_server/molecule/default/tests/test_default.py index eae90d8f1bdefe6ada514d620d544c5667eaaf75..c4f7547a7693bb517f656fd99e0ad8be1318036c 100644 --- a/roles/mail_server/molecule/default/tests/test_default.py +++ b/roles/mail_server/molecule/default/tests/test_default.py @@ -447,3 +447,38 @@ def test_imap_and_smtp_tls_files(host): assert tls_file.group == 'root' assert tls_file.mode == 0o644 assert tls_file.content_string == open("tests/data/x509/server/%s_imap.cert.pem" % hostname, "r").read().rstrip() + + +def test_imap_tls_connectivity(host): + """ + Tests connectivity over STARTTLS/TLS towards IMAP server. + """ + + hostname = host.run('hostname').stdout.strip() + fqdn = hostname[:hostname.rfind("-")] + + starttls = host.run('echo "a0001 LOGOUT" | openssl s_client -quiet -starttls imap -connect %s:143', fqdn) + assert starttls.rc == 0 + assert '* BYE Logging out' in starttls.stdout + + tls = host.run('echo "a0001 LOGOUT" | openssl s_client -quiet -connect %s:993', fqdn) + assert tls.rc == 0 + assert '* BYE Logging out' in starttls.stdout + + +def test_smtp_tls_connectivity(host): + """ + Tests connectivity over default/submission port towards SMTP + server. + """ + + hostname = host.run('hostname').stdout.strip() + fqdn = hostname[:hostname.rfind("-")] + + starttls = host.run('echo "QUIT" | openssl s_client -quiet -starttls smtp -connect %s:25', fqdn) + assert starttls.rc == 0 + assert '221 2.0.0 Bye' in starttls.stdout + + tls = host.run('echo "QUIT" | openssl s_client -quiet -starttls smtp -connect %s:587', fqdn) + assert tls.rc == 0 + assert '221 2.0.0 Bye' in starttls.stdout diff --git a/roles/mail_server/molecule/default/tests/test_mandatory.py b/roles/mail_server/molecule/default/tests/test_mandatory.py index 5f93602e03456878893608d414cf053f557aeb78..a2de012ed40728d88e5442ce9e49c8c19d8df603 100644 --- a/roles/mail_server/molecule/default/tests/test_mandatory.py +++ b/roles/mail_server/molecule/default/tests/test_mandatory.py @@ -110,20 +110,6 @@ def test_mail_owner(host): assert user.groups == ["vmail"] -def test_imap_tls_connectivity(host): - """ - Tests connectivity over STARTTLS/TLS towards IMAP server. - """ - - starttls = host.run('echo "a0001 LOGOUT" | openssl s_client -quiet -starttls imap -connect parameters-mandatory:143') - assert starttls.rc == 0 - assert '* BYE Logging out' in starttls.stdout - - tls = host.run('echo "a0001 LOGOUT" | openssl s_client -quiet -connect parameters-mandatory:993') - assert tls.rc == 0 - assert '* BYE Logging out' in starttls.stdout - - @pytest.mark.parametrize("port", [ 143, 993, @@ -194,21 +180,6 @@ def test_imap_max_user_connections_per_ip(host): assert " mail_max_userip_connections = 10" in config.stdout -def test_smtp_tls_connectivity(host): - """ - Tests connectivity over default/submission port towards SMTP - server. - """ - - starttls = host.run('echo "QUIT" | openssl s_client -quiet -starttls smtp -connect parameters-mandatory:25') - assert starttls.rc == 0 - assert '221 2.0.0 Bye' in starttls.stdout - - tls = host.run('echo "QUIT" | openssl s_client -quiet -starttls smtp -connect parameters-mandatory:587') - assert tls.rc == 0 - assert '221 2.0.0 Bye' in starttls.stdout - - def test_smtp_default_port_tls_version_and_ciphers(host): """ Tests TLS configuration for SMTP default port (needs to be less diff --git a/roles/mail_server/molecule/default/tests/test_optional.py b/roles/mail_server/molecule/default/tests/test_optional.py index e562d7fcee637adc541956c4c0a4a160c54f25a0..0f3cf0d2e35677e6c981cc137ff28a48daa3c7d8 100644 --- a/roles/mail_server/molecule/default/tests/test_optional.py +++ b/roles/mail_server/molecule/default/tests/test_optional.py @@ -133,20 +133,6 @@ def test_mail_owner(host): assert user.groups == ["virtmail"] -def test_imap_tls_connectivity(host): - """ - Tests connectivity over STARTTLS/TLS towards IMAP server. - """ - - starttls = host.run('echo "a0001 LOGOUT" | openssl s_client -quiet -starttls imap -connect parameters-optional:143') - assert starttls.rc == 0 - assert '* BYE Logging out' in starttls.stdout - - tls = host.run('echo "a0001 LOGOUT" | openssl s_client -quiet -connect parameters-optional:993') - assert tls.rc == 0 - assert '* BYE Logging out' in starttls.stdout - - @pytest.mark.parametrize("port", [ 143, 993, @@ -221,21 +207,6 @@ def test_imap_max_user_connections_per_ip(host): assert " mail_max_userip_connections = 2" in config.stdout -def test_smtp_tls_connectivity(host): - """ - Tests connectivity over default/submission port towards SMTP - server. - """ - - starttls = host.run('echo "QUIT" | openssl s_client -quiet -starttls smtp -connect parameters-optional:25') - assert starttls.rc == 0 - assert '221 2.0.0 Bye' in starttls.stdout - - tls = host.run('echo "QUIT" | openssl s_client -quiet -starttls smtp -connect parameters-optional:587') - assert tls.rc == 0 - assert '221 2.0.0 Bye' in starttls.stdout - - def test_smtp_default_port_tls_version_and_ciphers(host): """ Tests TLS configuration for SMTP default port (needs to be less