Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow client grant scopes to be sent as an empty array #318

Merged
merged 2 commits into from
Nov 28, 2023
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
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.

Loading