feat: add MyWhoosh token persistence

This commit is contained in:
Bastian Wagner
2026-08-15 14:38:50 +02:00
parent ef9ca9eeca
commit a28d06ffdd
5 changed files with 77 additions and 0 deletions

View File

View File

@@ -0,0 +1,18 @@
from pathlib import Path
from app.mywhoosh.models import MyWhooshToken
from app.mywhoosh.tokenstore import MyWhooshTokenStore
def test_tokenstore_round_trip_and_permissions(tmp_path: Path) -> None:
store = MyWhooshTokenStore(tmp_path / "tokens" / "7" / "mywhoosh.json")
token = MyWhooshToken(access_token="access", refresh_token="refresh", whoosh_id="whoosh-7")
store.save(token)
assert store.load() == token
assert oct(store.path.stat().st_mode & 0o777) == "0o600"
def test_missing_token_returns_none(tmp_path: Path) -> None:
store = MyWhooshTokenStore(tmp_path / "missing.json")
assert store.load() is None