Fix fitbit oauth reauth debug logging (#105450)
This commit is contained in:
parent
399f98a726
commit
0683b8be21
2 changed files with 7 additions and 1 deletions
|
@ -60,7 +60,10 @@ class FitbitOAuth2Implementation(AuthImplementation):
|
|||
resp.raise_for_status()
|
||||
except aiohttp.ClientResponseError as err:
|
||||
if _LOGGER.isEnabledFor(logging.DEBUG):
|
||||
error_body = await resp.text() if not session.closed else ""
|
||||
try:
|
||||
error_body = await resp.text()
|
||||
except aiohttp.ClientError:
|
||||
error_body = ""
|
||||
_LOGGER.debug(
|
||||
"Client response error status=%s, body=%s", err.status, error_body
|
||||
)
|
||||
|
|
|
@ -107,18 +107,21 @@ async def test_token_refresh_success(
|
|||
|
||||
|
||||
@pytest.mark.parametrize("token_expiration_time", [12345])
|
||||
@pytest.mark.parametrize("closing", [True, False])
|
||||
async def test_token_requires_reauth(
|
||||
hass: HomeAssistant,
|
||||
integration_setup: Callable[[], Awaitable[bool]],
|
||||
config_entry: MockConfigEntry,
|
||||
aioclient_mock: AiohttpClientMocker,
|
||||
setup_credentials: None,
|
||||
closing: bool,
|
||||
) -> None:
|
||||
"""Test where token is expired and the refresh attempt requires reauth."""
|
||||
|
||||
aioclient_mock.post(
|
||||
OAUTH2_TOKEN,
|
||||
status=HTTPStatus.UNAUTHORIZED,
|
||||
closing=closing,
|
||||
)
|
||||
|
||||
assert not await integration_setup()
|
||||
|
|
Loading…
Add table
Reference in a new issue