mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 19:25:12 +02:00
Ensure domain is correct format (#58429)
This commit is contained in:
@@ -576,6 +576,9 @@ async def async_get_integration(hass: HomeAssistant, domain: str) -> Integration
|
|||||||
|
|
||||||
|
|
||||||
async def _async_get_integration(hass: HomeAssistant, domain: str) -> Integration:
|
async def _async_get_integration(hass: HomeAssistant, domain: str) -> Integration:
|
||||||
|
if "." in domain:
|
||||||
|
raise ValueError(f"Invalid domain {domain}")
|
||||||
|
|
||||||
# Instead of using resolve_from_root we use the cache of custom
|
# Instead of using resolve_from_root we use the cache of custom
|
||||||
# components to find the integration.
|
# components to find the integration.
|
||||||
if integration := (await async_get_custom_components(hass)).get(domain):
|
if integration := (await async_get_custom_components(hass)).get(domain):
|
||||||
|
@@ -540,3 +540,9 @@ async def test_custom_integration_missing(hass, caplog):
|
|||||||
|
|
||||||
with pytest.raises(loader.IntegrationNotFound):
|
with pytest.raises(loader.IntegrationNotFound):
|
||||||
await loader.async_get_integration(hass, "test1")
|
await loader.async_get_integration(hass, "test1")
|
||||||
|
|
||||||
|
|
||||||
|
async def test_validation(hass):
|
||||||
|
"""Test we raise if invalid domain passed in."""
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
await loader.async_get_integration(hass, "some.thing")
|
||||||
|
Reference in New Issue
Block a user