Add RBAC tests for cinder os-quota-class-sets API

This patch adds RBAC tests for the cinder os-quota-class-sets API,
which cover the policy action "volume_extension:quota_classes" [0][1].

[0] https://github.com/openstack/cinder/blob/master/cinder/api/contrib/quota_classes.py#L44
[1] https://github.com/openstack/cinder/blob/master/cinder/api/contrib/quota_classes.py#L55

Change-Id: Iba5dc5caf7ed3f1ad344b0d7b2d6c13a9842cf79
This commit is contained in:
Felipe Monteiro 2017-04-30 04:41:44 +01:00
parent edcdbecd6b
commit d0b747bd64
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,60 @@
# Copyright 2017 AT&T Corporation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest import test
from patrole_tempest_plugin import rbac_rule_validation
from patrole_tempest_plugin.tests.api.volume import rbac_base
class QuotaClassesRbacTest(rbac_base.BaseVolumeRbacTest):
@classmethod
def skip_checks(cls):
super(QuotaClassesRbacTest, cls).skip_checks()
if not test.is_extension_enabled('os-quota-class-sets', 'volume'):
msg = ("%s skipped as os-quota-class-sets not enabled."
% cls.__name__)
raise cls.skipException(msg)
@classmethod
def setup_clients(cls):
super(QuotaClassesRbacTest, cls).setup_clients()
cls.client = cls.os_primary.quota_classes_client
cls.quota_name = data_utils.rand_name(cls.__name__ + '-QuotaClass')
@decorators.idempotent_id('1a060def-2b43-4534-97f5-5eadbbe8c726')
@rbac_rule_validation.action(service="cinder",
rule="volume_extension:quota_classes")
def test_show_quota_class_set(self):
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.show_quota_class_set(self.quota_name)['quota_class_set']
@decorators.idempotent_id('72159478-23a7-4c75-989f-6bac609eca62')
@rbac_rule_validation.action(service="cinder",
rule="volume_extension:quota_classes")
def test_update_quota_class_set(self):
quota_class_set = self.client.show_quota_class_set(self.quota_name)[
'quota_class_set']
quota_class_set.pop('id')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.update_quota_class_set(self.quota_name, **quota_class_set)
class QuotaClassesV3RbacTest(QuotaClassesRbacTest):
_api_version = 3

View File

@ -0,0 +1,5 @@
---
features:
- |
Add RBAC tests for cinder os-quota-class-sets API, which cover the
policy action "volume_extension:quota_classes".