diff --git a/.bumpversion-edge.toml b/.bumpversion-edge.toml index e2fc8e1..91b9bea 100644 --- a/.bumpversion-edge.toml +++ b/.bumpversion-edge.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "2.11.10" +current_version = "2.11.11" parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" serialize = ["{major}.{minor}.{patch}"] search = "{current_version}" diff --git a/GridboxConnectorAddon-edge/CHANGELOG.md b/GridboxConnectorAddon-edge/CHANGELOG.md index 97ba0c5..fa111d7 100644 --- a/GridboxConnectorAddon-edge/CHANGELOG.md +++ b/GridboxConnectorAddon-edge/CHANGELOG.md @@ -1,6 +1,6 @@ -## 2.11.9 +## 2.11.11 ### 🚀 Added diff --git a/GridboxConnectorAddon-edge/GridboxConnector/__main__.py b/GridboxConnectorAddon-edge/GridboxConnector/__main__.py index 82d7ac9..af5c394 100644 --- a/GridboxConnectorAddon-edge/GridboxConnector/__main__.py +++ b/GridboxConnectorAddon-edge/GridboxConnector/__main__.py @@ -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 diff --git a/GridboxConnectorAddon-edge/GridboxConnector/import unittest.py b/GridboxConnectorAddon-edge/GridboxConnector/import unittest.py new file mode 100644 index 0000000..4da826b --- /dev/null +++ b/GridboxConnectorAddon-edge/GridboxConnector/import unittest.py @@ -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() \ No newline at end of file diff --git a/GridboxConnectorAddon-edge/cloudSettings.json b/GridboxConnectorAddon-edge/cloudSettings.json index 5a2ee92..55aa6b4 100644 --- a/GridboxConnectorAddon-edge/cloudSettings.json +++ b/GridboxConnectorAddon-edge/cloudSettings.json @@ -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", diff --git a/GridboxConnectorAddon-edge/config.yaml b/GridboxConnectorAddon-edge/config.yaml index edfceed..755b31d 100644 --- a/GridboxConnectorAddon-edge/config.yaml +++ b/GridboxConnectorAddon-edge/config.yaml @@ -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" diff --git a/GridboxConnectorAddon-edge/rootfs/share/cloudSettings.json b/GridboxConnectorAddon-edge/rootfs/share/cloudSettings.json index 5a2ee92..55aa6b4 100644 --- a/GridboxConnectorAddon-edge/rootfs/share/cloudSettings.json +++ b/GridboxConnectorAddon-edge/rootfs/share/cloudSettings.json @@ -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",