feat(07.4-02): update api/auth.py call sites, promote FGP tests, version bump 0.1.3
- api/auth.py login + refresh call sites pass User-Agent and Accept-Language headers to create_access_token (D-05 — fgp binding at token issuance) - test_auth_fgp.py: promote all 4 xfail stubs to real assertions (FGP-01..04) - conftest.py: add _TEST_USER_AGENT constant; configure async_client to send consistent User-Agent; update auth_user/second_auth_user/admin_user fixtures to bind fgp to _TEST_USER_AGENT so tokens validate correctly in tests - test_auth_deps.py: import _TEST_USER_AGENT; update auth_client fixture and all create_access_token calls to use the constant - test_cloud.py: update _create_user_and_token to bind fgp to _TEST_USER_AGENT - test_documents.py: update 3 inline create_access_token calls to pass user_agent - test_security_headers.py: import _TEST_USER_AGENT; update headers_client + token creation to use the constant - Version bump: backend 0.1.2 → 0.1.3, frontend 0.1.2 → 0.1.3 - [Rule 1 - Bug] Fix httpx default User-Agent vs empty-string fgp mismatch in test infrastructure: 10 tests were failing due to fgp check rejecting tokens created with fgp="" when client sent "python-httpx/X.Y.Z"
This commit is contained in:
@@ -18,6 +18,8 @@ import pytest_asyncio
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from tests.conftest import _TEST_USER_AGENT
|
||||
|
||||
|
||||
# ── FakeRedis (needed by login endpoint) ─────────────────────────────────────
|
||||
|
||||
@@ -77,7 +79,12 @@ async def headers_client(db_session: AsyncSession):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as c:
|
||||
# Phase 7.4: send _TEST_USER_AGENT so fgp check matches tokens from this file
|
||||
async with AsyncClient(
|
||||
transport=ASGITransport(app=app),
|
||||
base_url="http://test",
|
||||
headers={"User-Agent": _TEST_USER_AGENT},
|
||||
) as c:
|
||||
yield c
|
||||
|
||||
app.dependency_overrides.clear()
|
||||
@@ -173,7 +180,8 @@ async def test_security_headers_on_authenticated_route(headers_client, db_sessio
|
||||
db_session.add(quota)
|
||||
await db_session.commit()
|
||||
|
||||
token = create_access_token(str(user_id), "user")
|
||||
# Phase 7.4: bind fgp to _TEST_USER_AGENT (matches headers_client default)
|
||||
token = create_access_token(str(user_id), "user", user_agent=_TEST_USER_AGENT)
|
||||
resp = await headers_client.get(
|
||||
"/api/auth/me",
|
||||
headers={"Authorization": f"Bearer {token}"},
|
||||
|
||||
Reference in New Issue
Block a user