mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Stop validating # of slots in zwave_js.set_credential action (#173644)
This commit is contained in:
@@ -432,15 +432,6 @@ async def async_set_credential(
|
||||
translation_key="no_available_credential_slots",
|
||||
translation_placeholders={"credential_type": cred_type_str},
|
||||
)
|
||||
elif not 1 <= credential_slot <= type_cap.number_of_credential_slots:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="credential_slot_out_of_range",
|
||||
translation_placeholders={
|
||||
"credential_type": cred_type_str,
|
||||
"max_slot": str(type_cap.number_of_credential_slots),
|
||||
},
|
||||
)
|
||||
|
||||
status = await node.access_control.set_credential(
|
||||
user_id, credential_type, credential_slot, credential_data
|
||||
|
||||
@@ -322,9 +322,6 @@
|
||||
"credential_rejected_wrong_uuid": {
|
||||
"message": "The device rejected the credential because the user unique identifier does not match."
|
||||
},
|
||||
"credential_slot_out_of_range": {
|
||||
"message": "Credential slot for {credential_type} must be between 1 and {max_slot}."
|
||||
},
|
||||
"credential_type_not_supported": {
|
||||
"message": "Credential type {credential_type} is not supported on this device"
|
||||
},
|
||||
|
||||
@@ -877,48 +877,6 @@ async def test_set_credential_length_validation(
|
||||
api.set_credential.assert_not_called()
|
||||
|
||||
|
||||
async def test_set_credential_slot_out_of_range(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
client: MagicMock,
|
||||
lock_schlage_be469: Node,
|
||||
integration: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Explicit credential_slot above device capacity fails fast."""
|
||||
api = _mock_access_control(lock_schlage_be469)
|
||||
cred_caps = api.get_credential_capabilities_cached.return_value
|
||||
cred_caps.supported_credential_types[
|
||||
UserCredentialType.PIN_CODE
|
||||
].number_of_credential_slots = 5
|
||||
|
||||
with pytest.raises(HomeAssistantError) as exc:
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"set_credential",
|
||||
{
|
||||
ATTR_ENTITY_ID: _lock_entity_id(
|
||||
entity_registry, device_registry, client, lock_schlage_be469
|
||||
),
|
||||
"user_id": 1,
|
||||
"credential_type": "pin_code",
|
||||
"credential_data": "1234",
|
||||
"credential_slot": 6,
|
||||
},
|
||||
blocking=True,
|
||||
return_response=True,
|
||||
)
|
||||
|
||||
# The explicit slot exceeds the device-reported capacity, so the helper
|
||||
# rejects the call with the rendered upper bound and never writes.
|
||||
assert exc.value.translation_key == "credential_slot_out_of_range"
|
||||
assert exc.value.translation_placeholders == {
|
||||
"credential_type": "pin_code",
|
||||
"max_slot": "5",
|
||||
}
|
||||
api.set_credential.assert_not_called()
|
||||
|
||||
|
||||
async def test_delete_credential(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
|
||||
Reference in New Issue
Block a user