diff --git a/CODEOWNERS b/CODEOWNERS index 8785ce382cb..7c45a66e166 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -287,6 +287,7 @@ homeassistant/components/motion_blinds/* @starkillerOG homeassistant/components/mpd/* @fabaff homeassistant/components/mqtt/* @home-assistant/core @emontnemery homeassistant/components/msteams/* @peroyvind +homeassistant/components/my/* @home-assistant/core homeassistant/components/myq/* @bdraco homeassistant/components/mysensors/* @MartinHjelmare @functionpointer homeassistant/components/mystrom/* @fabaff diff --git a/homeassistant/components/default_config/manifest.json b/homeassistant/components/default_config/manifest.json index f8be3c9fe2a..0f4b940cc36 100644 --- a/homeassistant/components/default_config/manifest.json +++ b/homeassistant/components/default_config/manifest.json @@ -18,6 +18,7 @@ "map", "media_source", "mobile_app", + "my", "person", "scene", "script", diff --git a/homeassistant/components/http/__init__.py b/homeassistant/components/http/__init__.py index 7f70d49f686..63c88427a5b 100644 --- a/homeassistant/components/http/__init__.py +++ b/homeassistant/components/http/__init__.py @@ -58,8 +58,9 @@ SSL_INTERMEDIATE = "intermediate" _LOGGER = logging.getLogger(__name__) DEFAULT_DEVELOPMENT = "0" -# To be able to load custom cards. -DEFAULT_CORS = "https://cast.home-assistant.io" +# Cast to be able to load custom cards. +# My to be able to check url and version info. +DEFAULT_CORS = ["https://cast.home-assistant.io", "https://my.home-assistant.io"] NO_LOGIN_ATTEMPT_THRESHOLD = -1 MAX_CLIENT_SIZE: int = 1024 ** 2 * 16 @@ -80,7 +81,7 @@ HTTP_SCHEMA = vol.All( vol.Optional(CONF_SSL_CERTIFICATE): cv.isfile, vol.Optional(CONF_SSL_PEER_CERTIFICATE): cv.isfile, vol.Optional(CONF_SSL_KEY): cv.isfile, - vol.Optional(CONF_CORS_ORIGINS, default=[DEFAULT_CORS]): vol.All( + vol.Optional(CONF_CORS_ORIGINS, default=DEFAULT_CORS): vol.All( cv.ensure_list, [cv.string] ), vol.Inclusive(CONF_USE_X_FORWARDED_FOR, "proxy"): cv.boolean, diff --git a/homeassistant/components/my/__init__.py b/homeassistant/components/my/__init__.py new file mode 100644 index 00000000000..8cc725cb9a5 --- /dev/null +++ b/homeassistant/components/my/__init__.py @@ -0,0 +1,12 @@ +"""Support for my.home-assistant.io redirect service.""" + +DOMAIN = "my" +URL_PATH = "_my_redirect" + + +async def async_setup(hass, config): + """Register hidden _my_redirect panel.""" + hass.components.frontend.async_register_built_in_panel( + DOMAIN, frontend_url_path=URL_PATH + ) + return True diff --git a/homeassistant/components/my/manifest.json b/homeassistant/components/my/manifest.json new file mode 100644 index 00000000000..3b9e253f353 --- /dev/null +++ b/homeassistant/components/my/manifest.json @@ -0,0 +1,7 @@ +{ + "domain": "my", + "name": "My Home Assistant", + "documentation": "https://www.home-assistant.io/integrations/my", + "dependencies": ["frontend"], + "codeowners": ["@home-assistant/core"] +} diff --git a/tests/components/http/test_init.py b/tests/components/http/test_init.py index 3dd587cd7a4..e7a3884c481 100644 --- a/tests/components/http/test_init.py +++ b/tests/components/http/test_init.py @@ -242,7 +242,10 @@ async def test_cors_defaults(hass): assert await async_setup_component(hass, "http", {}) assert len(mock_setup.mock_calls) == 1 - assert mock_setup.mock_calls[0][1][1] == ["https://cast.home-assistant.io"] + assert mock_setup.mock_calls[0][1][1] == [ + "https://cast.home-assistant.io", + "https://my.home-assistant.io", + ] async def test_storing_config(hass, aiohttp_client, aiohttp_unused_port): diff --git a/tests/components/my/__init__.py b/tests/components/my/__init__.py new file mode 100644 index 00000000000..82953c8dac2 --- /dev/null +++ b/tests/components/my/__init__.py @@ -0,0 +1 @@ +"""Tests for the my component.""" diff --git a/tests/components/my/test_init.py b/tests/components/my/test_init.py new file mode 100644 index 00000000000..86929271be9 --- /dev/null +++ b/tests/components/my/test_init.py @@ -0,0 +1,17 @@ +"""Test the my init.""" + +from unittest import mock + +from homeassistant.components.my import URL_PATH +from homeassistant.setup import async_setup_component + + +async def test_setup(hass): + """Test setup.""" + with mock.patch( + "homeassistant.components.frontend.async_register_built_in_panel" + ) as mock_register_panel: + assert await async_setup_component(hass, "my", {"foo": "bar"}) + assert mock_register_panel.call_args == mock.call( + hass, "my", frontend_url_path=URL_PATH + )