Raise error when unsupported (old) Bond firmware is detected (#38650)
This commit is contained in:
parent
4cceb4ad0a
commit
50cd6be18d
4 changed files with 26 additions and 2 deletions
|
@ -39,7 +39,11 @@ async def _validate_input(data: Dict[str, Any]) -> str:
|
|||
raise InputValidationError("unknown")
|
||||
|
||||
# Return unique ID from the hub to be stored in the config entry.
|
||||
return version["bondid"]
|
||||
bond_id = version.get("bondid")
|
||||
if not bond_id:
|
||||
raise InputValidationError("old_firmware")
|
||||
|
||||
return bond_id
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"error": {
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||
"old_firmware": "Unsupported old firmware on the Bond device - please upgrade before continuing",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
},
|
||||
"abort": {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"error": {
|
||||
"cannot_connect": "Failed to connect",
|
||||
"invalid_auth": "Invalid authentication",
|
||||
"old_firmware": "Unsupported old firmware on the Bond device - please upgrade before continuing",
|
||||
"unknown": "Unexpected error"
|
||||
},
|
||||
"flow_title": "Bond: {bond_id} ({host})",
|
||||
|
|
|
@ -79,6 +79,24 @@ async def test_user_form_cannot_connect(hass: core.HomeAssistant):
|
|||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_user_form_old_firmware(hass: core.HomeAssistant):
|
||||
"""Test we handle unsupported old firmware."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
with patch_bond_version(
|
||||
return_value={"no_bond_id": "present"}
|
||||
), patch_bond_device_ids():
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["errors"] == {"base": "old_firmware"}
|
||||
|
||||
|
||||
async def test_user_form_unexpected_client_error(hass: core.HomeAssistant):
|
||||
"""Test we handle unexpected client error gracefully."""
|
||||
await _help_test_form_unexpected_error(
|
||||
|
|
Loading…
Add table
Reference in a new issue