From ab57c83ee13098599dc212d7edb2d043d3595645 Mon Sep 17 00:00:00 2001 From: Renn F Date: Wed, 7 Oct 2026 12:21:29 +0200 Subject: [PATCH] test: pin the get_endpoint_id resolution order to the guard-core 142 contract The upstream-drift suite runs this adapter against guard-core@master, where get_endpoint_id now prefers state.guard_route_id over the guard_endpoint_id extra before the redacted method:path fallback. The bare Mock() in this test auto-created a truthy guard_route_id attribute, so the first assertion saw the Mock instead of the extra and the drift run went red. Pin the full resolution order explicitly: route id wins, then the extra, then the fallback. Full suite green locally against the local guard-core master (278 passed, 100% line coverage). --- tests/test_decorators/test_extension_integration.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_decorators/test_extension_integration.py b/tests/test_decorators/test_extension_integration.py index ebb1ff6..5a333d1 100644 --- a/tests/test_decorators/test_extension_integration.py +++ b/tests/test_decorators/test_extension_integration.py @@ -60,11 +60,20 @@ def test_get_endpoint_id_with_route(security_config: SecurityConfig) -> None: mock_request.path = "/test" mock_request.path_info = "/test" mock_request.method = "GET" + mock_request.guard_route_id = "orders:list" mock_request.guard_endpoint_id = "test_module.test_function" + # The stamped route id wins over the runtime endpoint-id extra + # (guard-core #142's get_endpoint_id resolution order). + endpoint_id = middleware._get_endpoint_id(mock_request) + assert endpoint_id == "orders:list" + + # No stamped route id: the runtime endpoint-id extra is honored. + mock_request.guard_route_id = None endpoint_id = middleware._get_endpoint_id(mock_request) assert endpoint_id == "test_module.test_function" + # Neither is present: the redacted method:path fallback. mock_request.guard_endpoint_id = None endpoint_id = middleware._get_endpoint_id(mock_request) assert endpoint_id == "GET:/test"