Preserve Warden config in attended child
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a058f3-8ba0-7692-a042-9a870fc3d663
This commit is contained in:
tegwick 2026-09-01 00:24:18 +02:00
parent b4c1d3900a
commit 8f01eefb1e
2 changed files with 32 additions and 0 deletions

View file

@ -403,6 +403,10 @@ def proxy_attended_login_exec(
root, session, root_created = _prepare_attended_login_home()
helper = session / _TOKEN_HELPER_NAME
env = _caller_env()
if not env.get("WARDEN_CONFIG"):
caller_config = Path.home() / ".config" / "warden" / "warden.yaml"
if caller_config.is_file():
env["WARDEN_CONFIG"] = str(caller_config)
env["HOME"] = str(session)
env.pop("BAO_TOKEN", None)
env.pop("VAULT_TOKEN", None)

View file

@ -427,6 +427,34 @@ def test_attended_login_contained_success_output_never_escapes(monkeypatch, tmp_
assert not (tmp_path / ".warden-attended-login").exists()
def test_attended_login_preserves_caller_warden_config_for_reviewed_child(
monkeypatch, tmp_path
):
monkeypatch.setattr(Path, "home", lambda: tmp_path)
monkeypatch.delenv("WARDEN_CONFIG", raising=False)
caller_config = tmp_path / ".config" / "warden" / "warden.yaml"
caller_config.parent.mkdir(parents=True)
caller_config.write_text("backend: local\n")
seen_config = None
def fake_run(argv, **kw):
nonlocal seen_config
helper = Path(kw["env"]["HOME"]) / ".vault-token"
if argv[:2] == ["bao", "login"]:
helper.write_text("non-production-test-double")
helper.chmod(0o600)
if argv == ["reviewed-child"]:
seen_config = kw["env"].get("WARDEN_CONFIG")
return subprocess.CompletedProcess(argv, 0, stdout=b"", stderr=b"")
monkeypatch.setattr("warden.proxy.subprocess.run", fake_run)
assert proxy_attended_login_exec(
ResolvedFetch(argv=["bao", "login", "-no-print"]),
child_argv=["reviewed-child"],
) == 0
assert seen_config == str(caller_config)
def test_real_catalog_login_entry_is_login_lane():
from warden.routing import load_catalog
e = load_catalog(_repo_catalog()).get("key-cape-oidc-login")