From 5dac49f576b5cd89508b4e133e433041e0189c46 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 11 Oct 2020 13:15:45 +0200 Subject: smoketest: nat: concentrate validation logic checks --- smoketest/scripts/cli/test_nat.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'smoketest') diff --git a/smoketest/scripts/cli/test_nat.py b/smoketest/scripts/cli/test_nat.py index 5c7c66840..0bb4761ea 100755 --- a/smoketest/scripts/cli/test_nat.py +++ b/smoketest/scripts/cli/test_nat.py @@ -45,10 +45,6 @@ class TestNAT(unittest.TestCase): self.session.set(source_path + ['rule', '1', 'destination', 'address', network]) self.session.set(source_path + ['rule', '1', 'exclude']) - # check validate() - outbound-interface must be defined - with self.assertRaises(ConfigSessionError): - self.session.commit() - self.session.set(source_path + ['rule', '1', 'outbound-interface', 'any']) self.session.commit() @@ -60,14 +56,22 @@ class TestNAT(unittest.TestCase): self.assertEqual(condensed_json['address']['network'], network.split('/')[0]) self.assertEqual(str(condensed_json['address']['prefix']), network.split('/')[1]) - def test_validation(self): + def test_validation_logic(self): """ T2813: Ensure translation address is specified """ - self.session.set(source_path + ['rule', '100', 'outbound-interface', 'eth0']) + rule = '5' + self.session.set(source_path + ['rule', rule, 'source', 'address', '192.0.2.0/24']) + + # check validate() - outbound-interface must be defined + with self.assertRaises(ConfigSessionError): + self.session.commit() + self.session.set(source_path + ['rule', rule, 'outbound-interface', 'eth0']) # check validate() - translation address not specified with self.assertRaises(ConfigSessionError): self.session.commit() + self.session.set(source_path + ['rule', rule, 'translation', 'address', 'masquerade']) + self.session.commit() if __name__ == '__main__': unittest.main() -- cgit v1.2.3