Browse Source

Merge "Add some create subnet negative tests"

Zuul 1 month ago
parent
commit
15748a0cd3
1 changed files with 33 additions and 0 deletions
  1. 33
    0
      neutron/tests/unit/db/test_db_base_plugin_v2.py

+ 33
- 0
neutron/tests/unit/db/test_db_base_plugin_v2.py View File

@@ -3295,6 +3295,17 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
3295 3295
             res = subnet_req.get_response(self.api)
3296 3296
             self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
3297 3297
 
3298
+    def test_create_subnet_invalid_gw_32_V4_cidr(self):
3299
+        with self.network() as network:
3300
+            data = {'subnet': {'network_id': network['network']['id'],
3301
+                    'cidr': '10.0.0.0/4',
3302
+                    'ip_version': constants.IP_VERSION_4,
3303
+                    'tenant_id': network['network']['tenant_id'],
3304
+                    'gateway_ip': '10.0.0.1/32'}}
3305
+            subnet_req = self.new_create_request('subnets', data)
3306
+            res = subnet_req.get_response(self.api)
3307
+            self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
3308
+
3298 3309
     def test_create_subnet_with_cidr_and_default_subnetpool(self):
3299 3310
         """Expect subnet-create to keep semantic with default pools."""
3300 3311
         with self.network() as network:
@@ -3375,6 +3386,28 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
3375 3386
             res = subnet_req.get_response(self.api)
3376 3387
             self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
3377 3388
 
3389
+    def test_create_subnet_invalid_gw_V6_cidr(self):
3390
+        with self.network() as network:
3391
+            data = {'subnet': {'network_id': network['network']['id'],
3392
+                    'cidr': '2001:db8:0:1::/64',
3393
+                    'ip_version': '6',
3394
+                    'tenant_id': network['network']['tenant_id'],
3395
+                    'gateway_ip': '2001:db8::1/64'}}
3396
+            subnet_req = self.new_create_request('subnets', data)
3397
+            res = subnet_req.get_response(self.api)
3398
+            self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
3399
+
3400
+    def test_create_subnet_invalid_gw_128_V6_cidr(self):
3401
+        with self.network() as network:
3402
+            data = {'subnet': {'network_id': network['network']['id'],
3403
+                    'cidr': '2001:db8:0:1::/64',
3404
+                    'ip_version': '6',
3405
+                    'tenant_id': network['network']['tenant_id'],
3406
+                    'gateway_ip': '2001:db8:0:1:1/128'}}
3407
+            subnet_req = self.new_create_request('subnets', data)
3408
+            res = subnet_req.get_response(self.api)
3409
+            self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
3410
+
3378 3411
     def test_create_subnet_V6_slaac_big_prefix(self):
3379 3412
         with self.network() as network:
3380 3413
             data = {'subnet': {'network_id': network['network']['id'],

Loading…
Cancel
Save