railiance-platform/tests/test_keycape_factor_recovery.py
codex 9575b51d6e
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s
KeyCape factor custody acceptance / acceptance (push) Successful in 4s
Implement audited lost-factor recovery and track remaining P04 acceptance
Assistant: codex
Assistant-Model: gpt-6-astra
Assistant-Session: 01a092fe-13b1-7f12-ac74-7d258af4d79c
2026-09-13 17:28:45 +02:00

13 lines
932 B
Python

import importlib.util,sys,unittest
from pathlib import Path
from unittest.mock import patch
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'scripts'))
import keycape_factor_recovery as m
class OwnerRecoveryTests(unittest.TestCase):
def test_actor_comes_from_authenticated_entity(self):
with patch.object(m,'call',return_value={'data':{'policies':['platform-admin'],'entity_id':'11111111-1111-1111-1111-111111111111'}}):
self.assertEqual(m.owner_identity(),'openbao:11111111-1111-1111-1111-111111111111')
def test_reader_or_missing_entity_cannot_run_recovery(self):
for data in [{'policies':['workload-kv-read-keycape-factor-read'],'entity_id':'11111111-1111-1111-1111-111111111111'},{'policies':['root'],'entity_id':''},{'policies':['root'],'entity_id':'11111111-1111-1111-1111-111111111111'}]:
with patch.object(m,'call',return_value={'data':data}):
with self.assertRaises(ValueError):m.owner_identity()