summaryrefslogtreecommitdiff
path: root/smoketest/scripts
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2024-07-14 17:59:54 -0500
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-07-17 13:21:10 +0000
commit65d4ee33269f18a5a4ebab34e6e3866623a6a043 (patch)
tree59aaca808007142249f3d85ba37619846ea697b4 /smoketest/scripts
parent08f524a62f4a805a63503af64ed1b26fa48c6337 (diff)
downloadvyos-1x-65d4ee33269f18a5a4ebab34e6e3866623a6a043.tar.gz
vyos-1x-65d4ee33269f18a5a4ebab34e6e3866623a6a043.zip
configdep: T6559: add smoketest of dependency script errormergify/bp/sagitta/pr-3813
(cherry picked from commit ad43aa885a8ef689da212088d6ebb37c32d72883)
Diffstat (limited to 'smoketest/scripts')
-rwxr-xr-xsmoketest/scripts/cli/test_config_dependency.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_config_dependency.py b/smoketest/scripts/cli/test_config_dependency.py
new file mode 100755
index 000000000..14e88321a
--- /dev/null
+++ b/smoketest/scripts/cli/test_config_dependency.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+# Copyright 2024 VyOS maintainers and contributors <maintainers@vyos.io>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+
+import unittest
+
+from base_vyostest_shim import VyOSUnitTestSHIM
+
+from vyos.configsession import ConfigSessionError
+
+
+class TestConfigDep(VyOSUnitTestSHIM.TestCase):
+ def test_configdep_error(self):
+ address_group = 'AG'
+ address = '192.168.137.5'
+ nat_base = ['nat', 'source', 'rule', '10']
+ interface = 'eth1'
+
+ self.cli_set(['firewall', 'group', 'address-group', address_group,
+ 'address', address])
+ self.cli_set(nat_base + ['outbound-interface', 'name', interface])
+ self.cli_set(nat_base + ['source', 'group', 'address-group', address_group])
+ self.cli_set(nat_base + ['translation', 'address', 'masquerade'])
+ self.cli_commit()
+
+ self.cli_delete(['firewall'])
+ # check error in call to dependent script (nat)
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+
+ # clean up remaining
+ self.cli_delete(['nat'])
+ self.cli_commit()
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)