Files @ 5b6d00b0beab
Branch filter:

Location: majic-ansible-roles/roles/wsgi_website/molecule/default/tests/test_parameters_paste_req.py - annotation

branko
MAR-170: Always enforce use of HTTPS in the wsgi_server role:

- Dropped the enforce_https parameter.
- Updated tests.
- Updated release notes.
import os

import testinfra.utils.ansible_runner


testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


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-paste-req/')

    assert page.rc == 0
    assert "This is the WSGI application at parameters-paste-req." in page.stdout
    assert "Requested URL was: https://parameters-paste-req/" 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-paste-req/static/static_file.txt')
    assert page.rc == 0
    assert "This is the WSGI application at parameters-paste-req." in page.stdout
    assert "Requested URL was: https://parameters-paste-req/static/static_file.txt" in page.stdout

    page = host.run('curl https://parameters-paste-req/media/media_file.txt')
    assert page.rc == 0
    assert "This is the WSGI application at parameters-paste-req." in page.stdout
    assert "Requested URL was: https://parameters-paste-req/media/media_file.txt" in page.stdout