diff --git a/homeassistant/components/kitchen_sink/__init__.py b/homeassistant/components/kitchen_sink/__init__.py index 5c8088823b2..8369892be85 100644 --- a/homeassistant/components/kitchen_sink/__init__.py +++ b/homeassistant/components/kitchen_sink/__init__.py @@ -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 diff --git a/homeassistant/components/kitchen_sink/config_flow.py b/homeassistant/components/kitchen_sink/config_flow.py index ded2b84e31c..54104784c50 100644 --- a/homeassistant/components/kitchen_sink/config_flow.py +++ b/homeassistant/components/kitchen_sink/config_flow.py @@ -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") diff --git a/homeassistant/components/kitchen_sink/strings.json b/homeassistant/components/kitchen_sink/strings.json index ce907a3368d..dca42ce8361 100644 --- a/homeassistant/components/kitchen_sink/strings.json +++ b/homeassistant/components/kitchen_sink/strings.json @@ -1,4 +1,11 @@ { + "config": { + "step": { + "reauth_confirm": { + "description": "Press SUBMIT to reauthenticate" + } + } + }, "issues": { "bad_psu": { "title": "The power supply is not stable", diff --git a/tests/components/kitchen_sink/test_config_flow.py b/tests/components/kitchen_sink/test_config_flow.py index 625aa7926fe..e157c3e5d0a 100644 --- a/tests/components/kitchen_sink/test_config_flow.py +++ b/tests/components/kitchen_sink/test_config_flow.py @@ -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"