mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Don't return resources in safe mode (#102865)
This commit is contained in:
parent
8eaf38cd44
commit
e0885ef109
@ -60,6 +60,9 @@ async def websocket_lovelace_resources(
|
|||||||
"""Send Lovelace UI resources over WebSocket configuration."""
|
"""Send Lovelace UI resources over WebSocket configuration."""
|
||||||
resources = hass.data[DOMAIN]["resources"]
|
resources = hass.data[DOMAIN]["resources"]
|
||||||
|
|
||||||
|
if hass.config.safe_mode:
|
||||||
|
connection.send_result(msg["id"], [])
|
||||||
|
|
||||||
if not resources.loaded:
|
if not resources.loaded:
|
||||||
await resources.async_load()
|
await resources.async_load()
|
||||||
resources.loaded = True
|
resources.loaded = True
|
||||||
|
@ -185,3 +185,26 @@ async def test_storage_resources_import_invalid(
|
|||||||
"resources"
|
"resources"
|
||||||
in hass_storage[dashboard.CONFIG_STORAGE_KEY_DEFAULT]["data"]["config"]
|
in hass_storage[dashboard.CONFIG_STORAGE_KEY_DEFAULT]["data"]["config"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_storage_resources_safe_mode(
|
||||||
|
hass: HomeAssistant, hass_ws_client, hass_storage: dict[str, Any]
|
||||||
|
) -> None:
|
||||||
|
"""Test defining resources in storage config."""
|
||||||
|
|
||||||
|
resource_config = [{**item, "id": uuid.uuid4().hex} for item in RESOURCE_EXAMPLES]
|
||||||
|
hass_storage[resources.RESOURCE_STORAGE_KEY] = {
|
||||||
|
"key": resources.RESOURCE_STORAGE_KEY,
|
||||||
|
"version": 1,
|
||||||
|
"data": {"items": resource_config},
|
||||||
|
}
|
||||||
|
assert await async_setup_component(hass, "lovelace", {})
|
||||||
|
|
||||||
|
client = await hass_ws_client(hass)
|
||||||
|
hass.config.safe_mode = True
|
||||||
|
|
||||||
|
# Fetch data
|
||||||
|
await client.send_json({"id": 5, "type": "lovelace/resources"})
|
||||||
|
response = await client.receive_json()
|
||||||
|
assert response["success"]
|
||||||
|
assert response["result"] == []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user