Skip to content

Commit

Permalink
Allow Domain Names for Broker and Hub; Remove IP Test
Browse files Browse the repository at this point in the history
IP test was nice, but doesn't allow for use of domain names.

Closed #403
  • Loading branch information
krkeegan committed May 17, 2021
1 parent 6f473a2 commit a14f7d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
10 changes: 0 additions & 10 deletions insteon_mqtt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions insteon_mqtt/schemas/config-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -164,7 +161,6 @@ mqtt:
schema:
broker:
type: string
check_with: valid_ip
required: True
port:
type: integer
Expand Down
7 changes: 7 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a14f7d6

Please sign in to comment.