Is_allowed_path raise for None path (#8953)

* is_allowed_path

* Fix #8948

* assert path is not None

* Update test_core.py

* Update test_core.py

* Update test_core.py
This commit is contained in:
Daniel Høyer Iversen 2017-08-15 15:41:37 +02:00 committed by Pascal Vizeli
parent 5309006494
commit 1892eb654f
2 changed files with 5 additions and 0 deletions

View file

@ -1079,6 +1079,8 @@ class Config(object):
def is_allowed_path(self, path: str) -> bool:
"""Check if the path is valid for access from outside."""
assert path is not None
parent = pathlib.Path(path).parent
try:
parent = parent.resolve() # pylint: disable=no-member

View file

@ -833,6 +833,9 @@ class TestConfig(unittest.TestCase):
for path in unvalid:
assert not self.config.is_allowed_path(path)
with self.assertRaises(AssertionError):
self.config.is_allowed_path(None)
@patch('homeassistant.core.monotonic')
def test_create_timer(mock_monotonic, loop):