Skip to content

Commit

Permalink
Add certificate status for cloud remote (home-assistant#91277)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Apr 12, 2023
1 parent d6c954a commit 2c8b704
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions homeassistant/components/cloud/http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ async def _account_data(hass: HomeAssistant, cloud: Cloud):
"logged_in": True,
"prefs": client.prefs.as_dict(),
"remote_certificate": certificate,
"remote_certificate_status": remote.certificate_status,
"remote_connected": remote.is_connected,
"remote_domain": remote.instance_domain,
"http_use_ssl": hass.config.api.use_ssl,
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/cloud/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"can_reach_cert_server": "Reach Certificate Server",
"can_reach_cloud": "Reach Home Assistant Cloud",
"can_reach_cloud_auth": "Reach Authentication Server",
"certificate_status": "Certificate Status",
"relayer_connected": "Relayer Connected",
"relayer_region": "Relayer Region",
"remote_connected": "Remote Connected",
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/cloud/system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def system_health_info(hass):
data["alexa_enabled"] = client.prefs.alexa_enabled
data["google_enabled"] = client.prefs.google_enabled
data["remote_server"] = cloud.remote.snitun_server
data["certificate_status"] = cloud.remote.certificate_status

data["can_reach_cert_server"] = system_health.async_check_can_reach_url(
hass, f"https://{cloud.acme_server}/directory"
Expand Down
1 change: 1 addition & 0 deletions tests/components/cloud/test_http_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ async def test_websocket_status(
"google_local_connected": False,
"remote_domain": None,
"remote_connected": False,
"remote_certificate_status": None,
"remote_certificate": None,
"http_use_ssl": False,
"active_subscription": False,
Expand Down
8 changes: 7 additions & 1 deletion tests/components/cloud/test_system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest.mock import Mock

from aiohttp import ClientError
from hass_nabucasa.remote import CertificateStatus

from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
Expand Down Expand Up @@ -32,7 +33,11 @@ async def test_cloud_system_health(
relayer_server="cloud.bla.com",
acme_server="cert-server",
is_logged_in=True,
remote=Mock(is_connected=False, snitun_server="us-west-1"),
remote=Mock(
is_connected=False,
snitun_server="us-west-1",
certificate_status=CertificateStatus.READY,
),
expiration_date=now,
is_connected=True,
client=Mock(
Expand All @@ -54,6 +59,7 @@ async def test_cloud_system_health(
assert info == {
"logged_in": True,
"subscription_expiration": now,
"certificate_status": "ready",
"relayer_connected": True,
"relayer_region": "xx-earth-616",
"remote_enabled": True,
Expand Down

0 comments on commit 2c8b704

Please sign in to comment.