Limit OAuth scopes for Netatmo and Home Assistant Cloud (#31538)
* Limit OAuth scopes for Netatmo and Home Assistant Cloud * Fix tests by making order of scopes predictablepull/31544/head
parent
24e9a638d5
commit
7233048fea
|
@ -25,24 +25,22 @@ class NetatmoFlowHandler(
|
|||
@property
|
||||
def extra_authorize_data(self) -> dict:
|
||||
"""Extra data that needs to be appended to the authorize url."""
|
||||
return {
|
||||
"scope": (
|
||||
" ".join(
|
||||
[
|
||||
"read_station",
|
||||
"read_camera",
|
||||
"access_camera",
|
||||
"write_camera",
|
||||
"read_presence",
|
||||
"access_presence",
|
||||
"read_homecoach",
|
||||
"read_smokedetector",
|
||||
"read_thermostat",
|
||||
"write_thermostat",
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
scopes = [
|
||||
"read_camera",
|
||||
"read_homecoach",
|
||||
"read_presence",
|
||||
"read_smokedetector",
|
||||
"read_station",
|
||||
"read_thermostat",
|
||||
"write_camera",
|
||||
"write_thermostat",
|
||||
]
|
||||
|
||||
if self.flow_impl.name != "Home Assistant Cloud":
|
||||
scopes.extend(["access_camera", "access_presence"])
|
||||
scopes.sort()
|
||||
|
||||
return {"scope": " ".join(scopes)}
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
"""Handle a flow start."""
|
||||
|
|
|
@ -54,15 +54,15 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock):
|
|||
|
||||
scope = "+".join(
|
||||
[
|
||||
"read_station",
|
||||
"read_camera",
|
||||
"access_camera",
|
||||
"write_camera",
|
||||
"read_presence",
|
||||
"access_presence",
|
||||
"read_camera",
|
||||
"read_homecoach",
|
||||
"read_presence",
|
||||
"read_smokedetector",
|
||||
"read_station",
|
||||
"read_thermostat",
|
||||
"write_camera",
|
||||
"write_thermostat",
|
||||
]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue