Skip to content
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
5 changes: 4 additions & 1 deletion pkg/directorysync/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ type User struct {
// The User's updated at date
UpdatedAt string `json:"updated_at"`

// The role given to this Directory User
// The highest priority role given to this Directory User
Role common.RoleResponse `json:"role,omitempty"`

// All roles given to this Directory User
Roles []common.RoleResponse `json:"roles"`
}

// ListUsersOpts contains the options to request provisioned Directory Users.
Expand Down
16 changes: 16 additions & 0 deletions pkg/directorysync/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func TestListUsers(t *testing.T) {
Role: common.RoleResponse{
Slug: "member",
},
Roles: []common.RoleResponse{
{Slug: "member"},
{Slug: "developer"},
},
},
},
ListMetadata: common.ListMetadata{
Expand Down Expand Up @@ -132,6 +136,10 @@ func listUsersTestHandler(w http.ResponseWriter, r *http.Request) {
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
CustomAttributes: json.RawMessage(`{"foo":"bar"}`),
Role: common.RoleResponse{Slug: "member"},
Roles: []common.RoleResponse{
{Slug: "member"},
{Slug: "developer"},
},
},
},
ListMetadata: common.ListMetadata{
Expand Down Expand Up @@ -299,6 +307,10 @@ func TestGetUser(t *testing.T) {
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
CustomAttributes: json.RawMessage(`{"foo":"bar"}`),
Role: common.RoleResponse{Slug: "member"},
Roles: []common.RoleResponse{
{Slug: "member"},
{Slug: "developer"},
},
},
},
}
Expand Down Expand Up @@ -359,6 +371,10 @@ func getUserTestHandler(w http.ResponseWriter, r *http.Request) {
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
CustomAttributes: json.RawMessage(`{"foo":"bar"}`),
Role: common.RoleResponse{Slug: "member"},
Roles: []common.RoleResponse{
{Slug: "member"},
{Slug: "developer"},
},
})
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand Down
8 changes: 8 additions & 0 deletions pkg/directorysync/directorysync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func TestDirectorySyncListUsers(t *testing.T) {
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
CustomAttributes: json.RawMessage(`{"foo":"bar"}`),
Role: expectedRole,
Roles: []common.RoleResponse{
{Slug: "member"},
{Slug: "developer"},
},
},
},
ListMetadata: common.ListMetadata{
Expand Down Expand Up @@ -143,6 +147,10 @@ func TestDirectorySyncGetUser(t *testing.T) {
RawAttributes: json.RawMessage(`{"foo":"bar"}`),
CustomAttributes: json.RawMessage(`{"foo":"bar"}`),
Role: expectedRole,
Roles: []common.RoleResponse{
{Slug: "member"},
{Slug: "developer"},
},
}
directoryUserResponse, err := GetUser(context.Background(), GetUserOpts{
User: "directory_user_id",
Expand Down
5 changes: 4 additions & 1 deletion pkg/sso/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,12 @@ type Profile struct {
// The user last name. Can be empty.
LastName string `json:"last_name"`

// The role given to this user profile. Can be empty.
// The highest priority role given to this user profile.
Role common.RoleResponse `json:"role"`

// All roles given to this user profile.
Roles []common.RoleResponse `json:"roles"`

// The user's group memberships. Can be empty.
Groups []string `json:"groups"`

Expand Down
16 changes: 16 additions & 0 deletions pkg/sso/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ func TestClientGetProfileAndToken(t *testing.T) {
Role: common.RoleResponse{
Slug: "admin",
},
Roles: []common.RoleResponse{
{Slug: "admin"},
{Slug: "developer"},
},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
Expand Down Expand Up @@ -227,6 +231,10 @@ func profileAndTokenTestHandler(w http.ResponseWriter, r *http.Request) {
Role: common.RoleResponse{
Slug: "admin",
},
Roles: []common.RoleResponse{
{Slug: "admin"},
{Slug: "developer"},
},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
Expand Down Expand Up @@ -278,6 +286,10 @@ func TestClientGetProfile(t *testing.T) {
Role: common.RoleResponse{
Slug: "admin",
},
Roles: []common.RoleResponse{
{Slug: "admin"},
{Slug: "developer"},
},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
Expand Down Expand Up @@ -337,6 +349,10 @@ func profileTestHandler(w http.ResponseWriter, r *http.Request) {
Role: common.RoleResponse{
Slug: "admin",
},
Roles: []common.RoleResponse{
{Slug: "admin"},
{Slug: "developer"},
},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
Expand Down
8 changes: 8 additions & 0 deletions pkg/sso/sso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func TestLogin(t *testing.T) {
Role: common.RoleResponse{
Slug: "admin",
},
Roles: []common.RoleResponse{
{Slug: "admin"},
{Slug: "developer"},
},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
Expand Down Expand Up @@ -176,6 +180,10 @@ func TestSsoGetProfile(t *testing.T) {
Role: common.RoleResponse{
Slug: "admin",
},
Roles: []common.RoleResponse{
{Slug: "admin"},
{Slug: "developer"},
},
Groups: []string{"Admins", "Developers"},
CustomAttributes: map[string]interface{}{
"license": "professional",
Expand Down