mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
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:
parent
ce19e6367f
commit
49b1643ff0
@ -33,8 +33,8 @@ TIMEOUT = 5
|
|||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
|
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
vol.Inclusive(CONF_USERNAME, 'authentication'): cv.string,
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
vol.Inclusive(CONF_PASSWORD, 'authentication'): cv.string,
|
||||||
vol.Optional(CONF_BLACKLIST, default=[]):
|
vol.Optional(CONF_BLACKLIST, default=[]):
|
||||||
vol.All(cv.ensure_list, [cv.entity_id]),
|
vol.All(cv.ensure_list, [cv.entity_id]),
|
||||||
vol.Optional(CONF_DB_NAME, default=DEFAULT_DATABASE): cv.string,
|
vol.Optional(CONF_DB_NAME, default=DEFAULT_DATABASE): cv.string,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The tests for the InfluxDB component."""
|
"""The tests for the InfluxDB component."""
|
||||||
import copy
|
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
@ -53,18 +52,23 @@ class TestInfluxDB(unittest.TestCase):
|
|||||||
self.assertEqual(EVENT_STATE_CHANGED,
|
self.assertEqual(EVENT_STATE_CHANGED,
|
||||||
self.hass.bus.listen.call_args_list[0][0][0])
|
self.hass.bus.listen.call_args_list[0][0][0])
|
||||||
|
|
||||||
def test_setup_missing_keys(self, mock_client):
|
def test_setup_minimal_config(self, mock_client):
|
||||||
"""Test the setup with missing keys."""
|
"""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 = {
|
config = {
|
||||||
'influxdb': {
|
'influxdb': {
|
||||||
'username': 'user',
|
'username': 'user'
|
||||||
'password': 'pass',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for missing in config['influxdb'].keys():
|
|
||||||
config_copy = copy.deepcopy(config)
|
assert not setup_component(self.hass, influxdb.DOMAIN, config)
|
||||||
del config_copy['influxdb'][missing]
|
|
||||||
assert not setup_component(self.hass, influxdb.DOMAIN, config_copy)
|
|
||||||
|
|
||||||
def test_setup_query_fail(self, mock_client):
|
def test_setup_query_fail(self, mock_client):
|
||||||
"""Test the setup for query failures."""
|
"""Test the setup for query failures."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user