mirror of
https://github.com/home-assistant/core
synced 2024-09-28 03:04:04 +02:00
Add reauth flow to kitchen sink (#109202)
This commit is contained in:
parent
340df38bd0
commit
cf6bcd63dd
@ -61,6 +61,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||
if "recorder" in hass.config.components:
|
||||
await _insert_statistics(hass)
|
||||
|
||||
# Start a reauth flow
|
||||
config_entry.async_start_reauth(hass)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
@ -20,3 +20,13 @@ class KitchenSinkConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
||||
return self.async_create_entry(title="Kitchen Sink", data=import_info)
|
||||
|
||||
async def async_step_reauth(self, data):
|
||||
"""Reauth step."""
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(self, user_input=None):
|
||||
"""Reauth confirm step."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="reauth_confirm")
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
@ -1,4 +1,11 @@
|
||||
{
|
||||
"config": {
|
||||
"step": {
|
||||
"reauth_confirm": {
|
||||
"description": "Press SUBMIT to reauthenticate"
|
||||
}
|
||||
}
|
||||
},
|
||||
"issues": {
|
||||
"bad_psu": {
|
||||
"title": "The power supply is not stable",
|
||||
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
||||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
from homeassistant.components.kitchen_sink import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
async def test_import(hass: HomeAssistant) -> None:
|
||||
@ -46,3 +47,20 @@ async def test_import_once(hass: HomeAssistant) -> None:
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
mock_setup_entry.assert_not_called()
|
||||
|
||||
|
||||
async def test_reauth(hass: HomeAssistant) -> None:
|
||||
"""Test reauth works."""
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
flows = hass.config_entries.flow.async_progress()
|
||||
assert len(flows) == 1
|
||||
assert flows[0]["handler"] == DOMAIN
|
||||
assert flows[0]["step_id"] == "reauth_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
Loading…
Reference in New Issue
Block a user