Handles login and returns an authenticated header.
(
app: FastAPIAppAdapter, core_lifecycle_td: AstrBotCoreLifecycle
)
| 378 | |
| 379 | @pytest_asyncio.fixture(scope="module") |
| 380 | async def authenticated_header( |
| 381 | app: FastAPIAppAdapter, core_lifecycle_td: AstrBotCoreLifecycle |
| 382 | ): |
| 383 | """Handles login and returns an authenticated header.""" |
| 384 | test_client = app.test_client() |
| 385 | response = await test_client.post( |
| 386 | "/api/auth/login", |
| 387 | json={ |
| 388 | "username": core_lifecycle_td.astrbot_config["dashboard"]["username"], |
| 389 | "password": _resolve_dashboard_password(core_lifecycle_td), |
| 390 | }, |
| 391 | ) |
| 392 | data = await response.get_json() |
| 393 | assert data["status"] == "ok" |
| 394 | token = data["data"]["token"] |
| 395 | return {"Authorization": f"Bearer {token}"} |
| 396 | |
| 397 | |
| 398 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected