Add some create subnet negative tests

There were some edge cases that were untested that generate
500 errors instead of 401's.

Will need a neutron-lib version with
https://review.openstack.org/#/c/623498/ in order to pass.

Change-Id: I925476bc2515a1755364d92ab8d622d747a4a0fb
Related-bug: #1807394
This commit is contained in:
Brian Haley 2018-12-07 15:01:00 -05:00 committed by Brian Haley
parent b86fa161ed
commit 98ef2ac8d6
1 changed files with 33 additions and 0 deletions

View File

@ -3280,6 +3280,17 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
res = subnet_req.get_response(self.api)
self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
def test_create_subnet_invalid_gw_32_V4_cidr(self):
with self.network() as network:
data = {'subnet': {'network_id': network['network']['id'],
'cidr': '10.0.0.0/4',
'ip_version': constants.IP_VERSION_4,
'tenant_id': network['network']['tenant_id'],
'gateway_ip': '10.0.0.1/32'}}
subnet_req = self.new_create_request('subnets', data)
res = subnet_req.get_response(self.api)
self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
def test_create_subnet_with_cidr_and_default_subnetpool(self):
"""Expect subnet-create to keep semantic with default pools."""
with self.network() as network:
@ -3360,6 +3371,28 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
res = subnet_req.get_response(self.api)
self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
def test_create_subnet_invalid_gw_V6_cidr(self):
with self.network() as network:
data = {'subnet': {'network_id': network['network']['id'],
'cidr': '2001:db8:0:1::/64',
'ip_version': '6',
'tenant_id': network['network']['tenant_id'],
'gateway_ip': '2001:db8::1/64'}}
subnet_req = self.new_create_request('subnets', data)
res = subnet_req.get_response(self.api)
self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
def test_create_subnet_invalid_gw_128_V6_cidr(self):
with self.network() as network:
data = {'subnet': {'network_id': network['network']['id'],
'cidr': '2001:db8:0:1::/64',
'ip_version': '6',
'tenant_id': network['network']['tenant_id'],
'gateway_ip': '2001:db8:0:1:1/128'}}
subnet_req = self.new_create_request('subnets', data)
res = subnet_req.get_response(self.api)
self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
def test_create_subnet_V6_slaac_big_prefix(self):
with self.network() as network:
data = {'subnet': {'network_id': network['network']['id'],