From 00d1cab0917e21c7320643ccf3332fd33bb74904 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 2 Feb 2016 08:41:18 +0100 Subject: [PATCH] add test for unsafe yaml --- tests/test_config.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_config.py b/tests/test_config.py index 781fc51731f..203ea8a6da5 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -94,6 +94,15 @@ class TestConfig(unittest.TestCase): with self.assertRaises(HomeAssistantError): config_util.load_yaml_config_file(YAML_PATH) + def test_load_yaml_config_raises_error_if_unsafe_yaml(self): + """ Test error raised if unsafe YAML. """ + with open(YAML_PATH, 'w') as f: + f.write('hello: !!python/object/apply:os.system') + + with self.assertRaises(HomeAssistantError): + config_util.load_yaml_config_file(YAML_PATH) + + def test_load_yaml_config_preserves_key_order(self): with open(YAML_PATH, 'w') as f: f.write('hello: 0\n')