예제 #1
0
def test_basic_authorization() -> None:
    headers = CIMultiDict()
    headers['Authorization'] = "Basic {}".format(b64encode(b'identity:secret').decode('ascii'))
    request = BaseRequestWebsocket('GET', 'http', '/', headers)
    auth = request.authorization
    assert auth.username == 'identity'
    assert auth.password == 'secret'
예제 #2
0
def test_query_string() -> None:
    base_request_websocket = BaseRequestWebsocket(
        "GET", "http", "/", b"a=b&a=c&f", CIMultiDict({"host": "localhost"}),
        "", "1.1")
    assert base_request_websocket.query_string == b"a=b&a=c&f"
    assert base_request_websocket.args.getlist("a") == ["b", "c"]
    assert base_request_websocket.args["f"] == ""
예제 #3
0
def test_basic_authorization() -> None:
    headers = CIMultiDict()
    headers["Authorization"] = "Basic {}".format(
        b64encode(b"identity:secret").decode("ascii"))
    request = BaseRequestWebsocket("GET", "http", "/", b"", headers, "", "1.1")
    auth = request.authorization
    assert auth.username == "identity"
    assert auth.password == "secret"
예제 #4
0
파일: test_base.py 프로젝트: zhankura/quart
def test_query_string() -> None:
    base_request_websocket = BaseRequestWebsocket(
        'GET',
        'http',
        '/',
        b'a=b&a=c&f',
        CIMultiDict({'host': 'localhost'}),
    )
    assert base_request_websocket.query_string == b'a=b&a=c&f'
    assert base_request_websocket.args.getlist('a') == ['b', 'c']
    assert base_request_websocket.args['f'] == ''
예제 #5
0
async def test_request_get_data_timeout() -> None:
    request = Request(
        'POST',
        'http',
        '/',
        b'',
        CIMultiDict(),
        body_timeout=1,
        send_push_promise=no_op_push,
    )
    with pytest.raises(RequestTimeout):
        await request.get_data()
예제 #6
0
async def test_request_exceeds_max_content_length() -> None:
    max_content_length = 5
    headers = CIMultiDict()
    headers['Content-Length'] = str(max_content_length + 1)
    request = Request(
        'POST',
        'http',
        '/',
        b'',
        headers,
        max_content_length=max_content_length,
        send_push_promise=no_op_push,
    )
    with pytest.raises(RequestEntityTooLarge):
        await request.get_data()