Fixes traceback if group name attribute is missing

This works around an issue where certain backends (e.g. LDAP)
did not provide a group name, only ID, which would cause most
identity management tasks in Horizon to fail. If no name is
provided, the ID is duplicated as the group name.

Change-Id: Iea87abf38d26cb2baff43521c7dd2ae0a00e9997
Closes-Bug: #1593571
(cherry picked from commit cb664ecf18)
This commit is contained in:
Edmund Rhudy 2016-08-19 14:50:12 -04:00 committed by Rob Cresswell
parent d009bb161c
commit c7a40ac6fb
2 changed files with 11 additions and 2 deletions

View File

@ -336,7 +336,10 @@ class UpdateProjectGroupsAction(workflows.MembershipAction):
domain=domain_id)
except Exception:
exceptions.handle(request, err_msg)
groups_list = [(group.id, group.name) for group in all_groups]
# some backends (e.g. LDAP) do not provide group names
groups_list = [
(group.id, getattr(group, 'name', group.id))
for group in all_groups]
# Get list of roles
role_list = []

View File

@ -240,7 +240,13 @@ def data(TEST):
'project_id': '2',
'domain_id': '2'}
group4 = groups.Group(groups.GroupManager(None), group_dict)
TEST.groups.add(group, group2, group3, group4)
# this group intentionally only has id/domain_id to match data
# returned from Keystone backends like LDAP
group_dict = {'id': "5",
'domain_id': '2'}
group5 = groups.Group(groups.GroupManager(None), group_dict)
TEST.groups.add(group, group2, group3, group4, group5)
role_assignments_dict = {'user': {'id': '1'},
'role': {'id': '1'},