-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Start reauth when roborock notices the MQTT session is unauthorized #159719
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 all commits
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -92,6 +92,44 @@ async def test_reauth_started( | |||||||
| assert flows[0]["step_id"] == "reauth_confirm" | ||||||||
|
|
||||||||
|
|
||||||||
| async def test_mqtt_session_unauthorized_hook_called( | ||||||||
| hass: HomeAssistant, | ||||||||
| mock_roborock_entry: MockConfigEntry, | ||||||||
| device_manager: AsyncMock, | ||||||||
| ) -> None: | ||||||||
| """Test that the mqtt session unauthorized hook is called on unauthorized event.""" | ||||||||
| device_manager_kwargs = {} | ||||||||
|
|
||||||||
| def create_device_manager(*args: Any, **kwargs: Any) -> AsyncMock: | ||||||||
| nonlocal device_manager_kwargs | ||||||||
| device_manager_kwargs = kwargs | ||||||||
| return device_manager | ||||||||
|
|
||||||||
| with patch( | ||||||||
| "homeassistant.components.roborock.create_device_manager", | ||||||||
| side_effect=create_device_manager, | ||||||||
| ): | ||||||||
| await hass.config_entries.async_setup(mock_roborock_entry.entry_id) | ||||||||
| await hass.async_block_till_done() | ||||||||
| assert mock_roborock_entry.state is ConfigEntryState.LOADED | ||||||||
|
|
||||||||
| flows = hass.config_entries.flow.async_progress() | ||||||||
| assert not flows | ||||||||
|
|
||||||||
| # Simulate an unauthorized event by calling the captured hook | ||||||||
| assert device_manager_kwargs | ||||||||
| mqtt_session_unauthorized_hook = device_manager_kwargs.get( | ||||||||
| "mqtt_session_unauthorized_hook" | ||||||||
| ) | ||||||||
| assert mqtt_session_unauthorized_hook | ||||||||
| mqtt_session_unauthorized_hook() | ||||||||
|
||||||||
| mqtt_session_unauthorized_hook() | |
| mqtt_session_unauthorized_hook() | |
| await hass.async_block_till_done() |
Uh oh!
There was an error while loading. Please reload this page.