Only return remote UI url if remote UI enabled (#30453)
This commit is contained in:
parent
63347ebeb5
commit
6e909ab3f1
2 changed files with 27 additions and 0 deletions
|
@ -155,6 +155,9 @@ def async_remote_ui_url(hass) -> str:
|
||||||
if not async_is_logged_in(hass):
|
if not async_is_logged_in(hass):
|
||||||
raise CloudNotAvailable
|
raise CloudNotAvailable
|
||||||
|
|
||||||
|
if not hass.data[DOMAIN].client.prefs.remote_enabled:
|
||||||
|
raise CloudNotAvailable
|
||||||
|
|
||||||
if not hass.data[DOMAIN].remote.instance_domain:
|
if not hass.data[DOMAIN].remote.instance_domain:
|
||||||
raise CloudNotAvailable
|
raise CloudNotAvailable
|
||||||
|
|
||||||
|
|
|
@ -163,3 +163,27 @@ async def test_on_connect(hass, mock_cloud_fixture):
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_load.mock_calls) == 0
|
assert len(mock_load.mock_calls) == 0
|
||||||
|
|
||||||
|
|
||||||
|
async def test_remote_ui_url(hass, mock_cloud_fixture):
|
||||||
|
"""Test getting remote ui url."""
|
||||||
|
cl = hass.data["cloud"]
|
||||||
|
|
||||||
|
# Not logged in
|
||||||
|
with pytest.raises(cloud.CloudNotAvailable):
|
||||||
|
cloud.async_remote_ui_url(hass)
|
||||||
|
|
||||||
|
with patch.object(cloud, "async_is_logged_in", return_value=True):
|
||||||
|
# Remote not enabled
|
||||||
|
with pytest.raises(cloud.CloudNotAvailable):
|
||||||
|
cloud.async_remote_ui_url(hass)
|
||||||
|
|
||||||
|
await cl.client.prefs.async_update(remote_enabled=True)
|
||||||
|
|
||||||
|
# No instance domain
|
||||||
|
with pytest.raises(cloud.CloudNotAvailable):
|
||||||
|
cloud.async_remote_ui_url(hass)
|
||||||
|
|
||||||
|
cl.remote._instance_domain = "example.com"
|
||||||
|
|
||||||
|
assert cloud.async_remote_ui_url(hass) == "https://example.com"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue