Disable google_assistant local SDK if SSL is enabled (#64983)

This commit is contained in:
Erik Montnemery 2022-01-26 18:55:30 +01:00 committed by GitHub
parent 189418a4dd
commit 07563f4fd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 7 deletions

View file

@ -30,7 +30,7 @@ from tests.common import (
async def test_google_entity_sync_serialize_with_local_sdk(hass):
"""Test sync serialize attributes of a GoogleEntity."""
hass.states.async_set("light.ceiling_lights", "off")
hass.config.api = Mock(port=1234, use_ssl=True)
hass.config.api = Mock(port=1234, use_ssl=False)
await async_process_ha_core_config(
hass,
{"external_url": "https://hostname:1234"},
@ -58,7 +58,7 @@ async def test_google_entity_sync_serialize_with_local_sdk(hass):
assert serialized["otherDeviceIds"] == [{"deviceId": "light.ceiling_lights"}]
assert serialized["customData"] == {
"httpPort": 1234,
"httpSSL": True,
"httpSSL": False,
"proxyDeviceId": "mock-user-id",
"webhookId": "mock-webhook-id",
"baseUrl": "https://hostname:1234",
@ -153,10 +153,12 @@ async def test_config_local_sdk_if_disabled(hass, hass_client):
},
enabled=False,
)
assert not config.is_local_sdk_active
client = await hass_client()
config.async_enable_local_sdk()
assert config.is_local_sdk_active
resp = await client.post(
"/api/webhook/mock-webhook-id", json={"requestId": "mock-req-id"}
@ -169,6 +171,7 @@ async def test_config_local_sdk_if_disabled(hass, hass_client):
}
config.async_disable_local_sdk()
assert not config.is_local_sdk_active
# Webhook is no longer active
resp = await client.post("/api/webhook/mock-webhook-id")
@ -176,6 +179,33 @@ async def test_config_local_sdk_if_disabled(hass, hass_client):
assert await resp.read() == b""
async def test_config_local_sdk_if_ssl_enabled(hass, hass_client):
"""Test the local SDK is not enabled when SSL is enabled."""
assert await async_setup_component(hass, "webhook", {})
hass.config.api.use_ssl = True
config = MockConfig(
hass=hass,
agent_user_ids={
"mock-user-id": {
STORE_GOOGLE_LOCAL_WEBHOOK_ID: "mock-webhook-id",
},
},
enabled=False,
)
assert not config.is_local_sdk_active
client = await hass_client()
config.async_enable_local_sdk()
assert not config.is_local_sdk_active
# Webhook should not be activated
resp = await client.post("/api/webhook/mock-webhook-id")
assert resp.status == HTTPStatus.OK
assert await resp.read() == b""
async def test_agent_user_id_storage(hass, hass_storage):
"""Test a disconnect message."""