세션 계약과 메모리 경계 보강
This commit is contained in:
parent
391639c1de
commit
2bb052f624
12 changed files with 836 additions and 116 deletions
|
|
@ -103,9 +103,43 @@ class SessionShareTest(unittest.IsolatedAsyncioTestCase):
|
|||
|
||||
summary = await share_routes._load_share_or_404(token)
|
||||
self.assertIn("Vignette 회기 리뷰", summary.title)
|
||||
self.assertIn(summary.reachedPhase, {"라포", "탐색", "개입", "정리"})
|
||||
self.assertNotIn("원문 학습자 민감 발화", summary.model_dump_json())
|
||||
self.assertIn("저장된 실제 축어록 2개", summary.summary)
|
||||
|
||||
async def test_public_share_normalizes_legacy_reached_phase(self) -> None:
|
||||
coded = share_routes._safe_payload({"reachedPhase": "rapport"})
|
||||
blank = share_routes._safe_payload({"reachedPhase": ""})
|
||||
invalid = share_routes._safe_payload({"reachedPhase": "unknown-stage"})
|
||||
missing = share_routes._safe_payload({})
|
||||
|
||||
self.assertEqual(coded.reachedPhase, "라포")
|
||||
self.assertIsNone(blank.reachedPhase)
|
||||
self.assertIsNone(invalid.reachedPhase)
|
||||
self.assertIsNone(missing.reachedPhase)
|
||||
|
||||
async def test_public_share_lookup_tolerates_legacy_blank_reached_phase(self) -> None:
|
||||
token = "legacyShareTokenValue000000000000"
|
||||
token_hash = session_persistence.share_token_hash(token)
|
||||
session_persistence._SESSION_SHARE_CACHE["legacy-share-session"] = {
|
||||
"session_id": "legacy-share-session",
|
||||
"token_hash": token_hash,
|
||||
"payload": {
|
||||
"title": "Legacy share",
|
||||
"description": "Legacy summary",
|
||||
"reachedPhase": "",
|
||||
},
|
||||
"created_at": 1_800_000_000.0,
|
||||
"updated_at": 1_800_000_000.0,
|
||||
"revoked_at": None,
|
||||
}
|
||||
session_persistence._SESSION_SHARE_TOKEN_INDEX[token_hash] = "legacy-share-session"
|
||||
|
||||
summary = await share_routes._load_share_or_404(token)
|
||||
|
||||
self.assertEqual(summary.title, "Legacy share")
|
||||
self.assertIsNone(summary.reachedPhase)
|
||||
|
||||
async def test_revoke_share_blocks_public_lookup(self) -> None:
|
||||
principal = _principal()
|
||||
_ended_session(principal)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue