Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 14 additions & 32 deletions openstack/identity/v3/roles/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
28 changes: 20 additions & 8 deletions openstack/identity/v3/roles/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down