Merge "Fix display of application credential roles"

This commit is contained in:
Zuul 2020-06-03 09:18:18 +00:00 committed by Gerrit Code Review
commit fbeaefcd66
2 changed files with 19 additions and 3 deletions

View File

@ -59,8 +59,9 @@ class ApplicationCredentialFilterAction(tables.FilterAction):
filter_choices = (("name", _("Application Credential Name ="), True))
def _role_names(obj):
return [role['name'].encode('utf-8') for role in obj.roles]
def _render_roles(obj):
names = [role['name'] for role in obj.roles]
return ', '.join(names)
class ApplicationCredentialsTable(tables.DataTable):
@ -73,7 +74,7 @@ class ApplicationCredentialsTable(tables.DataTable):
expires_at = tables.Column('expires_at',
verbose_name=_('Expiration'))
id = tables.Column('id', verbose_name=_('ID'))
roles = tables.Column(_role_names, verbose_name=_('Roles'))
roles = tables.Column(_render_roles, verbose_name=_('Roles'))
class Meta(object):
name = "application_credentials"

View File

@ -65,6 +65,21 @@ class ApplicationCredentialViewTests(test.TestCase):
mock_app_cred_create.assert_called_once_with(test.IsHttpRequest(),
**api_data)
@mock.patch.object(api.keystone, 'application_credential_list')
def test_application_credential_detail_list(self, mock_app_cred_list):
app_creds = self.application_credentials.list()
mock_app_cred_list.return_value = app_creds
res = self.client.get(
reverse('horizon:identity:application_credentials:index'))
self.assertTemplateUsed(
res, 'identity/application_credentials/index.html')
self.assertListEqual(res.context['table'].data, app_creds)
self.assertContains(res, 'Member, admin')
mock_app_cred_list.assert_called_once_with(test.IsHttpRequest(),
filters={})
@mock.patch.object(api.keystone, 'application_credential_get')
def test_application_credential_detail_get(self, mock_app_cred_get):
app_cred = self.application_credentials.list()[1]