Add check for unique id mismatch in reauth of Bring integration (#132499)
parent
1f8913d6cd
commit
2fd3aac268
|
@ -85,6 +85,7 @@ class BringConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
if user_input is not None:
|
||||
if not (errors := await self.validate_input(user_input)):
|
||||
self._abort_if_unique_id_mismatch()
|
||||
return self.async_update_reload_and_abort(
|
||||
self.reauth_entry, data=user_input
|
||||
)
|
||||
|
|
|
@ -7,9 +7,7 @@ rules:
|
|||
brands: done
|
||||
common-modules: done
|
||||
config-flow-test-coverage: done
|
||||
config-flow:
|
||||
status: todo
|
||||
comment: Check uuid match in reauth
|
||||
config-flow: done
|
||||
dependency-transparency: done
|
||||
docs-actions: done
|
||||
docs-high-level-description: todo
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
},
|
||||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_service%]",
|
||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
||||
"unique_id_mismatch": "The login details correspond to a different account. Please re-authenticate to the previously configured account."
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
|
|
|
@ -188,3 +188,29 @@ async def test_flow_reauth_error_and_recover(
|
|||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
assert len(hass.config_entries.async_entries()) == 1
|
||||
|
||||
|
||||
async def test_flow_reauth_unique_id_mismatch(
|
||||
hass: HomeAssistant,
|
||||
bring_config_entry: MockConfigEntry,
|
||||
mock_bring_client: AsyncMock,
|
||||
) -> None:
|
||||
"""Test we abort reauth if unique id mismatch."""
|
||||
|
||||
mock_bring_client.uuid = "11111111-11111111-11111111-11111111"
|
||||
|
||||
bring_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await bring_config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{CONF_EMAIL: "new-email", CONF_PASSWORD: "new-password"},
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unique_id_mismatch"
|
||||
|
|
Loading…
Reference in New Issue