Use entry.as_dict() in SimpliSafe diagnostics (#80121)

This commit is contained in:
Aaron Bach 2022-10-11 12:15:32 -06:00 committed by GitHub
parent d4465e4e69
commit 1262c0e221
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 7 deletions

View File

@ -5,7 +5,14 @@ from typing import Any
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS, CONF_CODE, CONF_LOCATION
from homeassistant.const import (
CONF_ADDRESS,
CONF_CODE,
CONF_LOCATION,
CONF_TOKEN,
CONF_UNIQUE_ID,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from . import SimpliSafe
@ -18,6 +25,7 @@ CONF_PAYMENT_PROFILE_ID = "paymentProfileId"
CONF_SERIAL = "serial"
CONF_SID = "sid"
CONF_SYSTEM_ID = "system_id"
CONF_TITLE = "title"
CONF_UID = "uid"
CONF_WIFI_SSID = "wifi_ssid"
@ -32,7 +40,13 @@ TO_REDACT = {
CONF_SERIAL,
CONF_SID,
CONF_SYSTEM_ID,
# Config entry title may contain sensitive data:
CONF_TITLE,
CONF_TOKEN,
CONF_UID,
# Config entry unique ID may contain sensitive data:
CONF_UNIQUE_ID,
CONF_USERNAME,
CONF_WIFI_SSID,
}
@ -45,9 +59,7 @@ async def async_get_config_entry_diagnostics(
return async_redact_data(
{
"entry": {
"options": dict(entry.options),
},
"entry": entry.as_dict(),
"subscription_data": simplisafe.subscription_data,
"systems": [system.as_dict() for system in simplisafe.systems.values()],
},

View File

@ -8,9 +8,17 @@ async def test_entry_diagnostics(hass, config_entry, hass_client, setup_simplisa
"""Test config entry diagnostics."""
assert await get_diagnostics_for_config_entry(hass, hass_client, config_entry) == {
"entry": {
"options": {
"code": REDACTED,
},
"entry_id": config_entry.entry_id,
"version": 1,
"domain": "simplisafe",
"title": REDACTED,
"data": {"token": REDACTED, "username": REDACTED},
"options": {"code": REDACTED},
"pref_disable_new_entities": False,
"pref_disable_polling": False,
"source": "user",
"unique_id": REDACTED,
"disabled_by": None,
},
"subscription_data": {
"system_123": {