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

Function test_setup_skip_requires_local_host

tests/test_dashboard.py:1486–1521  ·  view source on GitHub ↗
(
    app: FastAPIAppAdapter,
    core_lifecycle_td: AstrBotCoreLifecycle,
    monkeypatch: pytest.MonkeyPatch,
)

Source from the content-addressed store, hash-verified

1484
1485@pytest.mark.asyncio
1486async def test_setup_skip_requires_local_host(
1487 app: FastAPIAppAdapter,
1488 core_lifecycle_td: AstrBotCoreLifecycle,
1489 monkeypatch: pytest.MonkeyPatch,
1490):
1491 original_dashboard_config = copy.deepcopy(
1492 core_lifecycle_td.astrbot_config["dashboard"]
1493 )
1494 test_client = app.test_client()
1495
1496 try:
1497 monkeypatch.setenv("ASTRBOT_DASHBOARD_SKIP_DEFAULT_PASSWORD_AUTH", "true")
1498 core_lifecycle_td.astrbot_config["dashboard"]["host"] = "0.0.0.0"
1499 await _set_dashboard_password_change_required(core_lifecycle_td, True)
1500
1501 response = await test_client.get("/api/auth/setup-status")
1502 data = await response.get_json()
1503 assert data["status"] == "ok"
1504 assert data["data"]["setup_required"] is True
1505 assert data["data"]["skip_default_password_auth"] is False
1506
1507 response = await test_client.post(
1508 "/api/auth/setup",
1509 json={
1510 "username": "astrbot-admin",
1511 "password": "AstrbotSetup123",
1512 "confirm_password": "AstrbotSetup123",
1513 },
1514 )
1515 data = await response.get_json()
1516 assert data["status"] == "error"
1517 finally:
1518 await _restore_dashboard_password_state(
1519 core_lifecycle_td,
1520 original_dashboard_config,
1521 )
1522
1523
1524@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 6

test_clientMethod · 0.80
getMethod · 0.45
get_jsonMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected