aboutsummaryrefslogtreecommitdiff
path: root/tests/test_auth.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/test_auth.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py
index c302e8f..34df8ce 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -35,6 +35,12 @@ def test_load_user_returns_none_for_unknown_id(app: Flask) -> None:
assert load_user("99999:" + "a" * 64) is None
+@pytest.mark.parametrize("identifier", [None, 123, b"1:" + b"a" * 64])
+def test_load_user_rejects_non_string_sessions(app: Flask, identifier: object) -> None:
+ with app.app_context():
+ assert load_user(identifier) is None
+
+
def test_load_user_rejects_legacy_and_malformed_sessions(app: Flask) -> None:
with app.app_context():
user = User(username="account", password="secret")
@@ -122,6 +128,9 @@ def test_password_change_invalidates_existing_session(app: Flask) -> None:
pytest.param(r"/\evil.example", False, id="slash-backslash-host"),
pytest.param(r"/received\evil.example", False, id="backslash-in-path"),
pytest.param(r"\/evil.example", False, id="backslash-slash-host"),
+ pytest.param("/\n/evil.example", False, id="newline-host"),
+ pytest.param("/\r/evil.example", False, id="carriage-return-host"),
+ pytest.param("/\t/evil.example", False, id="tab-host"),
],
)
def test_is_safe_next_url(next_url: str, expected: bool) -> None: