Skip to content

Commit

Permalink
feat: remove redundance
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ragot committed Dec 22, 2023
1 parent 9dbd2cd commit 9846958
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
4 changes: 1 addition & 3 deletions ee/auth/pkg/api/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type clientSecretView struct {
type clientView struct {
auth.ClientOptions
ID string `json:"id"`
Scopes []string `json:"scopes"`
Secrets auth.Array[clientSecretView] `json:"secrets" gorm:"type:text"`
}

Expand All @@ -42,8 +41,7 @@ func mapBusinessClient(c auth.Client) clientView {
Metadata: c.Metadata,
Scopes: c.Scopes,
},
ID: c.Id,
Scopes: c.Scopes,
ID: c.Id,
Secrets: mapList(c.Secrets, func(i auth.ClientSecret) clientSecretView {
return clientSecretView{
ClientSecret: i,
Expand Down
9 changes: 1 addition & 8 deletions ee/auth/pkg/api/clients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ func TestCreateClient(t *testing.T) {

createdClient := readTestResponse[clientView](t, res)
require.NotEmpty(t, createdClient.ID)
tcScopes := tc.options.Scopes
tc.options.Scopes = nil
require.Equal(t, tc.options, createdClient.ClientOptions)
require.True(t, func() bool {
for _, scope := range tcScopes {
for _, scope := range tc.options.Scopes {
contain := collectionutils.Contains[string](createdClient.Scopes, scope)
if !contain {
t.Logf("scope %s not found in created client scopes", scope)
Expand All @@ -107,7 +105,6 @@ func TestCreateClient(t *testing.T) {
return true
}())
tc.options.Id = createdClient.ID
tc.options.Scopes = tcScopes
clientFromDatabase := auth.Client{}
require.NoError(t, db.Find(&clientFromDatabase, "id = ?", createdClient.ID).Error)
require.Equal(t, auth.Client{
Expand Down Expand Up @@ -175,13 +172,10 @@ func TestUpdateClient(t *testing.T) {
require.Equal(t, http.StatusOK, res.Code)

updatedClient := readTestResponse[clientView](t, res)
tcScopes := tc.options.Scopes
tc.options.Scopes = nil
require.NotEmpty(t, updatedClient.ID)
require.Equal(t, tc.options, updatedClient.ClientOptions)

tc.options.Id = updatedClient.ID
tc.options.Scopes = tcScopes
clientFromDatabase := auth.Client{}
require.NoError(t, db.Find(&clientFromDatabase, "id = ?", updatedClient.ID).Error)
require.Equal(t, auth.Client{
Expand Down Expand Up @@ -244,7 +238,6 @@ func TestReadClient(t *testing.T) {
require.Equal(t, clientView{
ClientOptions: opts,
ID: client1.Id,
Scopes: []string{"XXX"},
Secrets: []clientSecretView{{
ClientSecret: secret,
}},
Expand Down
2 changes: 1 addition & 1 deletion ee/auth/pkg/storage/sqlstorage/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func MigrateData(ctx context.Context, db *gorm.DB) error {
},
},
})

logging.FromContext(ctx).Info("Migrating data...")
return gormigrate.Migrate()
}

Expand Down

0 comments on commit 9846958

Please sign in to comment.