refactor: Return the display_name and name in the roles endpoint (#1328)

This commit is contained in:
Bruno Quaresma
2022-05-06 14:18:00 -05:00
committed by GitHub
parent 97ee5600c7
commit 00806580f5
6 changed files with 71 additions and 35 deletions

View File

@ -65,6 +65,12 @@ func TestIsOrgRole(t *testing.T) {
func TestListRoles(t *testing.T) {
t.Parallel()
siteRoles := rbac.SiteRoles()
siteRoleNames := make([]string, 0, len(siteRoles))
for _, role := range siteRoles {
siteRoleNames = append(siteRoleNames, role.Name)
}
// If this test is ever failing, just update the list to the roles
// expected from the builtin set.
require.ElementsMatch(t, []string{
@ -72,12 +78,18 @@ func TestListRoles(t *testing.T) {
"member",
"auditor",
},
rbac.SiteRoles())
siteRoleNames)
orgID := uuid.New()
orgRoles := rbac.OrganizationRoles(orgID)
orgRoleNames := make([]string, 0, len(orgRoles))
for _, role := range orgRoles {
orgRoleNames = append(orgRoleNames, role.Name)
}
require.ElementsMatch(t, []string{
fmt.Sprintf("organization-admin:%s", orgID.String()),
fmt.Sprintf("organization-member:%s", orgID.String()),
},
rbac.OrganizationRoles(orgID))
orgRoleNames)
}