summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_nat66.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-03-09 08:59:02 +0100
committerGitHub <noreply@github.com>2021-03-09 08:59:02 +0100
commit370d2d817f87418be15952af15e686badef4f687 (patch)
tree45ba1048455c81ed1540bc7e7f28673652a5332b /smoketest/scripts/cli/test_nat66.py
parentab6ef466c128ba48f85b13ba8d4be1476e844726 (diff)
parent988be4157422975bec75122e875b722f7c933966 (diff)
downloadvyos-1x-370d2d817f87418be15952af15e686badef4f687.tar.gz
vyos-1x-370d2d817f87418be15952af15e686badef4f687.zip
Merge pull request #762 from jack9603301/T2518
nptv6: T2518: Support IPv6 address translation
Diffstat (limited to 'smoketest/scripts/cli/test_nat66.py')
-rwxr-xr-xsmoketest/scripts/cli/test_nat66.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/smoketest/scripts/cli/test_nat66.py b/smoketest/scripts/cli/test_nat66.py
index ccc4196e0..4838fb8d8 100755
--- a/smoketest/scripts/cli/test_nat66.py
+++ b/smoketest/scripts/cli/test_nat66.py
@@ -44,7 +44,7 @@ class TestNAT66(unittest.TestCase):
translation_prefix = 'fc01::/64'
self.session.set(src_path + ['rule', '1', 'outbound-interface', 'eth1'])
self.session.set(src_path + ['rule', '1', 'source', 'prefix', source_prefix])
- self.session.set(src_path + ['rule', '1', 'translation', 'prefix', translation_prefix])
+ self.session.set(src_path + ['rule', '1', 'translation', 'address', translation_prefix])
# check validate() - outbound-interface must be defined
self.session.commit()
@@ -70,6 +70,36 @@ class TestNAT66(unittest.TestCase):
self.assertEqual(f'{translation_address}/{translation_mask}', translation_prefix)
self.assertEqual(f'{address}/{mask}', source_prefix)
+ def test_source_nat66_address(self):
+ source_prefix = 'fc00::/64'
+ translation_address = 'fc00::1'
+ self.session.set(src_path + ['rule', '1', 'outbound-interface', 'eth1'])
+ self.session.set(src_path + ['rule', '1', 'source', 'prefix', source_prefix])
+ self.session.set(src_path + ['rule', '1', 'translation', 'address', translation_address])
+
+ # check validate() - outbound-interface must be defined
+ self.session.commit()
+
+ tmp = cmd('sudo nft -j list table ip6 nat')
+ data_json = jmespath.search('nftables[?rule].rule[?chain]', json.loads(tmp))
+
+ for idx in range(0, len(data_json)):
+ data = data_json[idx]
+
+ self.assertEqual(data['chain'], 'POSTROUTING')
+ self.assertEqual(data['family'], 'ip6')
+ self.assertEqual(data['table'], 'nat')
+
+ iface = dict_search('match.right', data['expr'][0])
+ address = dict_search('match.right.prefix.addr', data['expr'][2])
+ mask = dict_search('match.right.prefix.len', data['expr'][2])
+ snat_address = dict_search('snat.addr', data['expr'][3])
+
+ self.assertEqual(iface, 'eth1')
+ # check for translation address
+ self.assertEqual(snat_address, translation_address)
+ self.assertEqual(f'{address}/{mask}', source_prefix)
+
def test_destination_nat66(self):
destination_address = 'fc00::1'
translation_address = 'fc01::1'
@@ -127,7 +157,6 @@ class TestNAT66(unittest.TestCase):
# T2813: Ensure translation address is specified
rule = '5'
source_prefix = 'fc00::/64'
- translation_prefix = 'fc00:2::/64'
self.session.set(src_path + ['rule', rule, 'source', 'prefix', source_prefix])
# check validate() - outbound-interface must be defined
@@ -139,7 +168,7 @@ class TestNAT66(unittest.TestCase):
with self.assertRaises(ConfigSessionError):
self.session.commit()
- self.session.set(src_path + ['rule', rule, 'translation', 'prefix', translation_prefix])
+ self.session.set(src_path + ['rule', rule, 'translation', 'address', 'masquerade'])
self.session.commit()
def test_nat66_no_rules(self):