From: John Schwarz Date: Mon, 3 Aug 2015 12:49:13 +0000 (+0300) Subject: Add API tests for non-accessible policies X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7ccc705f6177d9fd198f079e8b57cf44e58b1963;p=openstack-build%2Fneutron-build.git Add API tests for non-accessible policies 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 --- diff --git a/neutron/tests/api/base.py b/neutron/tests/api/base.py index 578478629..30d00b8d6 100644 --- a/neutron/tests/api/base.py +++ b/neutron/tests/api/base.py @@ -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 diff --git a/neutron/tests/api/test_qos.py b/neutron/tests/api/test_qos.py index 4b617e2f7..4be738a20 100644 --- a/neutron/tests/api/test_qos.py +++ b/neutron/tests/api/test_qos.py @@ -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) diff --git a/neutron/tests/tempest/services/network/json/network_client.py b/neutron/tests/tempest/services/network/json/network_client.py index c01c83c70..38569a888 100644 --- a/neutron/tests/tempest/services/network/json/network_client.py +++ b/neutron/tests/tempest/services/network/json/network_client.py @@ -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)