mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 05:05:09 +02:00
fixes
This commit is contained in:
@@ -221,7 +221,12 @@ class ActiveConnection:
|
|||||||
handler, schema = handler_schema
|
handler, schema = handler_schema
|
||||||
|
|
||||||
try:
|
try:
|
||||||
handler(self.hass, self, msg if schema is False else schema(msg))
|
if schema is False:
|
||||||
|
if len(msg) > 2:
|
||||||
|
raise vol.Invalid("Message has unexpected keys")
|
||||||
|
handler(self.hass, self, msg)
|
||||||
|
else:
|
||||||
|
handler(self.hass, self, schema(msg))
|
||||||
except Exception as err: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
self.async_handle_exception(msg, err)
|
self.async_handle_exception(msg, err)
|
||||||
|
|
||||||
|
@@ -122,6 +122,23 @@ async def test_async_response_request_context(
|
|||||||
assert msg["error"]["code"] == "invalid_format"
|
assert msg["error"]["code"] == "invalid_format"
|
||||||
assert msg["error"]["message"] == "Message incorrectly formatted."
|
assert msg["error"]["message"] == "Message incorrectly formatted."
|
||||||
|
|
||||||
|
await websocket_client.send_json(
|
||||||
|
{
|
||||||
|
"id": 10,
|
||||||
|
"type": "test-get-request",
|
||||||
|
"not_valid": "dog",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
msg = await websocket_client.receive_json()
|
||||||
|
assert msg["id"] == 10
|
||||||
|
assert not msg["success"]
|
||||||
|
assert msg["error"]["code"] == "invalid_format"
|
||||||
|
assert msg["error"]["message"] == (
|
||||||
|
"Message has unexpected keys. "
|
||||||
|
"Got {'id': 10, 'type': 'test-get-request', 'not_valid': 'dog'}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_supervisor_only(hass: HomeAssistant, websocket_client) -> None:
|
async def test_supervisor_only(hass: HomeAssistant, websocket_client) -> None:
|
||||||
"""Test that only the Supervisor can make requests."""
|
"""Test that only the Supervisor can make requests."""
|
||||||
|
Reference in New Issue
Block a user