import json import unittest from pathlib import Path ROOT = Path(__file__).resolve().parents[1] FINAL = ROOT / "packs/NOT-EDIT-final-merged-packs" RETIRED_PATHS = { "policies/user_assignment_policy_eligibility_lifecycle.json", "policies/profile_assignment_policy_eligibility_lifecycle.json", } class AssignmentPolicyLifecycleRetirementTest(unittest.TestCase): def test_final_pack_keeps_the_merged_l1_retirement(self): """Do not revive hooks that make policy-free User/Profile writes fail closed. App-packs #704 intentionally retired these declarations until the assignment-policy feature has an exact-tuple release gate. L2 final-pack regeneration must preserve that L1 decision; restoring the stale files would reintroduce the Test2 User-create 500 that prompted the retirement. """ pack = json.loads((FINAL / "pack.json").read_text()) component_paths = { component.get("path") for component in pack.get("components", []) } self.assertTrue(RETIRED_PATHS.isdisjoint(component_paths)) for relative_path in RETIRED_PATHS: with self.subTest(path=relative_path): self.assertFalse((FINAL / relative_path).exists()) def test_no_remaining_policy_declares_the_retired_hook(self): for path in sorted((FINAL / "policies").glob("*.json")): payload = json.loads(path.read_text()) hooks = payload.get("lifecycle", {}).get("hooks", []) with self.subTest(path=path.name): self.assertNotIn( "platform.assignment-policy-eligibility", {hook.get("capability") for hook in hooks}, ) if __name__ == "__main__": unittest.main()