Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
8719829f
Unverified
Commit
8719829f
authored
2 years ago
by
Maciej Bieniek
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add missing error catch in Shelly reauth flow (#79205)
parent
8c0e3b9d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/shelly/config_flow.py
+9
-1
9 additions, 1 deletion
homeassistant/components/shelly/config_flow.py
tests/components/shelly/test_config_flow.py
+37
-0
37 additions, 0 deletions
tests/components/shelly/test_config_flow.py
with
46 additions
and
1 deletion
homeassistant/components/shelly/config_flow.py
+
9
−
1
View file @
8719829f
...
...
@@ -278,7 +278,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
host
=
self
.
entry
.
data
[
CONF_HOST
]
if
user_input
is
not
None
:
info
=
await
self
.
_async_get_info
(
host
)
try
:
info
=
await
self
.
_async_get_info
(
host
)
except
(
asyncio
.
TimeoutError
,
aiohttp
.
ClientError
,
aioshelly
.
exceptions
.
FirmwareUnsupported
,
):
return
self
.
async_abort
(
reason
=
"
reauth_unsuccessful
"
)
if
self
.
entry
.
data
.
get
(
"
gen
"
,
1
)
!=
1
:
user_input
[
CONF_USERNAME
]
=
"
admin
"
try
:
...
...
This diff is collapsed.
Click to expand it.
tests/components/shelly/test_config_flow.py
+
37
−
0
View file @
8719829f
...
...
@@ -885,3 +885,40 @@ async def test_reauth_unsuccessful(hass, test_data):
assert
result
[
"
type
"
]
==
data_entry_flow
.
FlowResultType
.
ABORT
assert
result
[
"
reason
"
]
==
"
reauth_unsuccessful
"
@pytest.mark.parametrize
(
"
error
"
,
[
asyncio
.
TimeoutError
,
aiohttp
.
ClientError
,
aioshelly
.
exceptions
.
FirmwareUnsupported
,
],
)
async
def
test_reauth_get_info_error
(
hass
,
error
):
"""
Test reauthentication flow failed with error in get_info().
"""
entry
=
MockConfigEntry
(
domain
=
"
shelly
"
,
unique_id
=
"
test-mac
"
,
data
=
{
"
host
"
:
"
0.0.0.0
"
,
"
gen
"
:
2
}
)
entry
.
add_to_hass
(
hass
)
with
patch
(
"
aioshelly.common.get_info
"
,
side_effect
=
error
,
):
result
=
await
hass
.
config_entries
.
flow
.
async_init
(
DOMAIN
,
context
=
{
"
source
"
:
SOURCE_REAUTH
,
"
entry_id
"
:
entry
.
entry_id
},
data
=
entry
.
data
,
)
assert
result
[
"
type
"
]
==
data_entry_flow
.
FlowResultType
.
FORM
assert
result
[
"
step_id
"
]
==
"
reauth_confirm
"
result
=
await
hass
.
config_entries
.
flow
.
async_configure
(
result
[
"
flow_id
"
],
user_input
=
{
"
password
"
:
"
test2 password
"
},
)
assert
result
[
"
type
"
]
==
data_entry_flow
.
FlowResultType
.
ABORT
assert
result
[
"
reason
"
]
==
"
reauth_unsuccessful
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment