diff options
| author | Daniil Baturin <daniil@baturin.org> | 2017-01-13 21:46:16 +0700 |
|---|---|---|
| committer | Daniil Baturin <daniil@baturin.org> | 2017-01-13 21:46:16 +0700 |
| commit | 3de4790370ec8ee485c3f723c3471116dd094019 (patch) | |
| tree | e839e0fd9e7b1d879033dca0932e09c98dabb260 /test | |
| parent | ae5ad1099d6e751354ca4b1ded35cf178639c29f (diff) | |
| download | vyconf-3de4790370ec8ee485c3f723c3471116dd094019.tar.gz vyconf-3de4790370ec8ee485c3f723c3471116dd094019.zip | |
T254: disallow node names with characters significant to the curly config parser
(whitespace, braces, square brackets, quotes, and hash).
Diffstat (limited to 'test')
| -rw-r--r-- | test/data/interface_definition_sample.xml | 17 | ||||
| -rw-r--r-- | test/reference_tree_test.ml | 10 |
2 files changed, 26 insertions, 1 deletions
diff --git a/test/data/interface_definition_sample.xml b/test/data/interface_definition_sample.xml index c6185c0..292231e 100644 --- a/test/data/interface_definition_sample.xml +++ b/test/data/interface_definition_sample.xml @@ -60,4 +60,21 @@ </node> </children> </node> + <node name="interfaces"> + <children> + <tagNode name="ethernet"> + <properties> + <!-- no constraint, for testing if tag nodes with invalid characters in names + are detected --> + </properties> + <children> + <leafNode name="disable"> + <properties> + <valueless/> + </properties> + </leafNode> + </children> + </tagNode> + </children> + </node> </interfaceDefinition> diff --git a/test/reference_tree_test.ml b/test/reference_tree_test.ml index 6dfac5a..8002bdf 100644 --- a/test/reference_tree_test.ml +++ b/test/reference_tree_test.ml @@ -10,7 +10,8 @@ let raises_validation_error f = let test_load_valid_definition test_ctxt = let r = Vytree.make default_data "root" in let r = load_from_xml r (in_testdata_dir test_ctxt ["interface_definition_sample.xml"]) in - assert_equal (Vytree.list_children r) ["system"] + assert_equal (Vylist.in_list (Vytree.list_children r) "system") true; + assert_equal (Vylist.in_list (Vytree.list_children r) "interfaces") true (* Path validation tests *) let test_validate_path_leaf_valid test_ctxt = @@ -34,6 +35,12 @@ let test_validate_path_tag_node_complete_valid test_ctxt = assert_equal (validate_path (get_dir test_ctxt) r ["system"; "login"; "user"; "test"; "full-name"; "test user"]) (["system"; "login"; "user"; "test"; "full-name";], Some "test user") +let test_validate_path_tag_node_illegal_characters test_ctxt = + let r = Vytree.make default_data "root" in + let r = load_from_xml r (in_testdata_dir test_ctxt ["interface_definition_sample.xml"]) in + (* the space in "eth 0" is on purpose *) + assert_equal (raises_validation_error (fun () -> ignore @@ validate_path (get_dir test_ctxt) r ["interfaces"; "ethernet"; "eth 0"; "disable"])) true + let test_validate_path_tag_node_invalid_name test_ctxt = let r = Vytree.make default_data "root" in let r = load_from_xml r (in_testdata_dir test_ctxt ["interface_definition_sample.xml"]) in @@ -157,6 +164,7 @@ let suite = "test_validate_path_leaf_valid" >:: test_validate_path_leaf_valid; "test_validate_path_leaf_invalid" >:: test_validate_path_leaf_invalid; "test_validate_path_leaf_incomplete" >:: test_validate_path_leaf_incomplete; + "test_validate_path_tag_node_illegal_characters" >:: test_validate_path_tag_node_illegal_characters; "test_validate_path_tag_node_complete_valid" >:: test_validate_path_tag_node_complete_valid; "test_validate_path_tag_node_invalid_name" >:: test_validate_path_tag_node_invalid_name; "test_validate_path_tag_node_incomplete" >:: test_validate_path_tag_node_incomplete; |
