Skip to content

Commit f429c72

Browse files
committed
test: update dashboard password resolution and fix mock loggers
1 parent 8f62ad5 commit f429c72

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

tests/test_api_key_open_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def app(core_lifecycle_td: AstrBotCoreLifecycle):
7474

7575
def _resolve_dashboard_password(core_lifecycle_td: AstrBotCoreLifecycle) -> str:
7676
password = core_lifecycle_td.astrbot_config["dashboard"]["password"]
77-
if isinstance(password, str) and password.startswith("pbkdf2_sha256$"):
78-
return "astrbot"
77+
if isinstance(password, str) and ((password.startswith("pbkdf2_sha256$") or password.startswith("$argon2")) or password.startswith("$argon2")):
78+
return "astrbot-test-password"
7979
return password
8080

8181

tests/test_dashboard.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def app(core_lifecycle_td: AstrBotCoreLifecycle):
6161
def _resolve_dashboard_password(core_lifecycle_td: AstrBotCoreLifecycle) -> str:
6262
"""Return a login password compatible with both hashed and plain defaults."""
6363
password = core_lifecycle_td.astrbot_config["dashboard"]["password"]
64-
if isinstance(password, str) and password.startswith("pbkdf2_sha256$"):
65-
return "astrbot"
64+
if isinstance(password, str) and (password.startswith("pbkdf2_sha256$") or password.startswith("$argon2")):
65+
return "astrbot-test-password"
6666
return password
6767

6868

@@ -74,11 +74,12 @@ async def authenticated_header(app: Quart, core_lifecycle_td: AstrBotCoreLifecyc
7474
"/api/auth/login",
7575
json={
7676
"username": core_lifecycle_td.astrbot_config["dashboard"]["username"],
77+
7778
"password": _resolve_dashboard_password(core_lifecycle_td),
7879
},
7980
)
8081
data = await response.get_json()
81-
assert data["status"] == "ok"
82+
assert data["status"] == "ok", str(data)
8283
token = data["data"]["token"]
8384
return {"Authorization": f"Bearer {token}"}
8485

@@ -98,6 +99,7 @@ async def test_auth_login(app: Quart, core_lifecycle_td: AstrBotCoreLifecycle):
9899
"/api/auth/login",
99100
json={
100101
"username": core_lifecycle_td.astrbot_config["dashboard"]["username"],
102+
101103
"password": _resolve_dashboard_password(core_lifecycle_td),
102104
},
103105
)
@@ -142,11 +144,11 @@ async def fake_serve(app, config, shutdown_trigger):
142144
monkeypatch.setattr("astrbot.dashboard.server.serve", fake_serve)
143145
monkeypatch.setattr(
144146
"astrbot.dashboard.server.logger.warning",
145-
lambda message: warning_messages.append(message),
147+
lambda *args, **kwargs: warning_messages.append(message),
146148
)
147149
monkeypatch.setattr(
148150
"astrbot.dashboard.server.logger.info",
149-
lambda message: info_messages.append(message),
151+
lambda *args, **kwargs: info_messages.append(message),
150152
)
151153

152154
config = await server.run()
@@ -1095,7 +1097,7 @@ async def _fake_sync_skills_to_active_sandboxes():
10951097
_fake_sync_skills_to_active_sandboxes,
10961098
)
10971099
monkeypatch.setattr(
1098-
"astrbot.core.skills.skill_manager.get_astrbot_data_path",
1100+
"astrbot.core.utils.astrbot_path.get_astrbot_data_path",
10991101
lambda: str(data_dir),
11001102
)
11011103
monkeypatch.setattr(

tests/test_kb_import.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def app(core_lifecycle_td: AstrBotCoreLifecycle):
6666

6767
def _resolve_dashboard_password(core_lifecycle_td: AstrBotCoreLifecycle) -> str:
6868
password = core_lifecycle_td.astrbot_config["dashboard"]["password"]
69-
if isinstance(password, str) and password.startswith("pbkdf2_sha256$"):
70-
return "astrbot"
69+
if isinstance(password, str) and ((password.startswith("pbkdf2_sha256$") or password.startswith("$argon2")) or password.startswith("$argon2")):
70+
return "astrbot-test-password"
7171
return password
7272

7373

0 commit comments

Comments
 (0)