]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge "Change 422 error to 400 error"
authorJenkins <jenkins@review.openstack.org>
Sun, 9 Sep 2012 09:52:22 +0000 (09:52 +0000)
committerGerrit Code Review <review@openstack.org>
Sun, 9 Sep 2012 09:52:22 +0000 (09:52 +0000)
1  2 
quantum/tests/unit/test_db_plugin.py

index 1a6b351c986a65e7c7b12d100e5f9780a71d78a3,814570e70e339b34cf1cb39052714f7f5e00e8ff..eb69d2531827c92e8efce055fdf59fcb93de4ed3
@@@ -2030,87 -2030,8 +2030,87 @@@ class TestSubnetsV2(QuantumDbPluginV2Te
          with self.assertRaises(webob.exc.HTTPClientError) as ctx_manager:
              self._test_create_subnet(cidr=cidr,
                                       shared=True)
-         self.assertEquals(ctx_manager.exception.code, 422)
+         self.assertEquals(ctx_manager.exception.code, 400)
  
 +    def test_create_subnet_inconsistent_ipv6_cidrv4(self):
 +        with self.network() as network:
 +            data = {'subnet': {'network_id': network['network']['id'],
 +                               'cidr': '10.0.2.0/24',
 +                               'ip_version': 6,
 +                               'tenant_id': network['network']['tenant_id']}}
 +            subnet_req = self.new_create_request('subnets', data)
 +            res = subnet_req.get_response(self.api)
 +            self.assertEquals(res.status_int, 400)
 +
 +    def test_create_subnet_inconsistent_ipv4_cidrv6(self):
 +        with self.network() as network:
 +            data = {'subnet': {'network_id': network['network']['id'],
 +                               'cidr': 'fe80::0/80',
 +                               'ip_version': 4,
 +                               'tenant_id': network['network']['tenant_id']}}
 +            subnet_req = self.new_create_request('subnets', data)
 +            res = subnet_req.get_response(self.api)
 +            self.assertEquals(res.status_int, 400)
 +
 +    def test_create_subnet_inconsistent_ipv4_gatewayv6(self):
 +        with self.network() as network:
 +            data = {'subnet': {'network_id': network['network']['id'],
 +                               'cidr': '10.0.2.0/24',
 +                               'ip_version': 4,
 +                               'gateway_ip': 'fe80::1',
 +                               'tenant_id': network['network']['tenant_id']}}
 +            subnet_req = self.new_create_request('subnets', data)
 +            res = subnet_req.get_response(self.api)
 +            self.assertEquals(res.status_int, 400)
 +
 +    def test_create_subnet_inconsistent_ipv6_gatewayv4(self):
 +        with self.network() as network:
 +            data = {'subnet': {'network_id': network['network']['id'],
 +                               'cidr': 'fe80::0/80',
 +                               'ip_version': 6,
 +                               'gateway_ip': '192.168.0.1',
 +                               'tenant_id': network['network']['tenant_id']}}
 +            subnet_req = self.new_create_request('subnets', data)
 +            res = subnet_req.get_response(self.api)
 +            self.assertEquals(res.status_int, 400)
 +
 +    def test_create_subnet_inconsistent_ipv6_dns_v4(self):
 +        with self.network() as network:
 +            data = {'subnet': {'network_id': network['network']['id'],
 +                               'cidr': 'fe80::0/80',
 +                               'ip_version': 6,
 +                               'dns_nameservers': ['192.168.0.1'],
 +                               'tenant_id': network['network']['tenant_id']}}
 +            subnet_req = self.new_create_request('subnets', data)
 +            res = subnet_req.get_response(self.api)
 +            self.assertEquals(res.status_int, 400)
 +
 +    def test_create_subnet_inconsistent_ipv4_hostroute_dst_v6(self):
 +        host_routes = [{'destination': 'fe80::0/48',
 +                        'nexthop': '10.0.2.20'}]
 +        with self.network() as network:
 +            data = {'subnet': {'network_id': network['network']['id'],
 +                               'cidr': '10.0.2.0/24',
 +                               'ip_version': 4,
 +                               'host_routes': host_routes,
 +                               'tenant_id': network['network']['tenant_id']}}
 +            subnet_req = self.new_create_request('subnets', data)
 +            res = subnet_req.get_response(self.api)
 +            self.assertEquals(res.status_int, 400)
 +
 +    def test_create_subnet_inconsistent_ipv4_hostroute_np_v6(self):
 +        host_routes = [{'destination': '172.16.0.0/24',
 +                        'nexthop': 'fe80::1'}]
 +        with self.network() as network:
 +            data = {'subnet': {'network_id': network['network']['id'],
 +                               'cidr': '10.0.2.0/24',
 +                               'ip_version': 4,
 +                               'host_routes': host_routes,
 +                               'tenant_id': network['network']['tenant_id']}}
 +            subnet_req = self.new_create_request('subnets', data)
 +            res = subnet_req.get_response(self.api)
 +            self.assertEquals(res.status_int, 400)
 +
      def test_update_subnet(self):
          with self.subnet() as subnet:
              data = {'subnet': {'gateway_ip': '11.0.0.1'}}
                  req = self.new_update_request('subnets', data,
                                                subnet['subnet']['id'])
                  res = req.get_response(self.api)
-                 self.assertEqual(res.status_int, 422)
+                 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:
 +                data = {'subnet': {'gateway_ip': 'fe80::1'}}
 +                req = self.new_update_request('subnets', data,
 +                                              subnet['subnet']['id'])
 +                res = req.get_response(self.api)
 +                self.assertEquals(res.status_int, 400)
 +
 +    def test_update_subnet_inconsistent_ipv6_gatewayv4(self):
 +        with self.network() as network:
 +            with self.subnet(network=network,
 +                             ip_version=6, cidr='fe80::/48') as subnet:
 +                data = {'subnet': {'gateway_ip': '10.1.1.1'}}
 +                req = self.new_update_request('subnets', data,
 +                                              subnet['subnet']['id'])
 +                res = req.get_response(self.api)
 +                self.assertEquals(res.status_int, 400)
 +
 +    def test_update_subnet_inconsistent_ipv4_dns_v6(self):
 +        dns_nameservers = ['fe80::1']
 +        with self.network() as network:
 +            with self.subnet(network=network) as subnet:
 +                data = {'subnet': {'dns_nameservers': dns_nameservers}}
 +                req = self.new_update_request('subnets', data,
 +                                              subnet['subnet']['id'])
 +                res = req.get_response(self.api)
 +                self.assertEquals(res.status_int, 400)
 +
 +    def test_update_subnet_inconsistent_ipv6_hostroute_dst_v4(self):
 +        host_routes = [{'destination': 'fe80::0/48',
 +                        'nexthop': '10.0.2.20'}]
 +        with self.network() as network:
 +            with self.subnet(network=network,
 +                             ip_version=6, cidr='fe80::/48') as subnet:
 +                data = {'subnet': {'host_routes': host_routes}}
 +                req = self.new_update_request('subnets', data,
 +                                              subnet['subnet']['id'])
 +                res = req.get_response(self.api)
 +                self.assertEquals(res.status_int, 400)
 +
 +    def test_update_subnet_inconsistent_ipv6_hostroute_np_v4(self):
 +        host_routes = [{'destination': '172.16.0.0/24',
 +                        'nexthop': 'fe80::1'}]
 +        with self.network() as network:
 +            with self.subnet(network=network,
 +                             ip_version=6, cidr='fe80::/48') as subnet:
 +                data = {'subnet': {'host_routes': host_routes}}
 +                req = self.new_update_request('subnets', data,
 +                                              subnet['subnet']['id'])
 +                res = req.get_response(self.api)
 +                self.assertEquals(res.status_int, 400)
  
      def test_show_subnet(self):
          with self.network() as network: