File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -376,6 +376,7 @@ async def _async_request(
376376 body : dict [str , Any ] | None = None ,
377377 vin : str = "" ,
378378 ) -> dict [str , Any ]:
379+ vin = vin or self .vin
379380 access_token = await self .async_get_access_token ()
380381
381382 headers = {
Original file line number Diff line number Diff line change 11"""API tests."""
22
33from datetime import UTC , datetime
4+ import logging
45from unittest .mock import AsyncMock
56
67from aiohttp import ClientResponseError , ClientSession , RequestInfo
@@ -117,6 +118,22 @@ async def test_access_token_raises_api_exception(
117118 await api .async_get_access_token ()
118119
119120
121+ async def test_redacted_url (
122+ mock_client_session : ClientSession , mock_token_manager : VolvoCarsAuth , caplog : pytest .LogCaptureFixture
123+ ) -> None :
124+ """Test if request url is redacted in logs."""
125+ odometer_json = load_json_fixture ("odometer" )
126+ _mock_response (mock_client_session , odometer_json )
127+
128+ vin = "YV1ABCDEFG1234567"
129+ api = VolvoCarsApi (mock_client_session , mock_token_manager , "secretapikey" , vin )
130+
131+ with caplog .at_level (logging .DEBUG ):
132+ await api .async_get_odometer ()
133+ assert "Request [odometer]:" in caplog .text
134+ assert vin not in caplog .text
135+
136+
120137def _mock_response (mock_client_session : ClientSession , json : dict ) -> None :
121138 mock_response = AsyncMock ()
122139 mock_response .__aenter__ .return_value .json = AsyncMock (return_value = json )
You can’t perform that action at this time.
0 commit comments