Revert "Do not allow overriding users when uuid is duplicate (#149408)"

This reverts commit 08ea640629.
This commit is contained in:
Jan Bouwhuis
2025-08-06 09:30:01 +02:00
committed by GitHub
parent 119d0a0170
commit b2ff488519
2 changed files with 1 additions and 18 deletions

View File

@@ -120,9 +120,6 @@ class AuthStore:
new_user = models.User(**kwargs) new_user = models.User(**kwargs)
while new_user.id in self._users:
new_user = models.User(**kwargs)
self._users[new_user.id] = new_user self._users[new_user.id] = new_user
if credentials is None: if credentials is None:

View File

@@ -2,7 +2,7 @@
import asyncio import asyncio
from typing import Any from typing import Any
from unittest.mock import PropertyMock, patch from unittest.mock import patch
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
import pytest import pytest
@@ -300,20 +300,6 @@ async def test_loading_does_not_write_right_away(
assert hass_storage[auth_store.STORAGE_KEY] != {} assert hass_storage[auth_store.STORAGE_KEY] != {}
async def test_duplicate_uuid(
hass: HomeAssistant, hass_storage: dict[str, Any]
) -> None:
"""Test we don't override user if we have a duplicate user ID."""
hass_storage[auth_store.STORAGE_KEY] = MOCK_STORAGE_DATA
store = auth_store.AuthStore(hass)
await store.async_load()
with patch("uuid.UUID.hex", new_callable=PropertyMock) as hex_mock:
hex_mock.side_effect = ["user-id", "new-id"]
user = await store.async_create_user("Test User")
assert len(hex_mock.mock_calls) == 2
assert user.id == "new-id"
async def test_add_remove_user_affects_tokens( async def test_add_remove_user_affects_tokens(
hass: HomeAssistant, hass_storage: dict[str, Any] hass: HomeAssistant, hass_storage: dict[str, Any]
) -> None: ) -> None: