Skip to content

Commit

Permalink
Redact password from diagnostics.
Browse files Browse the repository at this point in the history
  • Loading branch information
denpamusic committed Aug 5, 2022
1 parent 225e130 commit 6f61954
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions custom_components/plum_ecomax/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def _redact_device_data(device_data: dict[str, Any]) -> dict[str, Any]:
if "product" in device_data:
device_data["product"].uid = REDACTED

if "password" in device_data:
device_data["password"] = REDACTED

return device_data


Expand Down
7 changes: 6 additions & 1 deletion tests/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async def test_diagnostics(hass: HomeAssistant, config_entry: ConfigEntry):
mock_connection.device.data = {
"test_data": "test_value",
"product": mock_product_info,
"password": "0000",
}
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = mock_connection
result = await async_get_config_entry_diagnostics(hass, config_entry)
Expand All @@ -40,5 +41,9 @@ async def test_diagnostics(hass: HomeAssistant, config_entry: ConfigEntry):
"capabilities": ["fuel_burned", "heating_temp"],
},
}
assert result["data"] == {"test_data": "test_value", "product": mock_product_info}
assert result["data"] == {
"test_data": "test_value",
"product": mock_product_info,
"password": REDACTED,
}
assert mock_product_info.uid == REDACTED

0 comments on commit 6f61954

Please sign in to comment.