8000 Hive auth fix for users by KJonline · Pull Request #73247 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Hive auth fix for users #73247

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

Merged
merged 3 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions homeassistant/components/hive/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self):
self.data = {}
self.tokens = {}
self.entry = None
self.device_registration = False

async def async_step_user(self, user_input=None):
"""Prompt user input. Create or edit entry."""
Expand Down Expand Up @@ -88,6 +89,7 @@ async def async_step_2fa(self, user_input=None):

if not errors:
try:
self.device_registration = True
return await self.async_setup_hive_entry()
except UnknownHiveError:
errors["base"] = "unknown"
Expand All @@ -102,9 +104,10 @@ async def async_setup_hive_entry(self):
raise UnknownHiveError

# Setup the config entry
await self.hive_auth.device_registration("Home Assistant")
if self.device_registration:
await self.hive_auth.device_registration("Home Assistant")
self.data["device_data"] = await self.hive_auth.getDeviceData()
self.data["tokens"] = self.tokens
self.data["device_data"] = await self.hive_auth.getDeviceData()
if self.context["source"] == config_entries.SOURCE_REAUTH:
self.hass.config_entries.async_update_entry(
self.entry, title=self.data["username"], data=self.data
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hive/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Hive",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/hive",
"requirements": ["pyhiveapi==0.5.5"],
"requirements": ["pyhiveapi==0.5.9"],
"codeowners": ["@Rendili", "@KJonline"],
"iot_class": "cloud_polling",
"loggers": ["apyhiveapi"]
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ pyheos==0.7.2
pyhik==0.3.0

# homeassistant.components.hive
pyhiveapi==0.5.5
pyhiveapi==0.5.9

# homeassistant.components.homematic
pyhomematic==0.1.77
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ pyhaversion==22.4.1
pyheos==0.7.2

# homeassistant.components.hive
pyhiveapi==0.5.5
pyhiveapi==0.5.9

# homeassistant.components.homematic
pyhomematic==0.1.77
Expand Down
30 changes: 0 additions & 30 deletions tests/components/hive/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ async def test_import_flow(hass):
"AccessToken": "mock-access-token",
},
},
), patch(
"homeassistant.components.hive.config_flow.Auth.device_registration",
return_value=True,
), patch(
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
return_value=[
"mock-device-group-key",
"mock-device-key",
"mock-device-password",
],
), patch(
"homeassistant.components.hive.async_setup", return_value=True
) as mock_setup, patch(
Expand All @@ -67,11 +57,6 @@ async def test_import_flow(hass):
},
"ChallengeName": "SUCCESS",
},
"device_data": [
"mock-device-group-key",
"mock-device-key",
"mock-device-password",
],
}
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1
Expand All @@ -96,16 +81,6 @@ async def test_user_flow(hass):
"AccessToken": "mock-access-token",
},
},
), patch(
"homeassistant.components.hive.config_flow.Auth.device_registration",
return_value=True,
), patch(
"homeassistant.components.hive.config_flow.Auth.getDeviceData",
return_value=[
"mock-device-group-key",
"mock-device-key",
"mock-device-password",
],
), patch(
"homeassistant.components.hive.async_setup", return_value=True
) as mock_setup, patch(
Expand All @@ -130,11 +105,6 @@ async def test_user_flow 5BE9 (hass):
},
"ChallengeName": "SUCCESS",
},
"device_data": [
"mock-device-group-key",
"mock-device-key",
"mock-device-password",
],
}

assert len(mock_setup.mock_calls) == 1
Expand Down
0