Changeset - 2c31a37b0ff2
[Not reviewed]
0 3 0
Branko Majic (branko) - 10 months ago 2025-02-03 14:52:19
branko@majic.rs
MAR-243: Drop inventory hostname usage from web_server tests.
3 files changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
roles/web_server/molecule/default/tests/test_default.py
Show inline comments
 
@@ -339,24 +339,24 @@ def test_certificate_validity_check_configuration(host):
 

	
 
def test_tls_enabled(host):
 
    """
 
    Tests if TLS has been enabled.
 
    """
 

	
 
    hostname = host.ansible.get_variables()['inventory_hostname']
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    tls = host.run('curl https://%s/', hostname)
 
    assert tls.rc == 0
 

	
 

	
 
def test_https_enforcement(host):
 
    """
 
    Tests if HTTPS is being enforced.
 
    """
 

	
 
    hostname = host.ansible.get_variables()['inventory_hostname']
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    https_enforcement = host.run('curl -I http://%s/', hostname)
 

	
 
    assert https_enforcement.rc == 0
 
    assert 'HTTP/1.1 301 Moved Permanently' in https_enforcement.stdout
 
    assert 'Location: https://%s/' % hostname in https_enforcement.stdout
roles/web_server/molecule/default/tests/test_mandatory.py
Show inline comments
 
@@ -53,13 +53,13 @@ def test_tls_version_and_ciphers(host):
 

	
 
def test_default_vhost_index_page(host):
 
    """
 
    Tests content of default vhost index page.
 
    """
 

	
 
    hostname = host.ansible.get_variables()['inventory_hostname']
 
    hostname = host.run('hostname').stdout.strip()
 
    page = host.run('curl https://%s/', hostname)
 

	
 
    assert page.rc == 0
 
    assert "<title>Welcome</title>" in page.stdout
 
    assert "<h1>Welcome</h1>" in page.stdout
 
    assert "<p>You are attempting to access the web server using a wrong name or an IP address. Please check your URL.</p>" in page.stdout
roles/web_server/molecule/default/tests/test_optional.py
Show inline comments
 
@@ -53,13 +53,13 @@ def test_tls_version_and_ciphers(host):
 

	
 
def test_default_vhost_index_page(host):
 
    """
 
    Tests content of default vhost index page.
 
    """
 

	
 
    hostname = host.ansible.get_variables()['inventory_hostname']
 
    hostname = host.run('hostname').stdout.strip()
 
    page = host.run('curl https://%s/', hostname)
 

	
 
    assert page.rc == 0
 
    assert "<title>Optional Welcome</title>" in page.stdout
 
    assert "<h1>Optional Welcome</h1>" in page.stdout
 
    assert "<p>Welcome to default virtual host.</p>" in page.stdout
 
@@ -67,13 +67,13 @@ def test_default_vhost_index_page(host):
 

	
 
def test_environment_indicator(host):
 
    """
 
    Tests if environment indicator is applied correctly.
 
    """
 

	
 
    hostname = host.ansible.get_variables()['inventory_hostname']
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    page = host.run('curl https://%s/' % hostname)
 

	
 
    expected_content = """
 
    <details open='true' style='position: fixed; left: 0; width: 100%; line-height: 1.5em; font-weight: bold; color: #00ff00;'>
 
        <summary style='background-color: #ff0000; list-style-type: none; position: fixed; bottom: 5px; z-index: 999999;'>&#128896;&#128898;</summary>
0 comments (0 inline, 0 general)