mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 19:27:51 +00:00
Use start_reauth helper method in integration tests (s) (#124793)
This commit is contained in:
parent
7652c35ee6
commit
9bcc31a9fe
@ -1749,11 +1749,7 @@ async def test_form_reauth_legacy(hass: HomeAssistant) -> None:
|
|||||||
"""Test reauthenticate legacy."""
|
"""Test reauthenticate legacy."""
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_OLD_ENTRY)
|
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_OLD_ENTRY)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
@ -1773,11 +1769,7 @@ async def test_form_reauth_websocket(hass: HomeAssistant) -> None:
|
|||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
@ -1798,11 +1790,7 @@ async def test_form_reauth_websocket_cannot_connect(
|
|||||||
"""Test reauthenticate websocket when we cannot connect on the first attempt."""
|
"""Test reauthenticate websocket when we cannot connect on the first attempt."""
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_ENTRYDATA_WS)
|
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_ENTRYDATA_WS)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
@ -1830,11 +1818,7 @@ async def test_form_reauth_websocket_not_supported(hass: HomeAssistant) -> None:
|
|||||||
"""Test reauthenticate websocket when the device is not supported."""
|
"""Test reauthenticate websocket when the device is not supported."""
|
||||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_ENTRYDATA_WS)
|
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_ENTRYDATA_WS)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
@ -1863,11 +1847,7 @@ async def test_form_reauth_encrypted(hass: HomeAssistant) -> None:
|
|||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
|
@ -268,9 +268,7 @@ async def test_reauth_no_form(hass: HomeAssistant, mock_sense) -> None:
|
|||||||
"homeassistant.config_entries.ConfigEntries.async_reload",
|
"homeassistant.config_entries.ConfigEntries.async_reload",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=MOCK_CONFIG
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "reauth_successful"
|
assert result["reason"] == "reauth_successful"
|
||||||
|
|
||||||
@ -288,9 +286,7 @@ async def test_reauth_password(hass: HomeAssistant, mock_sense) -> None:
|
|||||||
mock_sense.return_value.authenticate.side_effect = SenseAuthenticationException
|
mock_sense.return_value.authenticate.side_effect = SenseAuthenticationException
|
||||||
|
|
||||||
# Reauth success without user input
|
# Reauth success without user input
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
mock_sense.return_value.authenticate.side_effect = None
|
mock_sense.return_value.authenticate.side_effect = None
|
||||||
|
@ -192,15 +192,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
@ -254,15 +246,7 @@ async def test_reauth_flow_error(
|
|||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.sensibo.util.SensiboClient.async_get_devices",
|
"homeassistant.components.sensibo.util.SensiboClient.async_get_devices",
|
||||||
@ -338,15 +322,7 @@ async def test_flow_reauth_no_username_or_device(
|
|||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
@ -207,15 +207,7 @@ async def test_reauth(hass: HomeAssistant, config_entry_with_auth: ConfigEntry)
|
|||||||
"""Test the start of the config flow."""
|
"""Test the start of the config flow."""
|
||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry_with_auth.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": config_entry_with_auth.entry_id,
|
|
||||||
"unique_id": config_entry_with_auth.unique_id,
|
|
||||||
},
|
|
||||||
data=config_entry_with_auth.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("errors") == {}
|
assert result.get("errors") == {}
|
||||||
|
@ -99,11 +99,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
|
|||||||
mock_config = MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG)
|
mock_config = MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG)
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_REAUTH, "unique_id": UNIQUE_ID},
|
|
||||||
data=mock_config.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch("sharkiq.AylaApi.async_sign_in", return_value=True):
|
with patch("sharkiq.AylaApi.async_sign_in", return_value=True):
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
@ -131,11 +127,10 @@ async def test_reauth(
|
|||||||
msg: str,
|
msg: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauth failures."""
|
"""Test reauth failures."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
mock_config = MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG)
|
||||||
DOMAIN,
|
mock_config.add_to_hass(hass)
|
||||||
context={"source": config_entries.SOURCE_REAUTH, "unique_id": UNIQUE_ID},
|
|
||||||
data=CONFIG,
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
)
|
|
||||||
|
|
||||||
with patch("sharkiq.AylaApi.async_sign_in", side_effect=side_effect):
|
with patch("sharkiq.AylaApi.async_sign_in", side_effect=side_effect):
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
@ -23,7 +23,7 @@ from homeassistant.components.shelly.const import (
|
|||||||
BLEScannerMode,
|
BLEScannerMode,
|
||||||
)
|
)
|
||||||
from homeassistant.components.shelly.coordinator import ENTRY_RELOAD_COOLDOWN
|
from homeassistant.components.shelly.coordinator import ENTRY_RELOAD_COOLDOWN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_RECONFIGURE
|
from homeassistant.config_entries import SOURCE_RECONFIGURE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
@ -819,20 +819,15 @@ async def test_reauth_successful(
|
|||||||
domain="shelly", unique_id="test-mac", data={"host": "0.0.0.0", "gen": gen}
|
domain="shelly", unique_id="test-mac", data={"host": "0.0.0.0", "gen": gen}
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
result = await entry.start_reauth_flow(hass)
|
||||||
|
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.shelly.config_flow.get_info",
|
"homeassistant.components.shelly.config_flow.get_info",
|
||||||
return_value={"mac": "test-mac", "type": MODEL_1, "auth": True, "gen": gen},
|
return_value={"mac": "test-mac", "type": MODEL_1, "auth": True, "gen": gen},
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=user_input,
|
user_input=user_input,
|
||||||
@ -858,6 +853,9 @@ async def test_reauth_unsuccessful(
|
|||||||
domain="shelly", unique_id="test-mac", data={"host": "0.0.0.0", "gen": gen}
|
domain="shelly", unique_id="test-mac", data={"host": "0.0.0.0", "gen": gen}
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
result = await entry.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
@ -873,15 +871,6 @@ async def test_reauth_unsuccessful(
|
|||||||
new=AsyncMock(side_effect=InvalidAuthError),
|
new=AsyncMock(side_effect=InvalidAuthError),
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=user_input,
|
user_input=user_input,
|
||||||
@ -897,20 +886,14 @@ async def test_reauth_get_info_error(hass: HomeAssistant) -> None:
|
|||||||
domain="shelly", unique_id="test-mac", data={"host": "0.0.0.0", "gen": 2}
|
domain="shelly", unique_id="test-mac", data={"host": "0.0.0.0", "gen": 2}
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
result = await entry.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.shelly.config_flow.get_info",
|
"homeassistant.components.shelly.config_flow.get_info",
|
||||||
side_effect=DeviceConnectionError,
|
side_effect=DeviceConnectionError,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"password": "test2 password"},
|
user_input={"password": "test2 password"},
|
||||||
|
@ -8,11 +8,13 @@ from simplipy.errors import InvalidCredentialsError, SimplipyError
|
|||||||
|
|
||||||
from homeassistant.components.simplisafe import DOMAIN
|
from homeassistant.components.simplisafe import DOMAIN
|
||||||
from homeassistant.components.simplisafe.config_flow import CONF_AUTH_CODE
|
from homeassistant.components.simplisafe.config_flow import CONF_AUTH_CODE
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_CODE, CONF_TOKEN, CONF_USERNAME
|
from homeassistant.const import CONF_CODE, CONF_TOKEN, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
VALID_AUTH_CODE = "code12345123451234512345123451234512345123451"
|
VALID_AUTH_CODE = "code12345123451234512345123451234512345123451"
|
||||||
|
|
||||||
|
|
||||||
@ -90,13 +92,11 @@ async def test_options_flow(config_entry, hass: HomeAssistant) -> None:
|
|||||||
assert config_entry.options == {CONF_CODE: "4321"}
|
assert config_entry.options == {CONF_CODE: "4321"}
|
||||||
|
|
||||||
|
|
||||||
async def test_step_reauth(config_entry, hass: HomeAssistant, setup_simplisafe) -> None:
|
async def test_step_reauth(
|
||||||
|
config_entry: MockConfigEntry, hass: HomeAssistant, setup_simplisafe
|
||||||
|
) -> None:
|
||||||
"""Test the re-auth step."""
|
"""Test the re-auth step."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH},
|
|
||||||
data={CONF_USERNAME: "12345", CONF_TOKEN: "token123"},
|
|
||||||
)
|
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
@ -118,14 +118,10 @@ async def test_step_reauth(config_entry, hass: HomeAssistant, setup_simplisafe)
|
|||||||
|
|
||||||
@pytest.mark.parametrize("unique_id", ["some_other_id"])
|
@pytest.mark.parametrize("unique_id", ["some_other_id"])
|
||||||
async def test_step_reauth_wrong_account(
|
async def test_step_reauth_wrong_account(
|
||||||
config_entry, hass: HomeAssistant, setup_simplisafe
|
config_entry: MockConfigEntry, hass: HomeAssistant, setup_simplisafe
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the re-auth step where the wrong account is used during login."""
|
"""Test the re-auth step where the wrong account is used during login."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH},
|
|
||||||
data={CONF_USERNAME: "12345", CONF_TOKEN: "token123"},
|
|
||||||
)
|
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -5,10 +5,9 @@ from unittest.mock import patch
|
|||||||
from aioskybell import exceptions
|
from aioskybell import exceptions
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components.skybell.const import DOMAIN
|
from homeassistant.components.skybell.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_SOURCE
|
from homeassistant.const import CONF_PASSWORD
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
@ -104,15 +103,7 @@ async def test_step_reauth(hass: HomeAssistant) -> None:
|
|||||||
entry = MockConfigEntry(domain=DOMAIN, unique_id=USER_ID, data=CONF_DATA)
|
entry = MockConfigEntry(domain=DOMAIN, unique_id=USER_ID, data=CONF_DATA)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
CONF_SOURCE: config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
@ -130,15 +121,7 @@ async def test_step_reauth_failed(hass: HomeAssistant, skybell_mock) -> None:
|
|||||||
entry = MockConfigEntry(domain=DOMAIN, unique_id=USER_ID, data=CONF_DATA)
|
entry = MockConfigEntry(domain=DOMAIN, unique_id=USER_ID, data=CONF_DATA)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
CONF_SOURCE: config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
@ -101,19 +101,7 @@ async def test_reauth_password(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
# set up initially
|
# set up initially
|
||||||
entry = await setup_platform(hass)
|
entry = await setup_platform(hass)
|
||||||
with patch(
|
result = await entry.start_reauth_flow(hass)
|
||||||
"homeassistant.components.sleepiq.config_flow.AsyncSleepIQ.login",
|
|
||||||
side_effect=SleepIQLoginException,
|
|
||||||
):
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.sleepiq.config_flow.AsyncSleepIQ.login",
|
"homeassistant.components.sleepiq.config_flow.AsyncSleepIQ.login",
|
||||||
|
@ -66,15 +66,7 @@ async def test_reauth_success(hass: HomeAssistant, smarttub_api, account) -> Non
|
|||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry.unique_id,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
@ -107,15 +99,7 @@ async def test_reauth_wrong_account(hass: HomeAssistant, smarttub_api, account)
|
|||||||
|
|
||||||
# we try to reauth account #2, and the user successfully authenticates to account #1
|
# we try to reauth account #2, and the user successfully authenticates to account #1
|
||||||
account.id = mock_entry1.unique_id
|
account.id = mock_entry1.unique_id
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry2.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry2.unique_id,
|
|
||||||
"entry_id": mock_entry2.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry2.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
@ -11,7 +11,7 @@ from homeassistant.components.sonarr.const import (
|
|||||||
DEFAULT_WANTED_MAX_ITEMS,
|
DEFAULT_WANTED_MAX_ITEMS,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_SOURCE, CONF_URL, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_API_KEY, CONF_SOURCE, CONF_URL, CONF_VERIFY_SSL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -96,15 +96,7 @@ async def test_full_reauth_flow_implementation(
|
|||||||
"""Test the manual reauth flow from start to finish."""
|
"""Test the manual reauth flow from start to finish."""
|
||||||
entry = init_integration
|
entry = init_integration
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
CONF_SOURCE: SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
@ -13,7 +13,7 @@ from homeassistant.components.application_credentials import (
|
|||||||
async_import_client_credential,
|
async_import_client_credential,
|
||||||
)
|
)
|
||||||
from homeassistant.components.spotify.const import DOMAIN
|
from homeassistant.components.spotify.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZEROCONF
|
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
@ -201,15 +201,7 @@ async def test_reauthentication(
|
|||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
assert len(flows) == 1
|
assert len(flows) == 1
|
||||||
@ -269,15 +261,7 @@ async def test_reauth_account_mismatch(
|
|||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
|
||||||
|
@ -5,8 +5,8 @@ from unittest.mock import patch
|
|||||||
import steam
|
import steam
|
||||||
|
|
||||||
from homeassistant.components.steam_online.const import CONF_ACCOUNTS, DOMAIN
|
from homeassistant.components.steam_online.const import CONF_ACCOUNTS, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_SOURCE
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
@ -111,18 +111,10 @@ async def test_flow_user_already_configured(hass: HomeAssistant) -> None:
|
|||||||
async def test_flow_reauth(hass: HomeAssistant) -> None:
|
async def test_flow_reauth(hass: HomeAssistant) -> None:
|
||||||
"""Test reauth step."""
|
"""Test reauth step."""
|
||||||
entry = create_entry(hass)
|
entry = create_entry(hass)
|
||||||
|
result = await entry.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
with patch_interface():
|
with patch_interface():
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
CONF_SOURCE: SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
data=CONF_DATA,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={},
|
user_input={},
|
||||||
|
@ -69,14 +69,7 @@ async def test_reauth(hass: HomeAssistant, plant_fixture, inverter_fixture) -> N
|
|||||||
assert entries[0].data[CONF_USERNAME] == SUNWEG_MOCK_ENTRY.data[CONF_USERNAME]
|
assert entries[0].data[CONF_USERNAME] == SUNWEG_MOCK_ENTRY.data[CONF_USERNAME]
|
||||||
assert entries[0].data[CONF_PASSWORD] == SUNWEG_MOCK_ENTRY.data[CONF_PASSWORD]
|
assert entries[0].data[CONF_PASSWORD] == SUNWEG_MOCK_ENTRY.data[CONF_PASSWORD]
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
@ -155,15 +155,7 @@ async def test_reauthentication(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
@ -192,15 +184,7 @@ async def test_reauthentication_failure(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
@ -230,15 +214,7 @@ async def test_reauthentication_cannot_connect(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
@ -268,15 +244,7 @@ async def test_reauthentication_unknown_failure(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -21,12 +21,7 @@ from homeassistant.components.synology_dsm.const import (
|
|||||||
DEFAULT_SNAPSHOT_QUALITY,
|
DEFAULT_SNAPSHOT_QUALITY,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER, SOURCE_ZEROCONF
|
||||||
SOURCE_REAUTH,
|
|
||||||
SOURCE_SSDP,
|
|
||||||
SOURCE_USER,
|
|
||||||
SOURCE_ZEROCONF,
|
|
||||||
)
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_MAC,
|
CONF_MAC,
|
||||||
@ -297,24 +292,7 @@ async def test_reauth(hass: HomeAssistant, service: MagicMock) -> None:
|
|||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
with patch(
|
result = await entry.start_reauth_flow(hass)
|
||||||
"homeassistant.config_entries.ConfigEntries.async_reload",
|
|
||||||
return_value=True,
|
|
||||||
):
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"title_placeholders": {"name": entry.title},
|
|
||||||
},
|
|
||||||
data={
|
|
||||||
CONF_HOST: HOST,
|
|
||||||
CONF_USERNAME: USERNAME,
|
|
||||||
CONF_PASSWORD: PASSWORD,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user