mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Use gather ipv wait to remove credentials to catch exceptions (#57596)
This commit is contained in:
parent
e130c8671b
commit
0ae1186554
@ -286,7 +286,7 @@ class AuthManager:
|
|||||||
]
|
]
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
await asyncio.wait(tasks)
|
await asyncio.gather(*tasks)
|
||||||
|
|
||||||
await self._store.async_remove_user(user)
|
await self._store.async_remove_user(user)
|
||||||
|
|
||||||
|
@ -17,7 +17,13 @@ from homeassistant.auth.const import MFA_SESSION_EXPIRATION
|
|||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from tests.common import CLIENT_ID, MockUser, ensure_auth_manager_loaded, flush_store
|
from tests.common import (
|
||||||
|
CLIENT_ID,
|
||||||
|
MockUser,
|
||||||
|
async_capture_events,
|
||||||
|
ensure_auth_manager_loaded,
|
||||||
|
flush_store,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@ -931,14 +937,7 @@ async def test_enable_mfa_for_user(hass, hass_storage):
|
|||||||
|
|
||||||
async def test_async_remove_user(hass):
|
async def test_async_remove_user(hass):
|
||||||
"""Test removing a user."""
|
"""Test removing a user."""
|
||||||
events = []
|
events = async_capture_events(hass, "user_removed")
|
||||||
|
|
||||||
@callback
|
|
||||||
def user_removed(event):
|
|
||||||
events.append(event)
|
|
||||||
|
|
||||||
hass.bus.async_listen("user_removed", user_removed)
|
|
||||||
|
|
||||||
manager = await auth.auth_manager_from_config(
|
manager = await auth.auth_manager_from_config(
|
||||||
hass,
|
hass,
|
||||||
[
|
[
|
||||||
@ -983,6 +982,18 @@ async def test_async_remove_user(hass):
|
|||||||
assert events[0].data["user_id"] == user.id
|
assert events[0].data["user_id"] == user.id
|
||||||
|
|
||||||
|
|
||||||
|
async def test_async_remove_user_fail_if_remove_credential_fails(
|
||||||
|
hass, hass_admin_user, hass_admin_credential
|
||||||
|
):
|
||||||
|
"""Test removing a user."""
|
||||||
|
await hass.auth.async_link_user(hass_admin_user, hass_admin_credential)
|
||||||
|
|
||||||
|
with patch.object(
|
||||||
|
hass.auth, "async_remove_credentials", side_effect=ValueError
|
||||||
|
), pytest.raises(ValueError):
|
||||||
|
await hass.auth.async_remove_user(hass_admin_user)
|
||||||
|
|
||||||
|
|
||||||
async def test_new_users(mock_hass):
|
async def test_new_users(mock_hass):
|
||||||
"""Test newly created users."""
|
"""Test newly created users."""
|
||||||
manager = await auth.auth_manager_from_config(
|
manager = await auth.auth_manager_from_config(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user