diff options
| author | Dennis Fink | 2026-11-15 20:42:20 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-15 20:42:20 +0100 |
| commit | 509d93b2976e353d29441a7a7b7e78ca466dc4fd (patch) | |
| tree | 753e637aefabd4293f808addbf9c310eaf0aa552 /tests/test_auth.py | |
| parent | c74feda222745ab7cca8993df83d9ea5f9d07e5b (diff) | |
| download | webmentions-ssg-509d93b2976e353d29441a7a7b7e78ca466dc4fd.tar.gz webmentions-ssg-509d93b2976e353d29441a7a7b7e78ca466dc4fd.zip | |
refactor(core)!: standardize application terminology
Rename configuration keys, task helpers, forms, network utilities, and
view endpoints to make their responsibilities and domains more explicit.
Align source-management routes and templates with the new terminology
and rename the target-matching module and related task abstractions
consistently.
BREAKING CHANGE: configuration keys have been renamed and sent-source
routes move from `/sent` to `/sources`, with corresponding blueprint
endpoint changes.
Diffstat (limited to 'tests/test_auth.py')
| -rw-r--r-- | tests/test_auth.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py index 3b05b6f..8219a07 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -10,18 +10,23 @@ import pytest from flask import Flask from webmentions_ssg import auth, db -from webmentions_ssg.auth import AUTH, is_safe_next_url, load_user, validate_password +from webmentions_ssg.auth import ( + is_safe_next_url, + load_user_from_session_id, + login_manager, + validate_new_password, +) from webmentions_ssg.models import User @pytest.mark.parametrize("character", ["\x00", "\x1f", "\x7f", "\x80", "\x9f"]) def test_validate_password_rejects_unicode_controls(character: str) -> None: with pytest.raises(ValueError, match="control characters"): - validate_password(f"valid passphrase{character}") + validate_new_password(f"valid passphrase{character}") def test_user_loader_is_registered(app: Flask) -> None: - assert AUTH._user_callback is load_user + assert login_manager._user_callback is load_user_from_session_id def test_dummy_password_hash_is_lazily_cached(monkeypatch: pytest.MonkeyPatch) -> None: @@ -48,18 +53,18 @@ def test_load_user_returns_matching_user(app: Flask) -> None: user = User(username="account", password="secret") db.session.add(user) db.session.commit() - assert load_user(user.get_id()) is user + assert load_user_from_session_id(user.get_id()) is user def test_load_user_returns_none_for_unknown_id(app: Flask) -> None: with app.app_context(): - assert load_user("99999:" + "a" * 64) is None + assert load_user_from_session_id("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 + assert load_user_from_session_id(identifier) is None def test_load_user_rejects_legacy_and_malformed_sessions(app: Flask) -> None: @@ -79,7 +84,7 @@ def test_load_user_rejects_legacy_and_malformed_sessions(app: Flask) -> None: f"{user.id}:" + "0" * 64 + ":trailing", "-1:" + "0" * 64, ): - assert load_user(identifier) is None + assert load_user_from_session_id(identifier) is None def test_password_change_invalidates_existing_session(app: Flask) -> None: @@ -111,8 +116,8 @@ def test_password_change_invalidates_existing_session(app: Flask) -> None: user = db.session.get(User, int(old_identifier.split(":", 1)[0])) assert user is not None assert user.get_id() != old_identifier - assert load_user(old_identifier) is None - assert load_user(user.get_id()) is user + assert load_user_from_session_id(old_identifier) is None + assert load_user_from_session_id(user.get_id()) is user # A pre-existing, validly signed cookie no longer authenticates. assert client.get("/received").status_code == HTTPStatus.FOUND |
