diff --git a/roles/web_server/molecule/default/tests/test_default.py b/roles/web_server/molecule/default/tests/test_default.py index c3de34533f6cf3e7b2a16db596a65de63f68ecab..c86a1b2f100f099410a9d630f66fbede111f0711 100644 --- a/roles/web_server/molecule/default/tests/test_default.py +++ b/roles/web_server/molecule/default/tests/test_default.py @@ -276,3 +276,27 @@ def test_https_server_uses_correct_dh_parameters(host): used_dhparam = output[output.find(begin_marker):output.find(end_marker) + len(end_marker)] assert used_dhparam == expected_dhparam + + +def test_nginx_tls_files(host): + """ + Tests if TLS private key and certificate have been deployed correctly. + """ + + hostname = host.run('hostname').stdout.strip() + + with host.sudo(): + + tls_file = host.file('/etc/ssl/private/%s_https.key' % hostname) + assert tls_file.is_file + assert tls_file.user == 'root' + assert tls_file.group == 'root' + assert tls_file.mode == 0o640 + assert tls_file.content_string == open("tests/data/x509/%s_https.key.pem" % hostname, "r").read().rstrip() + + tls_file = host.file('/etc/ssl/certs/%s_https.pem' % hostname) + assert tls_file.is_file + assert tls_file.user == 'root' + assert tls_file.group == 'root' + assert tls_file.mode == 0o644 + assert tls_file.content_string == open("tests/data/x509/%s_https.cert.pem" % hostname, "r").read().rstrip() diff --git a/roles/web_server/molecule/default/tests/test_mandatory.py b/roles/web_server/molecule/default/tests/test_mandatory.py index a94c9e8a6b248bb4fa40c58ce91e9ae334c2e058..c09ed9f14607d3c0648d1ec8664578be2dce26df 100644 --- a/roles/web_server/molecule/default/tests/test_mandatory.py +++ b/roles/web_server/molecule/default/tests/test_mandatory.py @@ -7,30 +7,6 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-mandatory') -def test_nginx_tls_files(host): - """ - Tests if TLS private key and certificate have been deployed correctly. - """ - - hostname = host.run('hostname').stdout.strip() - - with host.sudo(): - - tls_file = host.file('/etc/ssl/private/%s_https.key' % hostname) - assert tls_file.is_file - assert tls_file.user == 'root' - assert tls_file.group == 'root' - assert tls_file.mode == 0o640 - assert tls_file.content_string == open("tests/data/x509/%s_https.key.pem" % hostname, "r").read().rstrip() - - tls_file = host.file('/etc/ssl/certs/%s_https.pem' % hostname) - assert tls_file.is_file - assert tls_file.user == 'root' - assert tls_file.group == 'root' - assert tls_file.mode == 0o644 - assert tls_file.content_string == open("tests/data/x509/%s_https.cert.pem" % hostname, "r").read().rstrip() - - def test_certificate_validity_check_configuration(host): """ Tests if certificate validity check configuration file has been deployed diff --git a/roles/web_server/molecule/default/tests/test_optional.py b/roles/web_server/molecule/default/tests/test_optional.py index 00cb4e637284e996178bb8a8f9bbc71560ed2cf3..502c6f0a34334284cda49ad39384f2a2f42ee0f4 100644 --- a/roles/web_server/molecule/default/tests/test_optional.py +++ b/roles/web_server/molecule/default/tests/test_optional.py @@ -7,30 +7,6 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-optional') -def test_nginx_tls_files(host): - """ - Tests if TLS private key and certificate have been deployed correctly. - """ - - hostname = host.run('hostname').stdout.strip() - - with host.sudo(): - - tls_file = host.file('/etc/ssl/private/%s_https.key' % hostname) - assert tls_file.is_file - assert tls_file.user == 'root' - assert tls_file.group == 'root' - assert tls_file.mode == 0o640 - assert tls_file.content_string == open("tests/data/x509/%s_https.key.pem" % hostname, "r").read().rstrip() - - tls_file = host.file('/etc/ssl/certs/%s_https.pem' % hostname) - assert tls_file.is_file - assert tls_file.user == 'root' - assert tls_file.group == 'root' - assert tls_file.mode == 0o644 - assert tls_file.content_string == open("tests/data/x509/%s_https.cert.pem" % hostname, "r").read().rstrip() - - def test_certificate_validity_check_configuration(host): """ Tests if certificate validity check configuration file has been deployed