Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a092fe-13b1-7f12-ac74-7d258af4d79c
13 lines
932 B
Python
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()
|