from grantflow.tests.security_reads_helpers import assert_auth_pair, enable_read_auth


def test_portfolio_read_endpoints_require_api_key_when_configured(monkeypatch):
    enable_read_auth(monkeypatch)

    for path in [
        "/portfolio/metrics",
        "/portfolio/metrics/export",
        "/portfolio/quality",
        "/portfolio/quality/export",
        "/portfolio/review-workflow",
        "/portfolio/review-workflow/export",
        "/portfolio/review-workflow/sla",
        "/portfolio/review-workflow/sla/export",
        "/portfolio/review-workflow/sla/hotspots",
        "/portfolio/review-workflow/sla/hotspots/export",
        "/portfolio/review-workflow/sla/hotspots/trends",
        "/portfolio/review-workflow/sla/hotspots/trends/export",
        "/portfolio/review-workflow/trends",
        "/portfolio/review-workflow/trends/export",
        "/portfolio/review-workflow/sla/trends",
        "/portfolio/review-workflow/sla/trends/export",
    ]:
        assert_auth_pair("get", path)
