test: restore independent mint admission coverage and refine remaining fixes
Assistant: codex Assistant-Model: gpt-6.1-sol Assistant-Session: 01a1468b-63fa-7710-85dc-8f2e16b3ebfa
This commit is contained in:
parent
3236d5000e
commit
342a6f25af
2 changed files with 115 additions and 7 deletions
|
|
@ -1,9 +1,9 @@
|
|||
"""Kernel admission against the real 1.3 successor type (NK-WP-0048-T16 candidate).
|
||||
|
||||
Unlike test_admit_1_2_adapter_descriptors.py, nothing is patched into the type's
|
||||
execution_descriptors: the map tested here is the one committed in
|
||||
security-case-type-revisions/1.3. The type is `proposed`, so the kernel must refuse
|
||||
it as it stands. Warden's BrowserInputs also pins each type version's parameter
|
||||
The committed-map tests use security-case-type-revisions/1.3 unchanged. One
|
||||
separate fixture-map test acknowledges only an agent-actor mint descriptor digest
|
||||
to reach the independent kernel mint prohibition after map validation. The type
|
||||
is `proposed`, so the kernel must refuse it as it stands. Warden's BrowserInputs also pins each type version's parameter
|
||||
fingerprint and knows only 1.1 and 1.2 (ops-warden case_inputs.PARAMETER_PINS), so an
|
||||
acknowledged 1.3 is still refused until ops-warden adds a 1.3 pin. That is an
|
||||
ops-warden owner change, and it is not made here. The tests show that 1.3's
|
||||
|
|
@ -74,7 +74,7 @@ class Admit13TypeTests(unittest.TestCase):
|
|||
ARTIFACT['params']['consumer_owner_repo'],
|
||||
version='1.3'))
|
||||
|
||||
def admit(self, desc, type_source, *, actor=None, lane=None):
|
||||
def admit(self, desc, type_source, *, actor=None, lane=None, agent_id=None):
|
||||
desc_bytes = c.encode(desc)
|
||||
adapter = Adapter(desc.adapter, desc.adapter_source, unused, unused)
|
||||
executor = Executor(Journal(Path(self.temp.name) / desc.step),
|
||||
|
|
@ -82,7 +82,10 @@ class Admit13TypeTests(unittest.TestCase):
|
|||
lambda purpose, source, evidence: evidence in EVIDENCE,
|
||||
browser_inputs=inputs.BrowserInputs(REPO))
|
||||
with mock.patch.dict(os.environ):
|
||||
os.environ.pop('WARDEN_AGENT_ID', None)
|
||||
if agent_id is None:
|
||||
os.environ.pop('WARDEN_AGENT_ID', None)
|
||||
else:
|
||||
os.environ['WARDEN_AGENT_ID'] = agent_id
|
||||
return executor.admit(self.case_source, type_source, desc_bytes,
|
||||
b'fixture-only-catalog', principal='founder', actor=actor or desc.actor,
|
||||
lane=lane or desc.lane,
|
||||
|
|
@ -125,7 +128,8 @@ class Admit13TypeTests(unittest.TestCase):
|
|||
def test_descriptor_outside_the_map_is_refused(self):
|
||||
acknowledged = with_status('acknowledged')
|
||||
mint = self.descriptors['mint-secret']
|
||||
for changed in (replace(mint, lane='other-lane'), replace(mint, retry_safe=True)):
|
||||
for changed in (replace(mint, lane='other-lane'), replace(mint, retry_safe=True),
|
||||
replace(mint, actor='agent')):
|
||||
with self.subTest(changed=changed), pinned_13(), self.assertRaisesRegex(
|
||||
Refused, 'no exact acknowledged machine descriptor'):
|
||||
self.admit(changed, acknowledged)
|
||||
|
|
@ -138,6 +142,20 @@ class Admit13TypeTests(unittest.TestCase):
|
|||
with pinned_13(), self.assertRaisesRegex(Refused, 'principal actor or lane mismatch'):
|
||||
self.admit(mint, acknowledged, actor='agent')
|
||||
|
||||
def test_agent_mint_is_refused_after_fixture_map_acknowledges_descriptor(self):
|
||||
# A committed-map mismatch cannot exercise the independent mint guard.
|
||||
mint = replace(self.descriptors['mint-secret'], actor='agent')
|
||||
typ = yaml.safe_load(with_status('acknowledged'))
|
||||
typ['spec']['execution_descriptors']['mint-secret'] = digest(c.encode(mint))
|
||||
with pinned_13(), self.assertRaisesRegex(Refused, 'agent mint is forbidden'):
|
||||
self.admit(mint, yaml.safe_dump(typ).encode())
|
||||
|
||||
def test_human_mint_is_refused_with_agent_runtime_identity(self):
|
||||
mint = self.descriptors['mint-secret']
|
||||
self.assertEqual(mint.actor, 'human')
|
||||
with pinned_13(), self.assertRaisesRegex(Refused, 'agent mint is forbidden'):
|
||||
self.admit(mint, with_status('acknowledged'), agent_id='fixture-agent')
|
||||
|
||||
def test_wrong_lane_is_refused(self):
|
||||
# Moved from test_admit_1_2_adapter_descriptors.py in r5.
|
||||
acknowledged = with_status('acknowledged')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue