req = self.new_update_request('subnets', data,
subnet['subnet']['id'])
res = req.get_response(self.api)
- self.assertEqual(res.status_int, 400)
+ self.assertEqual(res.status_int,
+ webob.exc.HTTPClientError.code)
+ def test_update_subnet_gw_ip_in_use_returns_409(self):
+ with self.network() as network:
+ with self.subnet(
+ network=network,
+ allocation_pools=[{'start': '10.0.0.100',
+ 'end': '10.0.0.253'}]) as subnet:
+ subnet_data = subnet['subnet']
+ with self.port(
+ subnet=subnet,
+ fixed_ips=[{'subnet_id': subnet_data['id'],
+ 'ip_address': subnet_data['gateway_ip']}]):
+ data = {'subnet': {'gateway_ip': '10.0.0.99'}}
+ req = self.new_update_request('subnets', data,
+ subnet_data['id'])
+ res = req.get_response(self.api)
+ self.assertEqual(res.status_int, 409)
+
def test_update_subnet_inconsistent_ipv4_gatewayv6(self):
with self.network() as network:
with self.subnet(network=network) as subnet:
host_routes=host_routes)
req = self.new_delete_request('subnets', subnet['subnet']['id'])
res = req.get_response(self.api)
- self.assertEqual(res.status_int, 204)
+ self.assertEqual(res.status_int, webob.exc.HTTPNoContent.code)
+ def _helper_test_validate_subnet(self, option, exception):
+ cfg.CONF.set_override(option, 0)
+ with self.network() as network:
+ subnet = {'network_id': network['network']['id'],
+ 'cidr': '10.0.2.0/24',
+ 'ip_version': 4,
+ 'tenant_id': network['network']['tenant_id'],
+ 'gateway_ip': '10.0.2.1',
+ 'dns_nameservers': ['8.8.8.8'],
+ 'host_routes': [{'destination': '135.207.0.0/16',
+ 'nexthop': '1.2.3.4'}]}
+ plugin = NeutronManager.get_plugin()
+ e = self.assertRaises(exception,
+ plugin._validate_subnet,
+ context.get_admin_context(
+ load_admin_roles=False),
+ subnet)
+ self.assertThat(
+ str(e),
+ matchers.Not(matchers.Contains('built-in function id')))
+
+ def test_validate_subnet_dns_nameservers_exhausted(self):
+ self._helper_test_validate_subnet(
+ 'max_dns_nameservers',
+ q_exc.DNSNameServersExhausted)
+
+ def test_validate_subnet_host_routes_exhausted(self):
+ self._helper_test_validate_subnet(
+ 'max_subnet_host_routes',
+ q_exc.HostRoutesExhausted)
+
class DbModelTestCase(base.BaseTestCase):
"""DB model tests."""