]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add API tests for non-accessible policies
authorJohn Schwarz <jschwarz@redhat.com>
Mon, 3 Aug 2015 12:49:13 +0000 (15:49 +0300)
committerIhar Hrachyshka <ihrachys@redhat.com>
Mon, 3 Aug 2015 19:48:33 +0000 (21:48 +0200)
Tests which dealt with creating a rule for a policy that the tenant has
no access to, or for a policy which does not even exist, were missing.
This patch adds them.

Partially-Implements: quantum-qos-api
Change-Id: I0a2679fa1ccfb7bae6083df9a71c6cb5205a21d9

neutron/tests/api/base.py
neutron/tests/api/test_qos.py
neutron/tests/tempest/services/network/json/network_client.py

index 57847862922f709e70818191297ca425de14eb1a..30d00b8d6d750dfe08049247570b8b9af0f8ecfa 100644 (file)
@@ -442,9 +442,10 @@ class BaseNetworkTest(neutron.tests.tempest.test.BaseTestCase):
         return fw_policy
 
     @classmethod
-    def create_qos_policy(cls, name, description, shared):
+    def create_qos_policy(cls, name, description, shared, tenant_id=None):
         """Wrapper utility that returns a test QoS policy."""
-        body = cls.admin_client.create_qos_policy(name, description, shared)
+        body = cls.admin_client.create_qos_policy(
+            name, description, shared, tenant_id)
         qos_policy = body['policy']
         cls.qos_policies.append(qos_policy)
         return qos_policy
index 4b617e2f76b3c1fc1a6fb35dea06f2110a2ce2a5..4be738a20f9e1eb4578512b562e7c05ed5fa2004 100644 (file)
@@ -312,3 +312,23 @@ class QosBandwidthLimitRuleTestJSON(base.BaseAdminNetworkTest):
         self.assertRaises(exceptions.ServerFault,
                           self.admin_client.show_bandwidth_limit_rule,
                           policy['id'], rule['id'])
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('f211222c-5808-46cb-a961-983bbab6b852')
+    def test_rule_create_rule_nonexistent_policy(self):
+        self.assertRaises(
+            exceptions.NotFound,
+            self.create_qos_bandwidth_limit_rule,
+            'policy', 200, 1337)
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('3ba4abf9-7976-4eaf-a5d0-a934a6e09b2d')
+    def test_rule_association_nonshared_policy(self):
+        policy = self.create_qos_policy(name='test-policy',
+                                        description='test policy',
+                                        shared=False,
+                                        tenant_id='tenant-id')
+        self.assertRaises(
+            exceptions.NotFound,
+            self.client.create_bandwidth_limit_rule,
+            policy['id'], 200, 1337)
index c01c83c706aa6df08d75e88fd384ab35be0b5185..38569a888097011d5331c68d5f03d44a6ebb19bd 100644 (file)
@@ -632,15 +632,16 @@ class NetworkClientJSON(service_client.ServiceClient):
         body = json.loads(body)
         return service_client.ResponseBody(resp, body)
 
-    def create_qos_policy(self, name, description, shared):
+    def create_qos_policy(self, name, description, shared, tenant_id=None):
         uri = '%s/qos/policies' % self.uri_prefix
-        post_data = self.serialize(
-            {'policy': {
+        post_data = {'policy': {
                 'name': name,
                 'description': description,
                 'shared': shared
-            }})
-        resp, body = self.post(uri, post_data)
+            }}
+        if tenant_id is not None:
+            post_data['policy']['tenant_id'] = tenant_id
+        resp, body = self.post(uri, self.serialize(post_data))
         body = self.deserialize_single(body)
         self.expected_success(201, resp.status)
         return service_client.ResponseBody(resp, body)