diff --git a/ariston/ariston_api.py b/ariston/ariston_api.py index 8e15817..035c56c 100644 --- a/ariston/ariston_api.py +++ b/ariston/ariston_api.py @@ -609,7 +609,7 @@ def __request( if len(response.content) > 0: json = response.json() - _LOGGER.debug("Response %s", json) + _LOGGER.debug("Response received") return json return None @@ -1560,7 +1560,7 @@ async def __async_request( if response.content_length and response.content_length > 0: json = await response.json() - _LOGGER.debug("Response %s", json) + _LOGGER.debug("Response received") return json return None diff --git a/tests/test_ariston_api.py b/tests/test_ariston_api.py index 1df0e8a..2624196 100644 --- a/tests/test_ariston_api.py +++ b/tests/test_ariston_api.py @@ -85,13 +85,15 @@ def test_login_token_is_sent_with_followup_request(self): FakeResponse([{"gw": "gateway-1"}]), ] - with patch( - "ariston.ariston_api.requests.request", side_effect=responses - ) as request: - self.assertTrue(api.connect()) - devices = api.get_detailed_devices() + with self.assertLogs("ariston.ariston_api", level="DEBUG") as logs: + with patch( + "ariston.ariston_api.requests.request", side_effect=responses + ) as request: + self.assertTrue(api.connect()) + devices = api.get_detailed_devices() self.assertEqual(devices, [{"gw": "gateway-1"}]) + self.assertNotIn("session-token", "\n".join(logs.output)) login_call, devices_call = request.call_args_list # requests expects seconds: a regression to milliseconds (30000) would # let a hung connection block the caller for hours. @@ -126,11 +128,12 @@ async def connect_and_discover(): self.assertTrue(await api.async_connect()) return await api.async_get_detailed_devices() - with patch( - "ariston.ariston_api.aiohttp.ClientSession", - side_effect=[login_session, devices_session], - ) as client_session: - devices = asyncio.run(connect_and_discover()) + with self.assertLogs("ariston.ariston_api", level="DEBUG") as logs: + with patch( + "ariston.ariston_api.aiohttp.ClientSession", + side_effect=[login_session, devices_session], + ) as client_session: + devices = asyncio.run(connect_and_discover()) # Every async request must set an explicit total timeout instead of # relying on aiohttp's 5 minute default. @@ -139,6 +142,7 @@ async def connect_and_discover(): self.assertEqual(call.kwargs["timeout"], aiohttp.ClientTimeout(total=30)) self.assertEqual(devices, [{"gw": "gateway-1"}]) + self.assertNotIn("async-session-token", "\n".join(logs.output)) self.assertEqual( login_session.calls[0][0], ("POST", "https://example.test/api/accounts/login"),