From a14f7d64ecb4afc073c32db827a78de3f6d7fd32 Mon Sep 17 00:00:00 2001 From: KRKeegan Date: Mon, 17 May 2021 08:09:16 -0700 Subject: [PATCH] Allow Domain Names for Broker and Hub; Remove IP Test IP test was nice, but doesn't allow for use of domain names. Closed #403 --- insteon_mqtt/config.py | 10 ---------- insteon_mqtt/schemas/config-schema.yaml | 4 ---- tests/test_config.py | 7 +++++++ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/insteon_mqtt/config.py b/insteon_mqtt/config.py index 882113de..e246bac2 100644 --- a/insteon_mqtt/config.py +++ b/insteon_mqtt/config.py @@ -347,16 +347,6 @@ def _find_error(self, meta, error_path, iter): class IMValidator(Validator): """ Adds a few check_with functions to validate specific settings """ - def _check_with_valid_ip(self, field, value): - """ Tests whether value is a valid ipv4 or ipv6 address - - Uses the library ipaddress for accuracy - """ - try: - ipaddress.ip_address(value) - except ValueError: - self._error(field, "Invalid IP Address") - def _check_with_valid_insteon_addr(self, field, value): """ Tests whether value is a valid Insteon Address for Insteon MQTT diff --git a/insteon_mqtt/schemas/config-schema.yaml b/insteon_mqtt/schemas/config-schema.yaml index 8cb3d6f6..9139ec1c 100644 --- a/insteon_mqtt/schemas/config-schema.yaml +++ b/insteon_mqtt/schemas/config-schema.yaml @@ -58,7 +58,6 @@ insteon: two following definitions must be satisfied. hub_ip: type: string - check_with: valid_ip hub_port: type: integer min: 0 @@ -140,8 +139,6 @@ insteon: mqtt: type: dict - meta: - schema_error: unknown field allow_unknown: ## The only unknown keys are user defined discovery_class settings type: dict @@ -164,7 +161,6 @@ mqtt: schema: broker: type: string - check_with: valid_ip required: True port: type: integer diff --git a/tests/test_config.py b/tests/test_config.py index e940ceef..c7bb1558 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -93,6 +93,13 @@ def test_good_hub(self): val = IM.config.validate(file) assert val == "" + #----------------------------------------------------------------------- + def test_dns(self): + file = os.path.join(os.path.dirname(os.path.realpath(__file__)), + 'configs', 'use_dns.yaml') + val = IM.config.validate(file) + assert val == "" + #----------------------------------------------------------------------- def test_validate_addr(self): validator = IM.config.IMValidator()