diff --git a/patrole_tempest_plugin/rbac_utils.py b/patrole_tempest_plugin/rbac_utils.py index 6db2199c..b7ac8d9e 100644 --- a/patrole_tempest_plugin/rbac_utils.py +++ b/patrole_tempest_plugin/rbac_utils.py @@ -23,6 +23,7 @@ from oslo_utils import excutils from tempest import clients from tempest.common import credentials_factory as credentials from tempest import config +from tempest.lib import exceptions as lib_exc from patrole_tempest_plugin import rbac_exceptions @@ -50,10 +51,11 @@ class RbacUtils(object): # Intialize the admin roles_client to perform role switching. admin_mgr = clients.Manager( credentials.get_configured_admin_credentials()) - if test_obj.get_identity_version() == 'v3': + if CONF.identity_feature_enabled.api_v3: admin_roles_client = admin_mgr.roles_v3_client else: - admin_roles_client = admin_mgr.roles_client + raise lib_exc.InvalidConfiguration( + "Patrole role overriding only supports v3 identity API.") self.admin_roles_client = admin_roles_client self._override_role(test_obj, False) diff --git a/patrole_tempest_plugin/tests/unit/fixtures.py b/patrole_tempest_plugin/tests/unit/fixtures.py index 4552224c..aee36fa7 100644 --- a/patrole_tempest_plugin/tests/unit/fixtures.py +++ b/patrole_tempest_plugin/tests/unit/fixtures.py @@ -69,12 +69,13 @@ class RbacUtilsFixture(fixtures.Fixture): self.useFixture(ConfPatcher(rbac_test_role='member', group='patrole')) self.useFixture(ConfPatcher( admin_role='admin', auth_version='v3', group='identity')) + self.useFixture(ConfPatcher( + api_v3=True, group='identity-feature-enabled')) test_obj_kwargs = { 'os_primary.credentials.user_id': self.USER_ID, 'os_primary.credentials.tenant_id': self.PROJECT_ID, 'os_primary.credentials.project_id': self.PROJECT_ID, - 'get_identity_version.return_value': 'v3' } self.mock_test_obj = mock.Mock( __name__='patrole_unit_test', spec=test.BaseTestCase, diff --git a/releasenotes/notes/deprecate-roles-client-in-rbac-utils-087eda0658d18fa9.yaml b/releasenotes/notes/deprecate-roles-client-in-rbac-utils-087eda0658d18fa9.yaml new file mode 100644 index 00000000..c42da8a0 --- /dev/null +++ b/releasenotes/notes/deprecate-roles-client-in-rbac-utils-087eda0658d18fa9.yaml @@ -0,0 +1,6 @@ +--- +deprecations: + - | + Patrole will only support the v3 Tempest roles client for role + overriding operations. Support for the v2 version has been dropped + because the Keystone v2 API is slated for removal.