Relaxes the configuration options for influxdb (#3869)

* Relaxes the configuration options for influxdb

By default influxdb allows unauthenticated access
Home Assistant required at least username and password to be present to properly submit data to influxdb

* Removes unused import of 'copy'

The copy module was used only in the removed test case responsible for testing the missing keys

* Updates InfluxDB config schema to require user and password

Current InfluxDB (v 1.0) can work without any authentication, but when authentication is enabled both username and password should be set.

* Removes extra white space in test_influxdb.py
This commit is contained in:
Georgi Kirichkov 2016-10-15 07:10:04 +03:00 committed by Paulus Schoutsen
parent ce19e6367f
commit 49b1643ff0
2 changed files with 15 additions and 11 deletions

View File

@ -33,8 +33,8 @@ TIMEOUT = 5
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Inclusive(CONF_USERNAME, 'authentication'): cv.string,
vol.Inclusive(CONF_PASSWORD, 'authentication'): cv.string,
vol.Optional(CONF_BLACKLIST, default=[]):
vol.All(cv.ensure_list, [cv.entity_id]),
vol.Optional(CONF_DB_NAME, default=DEFAULT_DATABASE): cv.string,

View File

@ -1,5 +1,4 @@
"""The tests for the InfluxDB component."""
import copy
import unittest
from unittest import mock
@ -53,18 +52,23 @@ class TestInfluxDB(unittest.TestCase):
self.assertEqual(EVENT_STATE_CHANGED,
self.hass.bus.listen.call_args_list[0][0][0])
def test_setup_missing_keys(self, mock_client):
"""Test the setup with missing keys."""
def test_setup_minimal_config(self, mock_client):
"""Tests the setup with minimal configuration."""
config = {
'influxdb': {}
}
assert setup_component(self.hass, influxdb.DOMAIN, config)
def test_setup_missing_password(self, mock_client):
"""Test the setup with existing username and missing password."""
config = {
'influxdb': {
'username': 'user',
'password': 'pass',
'username': 'user'
}
}
for missing in config['influxdb'].keys():
config_copy = copy.deepcopy(config)
del config_copy['influxdb'][missing]
assert not setup_component(self.hass, influxdb.DOMAIN, config_copy)
assert not setup_component(self.hass, influxdb.DOMAIN, config)
def test_setup_query_fail(self, mock_client):
"""Test the setup for query failures."""