From b21d839465c4f2dcf33c62bc5c8b4acaaf9804eb 2020-11-16 20:53:43 From: Branko Majic Date: 2020-11-16 20:53:43 Subject: [PATCH] MAR-170: Fixed tests for HTTPS enforcment in web_server role: - Make sure to use local machine's hostname when performing the test. --- diff --git a/roles/web_server/molecule/default/tests/test_default.py b/roles/web_server/molecule/default/tests/test_default.py index fbfffa675c9628b3e5467ac1e428f2ad990e7bcc..90acc411737422242668eed5cc81fab88f6784d7 100644 --- a/roles/web_server/molecule/default/tests/test_default.py +++ b/roles/web_server/molecule/default/tests/test_default.py @@ -335,13 +335,16 @@ def test_https_enforcement(host): Tests if HTTPS is being enforced. """ - https_enforcement = host.run('curl -I http://parameters-mandatory/') + hostname = host.run('hostname').stdout.strip() + fqdn = hostname[:hostname.rfind('-')] + + https_enforcement = host.run('curl -I http://%s/', fqdn) assert https_enforcement.rc == 0 assert 'HTTP/1.1 301 Moved Permanently' in https_enforcement.stdout - assert 'Location: https://parameters-mandatory/' in https_enforcement.stdout + assert 'Location: https://%s/' % fqdn in https_enforcement.stdout - https_enforcement = host.run('curl -I https://parameters-mandatory/') + https_enforcement = host.run('curl -I https://%s/', fqdn) assert https_enforcement.rc == 0 assert 'Strict-Transport-Security: max-age=31536000; includeSubDomains' in https_enforcement.stdout