1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Give mFi options to control TLS usage

The default configuration of the mFi controller generates self-signed
certificates which are valid for short periods of time, and which are
regnerated on start or as needed. This makes requests mad. Since most
people will be using the self-signed certificates anyway, add options
to let them choose non-TLS, or unverified connections if they want/need.

This bumps the mficlient requirement to 0.3.0 for proper handling of
verify=False.
This commit is contained in:
Dan Smith
2016-02-29 17:37:41 -08:00
parent 87e23e7d73
commit be04ebf9ed
4 changed files with 36 additions and 9 deletions

View File

@@ -27,6 +27,8 @@ class TestMfiSensorSetup(unittest.TestCase):
'port': 6123,
'username': 'user',
'password': 'pass',
'use_tls': True,
'verify_tls': True,
}
}
@@ -71,7 +73,8 @@ class TestMfiSensorSetup(unittest.TestCase):
del config[self.THING]['port']
assert self.COMPONENT.setup(self.hass, config)
mock_client.assert_called_once_with('foo', 'user', 'pass',
port=6443)
port=6443, use_tls=True,
verify=True)
@mock.patch('mficlient.client.MFiClient')
def test_setup_with_port(self, mock_client):
@@ -79,7 +82,19 @@ class TestMfiSensorSetup(unittest.TestCase):
config[self.THING]['port'] = 6123
assert self.COMPONENT.setup(self.hass, config)
mock_client.assert_called_once_with('foo', 'user', 'pass',
port=6123)
port=6123, use_tls=True,
verify=True)
@mock.patch('mficlient.client.MFiClient')
def test_setup_with_tls_disabled(self, mock_client):
config = dict(self.GOOD_CONFIG)
del config[self.THING]['port']
config[self.THING]['use_tls'] = False
config[self.THING]['verify_tls'] = False
assert self.COMPONENT.setup(self.hass, config)
mock_client.assert_called_once_with('foo', 'user', 'pass',
port=6080, use_tls=False,
verify=False)
@mock.patch('mficlient.client.MFiClient')
@mock.patch('homeassistant.components.sensor.mfi.MfiSensor')