diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 986171cbee7..eabbbb49362 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -398,7 +398,7 @@ def _get_domains(hass: core.HomeAssistant, config: dict[str, Any]) -> set[str]: domains.update(hass.config_entries.async_domains()) # Make sure the Hass.io component is loaded - if "HASSIO" in os.environ: + if "SUPERVISOR" in os.environ: domains.add("hassio") return domains diff --git a/homeassistant/components/hassio/__init__.py b/homeassistant/components/hassio/__init__.py index 93d902e4bae..cab17c94f0c 100644 --- a/homeassistant/components/hassio/__init__.py +++ b/homeassistant/components/hassio/__init__.py @@ -505,7 +505,7 @@ def get_supervisor_ip() -> str: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: C901 """Set up the Hass.io component.""" # Check local setup - for env in ("HASSIO", "HASSIO_TOKEN"): + for env in ("SUPERVISOR", "SUPERVISOR_TOKEN"): if os.environ.get(env): continue _LOGGER.error("Missing %s environment variable", env) @@ -517,7 +517,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa: async_load_websocket_api(hass) - host = os.environ["HASSIO"] + host = os.environ["SUPERVISOR"] websession = async_get_clientsession(hass) hass.data[DOMAIN] = hassio = HassIO(hass.loop, websession, host) diff --git a/homeassistant/components/hassio/auth.py b/homeassistant/components/hassio/auth.py index 2d76a758096..f52a8ef0617 100644 --- a/homeassistant/components/hassio/auth.py +++ b/homeassistant/components/hassio/auth.py @@ -42,7 +42,7 @@ class HassIOBaseAuth(HomeAssistantView): def _check_access(self, request: web.Request): """Check if this call is from Supervisor.""" # Check caller IP - hassio_ip = os.environ["HASSIO"].split(":")[0] + hassio_ip = os.environ["SUPERVISOR"].split(":")[0] if ip_address(request.transport.get_extra_info("peername")[0]) != ip_address( hassio_ip ): diff --git a/homeassistant/components/hassio/handler.py b/homeassistant/components/hassio/handler.py index 4146753b753..ba1b3bfaf35 100644 --- a/homeassistant/components/hassio/handler.py +++ b/homeassistant/components/hassio/handler.py @@ -246,7 +246,7 @@ class HassIO: method, f"http://{self._ip}{command}", json=payload, - headers={X_HASSIO: os.environ.get("HASSIO_TOKEN", "")}, + headers={X_HASSIO: os.environ.get("SUPERVISOR_TOKEN", "")}, timeout=aiohttp.ClientTimeout(total=timeout), ) diff --git a/homeassistant/components/hassio/http.py b/homeassistant/components/hassio/http.py index 532b947ac49..63ac1521cc5 100644 --- a/homeassistant/components/hassio/http.py +++ b/homeassistant/components/hassio/http.py @@ -124,7 +124,7 @@ class HassIOView(HomeAssistantView): def _init_header(request: web.Request) -> dict[str, str]: """Create initial header.""" headers = { - X_HASSIO: os.environ.get("HASSIO_TOKEN", ""), + X_HASSIO: os.environ.get("SUPERVISOR_TOKEN", ""), CONTENT_TYPE: request.content_type, } diff --git a/homeassistant/components/hassio/ingress.py b/homeassistant/components/hassio/ingress.py index 284ba42b3c1..c8b56e6f1bb 100644 --- a/homeassistant/components/hassio/ingress.py +++ b/homeassistant/components/hassio/ingress.py @@ -183,7 +183,7 @@ def _init_header(request: web.Request, token: str) -> CIMultiDict | dict[str, st headers[name] = value # Inject token / cleanup later on Supervisor - headers[X_HASSIO] = os.environ.get("HASSIO_TOKEN", "") + headers[X_HASSIO] = os.environ.get("SUPERVISOR_TOKEN", "") # Ingress information headers[X_INGRESS_PATH] = f"/api/hassio_ingress/{token}" diff --git a/homeassistant/components/hassio/system_health.py b/homeassistant/components/hassio/system_health.py index 1039a0237a8..b1fc208de80 100644 --- a/homeassistant/components/hassio/system_health.py +++ b/homeassistant/components/hassio/system_health.py @@ -6,8 +6,8 @@ from homeassistant.core import HomeAssistant, callback from . import get_host_info, get_info, get_os_info, get_supervisor_info -SUPERVISOR_PING = f"http://{os.environ['HASSIO']}/supervisor/ping" -OBSERVER_URL = f"http://{os.environ['HASSIO']}:4357" +SUPERVISOR_PING = f"http://{os.environ['SUPERVISOR']}/supervisor/ping" +OBSERVER_URL = f"http://{os.environ['SUPERVISOR']}:4357" @callback diff --git a/tests/components/hassio/__init__.py b/tests/components/hassio/__init__.py index 79520c6fd12..76aecd64098 100644 --- a/tests/components/hassio/__init__.py +++ b/tests/components/hassio/__init__.py @@ -1,2 +1,2 @@ """Tests for Hass.io component.""" -HASSIO_TOKEN = "123456" +SUPERVISOR_TOKEN = "123456" diff --git a/tests/components/hassio/conftest.py b/tests/components/hassio/conftest.py index 89a8c6f5c51..a6cd956c95e 100644 --- a/tests/components/hassio/conftest.py +++ b/tests/components/hassio/conftest.py @@ -9,16 +9,16 @@ from homeassistant.core import CoreState from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.setup import async_setup_component -from . import HASSIO_TOKEN +from . import SUPERVISOR_TOKEN @pytest.fixture def hassio_env(): """Fixture to inject hassio env.""" - with patch.dict(os.environ, {"HASSIO": "127.0.0.1"}), patch( + with patch.dict(os.environ, {"SUPERVISOR": "127.0.0.1"}), patch( "homeassistant.components.hassio.HassIO.is_connected", return_value={"result": "ok", "data": {}}, - ), patch.dict(os.environ, {"HASSIO_TOKEN": HASSIO_TOKEN}), patch( + ), patch.dict(os.environ, {"SUPERVISOR_TOKEN": SUPERVISOR_TOKEN}), patch( "homeassistant.components.hassio.HassIO.get_info", Mock(side_effect=HassioAPIError()), ): @@ -75,5 +75,5 @@ def hassio_handler(hass, aioclient_mock): websession = hass.loop.run_until_complete(get_client_session()) - with patch.dict(os.environ, {"HASSIO_TOKEN": HASSIO_TOKEN}): + with patch.dict(os.environ, {"SUPERVISOR_TOKEN": SUPERVISOR_TOKEN}): yield HassIO(hass.loop, websession, "127.0.0.1") diff --git a/tests/components/hassio/test_binary_sensor.py b/tests/components/hassio/test_binary_sensor.py index 0f4691e2795..ba9bcb2afdf 100644 --- a/tests/components/hassio/test_binary_sensor.py +++ b/tests/components/hassio/test_binary_sensor.py @@ -11,7 +11,7 @@ from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry -MOCK_ENVIRON = {"HASSIO": "127.0.0.1", "HASSIO_TOKEN": "abcdefgh"} +MOCK_ENVIRON = {"SUPERVISOR": "127.0.0.1", "SUPERVISOR_TOKEN": "abcdefgh"} @pytest.fixture(autouse=True) diff --git a/tests/components/hassio/test_diagnostics.py b/tests/components/hassio/test_diagnostics.py index 7bbc768681a..1f915e17e61 100644 --- a/tests/components/hassio/test_diagnostics.py +++ b/tests/components/hassio/test_diagnostics.py @@ -13,7 +13,7 @@ from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry from tests.components.diagnostics import get_diagnostics_for_config_entry -MOCK_ENVIRON = {"HASSIO": "127.0.0.1", "HASSIO_TOKEN": "abcdefgh"} +MOCK_ENVIRON = {"SUPERVISOR": "127.0.0.1", "SUPERVISOR_TOKEN": "abcdefgh"} @pytest.fixture(autouse=True) diff --git a/tests/components/hassio/test_init.py b/tests/components/hassio/test_init.py index ff595aaa602..c47b3bfbeca 100644 --- a/tests/components/hassio/test_init.py +++ b/tests/components/hassio/test_init.py @@ -17,7 +17,7 @@ from homeassistant.util import dt as dt_util from tests.common import MockConfigEntry, async_fire_time_changed -MOCK_ENVIRON = {"HASSIO": "127.0.0.1", "HASSIO_TOKEN": "abcdefgh"} +MOCK_ENVIRON = {"SUPERVISOR": "127.0.0.1", "SUPERVISOR_TOKEN": "abcdefgh"} @pytest.fixture() @@ -336,7 +336,7 @@ async def test_setup_core_push_timezone(hass, aioclient_mock): async def test_setup_hassio_no_additional_data(hass, aioclient_mock): """Test setup with API push default data.""" with patch.dict(os.environ, MOCK_ENVIRON), patch.dict( - os.environ, {"HASSIO_TOKEN": "123456"} + os.environ, {"SUPERVISOR_TOKEN": "123456"} ): result = await async_setup_component(hass, "hassio", {"hassio": {}}) assert result diff --git a/tests/components/hassio/test_sensor.py b/tests/components/hassio/test_sensor.py index 382d804eaac..868448cec2d 100644 --- a/tests/components/hassio/test_sensor.py +++ b/tests/components/hassio/test_sensor.py @@ -11,7 +11,7 @@ from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry -MOCK_ENVIRON = {"HASSIO": "127.0.0.1", "HASSIO_TOKEN": "abcdefgh"} +MOCK_ENVIRON = {"SUPERVISOR": "127.0.0.1", "SUPERVISOR_TOKEN": "abcdefgh"} @pytest.fixture(autouse=True) diff --git a/tests/components/hassio/test_update.py b/tests/components/hassio/test_update.py index 14d1d06ef38..48f6d894de0 100644 --- a/tests/components/hassio/test_update.py +++ b/tests/components/hassio/test_update.py @@ -12,7 +12,7 @@ from homeassistant.setup import async_setup_component from tests.common import MockConfigEntry -MOCK_ENVIRON = {"HASSIO": "127.0.0.1", "HASSIO_TOKEN": "abcdefgh"} +MOCK_ENVIRON = {"SUPERVISOR": "127.0.0.1", "SUPERVISOR_TOKEN": "abcdefgh"} @pytest.fixture(autouse=True) diff --git a/tests/components/http/test_ban.py b/tests/components/http/test_ban.py index fbd545e0506..5e482d16248 100644 --- a/tests/components/http/test_ban.py +++ b/tests/components/http/test_ban.py @@ -33,10 +33,10 @@ BANNED_IPS_WITH_SUPERVISOR = BANNED_IPS + [SUPERVISOR_IP] @pytest.fixture(name="hassio_env") def hassio_env_fixture(): """Fixture to inject hassio env.""" - with patch.dict(os.environ, {"HASSIO": "127.0.0.1"}), patch( + with patch.dict(os.environ, {"SUPERVISOR": "127.0.0.1"}), patch( "homeassistant.components.hassio.HassIO.is_connected", return_value={"result": "ok", "data": {}}, - ), patch.dict(os.environ, {"HASSIO_TOKEN": "123456"}): + ), patch.dict(os.environ, {"SUPERVISOR_TOKEN": "123456"}): yield diff --git a/tests/components/onboarding/test_views.py b/tests/components/onboarding/test_views.py index 025459e73b7..982f5b86e65 100644 --- a/tests/components/onboarding/test_views.py +++ b/tests/components/onboarding/test_views.py @@ -57,7 +57,7 @@ async def mock_supervisor_fixture(hass, aioclient_mock): """Mock supervisor.""" aioclient_mock.post("http://127.0.0.1/homeassistant/options", json={"result": "ok"}) aioclient_mock.post("http://127.0.0.1/supervisor/options", json={"result": "ok"}) - with patch.dict(os.environ, {"HASSIO": "127.0.0.1"}), patch( + with patch.dict(os.environ, {"SUPERVISOR": "127.0.0.1"}), patch( "homeassistant.components.hassio.HassIO.is_connected", return_value=True, ), patch( @@ -79,7 +79,7 @@ async def mock_supervisor_fixture(hass, aioclient_mock): "homeassistant.components.hassio.HassIO.get_ingress_panels", return_value={"panels": {}}, ), patch.dict( - os.environ, {"HASSIO_TOKEN": "123456"} + os.environ, {"SUPERVISOR_TOKEN": "123456"} ): yield diff --git a/tests/test_bootstrap.py b/tests/test_bootstrap.py index c6c507a0f73..232d8fb6bbf 100644 --- a/tests/test_bootstrap.py +++ b/tests/test_bootstrap.py @@ -84,7 +84,7 @@ async def test_load_hassio(hass): with patch.dict(os.environ, {}, clear=True): assert bootstrap._get_domains(hass, {}) == set() - with patch.dict(os.environ, {"HASSIO": "1"}): + with patch.dict(os.environ, {"SUPERVISOR": "1"}): assert bootstrap._get_domains(hass, {}) == {"hassio"}