From ecdd0af5731db47a80ab73e640689b28ca91c4e6 Mon Sep 17 00:00:00 2001 From: Rod Boev Date: Sun, 19 Jul 2026 16:12:55 -0400 Subject: [PATCH] test(gateway): cover capability-gated approval IDs --- tests/test_gateway_approval_legacy_path.py | 4 ++-- tests/test_gateway_approval_runs_api.py | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/test_gateway_approval_legacy_path.py b/tests/test_gateway_approval_legacy_path.py index c394224c..dabbf7ec 100644 --- a/tests/test_gateway_approval_legacy_path.py +++ b/tests/test_gateway_approval_legacy_path.py @@ -374,7 +374,7 @@ def test_legacy_approval_records_run_id_for_response_relay(): assert captured.get("url", "") == "http://gw:8642/v1/runs/run-legacy-1/approval", ( f"approval respond must relay to the gateway run; got {captured.get('url')!r}" ) - assert captured["body"] == {"choice": "once", "approval_id": "appr-legacy-runid"} + assert captured["body"] == {"choice": "once", "approval_id": ""} handler.send_response.assert_called_with(200) finally: with STREAMS_LOCK: @@ -697,7 +697,7 @@ def test_mirrored_run_id_survives_active_stream_loss(): assert captured.get("url", "") == f"http://gw:8642/v1/runs/{run_id}/approval", ( f"approval respond must relay to the mirrored gateway run; got {captured.get('url')!r}" ) - assert captured["body"] == {"choice": "once", "approval_id": approval_id} + assert captured["body"] == {"choice": "once", "approval_id": ""} handler.send_response.assert_called_with(200) assert entry.event.is_set(), "mirrored gateway approval was not resolved" assert entry.result == "once" diff --git a/tests/test_gateway_approval_runs_api.py b/tests/test_gateway_approval_runs_api.py index 6806a1f7..d2eaf917 100644 --- a/tests/test_gateway_approval_runs_api.py +++ b/tests/test_gateway_approval_runs_api.py @@ -305,7 +305,15 @@ def test_gateway_approval_event_translation(): assert result["run_id"] == "run-999" assert result["approval_id"] == "appr-1" empty_id = _gateway_runs_approval_event({**payload, "approval_id": "", "id": ""}) - assert empty_id["approval_id"] == "" + import api.route_approvals as approvals + sid = "translation-empty-id" + try: + approvals.submit_gateway_pending_mirror(sid, empty_id) + mirror = approvals.gateway_pending_mirror(sid, run_id="run-999") + assert mirror["approval_id"] + assert mirror.get("_gateway_agent_identity_v1") is not True + finally: + approvals._pending.pop(sid, None) downgraded = _gateway_runs_approval_event({ "command": "rm -rf /tmp/x",