chore: merge origin/master into dev

This commit is contained in:
LIghtJUNction
2026-05-19 21:15:22 +08:00
185 changed files with 10524 additions and 3637 deletions

View File

@@ -11,9 +11,15 @@ from werkzeug.datastructures import FileStorage
from astrbot.core import LogBroker
from astrbot.core.core_lifecycle import AstrBotCoreLifecycle
from astrbot.core.db.sqlite import SQLiteDatabase
from astrbot.core.utils.auth_password import (
hash_dashboard_password,
hash_legacy_dashboard_password,
)
from astrbot.dashboard.routes.route import Response
from astrbot.dashboard.server import AstrBotDashboard
_TEST_DASHBOARD_PASSWORD = "AstrbotTest123"
def _get_open_api_route(app: Quart):
rule = next(
@@ -67,6 +73,24 @@ async def core_lifecycle_td(tmp_path_factory):
core_lifecycle = AstrBotCoreLifecycle(log_broker, db)
await core_lifecycle.initialize()
generated_password = getattr(
core_lifecycle.astrbot_config,
"_generated_dashboard_password",
None,
)
dashboard_password = generated_password or _TEST_DASHBOARD_PASSWORD
if not generated_password:
core_lifecycle.astrbot_config["dashboard"]["pbkdf2_password"] = (
hash_dashboard_password(dashboard_password)
)
core_lifecycle.astrbot_config["dashboard"]["password"] = (
hash_legacy_dashboard_password(dashboard_password)
)
object.__setattr__(
core_lifecycle,
"_dashboard_plain_password",
dashboard_password,
)
try:
yield core_lifecycle
finally:
@@ -88,10 +112,13 @@ def app(core_lifecycle_td: AstrBotCoreLifecycle):
def _resolve_dashboard_password(core_lifecycle_td: AstrBotCoreLifecycle) -> str:
password = core_lifecycle_td.astrbot_config["dashboard"]["password"]
if isinstance(password, str) and (password.startswith("pbkdf2_sha256$") or password.startswith("$argon2")):
return "astrbot-test-password"
return str(password)
generated_password = getattr(core_lifecycle_td, "_dashboard_plain_password", None)
if generated_password:
return generated_password
password = core_lifecycle_td.astrbot_config["dashboard"]["pbkdf2_password"]
if isinstance(password, str) and password.startswith("pbkdf2_sha256$"):
return "astrbot"
return password
@pytest_asyncio.fixture(scope="module")