feat(identity): redirect legacy Zhuyuan ids to ICE-P
This commit is contained in:
parent
263142cc6b
commit
aa6652a646
28 changed files with 491 additions and 106 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import unittest
|
||||
|
||||
from resolve_route import parse_code_map
|
||||
from resolve_route import parse_code_map, resolve_subject_id
|
||||
|
||||
|
||||
class ParseCodeMapTests(unittest.TestCase):
|
||||
|
|
@ -23,5 +23,40 @@ LL-004=tcs-core/LL-004-LAKE-LAMP-WAKE-PATH.hdlp
|
|||
self.assertEqual(parse_code_map("OTHER=some/path", ("LL-004",)), {})
|
||||
|
||||
|
||||
class SubjectAliasTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.alias_map = {
|
||||
"mappings": [{
|
||||
"canonical_id": "ICE-P-ZY001",
|
||||
"subject_kind": "persona_system",
|
||||
"aliases": ["ICE-GL-ZY001", "ICE-PZY-001"],
|
||||
"route_id": "FD-PERSONA-LOGIN-001",
|
||||
"current_path": "current/zhuyuan",
|
||||
}],
|
||||
"conflicts": [{"id": "ICE-PCA-001", "state": "BLOCKED_DUPLICATE_SUBJECT"}],
|
||||
}
|
||||
|
||||
def test_legacy_persona_id_redirects_to_canonical_id(self):
|
||||
resolved = resolve_subject_id("ICE-GL-ZY001", self.alias_map)
|
||||
self.assertEqual(resolved["canonical_id"], "ICE-P-ZY001")
|
||||
self.assertTrue(resolved["redirected"])
|
||||
self.assertEqual(resolved["route_id"], "FD-PERSONA-LOGIN-001")
|
||||
|
||||
def test_canonical_persona_id_does_not_redirect(self):
|
||||
resolved = resolve_subject_id("ICE-P-ZY001", self.alias_map)
|
||||
self.assertEqual(resolved["status"], "RESOLVED")
|
||||
self.assertFalse(resolved["redirected"])
|
||||
|
||||
def test_human_id_is_not_rewritten_as_persona(self):
|
||||
resolved = resolve_subject_id("ICE-GL∞", self.alias_map)
|
||||
self.assertEqual(resolved["status"], "NOT_FOUND_NO_GUESS")
|
||||
self.assertIsNone(resolved["canonical_id"])
|
||||
|
||||
def test_conflicted_id_is_rejected_without_guessing(self):
|
||||
resolved = resolve_subject_id("ICE-PCA-001", self.alias_map)
|
||||
self.assertEqual(resolved["status"], "CONFLICT_REJECTED")
|
||||
self.assertIsNone(resolved["canonical_id"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue