Handle missing secret key during session save
This commit is contained in:
parent
7ef2946fb5
commit
b00c66248d
2 changed files with 28 additions and 6 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import pytest
|
||||
|
||||
import flask
|
||||
from flask.globals import app_ctx
|
||||
from flask.sessions import SessionInterface
|
||||
|
|
@ -26,3 +28,16 @@ def test_open_session_with_endpoint():
|
|||
|
||||
response = app.test_client().get("/")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_save_session_without_secret_key(app):
|
||||
app.secret_key = "test key"
|
||||
session = app.session_interface.session_class({"foo": "bar"})
|
||||
session.modified = True
|
||||
app.secret_key = None
|
||||
|
||||
with pytest.raises(RuntimeError) as e:
|
||||
app.session_interface.save_session(app, session, app.response_class())
|
||||
|
||||
assert e.value.args and "session is unavailable" in e.value.args[0]
|
||||
assert "no secret key was set" in e.value.args[0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue