Browse Source

NSX|V3 add test for ipv4 cidr address pairs

Change-Id: I3be5aa2dba4c1a926de1337beacd28fc50a33b4a
changes/73/763373/1
asarfaty 2 months ago
committed by Adit Sarfaty
parent
commit
35c8bfa59e
2 changed files with 61 additions and 3 deletions
  1. +58
    -0
      vmware_nsx/tests/unit/extensions/test_addresspairs.py
  2. +3
    -3
      vmware_nsx/tests/unit/nsx_v3/test_plugin.py

+ 58
- 0
vmware_nsx/tests/unit/extensions/test_addresspairs.py View File

@ -264,6 +264,64 @@ class TestAllowedAddressPairsNSXv3(test_v3_plugin.NsxV3PluginTestCaseMixin,
self.assertEqual(res.status_int, 400)
self._delete('ports', port['port']['id'])
def test_create_port_allowed_address_pairs_v4(self):
with self.network() as net:
# Single IPv4
address_pairs = [{'ip_address': '10.0.0.12'}]
res = self._create_port(self.fmt, net['network']['id'],
arg_list=(addr_apidef.ADDRESS_PAIRS,),
allowed_address_pairs=address_pairs)
port = self.deserialize(self.fmt, res)
address_pairs[0]['mac_address'] = port['port']['mac_address']
self.assertEqual(port['port'][addr_apidef.ADDRESS_PAIRS],
address_pairs)
self._delete('ports', port['port']['id'])
# IPv4 cidr
address_pairs = [{'ip_address': '10.0.0.0/24'}]
res = self._create_port(self.fmt, net['network']['id'],
arg_list=(addr_apidef.ADDRESS_PAIRS,),
allowed_address_pairs=address_pairs)
port = self.deserialize(self.fmt, res)
address_pairs[0]['mac_address'] = port['port']['mac_address']
self.assertEqual(port['port'][addr_apidef.ADDRESS_PAIRS],
address_pairs)
self._delete('ports', port['port']['id'])
# Illegal IPv4 cidr
address_pairs = [{'ip_address': '10.0.0.1/24'}]
res = self._create_port(self.fmt, net['network']['id'],
arg_list=(addr_apidef.ADDRESS_PAIRS,),
allowed_address_pairs=address_pairs)
port = self.deserialize(self.fmt, res)
self.assertIn('NeutronError', port)
# Too many ipv4 pairs
cfg.CONF.set_default('max_allowed_address_pair', 300)
address_pairs = []
count = 1
while count < 129:
address_pairs.append({'ip_address': '10.0.0.%s' % count})
count += 1
res = self._create_port(self.fmt, net['network']['id'],
arg_list=(addr_apidef.ADDRESS_PAIRS,),
allowed_address_pairs=address_pairs)
port = self.deserialize(self.fmt, res)
self.assertIn('NeutronError', port)
# Legal number of ipv4 pairs
address_pairs = []
count = 1
while count < 125:
address_pairs.append({'ip_address': '10.0.0.%s' % count})
count += 1
res = self._create_port(self.fmt, net['network']['id'],
arg_list=(addr_apidef.ADDRESS_PAIRS,),
allowed_address_pairs=address_pairs)
port = self.deserialize(self.fmt, res)
self.assertNotIn('NeutronError', port)
self._delete('ports', port['port']['id'])
def test_create_port_security_false_allowed_address_pairs(self):
self.skipTest('TBD')


+ 3
- 3
vmware_nsx/tests/unit/nsx_v3/test_plugin.py View File

@ -185,7 +185,7 @@ def _mock_nsx_backend_calls():
mock.patch(
"vmware_nsxlib.v3.NsxLib.get_version",
return_value='2.4.0').start()
return_value='3.1.0').start()
mock.patch(
"vmware_nsxlib.v3.load_balancer.Service.get_router_lb_service",
@ -2804,8 +2804,8 @@ class TestL3NatTestCase(L3NatTest,
def _prepare_external_subnet_on_address_scope(self,
ext_net,
address_scope):
as_id = address_scope['address_scope']['id']
addr_scope):
as_id = addr_scope['address_scope']['id']
subnet = netaddr.IPNetwork('10.10.10.0/21')
subnetpool = self._test_create_subnetpool(
[subnet.cidr], name='sp1',


Loading…
Cancel
Save