Fix reauth step in nest (#74090)

This commit is contained in:
epenet 2022-06-28 10:06:05 +02:00 committed by GitHub
parent 319ef38d34
commit 35df012b6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 19 deletions

View file

@ -11,7 +11,7 @@ from __future__ import annotations
import asyncio import asyncio
from collections import OrderedDict from collections import OrderedDict
from collections.abc import Iterable from collections.abc import Iterable, Mapping
from enum import Enum from enum import Enum
import logging import logging
import os import os
@ -218,14 +218,9 @@ class NestFlowHandler(
return await self.async_step_finish() return await self.async_step_finish()
return await self.async_step_pubsub() return await self.async_step_pubsub()
async def async_step_reauth( async def async_step_reauth(self, user_input: Mapping[str, Any]) -> FlowResult:
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Perform reauth upon an API authentication error.""" """Perform reauth upon an API authentication error."""
assert self.config_mode != ConfigMode.LEGACY, "Step only supported for SDM API" assert self.config_mode != ConfigMode.LEGACY, "Step only supported for SDM API"
if user_input is None:
_LOGGER.error("Reauth invoked with empty config entry data")
return self.async_abort(reason="missing_configuration")
self._data.update(user_input) self._data.update(user_input)
return await self.async_step_reauth_confirm() return await self.async_step_reauth_confirm()

View file

@ -505,18 +505,6 @@ async def test_reauth_multiple_config_entries(
assert entry.data.get("extra_data") assert entry.data.get("extra_data")
async def test_reauth_missing_config_entry(hass, setup_platform):
"""Test the reauth flow invoked missing existing data."""
await setup_platform()
# Invoke the reauth flow with no existing data
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=None
)
assert result["type"] == "abort"
assert result["reason"] == "missing_configuration"
@pytest.mark.parametrize( @pytest.mark.parametrize(
"nest_test_config,auth_implementation", [(TEST_CONFIG_HYBRID, APP_AUTH_DOMAIN)] "nest_test_config,auth_implementation", [(TEST_CONFIG_HYBRID, APP_AUTH_DOMAIN)]
) )