summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/helper.py2
-rw-r--r--src/tests/test_config_diff.py2
-rw-r--r--src/tests/test_config_merge.py50
-rw-r--r--src/tests/test_config_parser.py2
-rw-r--r--src/tests/test_configd_inspect.py2
-rw-r--r--src/tests/test_configverify.py2
-rw-r--r--src/tests/test_dependency_graph.py2
-rw-r--r--src/tests/test_dict_search.py2
-rw-r--r--src/tests/test_find_device_file.py2
-rw-r--r--src/tests/test_initial_setup.py2
-rw-r--r--src/tests/test_op_mode.py2
-rw-r--r--src/tests/test_task_scheduler.py2
-rw-r--r--src/tests/test_template.py11
-rw-r--r--src/tests/test_utils.py2
-rw-r--r--src/tests/test_utils_network.py2
15 files changed, 73 insertions, 14 deletions
diff --git a/src/tests/helper.py b/src/tests/helper.py
index cc0710494..2c4421d0a 100644
--- a/src/tests/helper.py
+++ b/src/tests/helper.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_config_diff.py b/src/tests/test_config_diff.py
index 4017fff4d..edbc0804e 100644
--- a/src/tests/test_config_diff.py
+++ b/src/tests/test_config_diff.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_config_merge.py b/src/tests/test_config_merge.py
new file mode 100644
index 000000000..c9b4ad5c8
--- /dev/null
+++ b/src/tests/test_config_merge.py
@@ -0,0 +1,50 @@
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import vyos.configtree
+
+from unittest import TestCase
+
+class TestConfigDiff(TestCase):
+ def setUp(self):
+ with open('tests/data/config.left', 'r') as f:
+ config_string = f.read()
+ self.config_left = vyos.configtree.ConfigTree(config_string)
+
+ with open('tests/data/config.right', 'r') as f:
+ config_string = f.read()
+ self.config_right = vyos.configtree.ConfigTree(config_string)
+
+ def test_merge_destructive(self):
+ res = vyos.configtree.merge(self.config_left, self.config_right,
+ destructive=True)
+ right_value = self.config_right.return_value(['node1', 'tag_node', 'foo', 'single'])
+ merge_value = res.return_value(['node1', 'tag_node', 'foo', 'single'])
+
+ # Check includes new value
+ self.assertEqual(right_value, merge_value)
+
+ # Check preserves non-confliciting paths
+ self.assertTrue(res.exists(['node3']))
+
+ def test_merge_non_destructive(self):
+ res = vyos.configtree.merge(self.config_left, self.config_right)
+ left_value = self.config_left.return_value(['node1', 'tag_node', 'foo', 'single'])
+ merge_value = res.return_value(['node1', 'tag_node', 'foo', 'single'])
+
+ # Check includes original value
+ self.assertEqual(left_value, merge_value)
+
+ # Check preserves non-confliciting paths
+ self.assertTrue(res.exists(['node3']))
diff --git a/src/tests/test_config_parser.py b/src/tests/test_config_parser.py
index 1b4a57311..823d5a7c1 100644
--- a/src/tests/test_config_parser.py
+++ b/src/tests/test_config_parser.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_configd_inspect.py b/src/tests/test_configd_inspect.py
index a0470221d..3363ab653 100644
--- a/src/tests/test_configd_inspect.py
+++ b/src/tests/test_configd_inspect.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2025 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_configverify.py b/src/tests/test_configverify.py
index f1ec65cd2..8f80365d7 100644
--- a/src/tests/test_configverify.py
+++ b/src/tests/test_configverify.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_dependency_graph.py b/src/tests/test_dependency_graph.py
index f3f1db376..12f50a1c4 100644
--- a/src/tests/test_dependency_graph.py
+++ b/src/tests/test_dependency_graph.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2023-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_dict_search.py b/src/tests/test_dict_search.py
index 6b4bc933a..ed147ec01 100644
--- a/src/tests/test_dict_search.py
+++ b/src/tests/test_dict_search.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_find_device_file.py b/src/tests/test_find_device_file.py
index 5b90f2034..02a33c224 100644
--- a/src/tests/test_find_device_file.py
+++ b/src/tests/test_find_device_file.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_initial_setup.py b/src/tests/test_initial_setup.py
index 7737f9df5..09feea7ba 100644
--- a/src/tests/test_initial_setup.py
+++ b/src/tests/test_initial_setup.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_op_mode.py b/src/tests/test_op_mode.py
index 23f709653..848a9666d 100644
--- a/src/tests/test_op_mode.py
+++ b/src/tests/test_op_mode.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2022-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_task_scheduler.py b/src/tests/test_task_scheduler.py
index 795ffeb9d..0d0319495 100644
--- a/src/tests/test_task_scheduler.py
+++ b/src/tests/test_task_scheduler.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_template.py b/src/tests/test_template.py
index 7cae867a0..e2548602d 100644
--- a/src/tests/test_template.py
+++ b/src/tests/test_template.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -192,10 +192,19 @@ class TestVyOSTemplate(TestCase):
self.assertIn(IKEv2_DEFAULT, ','.join(ciphers))
def test_get_default_port(self):
+ from vyos.defaults import config_files
from vyos.defaults import internal_ports
with self.assertRaises(RuntimeError):
+ vyos.template.get_default_config_file('UNKNOWN')
+ with self.assertRaises(RuntimeError):
vyos.template.get_default_port('UNKNOWN')
+ with self.assertRaises(RuntimeError):
+ vyos.template.nft_accept_invalid('UNKNOWN')
+ self.assertEqual(vyos.template.get_default_config_file('sshd_user_ca'),
+ config_files['sshd_user_ca'])
self.assertEqual(vyos.template.get_default_port('certbot_haproxy'),
internal_ports['certbot_haproxy'])
+ self.assertEqual(vyos.template.nft_accept_invalid('arp'),
+ 'ct state invalid ether type arp counter accept')
diff --git a/src/tests/test_utils.py b/src/tests/test_utils.py
index 7bfd2618e..5d642f4ea 100644
--- a/src/tests/test_utils.py
+++ b/src/tests/test_utils.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
diff --git a/src/tests/test_utils_network.py b/src/tests/test_utils_network.py
index 92fde447d..6d9a358c1 100644
--- a/src/tests/test_utils_network.py
+++ b/src/tests/test_utils_network.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2020-2025 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as