Add RBAC tests for v3 auth policy actions
Implements RBAC tests for v3 auth-related policy actions contained
in [0]. But since the Tempest identity v3 client currently only
has an endpoint for list_auth_projects [1], this patch only adds an
RBAC test for identity:get_auth_projects.
Once the other endpoints (show_auth_catalog and list_auth_domains)
are added to the Tempest client, then the remaining tests can be
added in a follow-up patch.
[0] https://github.com/openstack/keystone/blob/master/keystone/common/policies/auth.py
[1] https://github.com/openstack/tempest/blob/master/tempest/lib/services/identity/v3/identity_client.py
Change-Id: I002acfe760aeaab6d4618d366a2da522c6a27695
Partial-Bug: #1687317
diff --git a/patrole_tempest_plugin/tests/api/identity/rbac_base.py b/patrole_tempest_plugin/tests/api/identity/rbac_base.py
index b37477e..3e22f32 100644
--- a/patrole_tempest_plugin/tests/api/identity/rbac_base.py
+++ b/patrole_tempest_plugin/tests/api/identity/rbac_base.py
@@ -12,6 +12,7 @@
# 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 oslo_log import log as logging
from tempest.api.identity import base
@@ -215,6 +216,7 @@
cls.domains_client = cls.os_primary.domains_client
cls.endpoints_client = cls.os_primary.endpoints_v3_client
cls.groups_client = cls.os_primary.groups_client
+ cls.identity_client = cls.os_primary.identity_v3_client
cls.projects_client = cls.os_primary.projects_client
cls.policies_client = cls.os_primary.policies_client
cls.regions_client = cls.os_primary.regions_client
diff --git a/patrole_tempest_plugin/tests/api/identity/v3/test_auth_rbac.py b/patrole_tempest_plugin/tests/api/identity/v3/test_auth_rbac.py
new file mode 100644
index 0000000..2327cbb
--- /dev/null
+++ b/patrole_tempest_plugin/tests/api/identity/v3/test_auth_rbac.py
@@ -0,0 +1,43 @@
+# 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.identity import rbac_base
+
+
+class IdentityAuthV3RbacTest(rbac_base.BaseIdentityV3RbacTest):
+ """Tests the APIs that enforce the auth policy actions.
+
+ For more information about the auth policy actions, see:
+ https://github.com/openstack/keystone/blob/master/keystone/common/policies/auth.py
+ """
+
+ # TODO(felipemonteiro): Add tests for identity:get_auth_catalog and
+ # identity:get_auth_domains once the endpoints are implemented in Tempest's
+ # identity v3 client.
+
+ @classmethod
+ def setup_clients(cls):
+ super(IdentityAuthV3RbacTest, cls).setup_clients()
+ cls.client = cls.identity_client
+
+ @decorators.idempotent_id('2a9fbf7f-6feb-4161-ae4b-faf7d6421b1a')
+ @rbac_rule_validation.action(service="keystone",
+ rule="identity:get_auth_projects")
+ def test_list_auth_projects(self):
+ self.rbac_utils.switch_role(self, toggle_rbac_role=True)
+ self.client.list_auth_projects()['projects']