Ejemplo n.º 1
0
def test_get_host_nonstandard_https_port_ignoring_forwarded():
    hostchecker_ = hostchecker({'USE_X_FORWARDED_HOST': False})
    request = requestMock(b"/foo",
                          host=b'example.com',
                          port=8443,
                          isSecure=True,
                          headers={'X-Forwarded-Host': ['example.net']})
    request.requestHeaders.removeHeader(
        b'host')  # force hostchecker to use transport attributes
    assert hostchecker_.get_host(request) == 'example.com:8443'
Ejemplo n.º 2
0
def test_get_host_untrusted():
    hostchecker_ = hostchecker({'TRUSTED_HOSTS': ['example.net']})
    request = requestMock(b"/foo", host=b'example.com', port=80)
    with pytest.raises(werkzeug.exceptions.SecurityError):
        hostchecker_.get_host(request)
Ejemplo n.º 3
0
def test_get_host_trusted():
    hostchecker_ = hostchecker({'TRUSTED_HOSTS': ['example.com']})
    request = requestMock(b"/foo", host=b'example.com', port=80)
    assert hostchecker_.get_host(request) == 'example.com'