diff --git a/management/client_grant.go b/management/client_grant.go index cd907fd6..c591fdb0 100644 --- a/management/client_grant.go +++ b/management/client_grant.go @@ -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. diff --git a/management/client_grant_test.go b/management/client_grant_test.go index c7e2ec0f..4f3cef70 100644 --- a/management/client_grant_test.go +++ b/management/client_grant_test.go @@ -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) @@ -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) { @@ -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 { diff --git a/management/management.gen.go b/management/management.gen.go index fafebfd8..20dd9bfd 100644 --- a/management/management.gen.go +++ b/management/management.gen.go @@ -1803,6 +1803,14 @@ func (c *ClientGrant) GetOrganizationUsage() string { return *c.OrganizationUsage } +// GetScope returns the Scope field if it's non-nil, zero value otherwise. +func (c *ClientGrant) GetScope() []string { + if c == nil || c.Scope == nil { + return nil + } + return *c.Scope +} + // String returns a string representation of ClientGrant. func (c *ClientGrant) String() string { return Stringify(c) diff --git a/management/management.gen_test.go b/management/management.gen_test.go index 8d4565a2..84120bc6 100644 --- a/management/management.gen_test.go +++ b/management/management.gen_test.go @@ -2187,6 +2187,16 @@ func TestClientGrant_GetOrganizationUsage(tt *testing.T) { c.GetOrganizationUsage() } +func TestClientGrant_GetScope(tt *testing.T) { + var zeroValue []string + c := &ClientGrant{Scope: &zeroValue} + c.GetScope() + c = &ClientGrant{} + c.GetScope() + c = nil + c.GetScope() +} + func TestClientGrant_String(t *testing.T) { var rawJSON json.RawMessage v := &ClientGrant{}