MCPcopy
hub / github.com/encode/starlette / test_cookies_invalid

Function test_cookies_invalid

tests/test_requests.py:454–472  ·  tests/test_requests.py::test_cookies_invalid

Cookie strings that are against the RFC6265 spec but which browsers will send if set via document.cookie.

(
    set_cookie: str,
    expected: dict[str, str],
    test_client_factory: TestClientFactory,
)

Source from the content-addressed store, hash-verified

452 ],
453)
454def test_cookies_invalid(
455 set_cookie: str,
456 expected: dict[str, str],
457 test_client_factory: TestClientFactory,
458) -> None:
459 class="st">"""
460 Cookie strings that are against the RFC6265 spec but which browsers will send if set
461 via document.cookie.
462 class="st">"""
463
464 async def app(scope: Scope, receive: Receive, send: Send) -> None:
465 request = Request(scope, receive)
466 response = JSONResponse({class="st">"cookies": request.cookies})
467 await response(scope, receive, send)
468
469 client = test_client_factory(app)
470 response = client.get(class="st">"/", headers={class="st">"cookie": set_cookie})
471 result = response.json()
472 assert result[class="st">"cookies"] == expected
473
474
475def test_multiple_cookie_headers(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 3

test_client_factoryFunction · 0.85
jsonMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected