Changeset - b21d839465c4
[Not reviewed]
0 1 0
Branko Majic (branko) - 3 years ago 2020-11-16 20:53:43
branko@majic.rs
MAR-170: Fixed tests for HTTPS enforcment in web_server role:

- Make sure to use local machine's hostname when performing the test.
1 file changed with 6 insertions and 3 deletions:
0 comments (0 inline, 0 general)
roles/web_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general)