Skip to content

Commit

Permalink
Allow client grant scopes to be sent as an empty array (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Nov 28, 2023
1 parent ab9a930 commit 9c9892c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
3 changes: 2 additions & 1 deletion management/client_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type ClientGrant struct {
// The audience.
Audience *string `json:"audience,omitempty"`

Scope []string `json:"scope,omitempty"`
// The list of permissions (scopes) that are granted to the client.
Scope *[]string `json:"scope,omitempty"`

// If enabled, any organization can be used with this grant.
// If disabled (default), the grant must be explicitly assigned to the desired organizations.
Expand Down
10 changes: 5 additions & 5 deletions management/client_grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestClientGrantManager_Create(t *testing.T) {
expectedClientGrant := &ClientGrant{
ClientID: client.ClientID,
Audience: resourceServer.Identifier,
Scope: []string{"create:resource"},
Scope: &[]string{"create:resource"},
}

err := api.ClientGrant.Create(context.Background(), expectedClientGrant)
Expand Down Expand Up @@ -54,13 +54,13 @@ func TestClientGrantManager_Update(t *testing.T) {
expectedClientGrant.Audience = nil // Read-Only: Additional properties not allowed.
expectedClientGrant.ClientID = nil // Read-Only: Additional properties not allowed.

scope := expectedClientGrant.Scope
scope := expectedClientGrant.GetScope()
scope = append(scope, "update:resource")
expectedClientGrant.Scope = scope
expectedClientGrant.Scope = &scope

err := api.ClientGrant.Update(context.Background(), clientGrantID, expectedClientGrant)
assert.NoError(t, err)
assert.Equal(t, len(expectedClientGrant.Scope), 2)
assert.Equal(t, len(expectedClientGrant.GetScope()), 2)
}

func TestClientGrantManager_Delete(t *testing.T) {
Expand Down Expand Up @@ -113,7 +113,7 @@ func givenAClientGrant(t *testing.T, allowOrganizations bool) (clientGrant *Clie
clientGrant = &ClientGrant{
ClientID: client.ClientID,
Audience: resourceServer.Identifier,
Scope: []string{"create:resource"},
Scope: &[]string{"create:resource"},
}

if allowOrganizations {
Expand Down
8 changes: 8 additions & 0 deletions management/management.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions management/management.gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c9892c

Please sign in to comment.