From: Paul Michali Date: Fri, 10 May 2013 13:17:24 +0000 (-0700) Subject: Add negative UT cases for subnet/GW create/update X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c2a672fe2186be7d19f3c0eea5e60f8cfc29381d;p=openstack-build%2Fneutron-build.git Add negative UT cases for subnet/GW create/update When force_gateway_on_subnet is configured, ensure that a GW with IP same as subnet, and BCAST GW IP are rejected during subnet create. For subnet update, ensure GW outside of subnet is rejected. bug 1178675 Change-Id: Ice58f7e1be7966b247c165e52807405401e5a4ea --- diff --git a/quantum/tests/unit/midonet/test_midonet_plugin.py b/quantum/tests/unit/midonet/test_midonet_plugin.py index 11bb9b063..424beadb1 100644 --- a/quantum/tests/unit/midonet/test_midonet_plugin.py +++ b/quantum/tests/unit/midonet/test_midonet_plugin.py @@ -300,9 +300,20 @@ class TestMidonetSubnetsV2(test_plugin.TestSubnetsV2, self._setup_subnet_mocks() super(TestMidonetSubnetsV2, self).test_create_subnet_gw_values() - def test_create_force_subnet_gw_values(self): + def test_create_subnet_gw_outside_cidr_force_on_returns_400(self): self._setup_subnet_mocks() - super(TestMidonetSubnetsV2, self).test_create_force_subnet_gw_values() + super(TestMidonetSubnetsV2, + self).test_create_subnet_gw_outside_cidr_force_on_returns_400() + + def test_create_subnet_gw_of_network_force_on_returns_400(self): + self._setup_subnet_mocks() + super(TestMidonetSubnetsV2, + self).test_create_subnet_gw_of_network_force_on_returns_400() + + def test_create_subnet_gw_bcast_force_on_returns_400(self): + self._setup_subnet_mocks() + super(TestMidonetSubnetsV2, + self).test_create_subnet_gw_bcast_force_on_returns_400() def test_create_subnet_with_allocation_pool(self): self._setup_subnet_mocks() @@ -398,6 +409,9 @@ class TestMidonetSubnetsV2(test_plugin.TestSubnetsV2, super(TestMidonetSubnetsV2, self).test_update_subnet_shared_returns_400() + def test_update_subnet_gw_outside_cidr_force_on_returns_400(self): + pass + def test_update_subnet_inconsistent_ipv4_gatewayv6(self): pass diff --git a/quantum/tests/unit/test_db_plugin.py b/quantum/tests/unit/test_db_plugin.py index 825193fee..2b7269a7c 100644 --- a/quantum/tests/unit/test_db_plugin.py +++ b/quantum/tests/unit/test_db_plugin.py @@ -2695,7 +2695,7 @@ class TestSubnetsV2(QuantumDbPluginV2TestCase): self._test_create_subnet(expected=expected, gateway_ip=gateway) - def test_create_force_subnet_gw_values(self): + def test_create_subnet_gw_outside_cidr_force_on_returns_400(self): cfg.CONF.set_override('force_gateway_on_subnet', True) with self.network() as network: self._create_subnet(self.fmt, @@ -2704,6 +2704,24 @@ class TestSubnetsV2(QuantumDbPluginV2TestCase): 400, gateway_ip='100.0.0.1') + def test_create_subnet_gw_of_network_force_on_returns_400(self): + cfg.CONF.set_override('force_gateway_on_subnet', True) + with self.network() as network: + self._create_subnet(self.fmt, + network['network']['id'], + '10.0.0.0/24', + 400, + gateway_ip='10.0.0.0') + + def test_create_subnet_gw_bcast_force_on_returns_400(self): + cfg.CONF.set_override('force_gateway_on_subnet', True) + with self.network() as network: + self._create_subnet(self.fmt, + network['network']['id'], + '10.0.0.0/24', + 400, + gateway_ip='10.0.0.255') + def test_create_subnet_with_allocation_pool(self): gateway_ip = '10.0.0.1' cidr = '10.0.0.0/24' @@ -2968,6 +2986,16 @@ class TestSubnetsV2(QuantumDbPluginV2TestCase): res = req.get_response(self.api) self.assertEqual(res.status_int, 400) + def test_update_subnet_gw_outside_cidr_force_on_returns_400(self): + cfg.CONF.set_override('force_gateway_on_subnet', True) + with self.network() as network: + with self.subnet(network=network) as subnet: + data = {'subnet': {'gateway_ip': '100.0.0.1'}} + req = self.new_update_request('subnets', data, + subnet['subnet']['id']) + res = req.get_response(self.api) + self.assertEqual(res.status_int, 400) + def test_update_subnet_inconsistent_ipv4_gatewayv6(self): with self.network() as network: with self.subnet(network=network) as subnet: