diff --git a/homeassistant/components/cloud/__init__.py b/homeassistant/components/cloud/__init__.py index 0662487b765..c5918dcf28f 100644 --- a/homeassistant/components/cloud/__init__.py +++ b/homeassistant/components/cloud/__init__.py @@ -36,22 +36,23 @@ from homeassistant.util.aiohttp import MockRequest from . import account_link, http_api from .client import CloudClient from .const import ( - CONF_ACCOUNT_LINK_URL, - CONF_ACME_DIRECTORY_SERVER, + CONF_ACCOUNT_LINK_SERVER, + CONF_ACCOUNTS_SERVER, + CONF_ACME_SERVER, CONF_ALEXA, - CONF_ALEXA_ACCESS_TOKEN_URL, + CONF_ALEXA_SERVER, CONF_ALIASES, - CONF_CLOUDHOOK_CREATE_URL, + CONF_CLOUDHOOK_SERVER, CONF_COGNITO_CLIENT_ID, CONF_ENTITY_CONFIG, CONF_FILTER, CONF_GOOGLE_ACTIONS, - CONF_GOOGLE_ACTIONS_REPORT_STATE_URL, - CONF_RELAYER, - CONF_REMOTE_API_URL, - CONF_SUBSCRIPTION_INFO_URL, + CONF_RELAYER_SERVER, + CONF_REMOTE_SNI_SERVER, + CONF_REMOTESTATE_SERVER, + CONF_THINGTALK_SERVER, CONF_USER_POOL_ID, - CONF_VOICE_API_URL, + CONF_VOICE_SERVER, DOMAIN, MODE_DEV, MODE_PROD, @@ -107,17 +108,18 @@ CONFIG_SCHEMA = vol.Schema( vol.Optional(CONF_COGNITO_CLIENT_ID): str, vol.Optional(CONF_USER_POOL_ID): str, vol.Optional(CONF_REGION): str, - vol.Optional(CONF_RELAYER): str, - vol.Optional(CONF_SUBSCRIPTION_INFO_URL): vol.Url(), - vol.Optional(CONF_CLOUDHOOK_CREATE_URL): vol.Url(), - vol.Optional(CONF_REMOTE_API_URL): vol.Url(), - vol.Optional(CONF_ACME_DIRECTORY_SERVER): vol.Url(), vol.Optional(CONF_ALEXA): ALEXA_SCHEMA, vol.Optional(CONF_GOOGLE_ACTIONS): GACTIONS_SCHEMA, - vol.Optional(CONF_ALEXA_ACCESS_TOKEN_URL): vol.Url(), - vol.Optional(CONF_GOOGLE_ACTIONS_REPORT_STATE_URL): vol.Url(), - vol.Optional(CONF_ACCOUNT_LINK_URL): vol.Url(), - vol.Optional(CONF_VOICE_API_URL): vol.Url(), + vol.Optional(CONF_ACCOUNT_LINK_SERVER): str, + vol.Optional(CONF_ACCOUNTS_SERVER): str, + vol.Optional(CONF_ACME_SERVER): str, + vol.Optional(CONF_ALEXA_SERVER): str, + vol.Optional(CONF_CLOUDHOOK_SERVER): str, + vol.Optional(CONF_RELAYER_SERVER): str, + vol.Optional(CONF_REMOTE_SNI_SERVER): str, + vol.Optional(CONF_REMOTESTATE_SERVER): str, + vol.Optional(CONF_THINGTALK_SERVER): str, + vol.Optional(CONF_VOICE_SERVER): str, } ) }, diff --git a/homeassistant/components/cloud/const.py b/homeassistant/components/cloud/const.py index ea0240acccf..9fb4ffc7047 100644 --- a/homeassistant/components/cloud/const.py +++ b/homeassistant/components/cloud/const.py @@ -47,16 +47,18 @@ CONF_COGNITO_CLIENT_ID = "cognito_client_id" CONF_ENTITY_CONFIG = "entity_config" CONF_FILTER = "filter" CONF_GOOGLE_ACTIONS = "google_actions" -CONF_RELAYER = "relayer" CONF_USER_POOL_ID = "user_pool_id" -CONF_SUBSCRIPTION_INFO_URL = "subscription_info_url" -CONF_CLOUDHOOK_CREATE_URL = "cloudhook_create_url" -CONF_REMOTE_API_URL = "remote_api_url" -CONF_ACME_DIRECTORY_SERVER = "acme_directory_server" -CONF_ALEXA_ACCESS_TOKEN_URL = "alexa_access_token_url" -CONF_GOOGLE_ACTIONS_REPORT_STATE_URL = "google_actions_report_state_url" -CONF_ACCOUNT_LINK_URL = "account_link_url" -CONF_VOICE_API_URL = "voice_api_url" + +CONF_ACCOUNT_LINK_SERVER = "account_link_server" +CONF_ACCOUNTS_SERVER = "accounts_server" +CONF_ACME_SERVER = "acme_server" +CONF_ALEXA_SERVER = "alexa_server" +CONF_CLOUDHOOK_SERVER = "cloudhook_server" +CONF_RELAYER_SERVER = "relayer_server" +CONF_REMOTE_SNI_SERVER = "remote_sni_server" +CONF_REMOTESTATE_SERVER = "remotestate_server" +CONF_THINGTALK_SERVER = "thingtalk_server" +CONF_VOICE_SERVER = "voice_server" MODE_DEV = "development" MODE_PROD = "production" diff --git a/homeassistant/components/cloud/manifest.json b/homeassistant/components/cloud/manifest.json index 97f581d3bf0..23d72f7cb03 100644 --- a/homeassistant/components/cloud/manifest.json +++ b/homeassistant/components/cloud/manifest.json @@ -2,7 +2,7 @@ "domain": "cloud", "name": "Home Assistant Cloud", "documentation": "https://www.home-assistant.io/integrations/cloud", - "requirements": ["hass-nabucasa==0.56.0"], + "requirements": ["hass-nabucasa==0.59.0"], "dependencies": ["http", "webhook"], "after_dependencies": ["google_assistant", "alexa"], "codeowners": ["@home-assistant/cloud"], diff --git a/homeassistant/components/cloud/system_health.py b/homeassistant/components/cloud/system_health.py index 4d8a6eab64c..9f836114b3e 100644 --- a/homeassistant/components/cloud/system_health.py +++ b/homeassistant/components/cloud/system_health.py @@ -1,6 +1,5 @@ """Provide info to system health.""" from hass_nabucasa import Cloud -from yarl import URL from homeassistant.components import system_health from homeassistant.core import HomeAssistant, callback @@ -36,14 +35,14 @@ async def system_health_info(hass): data["remote_server"] = cloud.remote.snitun_server data["can_reach_cert_server"] = system_health.async_check_can_reach_url( - hass, cloud.acme_directory_server + hass, f"https://{cloud.acme_server}/directory" ) data["can_reach_cloud_auth"] = system_health.async_check_can_reach_url( hass, f"https://cognito-idp.{cloud.region}.amazonaws.com/{cloud.user_pool_id}/.well-known/jwks.json", ) data["can_reach_cloud"] = system_health.async_check_can_reach_url( - hass, URL(cloud.relayer).with_scheme("https").with_path("/status") + hass, f"https://{cloud.relayer_server}/status" ) return data diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 39bd8e35504..c3b2a14f2eb 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -20,7 +20,7 @@ ciso8601==2.2.0 cryptography==38.0.3 dbus-fast==1.75.0 fnvhash==0.1.0 -hass-nabucasa==0.56.0 +hass-nabucasa==0.59.0 home-assistant-bluetooth==1.8.1 home-assistant-frontend==20221130.0 httpx==0.23.1 diff --git a/requirements_all.txt b/requirements_all.txt index dc43172820d..90a2be0969d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -848,7 +848,7 @@ ha-philipsjs==2.9.0 habitipy==0.2.0 # homeassistant.components.cloud -hass-nabucasa==0.56.0 +hass-nabucasa==0.59.0 # homeassistant.components.splunk hass_splunk==0.1.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3296c2751c7..6ac28a78212 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -640,7 +640,7 @@ ha-philipsjs==2.9.0 habitipy==0.2.0 # homeassistant.components.cloud -hass-nabucasa==0.56.0 +hass-nabucasa==0.59.0 # homeassistant.components.tasmota hatasmota==0.6.1 diff --git a/tests/components/cloud/test_alexa_config.py b/tests/components/cloud/test_alexa_config.py index 4e0df3c8ee3..b7637780b12 100644 --- a/tests/components/cloud/test_alexa_config.py +++ b/tests/components/cloud/test_alexa_config.py @@ -129,7 +129,7 @@ async def test_alexa_config_report_state(hass, cloud_prefs, cloud_stub): async def test_alexa_config_invalidate_token(hass, cloud_prefs, aioclient_mock): """Test Alexa config should expose using prefs.""" aioclient_mock.post( - "http://example/alexa_token", + "https://example/access_token", json={ "access_token": "mock-token", "event_endpoint": "http://example.com/alexa_endpoint", @@ -142,7 +142,7 @@ async def test_alexa_config_invalidate_token(hass, cloud_prefs, aioclient_mock): "mock-user-id", cloud_prefs, Mock( - alexa_access_token_url="http://example/alexa_token", + alexa_server="example", auth=Mock(async_check_token=AsyncMock()), websession=async_get_clientsession(hass), ), @@ -181,7 +181,7 @@ async def test_alexa_config_fail_refresh_token( """Test Alexa config failing to refresh token.""" aioclient_mock.post( - "http://example/alexa_token", + "https://example/access_token", json={ "access_token": "mock-token", "event_endpoint": "http://example.com/alexa_endpoint", @@ -198,7 +198,7 @@ async def test_alexa_config_fail_refresh_token( "mock-user-id", cloud_prefs, Mock( - alexa_access_token_url="http://example/alexa_token", + alexa_server="example", auth=Mock(async_check_token=AsyncMock()), websession=async_get_clientsession(hass), ), @@ -228,7 +228,7 @@ async def test_alexa_config_fail_refresh_token( conf.async_invalidate_access_token() aioclient_mock.clear_requests() aioclient_mock.post( - "http://example/alexa_token", + "https://example/access_token", json={"reason": reject_reason}, status=400, ) @@ -254,7 +254,7 @@ async def test_alexa_config_fail_refresh_token( # State reporting should now be re-enabled for Alexa aioclient_mock.clear_requests() aioclient_mock.post( - "http://example/alexa_token", + "https://example/access_token", json={ "access_token": "mock-token", "event_endpoint": "http://example.com/alexa_endpoint", diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index 1f9af960f08..0dbc20d4f91 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -21,7 +21,7 @@ from . import mock_cloud, mock_cloud_prefs from tests.components.google_assistant import MockConfig -SUBSCRIPTION_INFO_URL = "https://api-test.hass.io/subscription_info" +SUBSCRIPTION_INFO_URL = "https://api-test.hass.io/payments/subscription_info" @pytest.fixture(name="mock_cloud_login") @@ -48,8 +48,8 @@ def setup_api_fixture(hass, aioclient_mock): "cognito_client_id": "cognito_client_id", "user_pool_id": "user_pool_id", "region": "region", - "relayer": "relayer", - "subscription_info_url": SUBSCRIPTION_INFO_URL, + "relayer_server": "relayer", + "accounts_server": "api-test.hass.io", "google_actions": {"filter": {"include_domains": "light"}}, "alexa": { "filter": {"include_entities": ["light.kitchen", "switch.ac"]} diff --git a/tests/components/cloud/test_init.py b/tests/components/cloud/test_init.py index 78a8f83eef6..48caf27dfe2 100644 --- a/tests/components/cloud/test_init.py +++ b/tests/components/cloud/test_init.py @@ -26,13 +26,13 @@ async def test_constructor_loads_info_from_config(hass): "cognito_client_id": "test-cognito_client_id", "user_pool_id": "test-user_pool_id", "region": "test-region", - "relayer": "test-relayer", - "subscription_info_url": "http://test-subscription-info-url", - "cloudhook_create_url": "http://test-cloudhook_create_url", - "remote_api_url": "http://test-remote_api_url", - "alexa_access_token_url": "http://test-alexa-token-url", - "acme_directory_server": "http://test-acme-directory-server", - "google_actions_report_state_url": "http://test-google-actions-report-state-url", + "relayer_server": "test-relayer-server", + "accounts_server": "test-acounts-server", + "cloudhook_server": "test-cloudhook-server", + "remote_sni_server": "test-remote-sni-server", + "alexa_server": "test-alexa-server", + "acme_server": "test-acme-server", + "remotestate_server": "test-remotestate-server", }, }, ) @@ -43,16 +43,13 @@ async def test_constructor_loads_info_from_config(hass): assert cl.cognito_client_id == "test-cognito_client_id" assert cl.user_pool_id == "test-user_pool_id" assert cl.region == "test-region" - assert cl.relayer == "test-relayer" - assert cl.subscription_info_url == "http://test-subscription-info-url" - assert cl.cloudhook_create_url == "http://test-cloudhook_create_url" - assert cl.remote_api_url == "http://test-remote_api_url" - assert cl.alexa_access_token_url == "http://test-alexa-token-url" - assert cl.acme_directory_server == "http://test-acme-directory-server" - assert ( - cl.google_actions_report_state_url - == "http://test-google-actions-report-state-url" - ) + assert cl.relayer_server == "test-relayer-server" + assert cl.iot.ws_server_url == "wss://test-relayer-server/websocket" + assert cl.accounts_server == "test-acounts-server" + assert cl.cloudhook_server == "test-cloudhook-server" + assert cl.alexa_server == "test-alexa-server" + assert cl.acme_server == "test-acme-server" + assert cl.remotestate_server == "test-remotestate-server" async def test_remote_services(hass, mock_cloud_fixture, hass_read_only_user): @@ -120,7 +117,7 @@ async def test_setup_existing_cloud_user(hass, hass_storage): "cognito_client_id": "test-cognito_client_id", "user_pool_id": "test-user_pool_id", "region": "test-region", - "relayer": "test-relayer", + "relayer_server": "test-relayer-serer", }, }, ) diff --git a/tests/components/cloud/test_system_health.py b/tests/components/cloud/test_system_health.py index cc37788bc4c..dae5ac4b4cc 100644 --- a/tests/components/cloud/test_system_health.py +++ b/tests/components/cloud/test_system_health.py @@ -13,7 +13,7 @@ from tests.common import get_system_health_info async def test_cloud_system_health(hass, aioclient_mock): """Test cloud system health.""" aioclient_mock.get("https://cloud.bla.com/status", text="") - aioclient_mock.get("https://cert-server", text="") + aioclient_mock.get("https://cert-server/directory", text="") aioclient_mock.get( "https://cognito-idp.us-east-1.amazonaws.com/AAAA/.well-known/jwks.json", exc=ClientError, @@ -25,8 +25,8 @@ async def test_cloud_system_health(hass, aioclient_mock): hass.data["cloud"] = Mock( region="us-east-1", user_pool_id="AAAA", - relayer="wss://cloud.bla.com/websocket_api", - acme_directory_server="https://cert-server", + relayer_server="cloud.bla.com", + acme_server="cert-server", is_logged_in=True, remote=Mock(is_connected=False, snitun_server="us-west-1"), expiration_date=now,