Add attended prune of retired bao.coulomb.social callbacks from platform-admin
Read-preserve-write via the reviewed loopback helper; keeps the tunnel callback and every other setting; also captures non-secret OIDC mount config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 150322@bnt-lap001 Assistant-Session: 16a7b788-374e-4915-a1df-fc87ffd9a5e4
This commit is contained in:
parent
85f6a14892
commit
7f25af3cb1
3 changed files with 166 additions and 0 deletions
58
tests/test_openbao_platform_admin_callback_prune.py
Normal file
58
tests/test_openbao_platform_admin_callback_prune.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import copy
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
'prune', Path(__file__).resolve().parents[1] / 'scripts/openbao_platform_admin_callback_prune.py')
|
||||
m = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(m)
|
||||
|
||||
DECLARED = json.loads((Path(__file__).resolve().parents[1] / 'openbao/auth/netkingdom-platform-admin-role.json').read_text())
|
||||
|
||||
|
||||
def live(role):
|
||||
state = {'role': copy.deepcopy(role)}
|
||||
writes = []
|
||||
|
||||
def write(value):
|
||||
writes.append(value)
|
||||
state['role'].update(value)
|
||||
return state, writes, (lambda: copy.deepcopy(state['role'])), write
|
||||
|
||||
|
||||
def test_prunes_only_the_two_retired_callbacks_and_keeps_settings():
|
||||
role = dict(DECLARED, allowed_redirect_uris=list(DECLARED['allowed_redirect_uris']) + list(m.RETIRED)
|
||||
if not set(m.RETIRED) <= set(DECLARED['allowed_redirect_uris']) else list(DECLARED['allowed_redirect_uris']))
|
||||
state, writes, read, write = live(role)
|
||||
changed, uris = m.prune(read, write)
|
||||
assert changed and len(writes) == 1
|
||||
assert not set(m.RETIRED) & set(uris)
|
||||
assert m.KEEP in uris and 'http://localhost:8250/oidc/callback' in uris
|
||||
assert state['role']['token_policies'] == ['platform-admin', 'operator-custody']
|
||||
assert state['role']['bound_claims'] == {'groups': ['net-kingdom-admins']}
|
||||
|
||||
|
||||
def test_idempotent_when_already_pruned():
|
||||
role = dict(DECLARED, allowed_redirect_uris=[u for u in DECLARED['allowed_redirect_uris'] if u not in m.RETIRED])
|
||||
_, writes, read, write = live(role)
|
||||
assert m.prune(read, write)[0] is False and writes == []
|
||||
|
||||
|
||||
def test_refuses_without_tunnel_callback():
|
||||
role = dict(DECLARED, allowed_redirect_uris=list(m.RETIRED))
|
||||
_, writes, read, write = live(role)
|
||||
with pytest.raises(m.Refused, match='tunnel_callback_missing'):
|
||||
m.prune(read, write)
|
||||
assert writes == []
|
||||
|
||||
|
||||
def test_refuses_when_readback_drops_other_settings():
|
||||
role = copy.deepcopy(DECLARED)
|
||||
calls = iter([copy.deepcopy(role), copy.deepcopy(role),
|
||||
dict(copy.deepcopy(role), token_ttl=60,
|
||||
allowed_redirect_uris=[u for u in role['allowed_redirect_uris'] if u not in m.RETIRED])])
|
||||
with pytest.raises(m.Refused, match='readback_settings_changed'):
|
||||
m.prune(lambda: next(calls), lambda value: None)
|
||||
Loading…
Add table
Add a link
Reference in a new issue