Do not redact diagnostics empty key (#69160)
parent
d7992c1e87
commit
0876239927
|
@ -33,6 +33,10 @@ def async_redact_data(data: _T, to_redact: Iterable[Any]) -> _T:
|
|||
redacted = {**data}
|
||||
|
||||
for key, value in redacted.items():
|
||||
if value is None:
|
||||
continue
|
||||
if isinstance(value, str) and not value:
|
||||
continue
|
||||
if key in to_redact:
|
||||
redacted[key] = REDACTED
|
||||
elif isinstance(value, Mapping):
|
||||
|
|
|
@ -15,7 +15,7 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry
|
|||
async def test_entry_diagnostics(hass, hass_client):
|
||||
"""Test config entry diagnostics."""
|
||||
config_entry = MockConfigEntry(
|
||||
domain=DOMAIN, data={CONF_API_KEY: "", "location": ""}
|
||||
domain=DOMAIN, data={CONF_API_KEY: "api_key", "location": ""}
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
with patch("CO2Signal.get_latest", return_value=VALID_PAYLOAD):
|
||||
|
|
|
@ -13,12 +13,18 @@ def test_redact():
|
|||
"key4_2": ["value4_2a", "value4_2b"],
|
||||
"key4_3": [["value4_3a", "value4_3b"], ["value4_3c", "value4_3d"]],
|
||||
},
|
||||
"key5": None,
|
||||
"key6": "",
|
||||
"key7": False,
|
||||
}
|
||||
|
||||
to_redact = {
|
||||
"key1",
|
||||
"key3",
|
||||
"key4_1",
|
||||
"key5",
|
||||
"key6",
|
||||
"key7",
|
||||
}
|
||||
|
||||
assert async_redact_data(data, to_redact) == {
|
||||
|
@ -30,4 +36,7 @@ def test_redact():
|
|||
"key4_2": ["value4_2a", "value4_2b"],
|
||||
"key4_3": [["value4_3a", "value4_3b"], ["value4_3c", "value4_3d"]],
|
||||
},
|
||||
"key5": None,
|
||||
"key6": "",
|
||||
"key7": REDACTED,
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ def mock_config_entry() -> MockConfigEntry:
|
|||
data={
|
||||
CONF_HOST: "192.168.1.2",
|
||||
CONF_PORT: 6053,
|
||||
CONF_PASSWORD: "",
|
||||
CONF_PASSWORD: "pwd",
|
||||
CONF_NOISE_PSK: "12345678123456781234567812345678",
|
||||
},
|
||||
unique_id="esphome-device",
|
||||
|
|
Loading…
Reference in New Issue