Fix CI: test clients need X-Requested-With for API access guard

This commit is contained in:
xpltd 2026-03-22 01:39:01 -05:00
parent 43b5ba3f72
commit 6804301825
2 changed files with 15 additions and 3 deletions

View file

@ -109,7 +109,11 @@ async def client(tmp_path: Path):
test_app.state.start_time = datetime.now(timezone.utc) test_app.state.start_time = datetime.now(timezone.utc)
transport = ASGITransport(app=test_app) 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 yield ac
# Teardown # Teardown

View file

@ -185,8 +185,16 @@ async def test_session_isolation(client, tmp_path):
transport = ASGITransport(app=test_app) transport = ASGITransport(app=test_app)
async with AsyncClient(transport=transport, base_url="http://test") as client_a: async with AsyncClient(
async with AsyncClient(transport=transport, base_url="http://test") as client_b: 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( await client_a.post(
"/api/downloads", "/api/downloads",
json={"url": "https://example.com/a"}, json={"url": "https://example.com/a"},