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'
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"] == ""
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"
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'] == ''
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()
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()