diff --git a/openstack/cloud/_identity.py b/openstack/cloud/_identity.py index a44119119..4a9a9bfcd 100644 --- a/openstack/cloud/_identity.py +++ b/openstack/cloud/_identity.py @@ -1061,7 +1061,7 @@ class IdentityCloudMixin(_normalize.Normalizer): self.list_groups.invalidate(self) return True - @_utils.valid_kwargs('domain_id') + @_utils.valid_kwargs('domain_id', 'name') def list_roles(self, **kwargs): """List Keystone roles. diff --git a/openstack/tests/unit/cloud/test_identity_roles.py b/openstack/tests/unit/cloud/test_identity_roles.py index 89eeddc1a..e8d503a4d 100644 --- a/openstack/tests/unit/cloud/test_identity_roles.py +++ b/openstack/tests/unit/cloud/test_identity_roles.py @@ -54,6 +54,22 @@ class TestIdentityRoles(base.TestCase): self.cloud.list_roles() self.assert_calls() + def test_list_role_by_name(self): + role_data = self._get_role_data() + self.register_uris([ + dict(method='GET', + uri=self.get_mock_url( + qs_elements=['name={0}'.format(role_data.role_name)]), + status_code=200, + json={'roles': [role_data.json_response['role']]}) + ]) + role = self.cloud.list_roles(name=role_data.role_name)[0] + + self.assertIsNotNone(role) + self.assertThat(role.id, matchers.Equals(role_data.role_id)) + self.assertThat(role.name, matchers.Equals(role_data.role_name)) + self.assert_calls() + def test_get_role_by_name(self): role_data = self._get_role_data() self.register_uris([