From 680430182523ccbfef06e64535c0e2b64d5c6af1 Mon Sep 17 00:00:00 2001 From: xpltd Date: Sun, 22 Mar 2026 01:39:01 -0500 Subject: [PATCH] Fix CI: test clients need X-Requested-With for API access guard --- backend/tests/conftest.py | 6 +++++- backend/tests/test_api.py | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py index bfff066..b25e49e 100644 --- a/backend/tests/conftest.py +++ b/backend/tests/conftest.py @@ -109,7 +109,11 @@ async def client(tmp_path: Path): test_app.state.start_time = datetime.now(timezone.utc) transport = ASGITransport(app=test_app) - async with AsyncClient(transport=transport, base_url="http://test") as ac: + async with AsyncClient( + transport=transport, + base_url="http://test", + headers={"X-Requested-With": "XMLHttpRequest"}, + ) as ac: yield ac # Teardown diff --git a/backend/tests/test_api.py b/backend/tests/test_api.py index 4f28a5c..cb76fb4 100644 --- a/backend/tests/test_api.py +++ b/backend/tests/test_api.py @@ -185,8 +185,16 @@ async def test_session_isolation(client, tmp_path): transport = ASGITransport(app=test_app) - async with AsyncClient(transport=transport, base_url="http://test") as client_a: - async with AsyncClient(transport=transport, base_url="http://test") as client_b: + async with AsyncClient( + transport=transport, + base_url="http://test", + headers={"X-Requested-With": "XMLHttpRequest"}, + ) as client_a: + async with AsyncClient( + transport=transport, + base_url="http://test", + headers={"X-Requested-With": "XMLHttpRequest"}, + ) as client_b: await client_a.post( "/api/downloads", json={"url": "https://example.com/a"},