fix(remote): return session cache for device-code and cache-only logins

Answered login prompts and uploaded cache now count as client auth; the client closes on exit and keeps the remote session alive during long downloads.
This commit is contained in:
imSp4rky
2026-09-16 19:36:31 -06:00
parent aec45e30cc
commit ffda836442
10 changed files with 222 additions and 18 deletions
+13
View File
@@ -94,3 +94,16 @@ def test_status_setter() -> None:
bridge = InputBridge()
bridge.status = AuthStatus.AUTHENTICATED
assert bridge.status is AuthStatus.AUTHENTICATED
def test_answered_only_after_an_accepted_response() -> None:
bridge = InputBridge()
assert bridge.submit_response("early") is False
assert bridge.answered is False
worker = threading.Thread(target=bridge.request_input, args=("code?",))
worker.start()
while bridge.status != AuthStatus.PENDING_INPUT:
time.sleep(0.01)
assert bridge.submit_response("CODE") is True
worker.join(timeout=2)
assert bridge.answered is True
+12
View File
@@ -130,3 +130,15 @@ async def test_max_sessions_evicts_oldest(store: SessionStore, monkeypatch: pyte
assert await store.get("a") is None # evicted
assert (await store.get("b")) is b
assert (await store.get("c")) is c
async def test_get_expiry_removes_cache_dir(store: SessionStore, monkeypatch: pytest.MonkeyPatch) -> None:
from datetime import datetime, timedelta, timezone
removed: list = []
monkeypatch.setattr(SessionStore, "cleanup_cache_dir", staticmethod(removed.append))
entry = await store.create("EXAMPLE", _FakeService())
entry.cache_tag = "_sessions/k/s/EXAMPLE"
entry.last_accessed = datetime.now(timezone.utc) - timedelta(seconds=store.ttl + 100)
assert await store.get(entry.session_id) is None
assert removed == ["_sessions/k/s/EXAMPLE"]