Skip to content

Commit

Permalink
👌 IMPROVE: modified logs
Browse files Browse the repository at this point in the history
  • Loading branch information
unl0ck committed Dec 2, 2024
1 parent 151894b commit 1bafd67
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .bumpversion-edge.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "2.11.10"
current_version = "2.11.11"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 2.11.9
## 2.11.11

### 🚀 Added

Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/GridboxConnector/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def run_addon():
logger.debug(gridbox_config["login"])
mqtt_settings = Settings.MQTT(host=mqtt_server, username=mqtt_user, password=mqtt_pw, port=mqtt_port)
viessmann_gridbox_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, logger=logger)
viessmann_gridbox_historical_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, device_name="Viessmann Gridbox Historical",device_identifiers="viessmann_gridbox_historical",logger=logger)
viessmann_gridbox_historical_device = HAViessmannGridboxConnector(mqtt_settings=mqtt_settings, device_name="Viessmann Gridbox Historical",device_identifiers="viessmann_gridbox_historical",logger=logger, prefix="historical")
gridboxConnector = GridboxConnector(gridbox_config)

# Starte die Threads
Expand Down
51 changes: 51 additions & 0 deletions GridboxConnectorAddon-edge/GridboxConnector/import unittest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import unittest
import logging
from unittest.mock import Mock, patch
from .utils import SensitiveDataFilter, get_bool_env

# FILE: GridboxConnectorAddon-edge/GridboxConnector/test_utils.py


class TestSensitiveDataFilter(unittest.TestCase):
def setUp(self):
self.filter = SensitiveDataFilter()

def test_filter(self):
record = logging.LogRecord(name="test", level=logging.INFO, pathname="", lineno=0, msg='{"username": "user", "password": "pass"}', args=(), exc_info=None)
self.filter.filter(record)
self.assertIn('"username": "***"', record.msg)
self.assertIn('"password": "***"', record.msg)

def test_filter_no_sensitive_data(self):
record = logging.LogRecord(name="test", level=logging.INFO, pathname="", lineno=0, msg='{"data": "value"}', args=(), exc_info=None)
self.filter.filter(record)
self.assertIn('"data": "value"', record.msg)

def test_filter_invalid_json(self):
record = logging.LogRecord(name="test", level=logging.INFO, pathname="", lineno=0, msg='Invalid JSON', args=(), exc_info=None)
self.filter.filter(record)
self.assertEqual(record.msg, 'Invalid JSON')

class TestGetBoolEnv(unittest.TestCase):
@patch('os.getenv', return_value="true")
def test_get_bool_env_true(self, mock_getenv):
self.assertTrue(get_bool_env("TEST_VAR"))

@patch('os.getenv', return_value="false")
def test_get_bool_env_false(self, mock_getenv):
self.assertFalse(get_bool_env("TEST_VAR"))

@patch('os.getenv', return_value=None)
def test_get_bool_env_default(self, mock_getenv):
self.assertFalse(get_bool_env("TEST_VAR"))

@patch('os.getenv', return_value="1")
def test_get_bool_env_one(self, mock_getenv):
self.assertTrue(get_bool_env("TEST_VAR"))

@patch('os.getenv', return_value="0")
def test_get_bool_env_zero(self, mock_getenv):
self.assertFalse(get_bool_env("TEST_VAR"))

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/cloudSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.11.10",
"version": "2.11.11",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
---
name: Viessmann Gridbox Connector (edge)
version: "2.11.10"
version: "2.11.11"
slug: "gridbox_connector_edge"
description: "Viessmann Gridbox Connector (edge)"
url: "https://github.com/unl0ck/homeassistant-addon-viessmann-gridbox/tree/main/GridboxConnectorAddon-edge"
Expand Down
2 changes: 1 addition & 1 deletion GridboxConnectorAddon-edge/rootfs/share/cloudSettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.11.10",
"version": "2.11.11",
"urls": {
"login": "https://gridx.eu.auth0.com/oauth/token",
"gateways": "https://api.gridx.de/gateways",
Expand Down

0 comments on commit 1bafd67

Please sign in to comment.