mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Improve error handling for application credentials deletion (#71868)
This commit is contained in:
parent
a32321aa9f
commit
aa35b87884
@ -17,6 +17,7 @@ from homeassistant.components import websocket_api
|
||||
from homeassistant.components.websocket_api.connection import ActiveConnection
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, CONF_DOMAIN, CONF_ID
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import collection, config_entry_oauth2_flow
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.storage import Store
|
||||
@ -98,7 +99,9 @@ class ApplicationCredentialsStorageCollection(collection.StorageCollection):
|
||||
entries = self.hass.config_entries.async_entries(current[CONF_DOMAIN])
|
||||
for entry in entries:
|
||||
if entry.data.get("auth_implementation") == item_id:
|
||||
raise ValueError("Cannot delete credential in use by an integration")
|
||||
raise HomeAssistantError(
|
||||
f"Cannot delete credential in use by integration {entry.domain}"
|
||||
)
|
||||
|
||||
await super().async_delete_item(item_id)
|
||||
|
||||
|
@ -445,6 +445,10 @@ async def test_config_flow(
|
||||
assert not resp.get("success")
|
||||
assert "error" in resp
|
||||
assert resp["error"].get("code") == "unknown_error"
|
||||
assert (
|
||||
resp["error"].get("message")
|
||||
== "Cannot delete credential in use by integration fake_integration"
|
||||
)
|
||||
|
||||
|
||||
async def test_config_flow_multiple_entries(
|
||||
|
Loading…
x
Reference in New Issue
Block a user