Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix diagnostics issue and add diagnostics test #855

Merged
merged 3 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pyoverkiz/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ async def refresh_token(self) -> None:
return

if not self._refresh_token:
raise ValueError("No refresh token provided. Login method must be used.")
raise ValueError(
"No refresh token provided. Login method must be used.")

# &grant_type=refresh_token&refresh_token=REFRESH_TOKEN
# Request access token
Expand Down Expand Up @@ -297,7 +298,8 @@ async def cozytouch_login(self) -> str:
# {'error': 'invalid_grant',
# 'error_description': 'Provided Authorization Grant is invalid.'}
if "error" in token and token["error"] == "invalid_grant":
raise CozyTouchBadCredentialsException(token["error_description"])
raise CozyTouchBadCredentialsException(
token["error_description"])

if "token_type" not in token:
raise CozyTouchServiceException("No CozyTouch token provided.")
Expand Down Expand Up @@ -474,7 +476,8 @@ async def get_execution_history(self) -> list[HistoryExecution]:
List execution history
"""
response = await self.__get("history/executions")
execution_history = [HistoryExecution(**h) for h in humps.decamelize(response)]
execution_history = [HistoryExecution(
**h) for h in humps.decamelize(response)]

return execution_history

Expand Down Expand Up @@ -803,7 +806,8 @@ async def check_response(response: ClientResponse) -> None:
except JSONDecodeError as error:
result = await response.text()
if "Server is down for maintenance" in result:
raise MaintenanceException("Server is down for maintenance") from error
raise MaintenanceException(
"Server is down for maintenance") from error
raise Exception(
f"Unknown error while requesting {response.url}. {response.status} - {result}"
) from error
Expand Down
6 changes: 6 additions & 0 deletions pyoverkiz/obfuscate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def obfuscate_sensitive_data(data: dict[str, Any]) -> JSON:
"""Mask Overkiz JSON data to remove sensitive data"""
mask_next_value = False

print(data)
iMicknl marked this conversation as resolved.
Show resolved Hide resolved

for key, value in data.items():
if key in ["gatewayId", "id", "deviceURL"]:
data[key] = obfuscate_id(value)
Expand Down Expand Up @@ -56,6 +58,10 @@ def obfuscate_sensitive_data(data: dict[str, Any]) -> JSON:
for val in value:
if isinstance(val, str):
continue
if isinstance(val, int):
continue
if isinstance(val, float):
continue
if isinstance(val, list):
continue

Expand Down
Loading