Cinder tests for Volume hosts policy actions
Adds cinder RBAC test for listing volume hosts
Implements bp: initial-tests-volume
Co-Authored-By: Rick Bartra <rb560u@att.com>
Co-Authored-By: Anthony Bellino <ab2434@att.com>
Change-Id: I6f31cee7963e1fef91f9846503e42885d7e7ead7
diff --git a/patrole_tempest_plugin/tests/api/volume/rbac_base.py b/patrole_tempest_plugin/tests/api/volume/rbac_base.py
index 60ec77e..1cb128e 100644
--- a/patrole_tempest_plugin/tests/api/volume/rbac_base.py
+++ b/patrole_tempest_plugin/tests/api/volume/rbac_base.py
@@ -65,3 +65,9 @@
cls.auth_provider = cls.os.auth_provider
cls.admin_client = cls.os_adm.volumes_client
cls.rbac_utils = rbac_utils()
+ version_checker = {
+ 1: [cls.os.volume_hosts_client, cls.os.volume_types_client],
+ 2: [cls.os.volume_hosts_v2_client, cls.os.volume_types_v2_client]
+ }
+ cls.volume_hosts_client, cls.volume_types_client = \
+ version_checker[cls._api_version]
diff --git a/patrole_tempest_plugin/tests/api/volume/test_volume_hosts_rbac.py b/patrole_tempest_plugin/tests/api/volume/test_volume_hosts_rbac.py
new file mode 100644
index 0000000..45720e6
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/volume/test_volume_hosts_rbac.py
@@ -0,0 +1,33 @@
+# 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 import decorators
+
+from patrole_tempest_plugin import rbac_rule_validation
+from patrole_tempest_plugin.tests.api.volume import rbac_base
+
+
+class VolumeHostsAdminRbacTest(rbac_base.BaseVolumeAdminRbacTest):
+
+ def tearDown(self):
+ self.rbac_utils.switch_role(self, switchToRbacRole=False)
+ super(VolumeHostsAdminRbacTest, self).tearDown()
+
+ @rbac_rule_validation.action(service="cinder",
+ rule="volume_extension:hosts")
+ @decorators.idempotent_id('64e837f5-5452-4e26-b934-c721ea7a8644')
+ def test_list_hosts(self):
+ self.rbac_utils.switch_role(self, switchToRbacRole=True)
+ self.volume_hosts_client.list_hosts()