mirror of
https://github.com/home-assistant/core.git
synced 2026-10-07 14:58:11 -04:00
Show invalid authentication for a wrong LaMetric API key during setup (#184195)
This commit is contained in:
@@ -201,6 +201,8 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
|
||||
)
|
||||
except AbortFlow:
|
||||
raise
|
||||
except LaMetricAuthenticationError:
|
||||
errors["base"] = "invalid_auth"
|
||||
except LaMetricConnectionError as ex:
|
||||
LOGGER.error("Error connecting to LaMetric: %s", ex)
|
||||
errors["base"] = "cannot_connect"
|
||||
@@ -267,6 +269,8 @@ class LaMetricFlowHandler(AbstractOAuth2FlowHandler, domain=DOMAIN):
|
||||
)
|
||||
except AbortFlow:
|
||||
raise
|
||||
except LaMetricAuthenticationError:
|
||||
errors["base"] = "invalid_auth"
|
||||
except LaMetricConnectionError as ex:
|
||||
LOGGER.error("Error connecting to LaMetric: %s", ex)
|
||||
errors["base"] = "cannot_connect"
|
||||
|
||||
@@ -545,6 +545,7 @@ async def test_cloud_abort_no_devices(
|
||||
@pytest.mark.parametrize(
|
||||
("side_effect", "reason"),
|
||||
[
|
||||
(LaMetricAuthenticationError, "invalid_auth"),
|
||||
(LaMetricConnectionTimeoutError, "cannot_connect"),
|
||||
(LaMetricConnectionError, "cannot_connect"),
|
||||
(LaMetricError, "unknown"),
|
||||
@@ -605,6 +606,7 @@ async def test_manual_errors(
|
||||
@pytest.mark.parametrize(
|
||||
("side_effect", "reason"),
|
||||
[
|
||||
(LaMetricAuthenticationError, "invalid_auth"),
|
||||
(LaMetricConnectionTimeoutError, "cannot_connect"),
|
||||
(LaMetricConnectionError, "cannot_connect"),
|
||||
(LaMetricError, "unknown"),
|
||||
|
||||
Reference in New Issue
Block a user