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

Function test_session_secret_key_fallbacks

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

Source from the content-addressed store, hash-verified

372
373
374def test_session_secret_key_fallbacks(app, client) -> None:
375 @app.post("/")
376 def set_session() -> str:
377 flask.session["a"] = 1
378 return ""
379
380 @app.get("/")
381 def get_session() -> dict[str, t.Any]:
382 return dict(flask.session)
383
384 # Set session with initial secret key
385 client.post()
386 assert client.get().json == {"a": 1}
387 # Change secret key, session can't be loaded and appears empty
388 app.secret_key = "new test key"
389 assert client.get().json == {}
390 # Add initial secret key as fallback, session can be loaded
391 app.config["SECRET_KEY_FALLBACKS"] = ["test key"]
392 assert client.get().json == {"a": 1}
393
394
395def test_session_expiration(app, client):

Callers

nothing calls this directly

Calls 2

postMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected