@@ -128,8 +128,9 @@ async def test_async_step_reauth_success(hass: HomeAssistant, user: User) -> Non
128128
129129 mock_entry = MockConfigEntry (
130130 domain = DOMAIN ,
131- unique_id = "UID" ,
132- data = {
CONF_EMAIL :
"[email protected] " },
131+ unique_id = "a_user_id" ,
132+ data = {
CONF_EMAIL :
"[email protected] " ,
CONF_PASSWORD :
"passw0rd" },
133+ version = 2 ,
133134 )
134135 mock_entry .add_to_hass (hass )
135136
@@ -151,13 +152,61 @@ async def test_async_step_reauth_success(hass: HomeAssistant, user: User) -> Non
151152 ):
152153 result = await hass .config_entries .flow .async_configure (
153154 result ["flow_id" ],
154- {
CONF_EMAIL :
"[email protected] " ,
CONF_PASSWORD :
"passw0rd " },
155+ {
CONF_EMAIL :
"[email protected] " ,
CONF_PASSWORD :
"new_password " },
155156 )
156157 await hass .async_block_till_done ()
157158
158159 assert result ["type" ] is FlowResultType .ABORT
159160 assert result ["reason" ] == "reauth_successful"
160161 assert len (mock_setup_entry .mock_calls ) == 1
162+ assert mock_entry .unique_id == "a_user_id"
163+ assert dict (mock_entry .data ) == {
164+ 165+ CONF_PASSWORD : "new_password" ,
166+ }
167+
168+
169+ async def test_async_step_reauth_mismatch (hass : HomeAssistant , user : User ) -> None :
170+ """Test mismatch reauthentication."""
171+
172+ mock_entry = MockConfigEntry (
173+ domain = DOMAIN ,
174+ unique_id = "UID" ,
175+ data = {
CONF_EMAIL :
"[email protected] " ,
CONF_PASSWORD :
"passw0rd" },
176+ version = 2 ,
177+ )
178+ mock_entry .add_to_hass (hass )
179+
180+ result = await mock_entry .start_reauth_flow (hass )
181+
182+ assert result ["type" ] is FlowResultType .FORM
183+ assert result ["step_id" ] == "reauth_confirm"
184+ assert result ["errors" ] == {}
185+
186+ with (
187+ patch (
188+ "homeassistant.components.aseko_pool_live.config_flow.Aseko.login" ,
189+ return_value = user ,
190+ ),
191+ patch (
192+ "homeassistant.components.aseko_pool_live.async_setup_entry" ,
193+ return_value = True ,
194+ ) as mock_setup_entry ,
195+ ):
196+ result = await hass .config_entries .flow .async_configure (
197+ result ["flow_id" ],
198+ {
CONF_EMAIL :
"[email protected] " ,
CONF_PASSWORD :
"new_password" },
199+ )
200+ await hass .async_block_till_done ()
201+
202+ assert result ["type" ] is FlowResultType .ABORT
203+ assert result ["reason" ] == "unique_id_mismatch"
204+ assert len (mock_setup_entry .mock_calls ) == 0
205+ assert mock_entry .unique_id == "UID"
206+ assert dict (mock_entry .data ) == {
207+ 208+ CONF_PASSWORD : "passw0rd" ,
209+ }
161210
162211
163212@pytest .mark .parametrize (
0 commit comments