Exemple #1
0
def test_should_add_session_cookies_to_request(context: BrowserContext,
                                               server: Server) -> None:
    context.add_cookies([{
        "name": "username",
        "value": "John Doe",
        "url": server.EMPTY_PAGE,
        "expires": -1,
        "httpOnly": False,
        "secure": False,
        "sameSite": "Lax",
    }])
    with server.expect_request("/empty.html") as server_req:
        context.request.get(server.EMPTY_PAGE)
    assert server_req.value.getHeader("Cookie") == "username=John Doe"
Exemple #2
0
def test_should_not_add_context_cookie_if_cookie_header_passed_as_parameter(
        context: BrowserContext, server: Server) -> None:
    context.add_cookies([{
        "name": "username",
        "value": "John Doe",
        "url": server.EMPTY_PAGE,
        "expires": -1,
        "httpOnly": False,
        "secure": False,
        "sameSite": "Lax",
    }])
    with server.expect_request("/empty.html") as server_req:
        context.request.get(server.EMPTY_PAGE, headers={"Cookie": "foo=bar"})
    assert server_req.value.getHeader("Cookie") == "foo=bar"