MCPcopy
hub / github.com/AstrBotDevs/AstrBot / authenticated_header

Function authenticated_header

tests/test_dashboard.py:380–395  ·  view source on GitHub ↗

Handles login and returns an authenticated header.

(
    app: FastAPIAppAdapter, core_lifecycle_td: AstrBotCoreLifecycle
)

Source from the content-addressed store, hash-verified

378
379@pytest_asyncio.fixture(scope="module")
380async 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

Callers

nothing calls this directly

Calls 4

test_clientMethod · 0.80
postMethod · 0.45
get_jsonMethod · 0.45

Tested by

no test coverage detected