aboutsummaryrefslogtreecommitdiff
path: root/tests/test_models.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/test_models.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_models.py b/tests/test_models.py
index 2fa2cb8..392b246 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -146,3 +146,19 @@ def test_source_repr() -> None:
def test_sent_webmention_repr() -> None:
webmention = SentWebmention(target="https://example.com/post", desired_revision=1)
assert repr(webmention) == "<SentWebmention 'https://example.com/post'>"
+
+
+def test_user_session_id_changes_when_password_hash_changes() -> None:
+ user = User(username="admin", password="a strong passphrase", id=42)
+ original_hash = user.password_hash
+ original_id = user.get_id()
+
+ assert original_id.startswith("42:")
+ assert original_hash not in original_id
+ assert len(original_id.split(":", 1)[1]) == 64
+
+ # Even a reset to the same password rehashes with a new salt, revoking
+ # any old session token.
+ user.password = "a strong passphrase"
+ assert user.password_hash != original_hash
+ assert user.get_id() != original_id