mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
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:
parent
5309006494
commit
1892eb654f
@ -1079,6 +1079,8 @@ class Config(object):
|
|||||||
|
|
||||||
def is_allowed_path(self, path: str) -> bool:
|
def is_allowed_path(self, path: str) -> bool:
|
||||||
"""Check if the path is valid for access from outside."""
|
"""Check if the path is valid for access from outside."""
|
||||||
|
assert path is not None
|
||||||
|
|
||||||
parent = pathlib.Path(path).parent
|
parent = pathlib.Path(path).parent
|
||||||
try:
|
try:
|
||||||
parent = parent.resolve() # pylint: disable=no-member
|
parent = parent.resolve() # pylint: disable=no-member
|
||||||
|
@ -833,6 +833,9 @@ class TestConfig(unittest.TestCase):
|
|||||||
for path in unvalid:
|
for path in unvalid:
|
||||||
assert not self.config.is_allowed_path(path)
|
assert not self.config.is_allowed_path(path)
|
||||||
|
|
||||||
|
with self.assertRaises(AssertionError):
|
||||||
|
self.config.is_allowed_path(None)
|
||||||
|
|
||||||
|
|
||||||
@patch('homeassistant.core.monotonic')
|
@patch('homeassistant.core.monotonic')
|
||||||
def test_create_timer(mock_monotonic, loop):
|
def test_create_timer(mock_monotonic, loop):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user