Extra hypervisor rbac tests
Adds additional hypervisor rbac tests that were previously missing.
The following tests were added:
- test_show_hypervisor
- test_list_servers_on_hypervisor
- test_show_hypervisor_statistics
- test_show_hypervisor_uptime
- test_search_hypervisor
Change-Id: Iec77d81895e30bd7adb764555fb6accc9f088ea4
diff --git a/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py b/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
index ecd0fd3..ba85b5b 100644
--- a/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
+++ b/patrole_tempest_plugin/tests/api/compute/test_hypervisor_rbac.py
@@ -23,11 +23,6 @@
class HypervisorRbacTest(rbac_base.BaseV2ComputeRbacTest):
@classmethod
- def setup_clients(cls):
- super(HypervisorRbacTest, cls).setup_clients()
- cls.client = cls.hypervisor_client
-
- @classmethod
def skip_checks(cls):
super(HypervisorRbacTest, cls).skip_checks()
if not test.is_extension_enabled('os-hypervisors', 'compute'):
@@ -35,6 +30,16 @@
% cls.__name__
raise cls.skipException(msg)
+ @classmethod
+ def setup_clients(cls):
+ super(HypervisorRbacTest, cls).setup_clients()
+ cls.client = cls.hypervisor_client
+
+ @classmethod
+ def resource_setup(cls):
+ super(HypervisorRbacTest, cls).resource_setup()
+ cls.hypervisor = cls.client.list_hypervisors()['hypervisors'][0]
+
@decorators.idempotent_id('17bbeb9a-e73e-445f-a771-c794448ef562')
@rbac_rule_validation.action(
service="nova",
@@ -42,3 +47,45 @@
def test_list_hypervisors(self):
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.list_hypervisors()['hypervisors']
+
+ @decorators.idempotent_id('8a7f6f9e-34a6-4480-8875-bba566c3a581')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-hypervisors")
+ def test_show_hypervisor(self):
+ self.rbac_utils.switch_role(self, toggle_rbac_role=True)
+ self.client.show_hypervisor(self.hypervisor['id'])['hypervisor']
+
+ @decorators.idempotent_id('b86f03cf-2e79-4d88-9eea-62f761591413')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-hypervisors")
+ def test_list_servers_on_hypervisor(self):
+ self.rbac_utils.switch_role(self, toggle_rbac_role=True)
+ self.client.list_servers_on_hypervisor(
+ self.hypervisor['hypervisor_hostname'])['hypervisors']
+
+ @decorators.idempotent_id('ca0e465c-6365-4a7f-ae58-6f8ddbca06c2')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-hypervisors")
+ def test_show_hypervisor_statistics(self):
+ self.rbac_utils.switch_role(self, toggle_rbac_role=True)
+ self.client.show_hypervisor_statistics()['hypervisor_statistics']
+
+ @decorators.idempotent_id('109b37c5-91ba-4da5-b2a2-d7618d84406d')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-hypervisors")
+ def test_show_hypervisor_uptime(self):
+ self.rbac_utils.switch_role(self, toggle_rbac_role=True)
+ self.client.show_hypervisor_uptime(self.hypervisor['id'])['hypervisor']
+
+ @decorators.idempotent_id('3dbc71c1-8f04-4674-a67c-dcb2fd99b1b4')
+ @rbac_rule_validation.action(
+ service="nova",
+ rule="os_compute_api:os-hypervisors")
+ def test_search_hypervisor(self):
+ self.rbac_utils.switch_role(self, toggle_rbac_role=True)
+ self.client.search_hypervisor(self.hypervisor['hypervisor_hostname'])[
+ 'hypervisors']
diff --git a/releasenotes/notes/add-extra-hypervisor-tests-9374e5fcdb0266e2.yaml b/releasenotes/notes/add-extra-hypervisor-tests-9374e5fcdb0266e2.yaml
new file mode 100644
index 0000000..0c46435
--- /dev/null
+++ b/releasenotes/notes/add-extra-hypervisor-tests-9374e5fcdb0266e2.yaml
@@ -0,0 +1,11 @@
+---
+features:
+ - |
+ Add additional compute hypervisor RBAC tests, so that the previously
+ missing hypervisor endpoints are covered. Tests for the following
+ endpoints were written:
+ * show_hypervisor
+ * list_servers_on_hypervisor
+ * show_hypervisor_statistics
+ * show_hypervisor_uptime
+ * search_hypervisor