Fix external internal url core check (#54310)

This commit is contained in:
Martin Hjelmare 2021-08-09 10:52:14 +02:00 committed by GitHub
parent 952d11cb03
commit a1abd4f0d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -1723,13 +1723,13 @@ class Config:
# In 2021.9 we fixed validation to disallow a path (because that's never correct)
# but this data still lives in storage, so we print a warning.
if "external_url" in data and urlparse(data["external_url"]).path not in (
if data.get("external_url") and urlparse(data["external_url"]).path not in (
"",
"/",
):
_LOGGER.warning("Invalid external_url set. It's not allowed to have a path")
if "internal_url" in data and urlparse(data["internal_url"]).path not in (
if data.get("internal_url") and urlparse(data["internal_url"]).path not in (
"",
"/",
):

View file

@ -1377,6 +1377,18 @@ async def test_additional_data_in_core_config(hass, hass_storage):
async def test_incorrect_internal_external_url(hass, hass_storage, caplog):
"""Test that we warn when detecting invalid internal/extenral url."""
config = ha.Config(hass)
hass_storage[ha.CORE_STORAGE_KEY] = {
"version": 1,
"data": {
"internal_url": None,
"external_url": None,
},
}
await config.async_load()
assert "Invalid external_url set" not in caplog.text
assert "Invalid internal_url set" not in caplog.text
hass_storage[ha.CORE_STORAGE_KEY] = {
"version": 1,
"data": {