MCPcopy Create free account
hub / github.com/pallets/flask / test_session_using_samesite_attribute

Function test_session_using_samesite_attribute

tests/test_basic.py:334–358  ·  view source on GitHub ↗
(app, client)

Source from the content-addressed store, hash-verified

332
333
334def test_session_using_samesite_attribute(app, client):
335 @app.route("/")
336 def index():
337 flask.session["testing"] = 42
338 return "Hello World"
339
340 app.config.update(SESSION_COOKIE_SAMESITE="invalid")
341
342 with pytest.raises(ValueError):
343 client.get("/")
344
345 app.config.update(SESSION_COOKIE_SAMESITE=None)
346 rv = client.get("/")
347 cookie = rv.headers["set-cookie"].lower()
348 assert "samesite" not in cookie
349
350 app.config.update(SESSION_COOKIE_SAMESITE="Strict")
351 rv = client.get("/")
352 cookie = rv.headers["set-cookie"].lower()
353 assert "samesite=strict" in cookie
354
355 app.config.update(SESSION_COOKIE_SAMESITE="Lax")
356 rv = client.get("/")
357 cookie = rv.headers["set-cookie"].lower()
358 assert "samesite=lax" in cookie
359
360
361def test_missing_session(app):

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected