Protect private API routes and scope agent data
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
"""Helpers for API tests that exercise authenticated application routes."""
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app import auth, database
|
||||
|
||||
|
||||
def authenticated_client(app: FastAPI) -> TestClient:
|
||||
database.ensure_user(database.LOCAL_USER_ID)
|
||||
token, _ = auth.issue_session(database.LOCAL_USER_ID)
|
||||
return TestClient(app, headers={"Authorization": f"Bearer {token}"})
|
||||
Reference in New Issue
Block a user