-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Abort reauth flows on config entry reload #140931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
ac07102
f37c756
5802be3
807ce27
84ccaf6
538da44
0410e5a
1e719df
e0ad80b
7c81bf1
26a7725
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,21 @@ async def async_step_init(self, user_input=None): | |
assert len(manager.mock_created_entries) == 0 | ||
|
||
|
||
async def test_abort_aborted_flow(manager: MockFlowManager) -> None: | ||
"""Test return abort from aborted flow.""" | ||
|
||
@manager.mock_reg_handler("test") | ||
class TestFlow(data_entry_flow.FlowHandler): | ||
async def async_step_init(self, user_input=None): | ||
manager.async_abort(self.flow_id) | ||
return self.async_abort(reason="blah") | ||
|
||
form = await manager.async_init("test") | ||
assert form["reason"] == "blah" | ||
assert len(manager.async_progress()) == 0 | ||
assert len(manager.mock_created_entries) == 0 | ||
|
||
|
||
async def test_abort_calls_async_remove(manager: MockFlowManager) -> None: | ||
"""Test abort calling the async_remove FlowHandler method.""" | ||
|
||
|
@@ -217,6 +232,31 @@ async def async_step_init(self, user_input=None): | |
assert entry["source"] is None | ||
|
||
|
||
async def test_create_aborted_flow(manager: MockFlowManager) -> None: | ||
"""Test return create_entry from aborted flow.""" | ||
|
||
@manager.mock_reg_handler("test") | ||
class TestFlow(data_entry_flow.FlowHandler): | ||
VERSION = 5 | ||
|
||
async def async_step_init(self, user_input=None): | ||
manager.async_abort(self.flow_id) | ||
return self.async_create_entry(title="Test Title", data="Test Data") | ||
|
||
with pytest.raises(data_entry_flow.UnknownFlow): | ||
await manager.async_init("test") | ||
assert len(manager.async_progress()) == 0 | ||
|
||
# The entry is created even if the flow is aborted | ||
assert len(manager.mock_created_entries) == 1 | ||
|
||
entry = manager.mock_created_entries[0] | ||
assert entry["handler"] == "test" | ||
assert entry["title"] == "Test Title" | ||
assert entry["data"] == "Test Data" | ||
assert entry["source"] is None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The behavior is quite illogical; an entry is created without checking if the flow still exists, but there's then an error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you please add a comment to this test explaining that. |
||
|
||
|
||
async def test_discovery_init_flow(manager: MockFlowManager) -> None: | ||
"""Test a flow initialized by discovery.""" | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.