From ce4efddad8b2405a9f921357b79fe6aab3e37e2b Mon Sep 17 00:00:00 2001 From: er-s-an <92594860+er-s-an@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:29:37 +0800 Subject: [PATCH] test(proxy): cover _has_truthy_permission shapes for codecov Dict/sequence/invalid cases for the get_spend_routes auth helper so codecov/patch sees the list/tuple and fallback branches (#47112). --- tests/unit/proxy/auth/test_route_checks.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/proxy/auth/test_route_checks.py b/tests/unit/proxy/auth/test_route_checks.py index f99f750f893..97c7d1cdc4f 100644 --- a/tests/unit/proxy/auth/test_route_checks.py +++ b/tests/unit/proxy/auth/test_route_checks.py @@ -2203,6 +2203,28 @@ def test_get_spend_routes_false_permission_denies_internal_user(route): assert "Only proxy admin" in str(exc_info.value) +@pytest.mark.parametrize( + "permissions, expected", + [ + ({"get_spend_routes": True}, True), + ({"get_spend_routes": False}, False), + ({}, False), + (["get_spend_routes"], True), + (("get_spend_routes",), True), + ({"get_spend_routes"}, True), + (["other"], False), + (None, False), + ("get_spend_routes", False), + ], +) +def test_has_truthy_permission_shapes(permissions, expected): + """Cover dict / sequence / invalid shapes for the shared helper (#47112).""" + assert ( + RouteChecks._has_truthy_permission(permissions, "get_spend_routes") + is expected + ) + + @pytest.mark.parametrize("route", ["/audit", "/audit/some-log-id"]) def test_proxy_admin_viewer_can_access_audit_logs(route): """