1
mirror of https://github.com/home-assistant/core synced 2024-10-01 05:30:36 +02:00

Fix update person validation (#30691)

This commit is contained in:
Paulus Schoutsen 2020-01-11 19:59:43 -08:00 committed by GitHub
parent 4dc39492a5
commit 117efb5a04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -214,7 +214,7 @@ class PersonStorageCollection(collection.StorageCollection):
user_id = update_data.get(CONF_USER_ID)
if user_id is not None:
if user_id is not None and user_id != data.get(CONF_USER_ID):
await self._validate_user_id(user_id)
return {**data, **update_data}

View File

@ -514,6 +514,18 @@ async def test_ws_update(hass, hass_ws_client, storage_setup):
"id": 6,
"type": "person/update",
"person_id": persons[0]["id"],
"user_id": persons[0]["user_id"],
}
)
resp = await client.receive_json()
assert resp["success"]
resp = await client.send_json(
{
"id": 7,
"type": "person/update",
"person_id": persons[0]["id"],
"name": "Updated Name",
"device_trackers": [DEVICE_TRACKER_2],
"user_id": None,