From 38ee89cb25dde620f27ab7ebd81f76daf0cbc7d9 Mon Sep 17 00:00:00 2001 From: freesky-edward Date: Wed, 20 Feb 2019 10:36:44 +0800 Subject: [PATCH 1/2] Fix the role assignment bug --- openstack/identity/v3/roles/results.go | 46 ++++++++------------------ 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/openstack/identity/v3/roles/results.go b/openstack/identity/v3/roles/results.go index 2e4cec087..3519cd831 100644 --- a/openstack/identity/v3/roles/results.go +++ b/openstack/identity/v3/roles/results.go @@ -131,41 +131,23 @@ func (r roleResult) Extract() (*Role, error) { // RoleAssignment is the result of a role assignments query. type RoleAssignment struct { - Role AssignedRole `json:"role,omitempty"` - Scope Scope `json:"scope,omitempty"` - User User `json:"user,omitempty"` - Group Group `json:"group,omitempty"` + Catalog string `json:"catalog"` + Description string `json:"description"` + DisplayName string `json:"display_name"` + ID string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Policy Policy `json:"policy"` } -// AssignedRole represents a Role in an assignment. -type AssignedRole struct { - ID string `json:"id,omitempty"` +type Policy struct { + Statement []Statement `json:"Statement"` + Version string `json:"Version"` } -// Scope represents a scope in a Role assignment. -type Scope struct { - Domain Domain `json:"domain,omitempty"` - Project Project `json:"project,omitempty"` -} - -// Domain represents a domain in a role assignment scope. -type Domain struct { - ID string `json:"id,omitempty"` -} - -// Project represents a project in a role assignment scope. -type Project struct { - ID string `json:"id,omitempty"` -} - -// User represents a user in a role assignment scope. -type User struct { - ID string `json:"id,omitempty"` -} - -// Group represents a group in a role assignment scope. -type Group struct { - ID string `json:"id,omitempty"` +type Statement struct { + Action []string `json:"Action"` + Effect string `json:"Effect"` } // RoleAssignmentPage is a single page of RoleAssignments results. @@ -195,7 +177,7 @@ func (r RoleAssignmentPage) NextPageURL() (string, error) { // acquired from List. func ExtractRoleAssignments(r pagination.Page) ([]RoleAssignment, error) { var s struct { - RoleAssignments []RoleAssignment `json:"role_assignments"` + RoleAssignments []RoleAssignment `json:"roles"` } err := (r.(RoleAssignmentPage)).ExtractInto(&s) return s.RoleAssignments, err From f318f21d96db2a8a511fd93ffc85510e406cd18c Mon Sep 17 00:00:00 2001 From: freesky-edward Date: Wed, 20 Feb 2019 14:23:32 +0800 Subject: [PATCH 2/2] fix ci issue --- .../identity/v3/roles/testing/fixtures.go | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/openstack/identity/v3/roles/testing/fixtures.go b/openstack/identity/v3/roles/testing/fixtures.go index 86d4ebb78..bf412f72d 100644 --- a/openstack/identity/v3/roles/testing/fixtures.go +++ b/openstack/identity/v3/roles/testing/fixtures.go @@ -300,18 +300,30 @@ func HandleUnassignSuccessfully(t *testing.T) { // FirstRoleAssignment is the first role assignment in the List request. var FirstRoleAssignment = roles.RoleAssignment{ - Role: roles.AssignedRole{ID: "123456"}, - Scope: roles.Scope{Domain: roles.Domain{ID: "161718"}}, - User: roles.User{ID: "313233"}, - Group: roles.Group{}, + Catalog: "BASE", + Description: "Tenant Administrator", + DisplayName: "Tenant Administrator", + ID: "699bd62cda304d2cad03fd2fb190b8cf", + Name: "te_admin", + Type: "AA", + Policy: roles.Policy{ + Statement: []roles.Statement{}, + Version: "v1", + }, } // SecondRoleAssignemnt is the second role assignemnt in the List request. var SecondRoleAssignment = roles.RoleAssignment{ - Role: roles.AssignedRole{ID: "123456"}, - Scope: roles.Scope{Project: roles.Project{ID: "456789"}}, - User: roles.User{ID: "313233"}, - Group: roles.Group{}, + Catalog: "BASE", + Description: "Security Administrator", + DisplayName: "Security Administrator", + ID: "699bd62cda304d2cad03fd2fb190b8ce", + Name: "secu_admin", + Type: "AA", + Policy: roles.Policy{ + Statement: []roles.Statement{}, + Version: "v1", + }, } // ExpectedRoleAssignmentsSlice is the slice of role assignments expected to be