Exemplo n.º 1
0
def good_origin_response(agent, request):
    """
    A fixture that performs a handshake with an Origin that matches the server.
    """
    host = make_authority(host=request.param[0])
    origin = make_root(host=request.param[0])
    version = request.param[1]

    response = pytest.blockon(
        make_request(agent, origin=origin, host=host, version=version))
    yield response
    client.readBody(response).cancel()  # immediately close the connection
def good_origin_response(agent, request):
    """
    A fixture that performs a handshake with an Origin that matches the server.
    """
    host = make_authority(host=request.param[0])
    origin = make_root(host=request.param[0])
    version = request.param[1]

    response = pytest.blockon(make_request(agent, origin=origin, host=host,
                                           version=version))
    yield response
    client.readBody(response).cancel() # immediately close the connection
Exemplo n.º 3
0
    response = pytest.blockon(
        make_request(agent, origin=origin, host=host, version=version))
    yield response
    client.readBody(response).cancel()  # immediately close the connection


# For use in the mismatched Origin tests.
OPPOSITE_SCHEME = 'https' if (SCHEME == 'http') else 'http'


@pytest.yield_fixture(
    params=[["http://not-my-origin.com", None, None],
            ["http://not-my-origin.com", None, '7'],
            ["http://not-my-origin.com", None, '8'],
            [make_root(port=55), None, None],
            [OPPOSITE_SCHEME + "://" + make_authority(), None, None],
            [make_root(), make_authority(port=55), None]])
def bad_origin_response(agent, request):
    """
    A fixture that performs a good handshake, but with an Origin that does not
    match the server.
    """
    origin = request.param[0]
    host = request.param[1]
    version = request.param[2]

    response = pytest.blockon(
        make_request(agent, origin=origin, host=host, version=version))
    yield response
    client.readBody(response).cancel()  # immediately close the connection
    version = request.param[1]

    response = pytest.blockon(make_request(agent, origin=origin, host=host,
                                           version=version))
    yield response
    client.readBody(response).cancel() # immediately close the connection

# For use in the mismatched Origin tests.
OPPOSITE_SCHEME = 'https' if (SCHEME == 'http') else 'http'

@pytest.yield_fixture(params=[
                              ["http://not-my-origin.com", None, None],
                              ["http://not-my-origin.com", None, '7'],
                              ["http://not-my-origin.com", None, '8'],
                              [make_root(port=55), None, None],
                              [OPPOSITE_SCHEME + "://" + make_authority(), None, None],
                              [make_root(), make_authority(port=55), None]
                             ])
def bad_origin_response(agent, request):
    """
    A fixture that performs a good handshake, but with an Origin that does not
    match the server.
    """
    origin = request.param[0]
    host = request.param[1]
    version = request.param[2]

    response = pytest.blockon(make_request(agent, origin=origin, host=host,
                                           version=version))
    yield response
    client.readBody(response).cancel() # immediately close the connection