Merge "Add negative UT cases for subnet/GW create/update"

This commit is contained in:
Jenkins 2013-05-16 06:50:13 +00:00 committed by Gerrit Code Review
commit cf9a0c7585
2 changed files with 45 additions and 3 deletions

View File

@ -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

View File

@ -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: