Remove sensor exposing UniFi WLAN password (#115929)

This commit is contained in:
Robert Svensson 2024-04-21 20:27:44 +02:00 committed by GitHub
parent 95b858648e
commit 83370a5bde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 0 additions and 84 deletions

View file

@ -350,19 +350,6 @@ ENTITY_DESCRIPTIONS: tuple[UnifiSensorEntityDescription, ...] = (
value_fn=async_device_state_value_fn,
options=list(DEVICE_STATES.values()),
),
UnifiSensorEntityDescription[Wlans, Wlan](
key="WLAN password",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
api_handler_fn=lambda api: api.wlans,
available_fn=async_wlan_available_fn,
device_info_fn=async_wlan_device_info_fn,
name_fn=lambda wlan: "Password",
object_fn=lambda api, obj_id: api.wlans[obj_id],
supported_fn=lambda hub, obj_id: hub.api.wlans[obj_id].x_passphrase is not None,
unique_id_fn=lambda hub, obj_id: f"password-{obj_id}",
value_fn=lambda hub, obj: obj.x_passphrase,
),
UnifiSensorEntityDescription[Devices, Device](
key="Device CPU utilization",
entity_category=EntityCategory.DIAGNOSTIC,

View file

@ -1000,77 +1000,6 @@ async def test_device_state(
assert hass.states.get("sensor.device_state").state == DEVICE_STATES[i]
async def test_wlan_password(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
aioclient_mock: AiohttpClientMocker,
mock_unifi_websocket,
websocket_mock,
) -> None:
"""Test the WLAN password sensor behavior."""
await setup_unifi_integration(hass, aioclient_mock, wlans_response=[WLAN])
sensor_password = "sensor.ssid_1_password"
password = "password"
new_password = "new_password"
ent_reg_entry = entity_registry.async_get(sensor_password)
assert ent_reg_entry.unique_id == "password-012345678910111213141516"
assert ent_reg_entry.disabled_by == RegistryEntryDisabler.INTEGRATION
assert ent_reg_entry.entity_category is EntityCategory.DIAGNOSTIC
# Enable entity
entity_registry.async_update_entity(entity_id=sensor_password, disabled_by=None)
await hass.async_block_till_done()
async_fire_time_changed(
hass,
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
)
await hass.async_block_till_done()
# Validate state object
wlan_password_sensor_1 = hass.states.get(sensor_password)
assert wlan_password_sensor_1.state == password
# Update state object - same password - no change to state
mock_unifi_websocket(message=MessageKey.WLAN_CONF_UPDATED, data=WLAN)
await hass.async_block_till_done()
wlan_password_sensor_2 = hass.states.get(sensor_password)
assert wlan_password_sensor_1.state == wlan_password_sensor_2.state
# Update state object - changed password - new state
data = deepcopy(WLAN)
data["x_passphrase"] = new_password
mock_unifi_websocket(message=MessageKey.WLAN_CONF_UPDATED, data=data)
await hass.async_block_till_done()
wlan_password_sensor_3 = hass.states.get(sensor_password)
assert wlan_password_sensor_1.state != wlan_password_sensor_3.state
# Availability signaling
# Controller disconnects
await websocket_mock.disconnect()
assert hass.states.get(sensor_password).state == STATE_UNAVAILABLE
# Controller reconnects
await websocket_mock.reconnect()
assert hass.states.get(sensor_password).state == new_password
# WLAN gets disabled
wlan_1 = deepcopy(WLAN)
wlan_1["enabled"] = False
mock_unifi_websocket(message=MessageKey.WLAN_CONF_UPDATED, data=wlan_1)
await hass.async_block_till_done()
assert hass.states.get(sensor_password).state == STATE_UNAVAILABLE
# WLAN gets re-enabled
wlan_1["enabled"] = True
mock_unifi_websocket(message=MessageKey.WLAN_CONF_UPDATED, data=wlan_1)
await hass.async_block_till_done()
assert hass.states.get(sensor_password).state == password
async def test_device_system_stats(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,