mirror of
https://github.com/home-assistant/core
synced 2024-10-05 05:22:27 +00:00
Ensure domain is correct format (#58429)
This commit is contained in:
parent
a813608185
commit
cd3e51b3e7
|
@ -576,6 +576,9 @@ 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
|
||||
# components to find the integration.
|
||||
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):
|
||||
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")
|
||||
|
|
Loading…
Reference in a new issue