diff --git a/Makefile b/Makefile index c65dd58a..c911ef3c 100755 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ help: ## This help .DEFAULT_GOAL := help build: ## Build package - go mod tidy && go mod vendor && go build ./... + go mod tidy && go build ./... run-example: ## Run example web application - cd examples/webapp && go mod tidy && go mod vendor && go run main.go + cd examples/webapp && go mod tidy && go run main.go run-gin-example: ## Run example web application - cd examples/ginwebapp && go mod tidy && go mod vendor && go run main.go + cd examples/ginwebapp && go mod tidy && go run main.go diff --git a/descope/api/client.go b/descope/api/client.go index 1a02a466..29c25c42 100644 --- a/descope/api/client.go +++ b/descope/api/client.go @@ -1148,11 +1148,11 @@ func NewClient(conf ClientParams) *Client { } else { // App has set a different transport layer, we will not change its attributes, and use it as is // this will include the tls config - rt = http.DefaultTransport + rt = http.DefaultTransport // notest } var timeout = time.Second * 60 if conf.RequestTimeout != 0 { - timeout = conf.RequestTimeout + timeout = conf.RequestTimeout // notest } httpClient = &http.Client{ Timeout: timeout, diff --git a/descope/internal/auth/auth.go b/descope/internal/auth/auth.go index 49fe5159..5a5f8d5d 100644 --- a/descope/internal/auth/auth.go +++ b/descope/internal/auth/auth.go @@ -391,7 +391,7 @@ func (auth *authenticationService) ExchangeAccessKey(ctx context.Context, access } tokens, err := auth.extractTokens(jwtResponse) - if err != nil { + if err != nil { // notest errMsg := err.Error() if len(errMsg) == 0 { errMsg = "Missing token in JWT response" diff --git a/descope/internal/mgmt/accesskey.go b/descope/internal/mgmt/accesskey.go index 10a0de52..a7883cd1 100644 --- a/descope/internal/mgmt/accesskey.go +++ b/descope/internal/mgmt/accesskey.go @@ -6,13 +6,16 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type accessKey struct { managementBase } -func (a *accessKey) Create(ctx context.Context, name string, expireTime int64, roleNames []string, keyTenants []*descope.AssociatedTenant, userID string, customClaims map[string]any, description string, permittedIPs []string) (string, *descope.AccessKeyResponse, error) { +var _ sdk.AccessKey = &accessKey{} + +func (a *accessKey) Create(ctx context.Context, name string, description string, expireTime int64, roleNames []string, keyTenants []*descope.AssociatedTenant, userID string, customClaims map[string]any, permittedIPs []string) (string, *descope.AccessKeyResponse, error) { if name == "" { return "", nil, utils.NewInvalidArgumentError("name") } diff --git a/descope/internal/mgmt/accesskey_test.go b/descope/internal/mgmt/accesskey_test.go index 9816a663..a1567c32 100644 --- a/descope/internal/mgmt/accesskey_test.go +++ b/descope/internal/mgmt/accesskey_test.go @@ -36,7 +36,7 @@ func TestAccessKeyCreateSuccess(t *testing.T) { require.Equal(t, "10.0.0.1", permittedIPs[0]) }, response)) cc := map[string]any{"k1": "v1"} - cleartext, key, err := mgmt.AccessKey().Create(context.Background(), "abc", 0, []string{"foo"}, nil, "uid", cc, desc, []string{"10.0.0.1"}) + cleartext, key, err := mgmt.AccessKey().Create(context.Background(), "abc", desc, 0, []string{"foo"}, nil, "uid", cc, []string{"10.0.0.1"}) require.NoError(t, err) require.Equal(t, "cleartext", cleartext) require.Equal(t, "abc", key.Name) @@ -49,7 +49,7 @@ func TestAccessKeyCreateSuccess(t *testing.T) { func TestAccessKeyCreateError(t *testing.T) { mgmt := newTestMgmt(nil, helpers.DoOk(nil)) - _, _, err := mgmt.AccessKey().Create(context.Background(), "", 0, nil, nil, "", nil, "", nil) + _, _, err := mgmt.AccessKey().Create(context.Background(), "", "", 0, nil, nil, "", nil, nil) require.Error(t, err) } diff --git a/descope/internal/mgmt/audit.go b/descope/internal/mgmt/audit.go index 9706ceab..2bf972ac 100644 --- a/descope/internal/mgmt/audit.go +++ b/descope/internal/mgmt/audit.go @@ -8,12 +8,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type audit struct { managementBase } +var _ sdk.Audit = &audit{} + func (a *audit) Search(ctx context.Context, options *descope.AuditSearchOptions) ([]*descope.AuditRecord, error) { body := map[string]any{ "userIds": options.UserIDs, diff --git a/descope/internal/mgmt/authz.go b/descope/internal/mgmt/authz.go index f240c6a0..5d910d50 100644 --- a/descope/internal/mgmt/authz.go +++ b/descope/internal/mgmt/authz.go @@ -7,12 +7,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type authz struct { managementBase } +var _ sdk.Authz = &authz{} + func (a *authz) SaveSchema(ctx context.Context, schema *descope.AuthzSchema, upgrade bool) error { if schema == nil { return utils.NewInvalidArgumentError("schema") diff --git a/descope/internal/mgmt/flow.go b/descope/internal/mgmt/flow.go index 7a71ade2..e74ce562 100644 --- a/descope/internal/mgmt/flow.go +++ b/descope/internal/mgmt/flow.go @@ -6,12 +6,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type flow struct { managementBase } +var _ sdk.Flow = &flow{} + func (r *flow) ListFlows(ctx context.Context) (*descope.FlowsResponse, error) { res, err := r.client.DoPostRequest(ctx, api.Routes.ManagementListFlows(), nil, nil, r.conf.ManagementKey) if err != nil { diff --git a/descope/internal/mgmt/group.go b/descope/internal/mgmt/group.go index 56775613..87da482d 100644 --- a/descope/internal/mgmt/group.go +++ b/descope/internal/mgmt/group.go @@ -6,12 +6,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type group struct { managementBase } +var _ sdk.Group = &group{} + func (r *group) LoadAllGroups(ctx context.Context, tenantID string) ([]*descope.Group, error) { if tenantID == "" { return nil, utils.NewInvalidArgumentError("tenantID") diff --git a/descope/internal/mgmt/jwt.go b/descope/internal/mgmt/jwt.go index 9510da4e..0418f992 100644 --- a/descope/internal/mgmt/jwt.go +++ b/descope/internal/mgmt/jwt.go @@ -5,12 +5,15 @@ import ( "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type jwt struct { managementBase } +var _ sdk.JWT = &jwt{} + type jwtRes struct { JWT string `json:"jwt,omitempty"` } diff --git a/descope/internal/mgmt/mgmt.go b/descope/internal/mgmt/mgmt.go index 5ae3c167..2942657f 100644 --- a/descope/internal/mgmt/mgmt.go +++ b/descope/internal/mgmt/mgmt.go @@ -40,7 +40,7 @@ func NewManagement(conf ManagementParams, c *api.Client) *managementService { base := managementBase{conf: &conf, client: c} service := &managementService{managementBase: base} service.tenant = &tenant{managementBase: base} - service.ssoApplication = &SSOApplication{managementBase: base} + service.ssoApplication = &ssoApplication{managementBase: base} service.user = &user{managementBase: base} service.accessKey = &accessKey{managementBase: base} service.sso = &sso{managementBase: base} @@ -52,7 +52,7 @@ func NewManagement(conf ManagementParams, c *api.Client) *managementService { service.project = &project{managementBase: base} service.audit = &audit{managementBase: base} service.authz = &authz{managementBase: base} - service.password = &password{managementBase: base} + service.password = &passwordManagement{managementBase: base} return service } diff --git a/descope/internal/mgmt/password.go b/descope/internal/mgmt/password.go index 5f0b28c0..471ee9ee 100644 --- a/descope/internal/mgmt/password.go +++ b/descope/internal/mgmt/password.go @@ -6,13 +6,16 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) -type password struct { +type passwordManagement struct { managementBase } -func (s *password) GetSettings(ctx context.Context, tenantID string) (*descope.PasswordSettings, error) { +var _ sdk.PasswordManagement = &passwordManagement{} + +func (s *passwordManagement) GetSettings(ctx context.Context, tenantID string) (*descope.PasswordSettings, error) { req := &api.HTTPRequest{ QueryParams: map[string]string{"tenantId": tenantID}, } @@ -23,7 +26,7 @@ func (s *password) GetSettings(ctx context.Context, tenantID string) (*descope.P return unmarshalPasswordSettingsResponse(res) } -func (s *password) ConfigureSettings(ctx context.Context, tenantID string, passwordSettings *descope.PasswordSettings) error { +func (s *passwordManagement) ConfigureSettings(ctx context.Context, tenantID string, passwordSettings *descope.PasswordSettings) error { req := map[string]any{ "tenantId": tenantID, "enabled": passwordSettings.Enabled, diff --git a/descope/internal/mgmt/permission.go b/descope/internal/mgmt/permission.go index 926ca5eb..f44e952d 100644 --- a/descope/internal/mgmt/permission.go +++ b/descope/internal/mgmt/permission.go @@ -6,12 +6,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type permission struct { managementBase } +var _ sdk.Permission = &permission{} + func (p *permission) Create(ctx context.Context, name, description string) error { if name == "" { return utils.NewInvalidArgumentError("name") diff --git a/descope/internal/mgmt/project.go b/descope/internal/mgmt/project.go index b7093b4a..d0f7f1c5 100644 --- a/descope/internal/mgmt/project.go +++ b/descope/internal/mgmt/project.go @@ -6,12 +6,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type project struct { managementBase } +var _ sdk.Project = &project{} + type updateProjectBody struct { Name string `json:"name"` } diff --git a/descope/internal/mgmt/role.go b/descope/internal/mgmt/role.go index 368e2543..e58354a9 100644 --- a/descope/internal/mgmt/role.go +++ b/descope/internal/mgmt/role.go @@ -6,12 +6,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type role struct { managementBase } +var _ sdk.Role = &role{} + func (r *role) Create(ctx context.Context, name, description string, permissionNames []string, tenantID string) error { if name == "" { return utils.NewInvalidArgumentError("name") diff --git a/descope/internal/mgmt/sso.go b/descope/internal/mgmt/sso.go index 7d590ac1..bdf813bd 100644 --- a/descope/internal/mgmt/sso.go +++ b/descope/internal/mgmt/sso.go @@ -6,12 +6,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type sso struct { managementBase } +var _ sdk.SSO = &sso{} + func (s *sso) LoadSettings(ctx context.Context, tenantID string) (*descope.SSOTenantSettingsResponse, error) { if tenantID == "" { return nil, utils.NewInvalidArgumentError("tenantID") diff --git a/descope/internal/mgmt/ssoapplication.go b/descope/internal/mgmt/ssoapplication.go index 6bf8855c..30c159fc 100644 --- a/descope/internal/mgmt/ssoapplication.go +++ b/descope/internal/mgmt/ssoapplication.go @@ -6,13 +6,16 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) -type SSOApplication struct { +type ssoApplication struct { managementBase } -func (s *SSOApplication) CreateOIDCApplication(ctx context.Context, appRequest *descope.OIDCApplicationRequest) (id string, err error) { +var _ sdk.SSOApplication = &ssoApplication{} + +func (s *ssoApplication) CreateOIDCApplication(ctx context.Context, appRequest *descope.OIDCApplicationRequest) (id string, err error) { if appRequest == nil { return "", utils.NewInvalidArgumentError("appRequest") } @@ -34,7 +37,7 @@ func (s *SSOApplication) CreateOIDCApplication(ctx context.Context, appRequest * return res.ID, nil } -func (s *SSOApplication) CreateSAMLApplication(ctx context.Context, appRequest *descope.SAMLApplicationRequest) (id string, err error) { +func (s *ssoApplication) CreateSAMLApplication(ctx context.Context, appRequest *descope.SAMLApplicationRequest) (id string, err error) { if appRequest == nil { return "", utils.NewInvalidArgumentError("appRequest") } @@ -56,7 +59,7 @@ func (s *SSOApplication) CreateSAMLApplication(ctx context.Context, appRequest * return res.ID, nil } -func (s *SSOApplication) UpdateOIDCApplication(ctx context.Context, appRequest *descope.OIDCApplicationRequest) error { +func (s *ssoApplication) UpdateOIDCApplication(ctx context.Context, appRequest *descope.OIDCApplicationRequest) error { if appRequest == nil { return utils.NewInvalidArgumentError("appRequest") } @@ -72,7 +75,7 @@ func (s *SSOApplication) UpdateOIDCApplication(ctx context.Context, appRequest * return err } -func (s *SSOApplication) UpdateSAMLApplication(ctx context.Context, appRequest *descope.SAMLApplicationRequest) error { +func (s *ssoApplication) UpdateSAMLApplication(ctx context.Context, appRequest *descope.SAMLApplicationRequest) error { if appRequest == nil { return utils.NewInvalidArgumentError("appRequest") } @@ -88,7 +91,7 @@ func (s *SSOApplication) UpdateSAMLApplication(ctx context.Context, appRequest * return err } -func (s *SSOApplication) Delete(ctx context.Context, id string) error { +func (s *ssoApplication) Delete(ctx context.Context, id string) error { if id == "" { return utils.NewInvalidArgumentError("id") } @@ -97,7 +100,7 @@ func (s *SSOApplication) Delete(ctx context.Context, id string) error { return err } -func (s *SSOApplication) Load(ctx context.Context, id string) (*descope.SSOApplication, error) { +func (s *ssoApplication) Load(ctx context.Context, id string) (*descope.SSOApplication, error) { if id == "" { return nil, utils.NewInvalidArgumentError("id") } @@ -111,7 +114,7 @@ func (s *SSOApplication) Load(ctx context.Context, id string) (*descope.SSOAppli return unmarshalLoadSSOApplicationResponse(res) } -func (s *SSOApplication) LoadAll(ctx context.Context) ([]*descope.SSOApplication, error) { +func (s *ssoApplication) LoadAll(ctx context.Context) ([]*descope.SSOApplication, error) { res, err := s.client.DoGetRequest(ctx, api.Routes.ManagementSSOApplicationLoadAll(), nil, s.conf.ManagementKey) if err != nil { return nil, err diff --git a/descope/internal/mgmt/tenant.go b/descope/internal/mgmt/tenant.go index 90d78104..72a13c06 100644 --- a/descope/internal/mgmt/tenant.go +++ b/descope/internal/mgmt/tenant.go @@ -6,15 +6,18 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type tenant struct { managementBase } +var _ sdk.Tenant = &tenant{} + func (t *tenant) Create(ctx context.Context, tenantRequest *descope.TenantRequest) (id string, err error) { if tenantRequest == nil { - tenantRequest = &descope.TenantRequest{} + tenantRequest = &descope.TenantRequest{} // notest } return t.createWithID(ctx, "", tenantRequest) } @@ -24,7 +27,7 @@ func (t *tenant) CreateWithID(ctx context.Context, id string, tenantRequest *des return utils.NewInvalidArgumentError("id") } if tenantRequest == nil { - tenantRequest = &descope.TenantRequest{} + tenantRequest = &descope.TenantRequest{} // notest } _, err := t.createWithID(ctx, id, tenantRequest) return err @@ -94,7 +97,7 @@ func (t *tenant) LoadAll(ctx context.Context) ([]*descope.Tenant, error) { func (t *tenant) SearchAll(ctx context.Context, options *descope.TenantSearchOptions) ([]*descope.Tenant, error) { // Init empty options if non given if options == nil { - options = &descope.TenantSearchOptions{} + options = &descope.TenantSearchOptions{} // notest } req := makeSearchTenantRequest(options) @@ -107,7 +110,7 @@ func (t *tenant) SearchAll(ctx context.Context, options *descope.TenantSearchOpt func (t *tenant) GetSettings(ctx context.Context, tenantID string) (*descope.TenantSettings, error) { if tenantID == "" { - return nil, utils.NewInvalidArgumentError("tenantID") + return nil, utils.NewInvalidArgumentError("tenantID") // notest } req := &api.HTTPRequest{ QueryParams: map[string]string{"id": tenantID}, diff --git a/descope/internal/mgmt/user.go b/descope/internal/mgmt/user.go index f645417c..3bf24181 100644 --- a/descope/internal/mgmt/user.go +++ b/descope/internal/mgmt/user.go @@ -7,12 +7,15 @@ import ( "github.com/descope/go-sdk/descope" "github.com/descope/go-sdk/descope/api" "github.com/descope/go-sdk/descope/internal/utils" + "github.com/descope/go-sdk/descope/sdk" ) type user struct { managementBase } +var _ sdk.User = &user{} + type createUserRequest struct { loginID string email string @@ -50,7 +53,7 @@ func (u *user) CreateTestUser(ctx context.Context, loginID string, user *descope func (u *user) CreateBatch(ctx context.Context, users []*descope.BatchUser) (*descope.UsersBatchResponse, error) { if users == nil { - users = []*descope.BatchUser{} + users = []*descope.BatchUser{} // notest } return u.createBatch(ctx, users, nil) } @@ -64,7 +67,7 @@ func (u *user) Invite(ctx context.Context, loginID string, user *descope.UserReq func (u *user) InviteBatch(ctx context.Context, users []*descope.BatchUser, options *descope.InviteOptions) (*descope.UsersBatchResponse, error) { if users == nil { - users = []*descope.BatchUser{} + users = []*descope.BatchUser{} // notest } return u.createBatch(ctx, users, options) } diff --git a/descope/internal/mgmt/user_test.go b/descope/internal/mgmt/user_test.go index 90afc25a..870306c9 100644 --- a/descope/internal/mgmt/user_test.go +++ b/descope/internal/mgmt/user_test.go @@ -924,7 +924,7 @@ func TestUserUpdatePhoneError(t *testing.T) { require.Nil(t, res) } -func TestUserUpdateNameSuccess(t *testing.T) { +func TestUserUpdateDisplayNameSuccess(t *testing.T) { response := map[string]any{ "user": map[string]any{ "name": "foo", @@ -942,20 +942,54 @@ func TestUserUpdateNameSuccess(t *testing.T) { require.Equal(t, "foo", res.Name) } -func TestUserUpdateNameBadInput(t *testing.T) { +func TestUserUpdateDisplayNameBadInput(t *testing.T) { m := newTestMgmt(nil, helpers.DoOk(nil)) res, err := m.User().UpdateDisplayName(context.Background(), "", "foo") require.Error(t, err) require.Nil(t, res) } -func TestUserUpdateNameError(t *testing.T) { +func TestUserUpdateDisplayNameError(t *testing.T) { m := newTestMgmt(nil, helpers.DoBadRequest(nil)) res, err := m.User().UpdateDisplayName(context.Background(), "abc", "foo") require.Error(t, err) require.Nil(t, res) } +func TestUserUpdateNamesSuccess(t *testing.T) { + response := map[string]any{ + "user": map[string]any{ + "name": "foo", + }} + m := newTestMgmt(nil, helpers.DoOkWithBody(func(r *http.Request) { + require.Equal(t, r.Header.Get("Authorization"), "Bearer a:key") + req := map[string]any{} + require.NoError(t, helpers.ReadBody(r, &req)) + require.Equal(t, "abc", req["loginId"]) + require.Equal(t, "g", req["givenName"]) + require.Equal(t, "m", req["middleName"]) + require.Equal(t, "f", req["familyName"]) + }, response)) + res, err := m.User().UpdateUserNames(context.Background(), "abc", "g", "m", "f") + require.NoError(t, err) + require.NotNil(t, res) + require.Equal(t, "foo", res.Name) +} + +func TestUserUpdateNamesBadInput(t *testing.T) { + m := newTestMgmt(nil, helpers.DoOk(nil)) + res, err := m.User().UpdateUserNames(context.Background(), "", "g", "m", "f") + require.Error(t, err) + require.Nil(t, res) +} + +func TestUserUpdateNamesError(t *testing.T) { + m := newTestMgmt(nil, helpers.DoBadRequest(nil)) + res, err := m.User().UpdateUserNames(context.Background(), "abc", "g", "m", "f") + require.Error(t, err) + require.Nil(t, res) +} + func TestUserUpdatePictureSuccess(t *testing.T) { response := map[string]any{ "user": map[string]any{ @@ -1288,6 +1322,46 @@ func TestUserRemoveTenantError(t *testing.T) { require.Nil(t, res) } +func TestUserSetTenantRoleSuccess(t *testing.T) { + response := map[string]any{ + "user": map[string]any{ + "userTenants": []map[string]any{ + { + "tenantId": "123", + "roleNames": []string{"foo"}, + }, + }, + }} + m := newTestMgmt(nil, helpers.DoOkWithBody(func(r *http.Request) { + require.Equal(t, r.Header.Get("Authorization"), "Bearer a:key") + req := map[string]any{} + require.NoError(t, helpers.ReadBody(r, &req)) + require.Equal(t, "abc", req["loginId"]) + require.Equal(t, "123", req["tenantId"]) + require.Equal(t, []any{"foo"}, req["roleNames"]) + }, response)) + res, err := m.User().SetTenantRoles(context.Background(), "abc", "123", []string{"foo"}) + require.NoError(t, err) + require.NotNil(t, res) + require.Len(t, res.UserTenants, 1) + require.Equal(t, "123", res.UserTenants[0].TenantID) + require.Equal(t, []string{"foo"}, res.UserTenants[0].Roles) +} + +func TestUserSetTenantRoleBadInput(t *testing.T) { + m := newTestMgmt(nil, helpers.DoOk(nil)) + res, err := m.User().SetTenantRoles(context.Background(), "", "123", []string{"foo"}) + require.Error(t, err) + require.Nil(t, res) +} + +func TestUserSetTenantRoleError(t *testing.T) { + m := newTestMgmt(nil, helpers.DoBadRequest(nil)) + res, err := m.User().SetTenantRoles(context.Background(), "abc", "123", []string{"foo"}) + require.Error(t, err) + require.Nil(t, res) +} + func TestUserAddTenantRoleSuccess(t *testing.T) { response := map[string]any{ "user": map[string]any{ diff --git a/descope/sdk/mgmt.go b/descope/sdk/mgmt.go index 2380f827..a90d30db 100644 --- a/descope/sdk/mgmt.go +++ b/descope/sdk/mgmt.go @@ -417,7 +417,7 @@ type AccessKey interface { // The description parameter is an optional text providing a brief summary about the access key. // The permittedIPs parameter is an optional list of IP addresses or CIDR ranges that are allowed to use this access key. // If not provided, all IPs are allowed. - Create(ctx context.Context, name string, expireTime int64, roles []string, keyTenants []*descope.AssociatedTenant, userID string, customClaims map[string]any, description string, permittedIPs []string) (string, *descope.AccessKeyResponse, error) + Create(ctx context.Context, name string, description string, expireTime int64, roles []string, keyTenants []*descope.AssociatedTenant, userID string, customClaims map[string]any, permittedIPs []string) (string, *descope.AccessKeyResponse, error) // Load an existing access key. // diff --git a/descope/tests/mocks/mgmt/managementmock.go b/descope/tests/mocks/mgmt/managementmock.go index b67e83b5..d7e443e6 100644 --- a/descope/tests/mocks/mgmt/managementmock.go +++ b/descope/tests/mocks/mgmt/managementmock.go @@ -740,7 +740,7 @@ func (m *MockUser) History(_ context.Context, userIDs []string) ([]*descope.User // Mock Access Key type MockAccessKey struct { - CreateAssert func(name string, expireTime int64, roles []string, keyTenants []*descope.AssociatedTenant, userID string, customClaims map[string]any, description string, permittedIPs []string) + CreateAssert func(name string, description string, expireTime int64, roles []string, keyTenants []*descope.AssociatedTenant, userID string, customClaims map[string]any, permittedIPs []string) CreateResponseFn func() (string, *descope.AccessKeyResponse) CreateError error @@ -766,9 +766,9 @@ type MockAccessKey struct { DeleteError error } -func (m *MockAccessKey) Create(_ context.Context, name string, expireTime int64, roles []string, keyTenants []*descope.AssociatedTenant, userID string, customClaims map[string]any, description string, permittedIPs []string) (string, *descope.AccessKeyResponse, error) { +func (m *MockAccessKey) Create(_ context.Context, name string, description string, expireTime int64, roles []string, keyTenants []*descope.AssociatedTenant, userID string, customClaims map[string]any, permittedIPs []string) (string, *descope.AccessKeyResponse, error) { if m.CreateAssert != nil { - m.CreateAssert(name, expireTime, roles, keyTenants, userID, customClaims, description, permittedIPs) + m.CreateAssert(name, description, expireTime, roles, keyTenants, userID, customClaims, permittedIPs) } var cleartext string var key *descope.AccessKeyResponse diff --git a/scripts/build/ci/build_go.sh b/scripts/build/ci/build_go.sh index 28ce0098..caee80f9 100755 --- a/scripts/build/ci/build_go.sh +++ b/scripts/build/ci/build_go.sh @@ -1,27 +1,27 @@ #!/usr/bin/env bash echo 'Building main package..' -go mod tidy && go mod vendor && go build -v ./... +go mod tidy && go build -v ./... if [ $? -ne 0 ]; then exit 1 fi echo 'Building gin package..' -(cd descope/gin && go mod tidy && go mod vendor && go build) +(cd descope/gin && go mod tidy && go build) if [ $? -ne 0 ]; then exit 1 fi echo 'Building mux web app example..' -(cd examples/webapp && go mod tidy && go mod vendor && go build) +(cd examples/webapp && go mod tidy && go build) if [ $? -ne 0 ]; then exit 1 fi echo 'Building gin web app example..' -(cd examples/ginwebapp && go mod tidy && go mod vendor && go build) +(cd examples/ginwebapp && go mod tidy && go build) if [ $? -ne 0 ]; then exit 1 fi echo 'Building importusers example..' -(cd examples/importusers && go mod tidy && go mod vendor && go build) +(cd examples/importusers && go mod tidy && go build) if [ $? -ne 0 ]; then exit 1 fi diff --git a/scripts/lint/lint.sh b/scripts/lint/lint.sh index 97f4234d..a27e7d39 100644 --- a/scripts/lint/lint.sh +++ b/scripts/lint/lint.sh @@ -43,9 +43,8 @@ lint_check_not_main() { # Run go mod commands lint_go_mod() { - echo "- Running go tidy and go mod vendor" + echo "- Running go tidy" go mod tidy - go mod vendor } # Run go build (default is cmd dir)