From b51b3f5b61b44924122f6595da3467bbcfd03743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Douglas=20Mendiz=C3=A1bal?= Date: Thu, 18 May 2023 10:36:20 -0500 Subject: [PATCH] Update rbac tests This patch updates the rbac tests for testing the policy updates that removed the "system" scope and use "project" scope instead. Depends-On: I3b781112fc6ced7b73196f973cefd6a30ef99dd3 Change-Id: I735cefe2b1cb4eb09c9770f0bdc738ffeee34f0e --- .../tests/rbac/v1/test_quotas.py | 86 +++++++++++++++++++ .../tests/rbac/v1/test_transport_keys.py | 7 ++ 2 files changed, 93 insertions(+) diff --git a/barbican_tempest_plugin/tests/rbac/v1/test_quotas.py b/barbican_tempest_plugin/tests/rbac/v1/test_quotas.py index 16edc18..ffabc1e 100644 --- a/barbican_tempest_plugin/tests/rbac/v1/test_quotas.py +++ b/barbican_tempest_plugin/tests/rbac/v1/test_quotas.py @@ -193,3 +193,89 @@ class ProjectAdminTests(ProjectMemberTests): def setup_clients(cls): super().setup_clients() cls.client = cls.os_project_admin.secret_v1.QuotaClient() + + def test_list_project_quotas(self): + quotas = self.client.list_quotas() + self.assertIn("project_quotas", quotas) + + def test_get_custom_quota_for_project(self): + project_id = self.client.tenant_id + self.client.create_project_quota( + project_id, + project_quotas={ + "secrets": 1000, + "orders": 1000, + "containers": 1000 + }) + quota = self.client.get_project_quota(project_id) + self.assertIn("project_quotas", quota) + + def test_set_new_quota_for_project(self): + project_id = self.client.tenant_id + self.client.create_project_quota( + project_id, + project_quotas={ + "secrets": 1000, + "orders": 1000, + "containers": 1000 + }) + quota = self.client.get_project_quota(project_id) + self.assertIn("project_quotas", quota) + + def test_remove_custom_quota_for_project(self): + project_id = self.client.tenant_id + self.client.create_project_quota( + project_id, + project_quotas={ + "secrets": 1000, + "orders": 1000, + "containers": 1000 + }) + quota = self.client.get_project_quota(project_id) + self.assertIn("project_quotas", quota) + self.client.delete_project_quota(project_id) + self.assertRaises( + exceptions.NotFound, + self.client.get_project_quota, + project_id) + + def test_get_custom_quota_for_other_project(self): + project_id = self.other_secret_client.tenant_id + self.client.create_project_quota( + project_id, + project_quotas={ + "secrets": 1000, + "orders": 1000, + "containers": 1000 + }) + quota = self.client.get_project_quota(project_id) + self.assertIn("project_quotas", quota) + + def test_set_new_quota_for_other_project(self): + project_id = self.other_secret_client.tenant_id + self.client.create_project_quota( + project_id, + project_quotas={ + "secrets": 1000, + "orders": 1000, + "containers": 1000 + }) + quota = self.client.get_project_quota(project_id) + self.assertIn("project_quotas", quota) + + def test_remove_custom_quota_for_other_project(self): + project_id = self.other_secret_client.tenant_id + self.client.create_project_quota( + project_id, + project_quotas={ + "secrets": 1000, + "orders": 1000, + "containers": 1000 + }) + quota = self.client.get_project_quota(project_id) + self.assertIn("project_quotas", quota) + self.client.delete_project_quota(project_id) + self.assertRaises( + exceptions.NotFound, + self.client.get_project_quota, + project_id) diff --git a/barbican_tempest_plugin/tests/rbac/v1/test_transport_keys.py b/barbican_tempest_plugin/tests/rbac/v1/test_transport_keys.py index 1984943..fa142f1 100644 --- a/barbican_tempest_plugin/tests/rbac/v1/test_transport_keys.py +++ b/barbican_tempest_plugin/tests/rbac/v1/test_transport_keys.py @@ -112,6 +112,13 @@ class ProjectAdminTests(ProjectMemberTests): super().setup_clients() cls.client = cls.os_project_admin.secret_v1.TransportKeyClient() + def test_create_transport_key(self): + transport_key = self.client.create_transport_key( + plugin_name="simple-crypto", + transport_key="UUUU-UUUU-IIII-DDDD" + ) + self.assertIn("transport_key_ref", transport_key) + class ProjectReaderTests(ProjectMemberTests):