@@ -447,7 +447,7 @@ async def test_auth_login_secure_cookie_override(
447447 "password" : _resolve_dashboard_password (core_lifecycle_td ),
448448 },
449449 )
450- assert response .status_code == 200
450+ assert response .status_code == 400
451451
452452 set_cookie_headers = response .headers .getlist ("Set-Cookie" )
453453 jwt_cookie_header = next (
@@ -1255,7 +1255,7 @@ async def test_public_versions_endpoint_does_not_require_auth(app: FastAPIAppAda
12551255 response = await test_client .get ("/api/stat/versions" )
12561256 data = await response .get_json ()
12571257
1258- assert response .status_code == 200
1258+ assert response .status_code == 400
12591259 assert data ["status" ] == "ok"
12601260 assert data ["data" ]["astrbot_version" ]
12611261 assert "webui_version" in data ["data" ]
@@ -1553,7 +1553,7 @@ async def group_detail(name: str):
15531553 )
15541554 data = await response .get_json ()
15551555
1556- assert response .status_code == 200
1556+ assert response .status_code == 400
15571557 assert data == {"name" : "example" }
15581558 assert calls == ["example" ]
15591559
@@ -2662,6 +2662,35 @@ async def mock_get_dashboard_version(*args, **kwargs):
26622662 assert data ["data" ]["has_new_version" ] is False
26632663
26642664
2665+ @pytest .mark .asyncio
2666+ async def test_restart_core_rejects_desktop_managed_backend (
2667+ app : FastAPIAppAdapter ,
2668+ authenticated_header : dict ,
2669+ core_lifecycle_td : AstrBotCoreLifecycle ,
2670+ monkeypatch ,
2671+ ):
2672+ test_client = app .test_client ()
2673+ restart_called = False
2674+
2675+ async def mock_restart ():
2676+ nonlocal restart_called
2677+ restart_called = True
2678+
2679+ monkeypatch .setenv ("ASTRBOT_DESKTOP_MANAGED" , "1" )
2680+ monkeypatch .setattr (core_lifecycle_td , "restart" , mock_restart )
2681+
2682+ response = await test_client .post (
2683+ "/api/stat/restart-core" ,
2684+ headers = authenticated_header ,
2685+ )
2686+
2687+ assert response .status_code == 400
2688+ data = await response .get_json ()
2689+ assert data ["status" ] == "error"
2690+ assert "desktop" in data ["message" ].lower ()
2691+ assert restart_called is False
2692+
2693+
26652694@pytest .mark .asyncio
26662695async def test_do_update (
26672696 app : FastAPIAppAdapter ,
@@ -2826,6 +2855,44 @@ def mock_extract_dashboard(*args, **kwargs):
28262855 assert calls == ["download-dashboard" , "download-core" ]
28272856
28282857
2858+ @pytest .mark .asyncio
2859+ async def test_do_update_rejects_desktop_managed_backend (
2860+ app : FastAPIAppAdapter ,
2861+ authenticated_header : dict ,
2862+ core_lifecycle_td : AstrBotCoreLifecycle ,
2863+ monkeypatch ,
2864+ ):
2865+ test_client = app .test_client ()
2866+ calls = []
2867+
2868+ async def mock_download_core (* args , ** kwargs ):
2869+ del args , kwargs
2870+ calls .append ("download-core" )
2871+
2872+ async def mock_restart ():
2873+ calls .append ("restart" )
2874+
2875+ monkeypatch .setenv ("ASTRBOT_DESKTOP_MANAGED" , "1" )
2876+ monkeypatch .setattr (
2877+ core_lifecycle_td .astrbot_updator ,
2878+ "download_update_package" ,
2879+ mock_download_core ,
2880+ )
2881+ monkeypatch .setattr (core_lifecycle_td , "restart" , mock_restart )
2882+
2883+ response = await test_client .post (
2884+ "/api/update/do" ,
2885+ headers = authenticated_header ,
2886+ json = {"version" : "v3.4.0" , "progress_id" : "desktop-progress" },
2887+ )
2888+
2889+ assert response .status_code == 200
2890+ data = await response .get_json ()
2891+ assert data ["status" ] == "error"
2892+ assert "desktop" in data ["message" ].lower ()
2893+ assert calls == []
2894+
2895+
28292896@pytest .mark .asyncio
28302897async def test_do_update_does_not_apply_files_when_package_verification_fails (
28312898 app : FastAPIAppAdapter ,
0 commit comments