summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-11-15 12:08:38 +0100
committerChristian Poessinger <christian@poessinger.com>2020-11-15 12:23:43 +0100
commit273fedf74156a0249d672c80b3b43c4df6f6d966 (patch)
tree243c2b9d93aaeed49ffbad3b19d999a3b4d2ef6d /smoketest/scripts/cli
parent9152e5b3665a844bfdf05a88be069b631679acab (diff)
downloadvyos-1x-273fedf74156a0249d672c80b3b43c4df6f6d966.tar.gz
vyos-1x-273fedf74156a0249d672c80b3b43c4df6f6d966.zip
smoketest: tunnel: validate if local/remote address matches proper address family
Certain tunnel types require that the local and remote IP is either both IPv4 or IPv6, add a check which ensures that an error is throws if this is not the case.
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_tunnel.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_interfaces_tunnel.py b/smoketest/scripts/cli/test_interfaces_tunnel.py
index 1033196ce..c11426d01 100755
--- a/smoketest/scripts/cli/test_interfaces_tunnel.py
+++ b/smoketest/scripts/cli/test_interfaces_tunnel.py
@@ -156,6 +156,64 @@ class TunnelInterfaceTest(BasicInterfaceTest.BaseTest):
self.assertEqual(self.local_v6, conf['linkinfo']['info_data']['local'])
self.assertEqual(remote_ip6, conf['linkinfo']['info_data']['remote'])
+ def test_ipv4_local_remove_addr(self):
+ """ When running tests ensure that for certain encapsulation types the
+ local and remote IP address is actually an IPv4 address """
+
+ interface = f'tun1000'
+ local_if_addr = f'10.10.200.1/24'
+ for encapsulation in ['ipip', 'sit', 'gre']:
+ self.session.set(self._base_path + [interface, 'address', local_if_addr])
+ self.session.set(self._base_path + [interface, 'encapsulation', encapsulation])
+ self.session.set(self._base_path + [interface, 'local-ip', self.local_v6])
+ self.session.set(self._base_path + [interface, 'remote-ip', remote_ip6])
+
+ # Encapsulation mode requires IPv6 local-ip
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+ self.session.set(self._base_path + [interface, 'local-ip', self.local_v4])
+
+ # Encapsulation mode requires IPv6 local-ip
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+ self.session.set(self._base_path + [interface, 'remote-ip', remote_ip4])
+
+ # Check if commit is ok
+ self.session.commit()
+
+ # cleanup this instance
+ self.session.delete(self._base_path + [interface])
+ self.session.commit()
+
+ def test_ipv6_local_remove_addr(self):
+ """ When running tests ensure that for certain encapsulation types the
+ local and remote IP address is actually an IPv6 address """
+
+ interface = f'tun1010'
+ local_if_addr = f'10.10.200.1/24'
+ for encapsulation in ['ipip6', 'ip6ip6', 'ip6gre']:
+ self.session.set(self._base_path + [interface, 'address', local_if_addr])
+ self.session.set(self._base_path + [interface, 'encapsulation', encapsulation])
+ self.session.set(self._base_path + [interface, 'local-ip', self.local_v4])
+ self.session.set(self._base_path + [interface, 'remote-ip', remote_ip4])
+
+ # Encapsulation mode requires IPv6 local-ip
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+ self.session.set(self._base_path + [interface, 'local-ip', self.local_v6])
+
+ # Encapsulation mode requires IPv6 local-ip
+ with self.assertRaises(ConfigSessionError):
+ self.session.commit()
+ self.session.set(self._base_path + [interface, 'remote-ip', remote_ip6])
+
+ # Check if commit is ok
+ self.session.commit()
+
+ # cleanup this instance
+ self.session.delete(self._base_path + [interface])
+ self.session.commit()
+
def test_ip6ip6(self):
interface = 'tun120'
encapsulation = 'ip6ip6'