Files
@ 0bfda9b0c3fe
Branch filter:
Location: majic-ansible-roles/roles/wsgi_website/molecule/default/tests/test_parameters_mandatory.py - annotation
0bfda9b0c3fe
2.0 KiB
text/x-python
MAR-132: Pin packages as part of wsgi_website role test to ensure reproducability:
- Provide explicit list of packages being deployed. This should ensure
we can always reproduce the tests without being affected by new
releases of packages.
- Updated expected requirements in test for the jedi version.
- Provide explicit list of packages being deployed. This should ensure
we can always reproduce the tests without being affected by new
releases of packages.
- Updated expected requirements in test for the jedi version.
b5ed796b566a 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 f05151d6f802 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 c8d4251a6ea5 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 998aab91d6b4 a1e0221d24e7 998aab91d6b4 998aab91d6b4 998aab91d6b4 | import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory'])
def test_https_enforcement(host):
"""
Tests if HTTPS is being enforced.
"""
https_enforcement = host.run('curl -I http://parameters-mandatory/')
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
https_enforcement = host.run('curl -I https://parameters-mandatory/')
assert https_enforcement.rc == 0
assert 'Strict-Transport-Security: max-age=31536000; includeSubDomains' in https_enforcement.stdout
def test_index_page(host):
"""
Tests if index page is served correctly. This covers:
- Basic WSGI application operation.
- Handling of environment variables.
- Handling of proxy headers.
"""
page = host.run('curl -H "Accept-Encoding: plain" https://parameters-mandatory/')
assert page.rc == 0
assert "This is the WSGI application at parameters-mandatory." in page.stdout
assert "Requested URL was: https://parameters-mandatory/" in page.stdout
assert "MY_ENV_VAR: None" in page.stdout
assert "Accept-Encoding: plain" in page.stdout
assert "Python version: 2." in page.stdout
def test_static_file_serving(host):
"""
Tests serving of static files.
"""
page = host.run('curl https://parameters-mandatory/static/static_file.txt')
assert page.rc == 0
assert "This is the WSGI application at parameters-mandatory." in page.stdout
assert "Requested URL was: https://parameters-mandatory/static/static_file.txt" in page.stdout
page = host.run('curl https://parameters-mandatory/media/media_file.txt')
assert page.rc == 0
assert "This is the WSGI application at parameters-mandatory." in page.stdout
assert "Requested URL was: https://parameters-mandatory/media/media_file.txt" in page.stdout
|