diff --git a/auth/api/http/keys/endpoint_test.go b/auth/api/http/keys/endpoint_test.go index f200f9f5ee2..fd31e58588d 100644 --- a/auth/api/http/keys/endpoint_test.go +++ b/auth/api/http/keys/endpoint_test.go @@ -70,11 +70,12 @@ func newService() (auth.Service, *mocks.KeyRepository) { krepo := new(mocks.KeyRepository) prepo := new(mocks.PolicyAgent) drepo := new(mocks.DomainsRepository) + patsRepo := new(mocks.PATSRepository) idProvider := uuid.NewMock() t := jwt.New([]byte(secret)) - return auth.New(krepo, drepo, idProvider, t, prepo, loginDuration, refreshDuration, invalidDuration), krepo + return auth.New(krepo, drepo, patsRepo, idProvider, t, prepo, loginDuration, refreshDuration, invalidDuration), krepo } func newServer(svc auth.Service) *httptest.Server { diff --git a/auth/api/http/pats/endpoint.go b/auth/api/http/pats/endpoint.go index 3d751c92b2f..3c35241078c 100644 --- a/auth/api/http/pats/endpoint.go +++ b/auth/api/http/pats/endpoint.go @@ -10,14 +10,14 @@ import ( "github.com/go-kit/kit/endpoint" ) -func createPatEndpoint(svc auth.Service) endpoint.Endpoint { +func createPATEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(createPatReq) if err := req.validate(); err != nil { return nil, err } - pat, err := svc.Create(ctx, req.token, req.Name, req.Description, req.Duration, req.Scope) + pat, err := svc.CreatePAT(ctx, req.token, req.Name, req.Description, req.Duration, req.Scope) if err != nil { return nil, err } @@ -26,14 +26,14 @@ func createPatEndpoint(svc auth.Service) endpoint.Endpoint { } } -func retrieveEndpoint(svc auth.Service) endpoint.Endpoint { +func retrievePATEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(retrievePatReq) if err := req.validate(); err != nil { return nil, err } - pat, err := svc.Retrieve(ctx, req.token, req.id) + pat, err := svc.RetrievePAT(ctx, req.token, req.id) if err != nil { return nil, err } @@ -42,14 +42,14 @@ func retrieveEndpoint(svc auth.Service) endpoint.Endpoint { } } -func updateNameEndpoint(svc auth.Service) endpoint.Endpoint { +func updatePATNameEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(updatePatNameReq) if err := req.validate(); err != nil { return nil, err } - pat, err := svc.UpdateName(ctx, req.token, req.id, req.Name) + pat, err := svc.UpdatePATName(ctx, req.token, req.id, req.Name) if err != nil { return nil, err } @@ -58,14 +58,14 @@ func updateNameEndpoint(svc auth.Service) endpoint.Endpoint { } } -func updateDescriptionEndpoint(svc auth.Service) endpoint.Endpoint { +func updatePATDescriptionEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(updatePatDescriptionReq) if err := req.validate(); err != nil { return nil, err } - pat, err := svc.UpdateDescription(ctx, req.token, req.id, req.Description) + pat, err := svc.UpdatePATDescription(ctx, req.token, req.id, req.Description) if err != nil { return nil, err } @@ -74,7 +74,7 @@ func updateDescriptionEndpoint(svc auth.Service) endpoint.Endpoint { } } -func listEndpoint(svc auth.Service) endpoint.Endpoint { +func listPATSEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(listPatsReq) if err := req.validate(); err != nil { @@ -85,7 +85,7 @@ func listEndpoint(svc auth.Service) endpoint.Endpoint { Limit: req.limit, Offset: req.offset, } - patsPage, err := svc.List(ctx, req.token, pm) + patsPage, err := svc.ListPATS(ctx, req.token, pm) if err != nil { return nil, err } @@ -94,14 +94,14 @@ func listEndpoint(svc auth.Service) endpoint.Endpoint { } } -func deleteEndpoint(svc auth.Service) endpoint.Endpoint { +func deletePATEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(deletePatReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.Delete(ctx, req.token, req.id); err != nil { + if err := svc.DeletePAT(ctx, req.token, req.id); err != nil { return nil, err } @@ -109,14 +109,14 @@ func deleteEndpoint(svc auth.Service) endpoint.Endpoint { } } -func resetSecretEndpoint(svc auth.Service) endpoint.Endpoint { +func resetPATSecretEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(resetPatSecretReq) if err := req.validate(); err != nil { return nil, err } - pat, err := svc.ResetSecret(ctx, req.token, req.id, req.Duration) + pat, err := svc.ResetPATSecret(ctx, req.token, req.id, req.Duration) if err != nil { return nil, err } @@ -125,14 +125,14 @@ func resetSecretEndpoint(svc auth.Service) endpoint.Endpoint { } } -func revokeSecretEndpoint(svc auth.Service) endpoint.Endpoint { +func revokePATSecretEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(revokePatSecretReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.RevokeSecret(ctx, req.token, req.id); err != nil { + if err := svc.RevokePATSecret(ctx, req.token, req.id); err != nil { return nil, err } @@ -140,14 +140,14 @@ func revokeSecretEndpoint(svc auth.Service) endpoint.Endpoint { } } -func addScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { +func addPATScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(addPatScopeEntryReq) if err := req.validate(); err != nil { return nil, err } - scope, err := svc.AddScopeEntry(ctx, req.token, req.id, req.PlatformEntityType, req.OptionalDomainID, req.OptionalDomainEntityType, req.Operation, req.EntityIDs...) + scope, err := svc.AddPATScopeEntry(ctx, req.token, req.id, req.PlatformEntityType, req.OptionalDomainID, req.OptionalDomainEntityType, req.Operation, req.EntityIDs...) if err != nil { return nil, err } @@ -156,14 +156,14 @@ func addScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { } } -func removeScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { +func removePATScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(removePatScopeEntryReq) if err := req.validate(); err != nil { return nil, err } - scope, err := svc.RemoveScopeEntry(ctx, req.token, req.id, req.PlatformEntityType, req.OptionalDomainID, req.OptionalDomainEntityType, req.Operation, req.EntityIDs...) + scope, err := svc.RemovePATScopeEntry(ctx, req.token, req.id, req.PlatformEntityType, req.OptionalDomainID, req.OptionalDomainEntityType, req.Operation, req.EntityIDs...) if err != nil { return nil, err } @@ -172,14 +172,14 @@ func removeScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { } -func clearAllScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { +func clearPATAllScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(clearAllScopeEntryReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.ClearAllScopeEntry(ctx, req.token, req.id); err != nil { + if err := svc.ClearPATAllScopeEntry(ctx, req.token, req.id); err != nil { return nil, err } @@ -187,14 +187,14 @@ func clearAllScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { } } -func testCheckScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { +func testCheckPATScopeEntryEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(testCheckPatScopeReq) if err := req.validate(); err != nil { return nil, err } - if err := svc.TestCheckScopeEntry(ctx, req.token, req.PlatformEntityType, req.OptionalDomainID, req.OptionalDomainEntityType, req.Operation, req.EntityIDs...); err != nil { + if err := svc.TestCheckPATScopeEntry(ctx, req.token, req.PlatformEntityType, req.OptionalDomainID, req.OptionalDomainEntityType, req.Operation, req.EntityIDs...); err != nil { return nil, err } diff --git a/auth/api/http/pats/requests.go b/auth/api/http/pats/requests.go index 07240674123..44ce84c988f 100644 --- a/auth/api/http/pats/requests.go +++ b/auth/api/http/pats/requests.go @@ -9,7 +9,7 @@ import ( "time" "github.com/absmach/magistrala/auth" - "github.com/absmach/magistrala/internal/apiutil" + "github.com/absmach/magistrala/pkg/apiutil" "github.com/absmach/magistrala/pkg/errors" ) diff --git a/auth/api/http/pats/transport.go b/auth/api/http/pats/transport.go index d1ce3190cd8..e32180ebd19 100644 --- a/auth/api/http/pats/transport.go +++ b/auth/api/http/pats/transport.go @@ -12,7 +12,7 @@ import ( "github.com/absmach/magistrala/auth" "github.com/absmach/magistrala/internal/api" - "github.com/absmach/magistrala/internal/apiutil" + "github.com/absmach/magistrala/pkg/apiutil" "github.com/absmach/magistrala/pkg/errors" "github.com/go-chi/chi/v5" kithttp "github.com/go-kit/kit/transport/http" @@ -30,85 +30,85 @@ func MakeHandler(svc auth.Service, mux *chi.Mux, logger *slog.Logger) *chi.Mux { } mux.Route("/pats", func(r chi.Router) { r.Post("/", kithttp.NewServer( - createPatEndpoint(svc), - decodeCreatePatRequest, + createPATEndpoint(svc), + decodeCreatePATRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Get("/{id}", kithttp.NewServer( - (retrieveEndpoint(svc)), - decodeRetrievePatRequest, + (retrievePATEndpoint(svc)), + decodeRetrievePATRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Put("/{id}/name", kithttp.NewServer( - (updateNameEndpoint(svc)), - decodeUpdateNameRequest, + (updatePATNameEndpoint(svc)), + decodeUpdatePATNameRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Put("/{id}/description", kithttp.NewServer( - (updateDescriptionEndpoint(svc)), - decodeUpdateDescriptionRequest, + (updatePATDescriptionEndpoint(svc)), + decodeUpdatePATDescriptionRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Get("/", kithttp.NewServer( - (listEndpoint(svc)), - decodeListRequest, + (listPATSEndpoint(svc)), + decodeListPATSRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Delete("/{id}", kithttp.NewServer( - (deleteEndpoint(svc)), - decodeDeleteRequest, + (deletePATEndpoint(svc)), + decodeDeletePATRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Put("/{id}/secret/reset", kithttp.NewServer( - (resetSecretEndpoint(svc)), - decodeResetSecretRequest, + (resetPATSecretEndpoint(svc)), + decodeResetPATSecretRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Put("/{id}/secret/revoke", kithttp.NewServer( - (revokeSecretEndpoint(svc)), - decodeRevokeSecretRequest, + (revokePATSecretEndpoint(svc)), + decodeRevokePATSecretRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Put("/{id}/scope/add", kithttp.NewServer( - (addScopeEntryEndpoint(svc)), - decodeAddScopeEntryRequest, + (addPATScopeEntryEndpoint(svc)), + decodeAddPATScopeEntryRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Put("/{id}/scope/remove", kithttp.NewServer( - (removeScopeEntryEndpoint(svc)), - decodeRemoveScopeEntryRequest, + (removePATScopeEntryEndpoint(svc)), + decodeRemovePATScopeEntryRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Delete("/{id}/scope", kithttp.NewServer( - (clearAllScopeEntryEndpoint(svc)), - decodeClearAllScopeEntryRequest, + (clearPATAllScopeEntryEndpoint(svc)), + decodeClearPATAllScopeEntryRequest, api.EncodeResponse, opts..., ).ServeHTTP) r.Get("/check", kithttp.NewServer( - (testCheckScopeEntryEndpoint(svc)), - decodeTestCheckScopeEntryRequest, + (testCheckPATScopeEntryEndpoint(svc)), + decodeTestCheckPATScopeEntryRequest, api.EncodeResponse, opts..., ).ServeHTTP) @@ -116,7 +116,7 @@ func MakeHandler(svc auth.Service, mux *chi.Mux, logger *slog.Logger) *chi.Mux { return mux } -func decodeCreatePatRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeCreatePATRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -128,7 +128,7 @@ func decodeCreatePatRequest(_ context.Context, r *http.Request) (interface{}, er return req, nil } -func decodeRetrievePatRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeRetrievePATRequest(_ context.Context, r *http.Request) (interface{}, error) { req := retrievePatReq{ token: apiutil.ExtractBearerToken(r), id: chi.URLParam(r, "id"), @@ -136,7 +136,7 @@ func decodeRetrievePatRequest(_ context.Context, r *http.Request) (interface{}, return req, nil } -func decodeUpdateNameRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeUpdatePATNameRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -151,7 +151,7 @@ func decodeUpdateNameRequest(_ context.Context, r *http.Request) (interface{}, e return req, nil } -func decodeUpdateDescriptionRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeUpdatePATDescriptionRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -166,7 +166,7 @@ func decodeUpdateDescriptionRequest(_ context.Context, r *http.Request) (interfa return req, nil } -func decodeListRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeListPATSRequest(_ context.Context, r *http.Request) (interface{}, error) { l, err := apiutil.ReadNumQuery[uint64](r, api.LimitKey, api.DefLimit) if err != nil { return nil, errors.Wrap(apiutil.ErrValidation, err) @@ -186,7 +186,7 @@ func decodeListRequest(_ context.Context, r *http.Request) (interface{}, error) return req, nil } -func decodeDeleteRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeDeletePATRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -197,7 +197,7 @@ func decodeDeleteRequest(_ context.Context, r *http.Request) (interface{}, error }, nil } -func decodeResetSecretRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeResetPATSecretRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -212,7 +212,7 @@ func decodeResetSecretRequest(_ context.Context, r *http.Request) (interface{}, return req, nil } -func decodeRevokeSecretRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeRevokePATSecretRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -223,7 +223,7 @@ func decodeRevokeSecretRequest(_ context.Context, r *http.Request) (interface{}, }, nil } -func decodeAddScopeEntryRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeAddPATScopeEntryRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -238,7 +238,7 @@ func decodeAddScopeEntryRequest(_ context.Context, r *http.Request) (interface{} return req, nil } -func decodeRemoveScopeEntryRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeRemovePATScopeEntryRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -253,7 +253,7 @@ func decodeRemoveScopeEntryRequest(_ context.Context, r *http.Request) (interfac return req, nil } -func decodeClearAllScopeEntryRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeClearPATAllScopeEntryRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } @@ -264,7 +264,7 @@ func decodeClearAllScopeEntryRequest(_ context.Context, r *http.Request) (interf }, nil } -func decodeTestCheckScopeEntryRequest(_ context.Context, r *http.Request) (interface{}, error) { +func decodeTestCheckPATScopeEntryRequest(_ context.Context, r *http.Request) (interface{}, error) { if !strings.Contains(r.Header.Get("Content-Type"), contentType) { return nil, apiutil.ErrUnsupportedContentType } diff --git a/auth/api/logging.go b/auth/api/logging.go index fe984f969d9..210af379073 100644 --- a/auth/api/logging.go +++ b/auth/api/logging.go @@ -508,7 +508,7 @@ func (lm *loggingMiddleware) DeleteEntityPolicies(ctx context.Context, entityTyp return lm.svc.DeleteEntityPolicies(ctx, entityType, id) } -func (lm *loggingMiddleware) Create(ctx context.Context, token, name, description string, duration time.Duration, scope auth.Scope) (pa auth.PAT, err error) { +func (lm *loggingMiddleware) CreatePAT(ctx context.Context, token, name, description string, duration time.Duration, scope auth.Scope) (pa auth.PAT, err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -524,9 +524,9 @@ func (lm *loggingMiddleware) Create(ctx context.Context, token, name, descriptio } lm.logger.Info("Create PAT completed successfully", args...) }(time.Now()) - return lm.svc.Create(ctx, token, name, description, duration, scope) + return lm.svc.CreatePAT(ctx, token, name, description, duration, scope) } -func (lm *loggingMiddleware) UpdateName(ctx context.Context, token, patID, name string) (pa auth.PAT, err error) { +func (lm *loggingMiddleware) UpdatePATName(ctx context.Context, token, patID, name string) (pa auth.PAT, err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -540,9 +540,9 @@ func (lm *loggingMiddleware) UpdateName(ctx context.Context, token, patID, name } lm.logger.Info("Update PAT name completed successfully", args...) }(time.Now()) - return lm.svc.UpdateName(ctx, token, patID, name) + return lm.svc.UpdatePATName(ctx, token, patID, name) } -func (lm *loggingMiddleware) UpdateDescription(ctx context.Context, token, patID, description string) (pa auth.PAT, err error) { +func (lm *loggingMiddleware) UpdatePATDescription(ctx context.Context, token, patID, description string) (pa auth.PAT, err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -556,9 +556,9 @@ func (lm *loggingMiddleware) UpdateDescription(ctx context.Context, token, patID } lm.logger.Info("Update PAT description completed successfully", args...) }(time.Now()) - return lm.svc.UpdateDescription(ctx, token, patID, description) + return lm.svc.UpdatePATDescription(ctx, token, patID, description) } -func (lm *loggingMiddleware) Retrieve(ctx context.Context, token, patID string) (pa auth.PAT, err error) { +func (lm *loggingMiddleware) RetrievePAT(ctx context.Context, token, patID string) (pa auth.PAT, err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -571,9 +571,9 @@ func (lm *loggingMiddleware) Retrieve(ctx context.Context, token, patID string) } lm.logger.Info("Retrieve PAT completed successfully", args...) }(time.Now()) - return lm.svc.Retrieve(ctx, token, patID) + return lm.svc.RetrievePAT(ctx, token, patID) } -func (lm *loggingMiddleware) List(ctx context.Context, token string, pm auth.PATSPageMeta) (pp auth.PATSPage, err error) { +func (lm *loggingMiddleware) ListPATS(ctx context.Context, token string, pm auth.PATSPageMeta) (pp auth.PATSPage, err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -587,9 +587,9 @@ func (lm *loggingMiddleware) List(ctx context.Context, token string, pm auth.PAT } lm.logger.Info("List PATS completed successfully", args...) }(time.Now()) - return lm.svc.List(ctx, token, pm) + return lm.svc.ListPATS(ctx, token, pm) } -func (lm *loggingMiddleware) Delete(ctx context.Context, token, patID string) (err error) { +func (lm *loggingMiddleware) DeletePAT(ctx context.Context, token, patID string) (err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -602,9 +602,9 @@ func (lm *loggingMiddleware) Delete(ctx context.Context, token, patID string) (e } lm.logger.Info("Delete PAT completed successfully", args...) }(time.Now()) - return lm.svc.Delete(ctx, token, patID) + return lm.svc.DeletePAT(ctx, token, patID) } -func (lm *loggingMiddleware) ResetSecret(ctx context.Context, token, patID string, duration time.Duration) (pa auth.PAT, err error) { +func (lm *loggingMiddleware) ResetPATSecret(ctx context.Context, token, patID string, duration time.Duration) (pa auth.PAT, err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -618,9 +618,9 @@ func (lm *loggingMiddleware) ResetSecret(ctx context.Context, token, patID strin } lm.logger.Info("Reset PAT secret completed successfully", args...) }(time.Now()) - return lm.svc.ResetSecret(ctx, token, patID, duration) + return lm.svc.ResetPATSecret(ctx, token, patID, duration) } -func (lm *loggingMiddleware) RevokeSecret(ctx context.Context, token, patID string) (err error) { +func (lm *loggingMiddleware) RevokePATSecret(ctx context.Context, token, patID string) (err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -633,9 +633,9 @@ func (lm *loggingMiddleware) RevokeSecret(ctx context.Context, token, patID stri } lm.logger.Info("Revoke PAT secret completed successfully", args...) }(time.Now()) - return lm.svc.RevokeSecret(ctx, token, patID) + return lm.svc.RevokePATSecret(ctx, token, patID) } -func (lm *loggingMiddleware) AddScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (sc auth.Scope, err error) { +func (lm *loggingMiddleware) AddPATScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (sc auth.Scope, err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -653,9 +653,9 @@ func (lm *loggingMiddleware) AddScopeEntry(ctx context.Context, token, patID str } lm.logger.Info("Add entry to PAT scope completed successfully", args...) }(time.Now()) - return lm.svc.AddScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return lm.svc.AddPATScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } -func (lm *loggingMiddleware) RemoveScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (sc auth.Scope, err error) { +func (lm *loggingMiddleware) RemovePATScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (sc auth.Scope, err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -673,9 +673,9 @@ func (lm *loggingMiddleware) RemoveScopeEntry(ctx context.Context, token, patID } lm.logger.Info("Remove entry from PAT scope completed successfully", args...) }(time.Now()) - return lm.svc.RemoveScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return lm.svc.RemovePATScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } -func (lm *loggingMiddleware) ClearAllScopeEntry(ctx context.Context, token, patID string) (err error) { +func (lm *loggingMiddleware) ClearPATAllScopeEntry(ctx context.Context, token, patID string) (err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -688,9 +688,9 @@ func (lm *loggingMiddleware) ClearAllScopeEntry(ctx context.Context, token, patI } lm.logger.Info("Clear all entry from PAT scope completed successfully", args...) }(time.Now()) - return lm.svc.ClearAllScopeEntry(ctx, token, patID) + return lm.svc.ClearPATAllScopeEntry(ctx, token, patID) } -func (lm *loggingMiddleware) TestCheckScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (err error) { +func (lm *loggingMiddleware) TestCheckPATScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (err error) { defer func(begin time.Time) { args := []any{ slog.String("duration", time.Since(begin).String()), @@ -707,7 +707,7 @@ func (lm *loggingMiddleware) TestCheckScopeEntry(ctx context.Context, paToken st } lm.logger.Info("Test Check entry in PAT scope completed successfully", args...) }(time.Now()) - return lm.svc.TestCheckScopeEntry(ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return lm.svc.TestCheckPATScopeEntry(ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } func (lm *loggingMiddleware) IdentifyPAT(ctx context.Context, paToken string) (pa auth.PAT, err error) { defer func(begin time.Time) { diff --git a/auth/api/metrics.go b/auth/api/metrics.go index 722846ffa04..29922329c01 100644 --- a/auth/api/metrics.go +++ b/auth/api/metrics.go @@ -248,98 +248,98 @@ func (ms *metricsMiddleware) DeleteEntityPolicies(ctx context.Context, entityTyp return ms.svc.DeleteEntityPolicies(ctx, entityType, id) } -func (ms *metricsMiddleware) Create(ctx context.Context, token, name, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { +func (ms *metricsMiddleware) CreatePAT(ctx context.Context, token, name, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { defer func(begin time.Time) { ms.counter.With("method", "create_pat").Add(1) ms.latency.With("method", "create_pat").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.Create(ctx, token, name, description, duration, scope) + return ms.svc.CreatePAT(ctx, token, name, description, duration, scope) } -func (ms *metricsMiddleware) UpdateName(ctx context.Context, token, patID, name string) (auth.PAT, error) { +func (ms *metricsMiddleware) UpdatePATName(ctx context.Context, token, patID, name string) (auth.PAT, error) { defer func(begin time.Time) { ms.counter.With("method", "update_pat_name").Add(1) ms.latency.With("method", "update_pat_name").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.UpdateName(ctx, token, patID, name) + return ms.svc.UpdatePATName(ctx, token, patID, name) } -func (ms *metricsMiddleware) UpdateDescription(ctx context.Context, token, patID, description string) (auth.PAT, error) { +func (ms *metricsMiddleware) UpdatePATDescription(ctx context.Context, token, patID, description string) (auth.PAT, error) { defer func(begin time.Time) { ms.counter.With("method", "update_pat_description").Add(1) ms.latency.With("method", "update_pat_description").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.UpdateDescription(ctx, token, patID, description) + return ms.svc.UpdatePATDescription(ctx, token, patID, description) } -func (ms *metricsMiddleware) Retrieve(ctx context.Context, token, patID string) (auth.PAT, error) { +func (ms *metricsMiddleware) RetrievePAT(ctx context.Context, token, patID string) (auth.PAT, error) { defer func(begin time.Time) { ms.counter.With("method", "retrieve_pat").Add(1) ms.latency.With("method", "retrieve_pat").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.Retrieve(ctx, token, patID) + return ms.svc.RetrievePAT(ctx, token, patID) } -func (ms *metricsMiddleware) List(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { +func (ms *metricsMiddleware) ListPATS(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { defer func(begin time.Time) { ms.counter.With("method", "list_pats").Add(1) ms.latency.With("method", "list_pats").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.List(ctx, token, pm) + return ms.svc.ListPATS(ctx, token, pm) } -func (ms *metricsMiddleware) Delete(ctx context.Context, token, patID string) error { +func (ms *metricsMiddleware) DeletePAT(ctx context.Context, token, patID string) error { defer func(begin time.Time) { ms.counter.With("method", "delete_pat").Add(1) ms.latency.With("method", "delete_pat").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.Delete(ctx, token, patID) + return ms.svc.DeletePAT(ctx, token, patID) } -func (ms *metricsMiddleware) ResetSecret(ctx context.Context, token, patID string, duration time.Duration) (auth.PAT, error) { +func (ms *metricsMiddleware) ResetPATSecret(ctx context.Context, token, patID string, duration time.Duration) (auth.PAT, error) { defer func(begin time.Time) { ms.counter.With("method", "reset_pat_secret").Add(1) ms.latency.With("method", "reset_pat_secret").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.ResetSecret(ctx, token, patID, duration) + return ms.svc.ResetPATSecret(ctx, token, patID, duration) } -func (ms *metricsMiddleware) RevokeSecret(ctx context.Context, token, patID string) error { +func (ms *metricsMiddleware) RevokePATSecret(ctx context.Context, token, patID string) error { defer func(begin time.Time) { ms.counter.With("method", "revoke_pat_secret").Add(1) ms.latency.With("method", "revoke_pat_secret").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.RevokeSecret(ctx, token, patID) + return ms.svc.RevokePATSecret(ctx, token, patID) } -func (ms *metricsMiddleware) AddScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { +func (ms *metricsMiddleware) AddPATScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { defer func(begin time.Time) { ms.counter.With("method", "add_pat_scope_entry").Add(1) ms.latency.With("method", "add_pat_scope_entry").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.AddScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return ms.svc.AddPATScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } -func (ms *metricsMiddleware) RemoveScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { +func (ms *metricsMiddleware) RemovePATScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { defer func(begin time.Time) { ms.counter.With("method", "remove_pat_scope_entry").Add(1) ms.latency.With("method", "remove_pat_scope_entry").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.RemoveScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return ms.svc.RemovePATScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } -func (ms *metricsMiddleware) ClearAllScopeEntry(ctx context.Context, token, patID string) error { +func (ms *metricsMiddleware) ClearPATAllScopeEntry(ctx context.Context, token, patID string) error { defer func(begin time.Time) { ms.counter.With("method", "clear_pat_all_scope_entry").Add(1) ms.latency.With("method", "clear_pat_all_scope_entry").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.ClearAllScopeEntry(ctx, token, patID) + return ms.svc.ClearPATAllScopeEntry(ctx, token, patID) } -func (ms *metricsMiddleware) TestCheckScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { +func (ms *metricsMiddleware) TestCheckPATScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { defer func(begin time.Time) { ms.counter.With("method", "test_check_pat_scope_entry").Add(1) ms.latency.With("method", "test_check_pat_scope_entry").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.TestCheckScopeEntry(ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return ms.svc.TestCheckPATScopeEntry(ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } func (ms *metricsMiddleware) IdentifyPAT(ctx context.Context, paToken string) (auth.PAT, error) { diff --git a/auth/events/streams.go b/auth/events/streams.go index 0081a962fa2..e2d971cdad4 100644 --- a/auth/events/streams.go +++ b/auth/events/streams.go @@ -5,6 +5,7 @@ package events import ( "context" + "time" "github.com/absmach/magistrala/auth" "github.com/absmach/magistrala/pkg/events" @@ -262,3 +263,46 @@ func (es *eventStore) CountSubjects(ctx context.Context, pr auth.PolicyReq) (uin func (es *eventStore) ListPermissions(ctx context.Context, pr auth.PolicyReq, filterPermission []string) (auth.Permissions, error) { return es.svc.ListPermissions(ctx, pr, filterPermission) } + +func (es *eventStore) CreatePAT(ctx context.Context, token, name, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { + return es.svc.CreatePAT(ctx, token, name, description, duration, scope) +} +func (es *eventStore) UpdatePATName(ctx context.Context, token, patID, name string) (auth.PAT, error) { + return es.svc.UpdatePATName(ctx, token, patID, name) +} +func (es *eventStore) UpdatePATDescription(ctx context.Context, token, patID, description string) (auth.PAT, error) { + return es.svc.UpdatePATDescription(ctx, token, patID, description) +} +func (es *eventStore) RetrievePAT(ctx context.Context, token, patID string) (auth.PAT, error) { + return es.svc.RetrievePAT(ctx, token, patID) +} +func (es *eventStore) ListPATS(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { + return es.svc.ListPATS(ctx, token, pm) +} +func (es *eventStore) DeletePAT(ctx context.Context, token, patID string) error { + return es.svc.DeletePAT(ctx, token, patID) +} +func (es *eventStore) ResetPATSecret(ctx context.Context, token, patID string, duration time.Duration) (auth.PAT, error) { + return es.svc.ResetPATSecret(ctx, token, patID, duration) +} +func (es *eventStore) RevokePATSecret(ctx context.Context, token, patID string) error { + return es.svc.RevokePATSecret(ctx, token, patID) +} +func (es *eventStore) AddPATScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { + return es.svc.AddPATScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) +} +func (es *eventStore) RemovePATScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { + return es.svc.RemovePATScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) +} +func (es *eventStore) ClearPATAllScopeEntry(ctx context.Context, token, patID string) error { + return es.svc.ClearPATAllScopeEntry(ctx, token, patID) +} +func (es *eventStore) TestCheckPATScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { + return es.svc.TestCheckPATScopeEntry(ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) +} +func (es *eventStore) IdentifyPAT(ctx context.Context, paToken string) (auth.PAT, error) { + return es.svc.IdentifyPAT(ctx, paToken) +} +func (es *eventStore) AuthorizePAT(ctx context.Context, paToken string) (auth.PAT, error) { + return es.svc.AuthorizePAT(ctx, paToken) +} diff --git a/auth/mocks/pats.go b/auth/mocks/pats.go index 9f15fdf508b..3b53eaf6477 100644 --- a/auth/mocks/pats.go +++ b/auth/mocks/pats.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. // Copyright (c) Abstract Machines @@ -19,8 +19,8 @@ type PATS struct { mock.Mock } -// AddScopeEntry provides a mock function with given fields: ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs -func (_m *PATS) AddScopeEntry(ctx context.Context, token string, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { +// AddPATScopeEntry provides a mock function with given fields: ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs +func (_m *PATS) AddPATScopeEntry(ctx context.Context, token string, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { _va := make([]interface{}, len(entityIDs)) for _i := range entityIDs { _va[_i] = entityIDs[_i] @@ -31,7 +31,7 @@ func (_m *PATS) AddScopeEntry(ctx context.Context, token string, patID string, p ret := _m.Called(_ca...) if len(ret) == 0 { - panic("no return value specified for AddScopeEntry") + panic("no return value specified for AddPATScopeEntry") } var r0 auth.Scope @@ -82,12 +82,12 @@ func (_m *PATS) AuthorizePAT(ctx context.Context, paToken string) (auth.PAT, err return r0, r1 } -// ClearAllScopeEntry provides a mock function with given fields: ctx, token, patID -func (_m *PATS) ClearAllScopeEntry(ctx context.Context, token string, patID string) error { +// ClearPATAllScopeEntry provides a mock function with given fields: ctx, token, patID +func (_m *PATS) ClearPATAllScopeEntry(ctx context.Context, token string, patID string) error { ret := _m.Called(ctx, token, patID) if len(ret) == 0 { - panic("no return value specified for ClearAllScopeEntry") + panic("no return value specified for ClearPATAllScopeEntry") } var r0 error @@ -100,12 +100,12 @@ func (_m *PATS) ClearAllScopeEntry(ctx context.Context, token string, patID stri return r0 } -// Create provides a mock function with given fields: ctx, token, name, description, duration, scope -func (_m *PATS) Create(ctx context.Context, token string, name string, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { +// CreatePAT provides a mock function with given fields: ctx, token, name, description, duration, scope +func (_m *PATS) CreatePAT(ctx context.Context, token string, name string, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { ret := _m.Called(ctx, token, name, description, duration, scope) if len(ret) == 0 { - panic("no return value specified for Create") + panic("no return value specified for CreatePAT") } var r0 auth.PAT @@ -128,12 +128,12 @@ func (_m *PATS) Create(ctx context.Context, token string, name string, descripti return r0, r1 } -// Delete provides a mock function with given fields: ctx, token, patID -func (_m *PATS) Delete(ctx context.Context, token string, patID string) error { +// DeletePAT provides a mock function with given fields: ctx, token, patID +func (_m *PATS) DeletePAT(ctx context.Context, token string, patID string) error { ret := _m.Called(ctx, token, patID) if len(ret) == 0 { - panic("no return value specified for Delete") + panic("no return value specified for DeletePAT") } var r0 error @@ -174,12 +174,12 @@ func (_m *PATS) IdentifyPAT(ctx context.Context, paToken string) (auth.PAT, erro return r0, r1 } -// List provides a mock function with given fields: ctx, token, pm -func (_m *PATS) List(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { +// ListPATS provides a mock function with given fields: ctx, token, pm +func (_m *PATS) ListPATS(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { ret := _m.Called(ctx, token, pm) if len(ret) == 0 { - panic("no return value specified for List") + panic("no return value specified for ListPATS") } var r0 auth.PATSPage @@ -202,8 +202,8 @@ func (_m *PATS) List(ctx context.Context, token string, pm auth.PATSPageMeta) (a return r0, r1 } -// RemoveScopeEntry provides a mock function with given fields: ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs -func (_m *PATS) RemoveScopeEntry(ctx context.Context, token string, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { +// RemovePATScopeEntry provides a mock function with given fields: ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs +func (_m *PATS) RemovePATScopeEntry(ctx context.Context, token string, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { _va := make([]interface{}, len(entityIDs)) for _i := range entityIDs { _va[_i] = entityIDs[_i] @@ -214,7 +214,7 @@ func (_m *PATS) RemoveScopeEntry(ctx context.Context, token string, patID string ret := _m.Called(_ca...) if len(ret) == 0 { - panic("no return value specified for RemoveScopeEntry") + panic("no return value specified for RemovePATScopeEntry") } var r0 auth.Scope @@ -237,12 +237,12 @@ func (_m *PATS) RemoveScopeEntry(ctx context.Context, token string, patID string return r0, r1 } -// ResetSecret provides a mock function with given fields: ctx, token, patID, duration -func (_m *PATS) ResetSecret(ctx context.Context, token string, patID string, duration time.Duration) (auth.PAT, error) { +// ResetPATSecret provides a mock function with given fields: ctx, token, patID, duration +func (_m *PATS) ResetPATSecret(ctx context.Context, token string, patID string, duration time.Duration) (auth.PAT, error) { ret := _m.Called(ctx, token, patID, duration) if len(ret) == 0 { - panic("no return value specified for ResetSecret") + panic("no return value specified for ResetPATSecret") } var r0 auth.PAT @@ -265,12 +265,12 @@ func (_m *PATS) ResetSecret(ctx context.Context, token string, patID string, dur return r0, r1 } -// Retrieve provides a mock function with given fields: ctx, token, patID -func (_m *PATS) Retrieve(ctx context.Context, token string, patID string) (auth.PAT, error) { +// RetrievePAT provides a mock function with given fields: ctx, token, patID +func (_m *PATS) RetrievePAT(ctx context.Context, token string, patID string) (auth.PAT, error) { ret := _m.Called(ctx, token, patID) if len(ret) == 0 { - panic("no return value specified for Retrieve") + panic("no return value specified for RetrievePAT") } var r0 auth.PAT @@ -293,12 +293,12 @@ func (_m *PATS) Retrieve(ctx context.Context, token string, patID string) (auth. return r0, r1 } -// RevokeSecret provides a mock function with given fields: ctx, token, patID -func (_m *PATS) RevokeSecret(ctx context.Context, token string, patID string) error { +// RevokePATSecret provides a mock function with given fields: ctx, token, patID +func (_m *PATS) RevokePATSecret(ctx context.Context, token string, patID string) error { ret := _m.Called(ctx, token, patID) if len(ret) == 0 { - panic("no return value specified for RevokeSecret") + panic("no return value specified for RevokePATSecret") } var r0 error @@ -311,8 +311,8 @@ func (_m *PATS) RevokeSecret(ctx context.Context, token string, patID string) er return r0 } -// TestCheckScopeEntry provides a mock function with given fields: ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs -func (_m *PATS) TestCheckScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { +// TestCheckPATScopeEntry provides a mock function with given fields: ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs +func (_m *PATS) TestCheckPATScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { _va := make([]interface{}, len(entityIDs)) for _i := range entityIDs { _va[_i] = entityIDs[_i] @@ -323,7 +323,7 @@ func (_m *PATS) TestCheckScopeEntry(ctx context.Context, paToken string, platfor ret := _m.Called(_ca...) if len(ret) == 0 { - panic("no return value specified for TestCheckScopeEntry") + panic("no return value specified for TestCheckPATScopeEntry") } var r0 error @@ -336,12 +336,12 @@ func (_m *PATS) TestCheckScopeEntry(ctx context.Context, paToken string, platfor return r0 } -// UpdateDescription provides a mock function with given fields: ctx, token, patID, description -func (_m *PATS) UpdateDescription(ctx context.Context, token string, patID string, description string) (auth.PAT, error) { +// UpdatePATDescription provides a mock function with given fields: ctx, token, patID, description +func (_m *PATS) UpdatePATDescription(ctx context.Context, token string, patID string, description string) (auth.PAT, error) { ret := _m.Called(ctx, token, patID, description) if len(ret) == 0 { - panic("no return value specified for UpdateDescription") + panic("no return value specified for UpdatePATDescription") } var r0 auth.PAT @@ -364,12 +364,12 @@ func (_m *PATS) UpdateDescription(ctx context.Context, token string, patID strin return r0, r1 } -// UpdateName provides a mock function with given fields: ctx, token, patID, name -func (_m *PATS) UpdateName(ctx context.Context, token string, patID string, name string) (auth.PAT, error) { +// UpdatePATName provides a mock function with given fields: ctx, token, patID, name +func (_m *PATS) UpdatePATName(ctx context.Context, token string, patID string, name string) (auth.PAT, error) { ret := _m.Called(ctx, token, patID, name) if len(ret) == 0 { - panic("no return value specified for UpdateName") + panic("no return value specified for UpdatePATName") } var r0 auth.PAT diff --git a/auth/mocks/patsrepo.go b/auth/mocks/patsrepo.go index 6eca8cfc5e4..10cc48612a5 100644 --- a/auth/mocks/patsrepo.go +++ b/auth/mocks/patsrepo.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. // Copyright (c) Abstract Machines diff --git a/auth/mocks/service.go b/auth/mocks/service.go index a769e78b8e0..ccf50a34f25 100644 --- a/auth/mocks/service.go +++ b/auth/mocks/service.go @@ -19,6 +19,41 @@ type Service struct { mock.Mock } +// AddPATScopeEntry provides a mock function with given fields: ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs +func (_m *Service) AddPATScopeEntry(ctx context.Context, token string, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { + _va := make([]interface{}, len(entityIDs)) + for _i := range entityIDs { + _va[_i] = entityIDs[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for AddPATScopeEntry") + } + + var r0 auth.Scope + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.PlatformEntityType, string, auth.DomainEntityType, auth.OperationType, ...string) (auth.Scope, error)); ok { + return rf(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.PlatformEntityType, string, auth.DomainEntityType, auth.OperationType, ...string) auth.Scope); ok { + r0 = rf(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + } else { + r0 = ret.Get(0).(auth.Scope) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, auth.PlatformEntityType, string, auth.DomainEntityType, auth.OperationType, ...string) error); ok { + r1 = rf(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // AddPolicies provides a mock function with given fields: ctx, prs func (_m *Service) AddPolicies(ctx context.Context, prs []auth.PolicyReq) error { ret := _m.Called(ctx, prs) @@ -55,41 +90,6 @@ func (_m *Service) AddPolicy(ctx context.Context, pr auth.PolicyReq) error { return r0 } -// AddScopeEntry provides a mock function with given fields: ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs -func (_m *Service) AddScopeEntry(ctx context.Context, token string, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { - _va := make([]interface{}, len(entityIDs)) - for _i := range entityIDs { - _va[_i] = entityIDs[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for AddScopeEntry") - } - - var r0 auth.Scope - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.PlatformEntityType, string, auth.DomainEntityType, auth.OperationType, ...string) (auth.Scope, error)); ok { - return rf(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.PlatformEntityType, string, auth.DomainEntityType, auth.OperationType, ...string) auth.Scope); ok { - r0 = rf(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) - } else { - r0 = ret.Get(0).(auth.Scope) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, auth.PlatformEntityType, string, auth.DomainEntityType, auth.OperationType, ...string) error); ok { - r1 = rf(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // AssignUsers provides a mock function with given fields: ctx, token, id, userIds, relation func (_m *Service) AssignUsers(ctx context.Context, token string, id string, userIds []string, relation string) error { ret := _m.Called(ctx, token, id, userIds, relation) @@ -182,12 +182,12 @@ func (_m *Service) ChangeDomainStatus(ctx context.Context, token string, id stri return r0, r1 } -// ClearAllScopeEntry provides a mock function with given fields: ctx, token, patID -func (_m *Service) ClearAllScopeEntry(ctx context.Context, token string, patID string) error { +// ClearPATAllScopeEntry provides a mock function with given fields: ctx, token, patID +func (_m *Service) ClearPATAllScopeEntry(ctx context.Context, token string, patID string) error { ret := _m.Called(ctx, token, patID) if len(ret) == 0 { - panic("no return value specified for ClearAllScopeEntry") + panic("no return value specified for ClearPATAllScopeEntry") } var r0 error @@ -256,27 +256,27 @@ func (_m *Service) CountSubjects(ctx context.Context, pr auth.PolicyReq) (uint64 return r0, r1 } -// Create provides a mock function with given fields: ctx, token, name, description, duration, scope -func (_m *Service) Create(ctx context.Context, token string, name string, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { - ret := _m.Called(ctx, token, name, description, duration, scope) +// CreateDomain provides a mock function with given fields: ctx, token, d +func (_m *Service) CreateDomain(ctx context.Context, token string, d auth.Domain) (auth.Domain, error) { + ret := _m.Called(ctx, token, d) if len(ret) == 0 { - panic("no return value specified for Create") + panic("no return value specified for CreateDomain") } - var r0 auth.PAT + var r0 auth.Domain var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string, time.Duration, auth.Scope) (auth.PAT, error)); ok { - return rf(ctx, token, name, description, duration, scope) + if rf, ok := ret.Get(0).(func(context.Context, string, auth.Domain) (auth.Domain, error)); ok { + return rf(ctx, token, d) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string, time.Duration, auth.Scope) auth.PAT); ok { - r0 = rf(ctx, token, name, description, duration, scope) + if rf, ok := ret.Get(0).(func(context.Context, string, auth.Domain) auth.Domain); ok { + r0 = rf(ctx, token, d) } else { - r0 = ret.Get(0).(auth.PAT) + r0 = ret.Get(0).(auth.Domain) } - if rf, ok := ret.Get(1).(func(context.Context, string, string, string, time.Duration, auth.Scope) error); ok { - r1 = rf(ctx, token, name, description, duration, scope) + if rf, ok := ret.Get(1).(func(context.Context, string, auth.Domain) error); ok { + r1 = rf(ctx, token, d) } else { r1 = ret.Error(1) } @@ -284,27 +284,27 @@ func (_m *Service) Create(ctx context.Context, token string, name string, descri return r0, r1 } -// CreateDomain provides a mock function with given fields: ctx, token, d -func (_m *Service) CreateDomain(ctx context.Context, token string, d auth.Domain) (auth.Domain, error) { - ret := _m.Called(ctx, token, d) +// CreatePAT provides a mock function with given fields: ctx, token, name, description, duration, scope +func (_m *Service) CreatePAT(ctx context.Context, token string, name string, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { + ret := _m.Called(ctx, token, name, description, duration, scope) if len(ret) == 0 { - panic("no return value specified for CreateDomain") + panic("no return value specified for CreatePAT") } - var r0 auth.Domain + var r0 auth.PAT var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, auth.Domain) (auth.Domain, error)); ok { - return rf(ctx, token, d) + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, time.Duration, auth.Scope) (auth.PAT, error)); ok { + return rf(ctx, token, name, description, duration, scope) } - if rf, ok := ret.Get(0).(func(context.Context, string, auth.Domain) auth.Domain); ok { - r0 = rf(ctx, token, d) + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, time.Duration, auth.Scope) auth.PAT); ok { + r0 = rf(ctx, token, name, description, duration, scope) } else { - r0 = ret.Get(0).(auth.Domain) + r0 = ret.Get(0).(auth.PAT) } - if rf, ok := ret.Get(1).(func(context.Context, string, auth.Domain) error); ok { - r1 = rf(ctx, token, d) + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, time.Duration, auth.Scope) error); ok { + r1 = rf(ctx, token, name, description, duration, scope) } else { r1 = ret.Error(1) } @@ -330,12 +330,12 @@ func (_m *Service) DeleteEntityPolicies(ctx context.Context, entityType string, return r0 } -// Delete provides a mock function with given fields: ctx, token, patID -func (_m *Service) Delete(ctx context.Context, token string, patID string) error { +// DeletePAT provides a mock function with given fields: ctx, token, patID +func (_m *Service) DeletePAT(ctx context.Context, token string, patID string) error { ret := _m.Called(ctx, token, patID) if len(ret) == 0 { - panic("no return value specified for Delete") + panic("no return value specified for DeletePAT") } var r0 error @@ -468,34 +468,6 @@ func (_m *Service) Issue(ctx context.Context, token string, key auth.Key) (auth. return r0, r1 } -// List provides a mock function with given fields: ctx, token, pm -func (_m *Service) List(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { - ret := _m.Called(ctx, token, pm) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 auth.PATSPage - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, auth.PATSPageMeta) (auth.PATSPage, error)); ok { - return rf(ctx, token, pm) - } - if rf, ok := ret.Get(0).(func(context.Context, string, auth.PATSPageMeta) auth.PATSPage); ok { - r0 = rf(ctx, token, pm) - } else { - r0 = ret.Get(0).(auth.PATSPage) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, auth.PATSPageMeta) error); ok { - r1 = rf(ctx, token, pm) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // ListAllObjects provides a mock function with given fields: ctx, pr func (_m *Service) ListAllObjects(ctx context.Context, pr auth.PolicyReq) (auth.PolicyPage, error) { ret := _m.Called(ctx, pr) @@ -608,6 +580,34 @@ func (_m *Service) ListObjects(ctx context.Context, pr auth.PolicyReq, nextPageT return r0, r1 } +// ListPATS provides a mock function with given fields: ctx, token, pm +func (_m *Service) ListPATS(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { + ret := _m.Called(ctx, token, pm) + + if len(ret) == 0 { + panic("no return value specified for ListPATS") + } + + var r0 auth.PATSPage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, auth.PATSPageMeta) (auth.PATSPage, error)); ok { + return rf(ctx, token, pm) + } + if rf, ok := ret.Get(0).(func(context.Context, string, auth.PATSPageMeta) auth.PATSPage); ok { + r0 = rf(ctx, token, pm) + } else { + r0 = ret.Get(0).(auth.PATSPage) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, auth.PATSPageMeta) error); ok { + r1 = rf(ctx, token, pm) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // ListPermissions provides a mock function with given fields: ctx, pr, filterPermission func (_m *Service) ListPermissions(ctx context.Context, pr auth.PolicyReq, filterPermission []string) (auth.Permissions, error) { ret := _m.Called(ctx, pr, filterPermission) @@ -694,8 +694,8 @@ func (_m *Service) ListUserDomains(ctx context.Context, token string, userID str return r0, r1 } -// RemoveScopeEntry provides a mock function with given fields: ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs -func (_m *Service) RemoveScopeEntry(ctx context.Context, token string, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { +// RemovePATScopeEntry provides a mock function with given fields: ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs +func (_m *Service) RemovePATScopeEntry(ctx context.Context, token string, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { _va := make([]interface{}, len(entityIDs)) for _i := range entityIDs { _va[_i] = entityIDs[_i] @@ -706,7 +706,7 @@ func (_m *Service) RemoveScopeEntry(ctx context.Context, token string, patID str ret := _m.Called(_ca...) if len(ret) == 0 { - panic("no return value specified for RemoveScopeEntry") + panic("no return value specified for RemovePATScopeEntry") } var r0 auth.Scope @@ -729,12 +729,12 @@ func (_m *Service) RemoveScopeEntry(ctx context.Context, token string, patID str return r0, r1 } -// ResetSecret provides a mock function with given fields: ctx, token, patID, duration -func (_m *Service) ResetSecret(ctx context.Context, token string, patID string, duration time.Duration) (auth.PAT, error) { +// ResetPATSecret provides a mock function with given fields: ctx, token, patID, duration +func (_m *Service) ResetPATSecret(ctx context.Context, token string, patID string, duration time.Duration) (auth.PAT, error) { ret := _m.Called(ctx, token, patID, duration) if len(ret) == 0 { - panic("no return value specified for ResetSecret") + panic("no return value specified for ResetPATSecret") } var r0 auth.PAT @@ -757,34 +757,6 @@ func (_m *Service) ResetSecret(ctx context.Context, token string, patID string, return r0, r1 } -// Retrieve provides a mock function with given fields: ctx, token, patID -func (_m *Service) Retrieve(ctx context.Context, token string, patID string) (auth.PAT, error) { - ret := _m.Called(ctx, token, patID) - - if len(ret) == 0 { - panic("no return value specified for Retrieve") - } - - var r0 auth.PAT - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (auth.PAT, error)); ok { - return rf(ctx, token, patID) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) auth.PAT); ok { - r0 = rf(ctx, token, patID) - } else { - r0 = ret.Get(0).(auth.PAT) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, token, patID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // RetrieveDomain provides a mock function with given fields: ctx, token, id func (_m *Service) RetrieveDomain(ctx context.Context, token string, id string) (auth.Domain, error) { ret := _m.Called(ctx, token, id) @@ -871,60 +843,45 @@ func (_m *Service) RetrieveKey(ctx context.Context, token string, id string) (au return r0, r1 } -// Revoke provides a mock function with given fields: ctx, token, id -func (_m *Service) Revoke(ctx context.Context, token string, id string) error { - ret := _m.Called(ctx, token, id) +// RetrievePAT provides a mock function with given fields: ctx, token, patID +func (_m *Service) RetrievePAT(ctx context.Context, token string, patID string) (auth.PAT, error) { + ret := _m.Called(ctx, token, patID) if len(ret) == 0 { - panic("no return value specified for Revoke") + panic("no return value specified for RetrievePAT") } - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, token, id) - } else { - r0 = ret.Error(0) + var r0 auth.PAT + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (auth.PAT, error)); ok { + return rf(ctx, token, patID) } - - return r0 -} - -// RevokeSecret provides a mock function with given fields: ctx, token, patID -func (_m *Service) RevokeSecret(ctx context.Context, token string, patID string) error { - ret := _m.Called(ctx, token, patID) - - if len(ret) == 0 { - panic("no return value specified for RevokeSecret") + if rf, ok := ret.Get(0).(func(context.Context, string, string) auth.PAT); ok { + r0 = rf(ctx, token, patID) + } else { + r0 = ret.Get(0).(auth.PAT) } - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, token, patID) + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, token, patID) } else { - r0 = ret.Error(0) + r1 = ret.Error(1) } - return r0 + return r0, r1 } -// TestCheckScopeEntry provides a mock function with given fields: ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs -func (_m *Service) TestCheckScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { - _va := make([]interface{}, len(entityIDs)) - for _i := range entityIDs { - _va[_i] = entityIDs[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) +// Revoke provides a mock function with given fields: ctx, token, id +func (_m *Service) Revoke(ctx context.Context, token string, id string) error { + ret := _m.Called(ctx, token, id) if len(ret) == 0 { - panic("no return value specified for TestCheckScopeEntry") + panic("no return value specified for Revoke") } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, auth.PlatformEntityType, string, auth.DomainEntityType, auth.OperationType, ...string) error); ok { - r0 = rf(ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, token, id) } else { r0 = ret.Error(0) } @@ -932,12 +889,12 @@ func (_m *Service) TestCheckScopeEntry(ctx context.Context, paToken string, plat return r0 } -// RevokeSecret provides a mock function with given fields: ctx, token, patID -func (_m *Service) RevokeSecret(ctx context.Context, token string, patID string) error { +// RevokePATSecret provides a mock function with given fields: ctx, token, patID +func (_m *Service) RevokePATSecret(ctx context.Context, token string, patID string) error { ret := _m.Called(ctx, token, patID) if len(ret) == 0 { - panic("no return value specified for RevokeSecret") + panic("no return value specified for RevokePATSecret") } var r0 error @@ -950,8 +907,8 @@ func (_m *Service) RevokeSecret(ctx context.Context, token string, patID string) return r0 } -// TestCheckScope provides a mock function with given fields: ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs -func (_m *Service) TestCheckScope(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { +// TestCheckPATScopeEntry provides a mock function with given fields: ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs +func (_m *Service) TestCheckPATScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { _va := make([]interface{}, len(entityIDs)) for _i := range entityIDs { _va[_i] = entityIDs[_i] @@ -962,7 +919,7 @@ func (_m *Service) TestCheckScope(ctx context.Context, paToken string, platformE ret := _m.Called(_ca...) if len(ret) == 0 { - panic("no return value specified for TestCheckScope") + panic("no return value specified for TestCheckPATScopeEntry") } var r0 error @@ -993,27 +950,27 @@ func (_m *Service) UnassignUser(ctx context.Context, token string, id string, us return r0 } -// UpdateDescription provides a mock function with given fields: ctx, token, patID, description -func (_m *Service) UpdateDescription(ctx context.Context, token string, patID string, description string) (auth.PAT, error) { - ret := _m.Called(ctx, token, patID, description) +// UpdateDomain provides a mock function with given fields: ctx, token, id, d +func (_m *Service) UpdateDomain(ctx context.Context, token string, id string, d auth.DomainReq) (auth.Domain, error) { + ret := _m.Called(ctx, token, id, d) if len(ret) == 0 { - panic("no return value specified for UpdateDescription") + panic("no return value specified for UpdateDomain") } - var r0 auth.PAT + var r0 auth.Domain var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (auth.PAT, error)); ok { - return rf(ctx, token, patID, description) + if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.DomainReq) (auth.Domain, error)); ok { + return rf(ctx, token, id, d) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) auth.PAT); ok { - r0 = rf(ctx, token, patID, description) + if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.DomainReq) auth.Domain); ok { + r0 = rf(ctx, token, id, d) } else { - r0 = ret.Get(0).(auth.PAT) + r0 = ret.Get(0).(auth.Domain) } - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, token, patID, description) + if rf, ok := ret.Get(1).(func(context.Context, string, string, auth.DomainReq) error); ok { + r1 = rf(ctx, token, id, d) } else { r1 = ret.Error(1) } @@ -1021,27 +978,27 @@ func (_m *Service) UpdateDescription(ctx context.Context, token string, patID st return r0, r1 } -// UpdateDomain provides a mock function with given fields: ctx, token, id, d -func (_m *Service) UpdateDomain(ctx context.Context, token string, id string, d auth.DomainReq) (auth.Domain, error) { - ret := _m.Called(ctx, token, id, d) +// UpdatePATDescription provides a mock function with given fields: ctx, token, patID, description +func (_m *Service) UpdatePATDescription(ctx context.Context, token string, patID string, description string) (auth.PAT, error) { + ret := _m.Called(ctx, token, patID, description) if len(ret) == 0 { - panic("no return value specified for UpdateDomain") + panic("no return value specified for UpdatePATDescription") } - var r0 auth.Domain + var r0 auth.PAT var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.DomainReq) (auth.Domain, error)); ok { - return rf(ctx, token, id, d) + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (auth.PAT, error)); ok { + return rf(ctx, token, patID, description) } - if rf, ok := ret.Get(0).(func(context.Context, string, string, auth.DomainReq) auth.Domain); ok { - r0 = rf(ctx, token, id, d) + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) auth.PAT); ok { + r0 = rf(ctx, token, patID, description) } else { - r0 = ret.Get(0).(auth.Domain) + r0 = ret.Get(0).(auth.PAT) } - if rf, ok := ret.Get(1).(func(context.Context, string, string, auth.DomainReq) error); ok { - r1 = rf(ctx, token, id, d) + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, token, patID, description) } else { r1 = ret.Error(1) } @@ -1049,12 +1006,12 @@ func (_m *Service) UpdateDomain(ctx context.Context, token string, id string, d return r0, r1 } -// UpdateName provides a mock function with given fields: ctx, token, patID, name -func (_m *Service) UpdateName(ctx context.Context, token string, patID string, name string) (auth.PAT, error) { +// UpdatePATName provides a mock function with given fields: ctx, token, patID, name +func (_m *Service) UpdatePATName(ctx context.Context, token string, patID string, name string) (auth.PAT, error) { ret := _m.Called(ctx, token, patID, name) if len(ret) == 0 { - panic("no return value specified for UpdateName") + panic("no return value specified for UpdatePATName") } var r0 auth.PAT diff --git a/auth/pat.go b/auth/pat.go index a669a276410..ddf70a0d9af 100644 --- a/auth/pat.go +++ b/auth/pat.go @@ -657,40 +657,40 @@ func (pat PAT) Expired() bool { type PATS interface { // Create function creates new PAT for given valid inputs. - Create(ctx context.Context, token, name, description string, duration time.Duration, scope Scope) (PAT, error) + CreatePAT(ctx context.Context, token, name, description string, duration time.Duration, scope Scope) (PAT, error) // UpdateName function updates the name for the given PAT ID. - UpdateName(ctx context.Context, token, patID, name string) (PAT, error) + UpdatePATName(ctx context.Context, token, patID, name string) (PAT, error) // UpdateDescription function updates the description for the given PAT ID. - UpdateDescription(ctx context.Context, token, patID, description string) (PAT, error) + UpdatePATDescription(ctx context.Context, token, patID, description string) (PAT, error) // Retrieve function retrieves the PAT for given ID. - Retrieve(ctx context.Context, token, patID string) (PAT, error) + RetrievePAT(ctx context.Context, token, patID string) (PAT, error) // List function lists all the PATs for the user. - List(ctx context.Context, token string, pm PATSPageMeta) (PATSPage, error) + ListPATS(ctx context.Context, token string, pm PATSPageMeta) (PATSPage, error) // Delete function deletes the PAT for given ID. - Delete(ctx context.Context, token, patID string) error + DeletePAT(ctx context.Context, token, patID string) error // ResetSecret function reset the secret and creates new secret for the given ID. - ResetSecret(ctx context.Context, token, patID string, duration time.Duration) (PAT, error) + ResetPATSecret(ctx context.Context, token, patID string, duration time.Duration) (PAT, error) // RevokeSecret function revokes the secret for the given ID. - RevokeSecret(ctx context.Context, token, patID string) error + RevokePATSecret(ctx context.Context, token, patID string) error // AddScope function adds a new scope entry. - AddScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error) + AddPATScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error) // RemoveScope function removes a scope entry. - RemoveScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error) + RemovePATScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error) // ClearAllScope function removes all scope entry. - ClearAllScopeEntry(ctx context.Context, token, patID string) error + ClearPATAllScopeEntry(ctx context.Context, token, patID string) error // This will be removed during PR merge. TestCheckScope will check the given scope exists. - TestCheckScopeEntry(ctx context.Context, paToken string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) error + TestCheckPATScopeEntry(ctx context.Context, paToken string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) error // IdentifyPAT function will valid the secret. IdentifyPAT(ctx context.Context, paToken string) (PAT, error) diff --git a/auth/service.go b/auth/service.go index e42fee9697f..eedad5ac366 100644 --- a/auth/service.go +++ b/auth/service.go @@ -1083,7 +1083,7 @@ func (svc service) DeleteEntityPolicies(ctx context.Context, entityType, id stri } } -func (svc service) Create(ctx context.Context, token, name, description string, duration time.Duration, scope Scope) (PAT, error) { +func (svc service) CreatePAT(ctx context.Context, token, name, description string, duration time.Duration, scope Scope) (PAT, error) { key, err := svc.Identify(ctx, token) if err != nil { return PAT{}, err @@ -1098,7 +1098,7 @@ func (svc service) Create(ctx context.Context, token, name, description string, return pat, nil } -func (svc service) UpdateName(ctx context.Context, token, patID, name string) (PAT, error) { +func (svc service) UpdatePATName(ctx context.Context, token, patID, name string) (PAT, error) { key, err := svc.Identify(ctx, token) if err != nil { return PAT{}, err @@ -1109,7 +1109,7 @@ func (svc service) UpdateName(ctx context.Context, token, patID, name string) (P } return pat, nil } -func (svc service) UpdateDescription(ctx context.Context, token, patID, description string) (PAT, error) { +func (svc service) UpdatePATDescription(ctx context.Context, token, patID, description string) (PAT, error) { key, err := svc.Identify(ctx, token) if err != nil { return PAT{}, err @@ -1120,7 +1120,7 @@ func (svc service) UpdateDescription(ctx context.Context, token, patID, descript } return pat, nil } -func (svc service) Retrieve(ctx context.Context, token, patID string) (PAT, error) { +func (svc service) RetrievePAT(ctx context.Context, token, patID string) (PAT, error) { key, err := svc.Identify(ctx, token) if err != nil { return PAT{}, err @@ -1132,7 +1132,7 @@ func (svc service) Retrieve(ctx context.Context, token, patID string) (PAT, erro } return pat, nil } -func (svc service) List(ctx context.Context, token string, pm PATSPageMeta) (PATSPage, error) { +func (svc service) ListPATS(ctx context.Context, token string, pm PATSPageMeta) (PATSPage, error) { key, err := svc.Identify(ctx, token) if err != nil { return PATSPage{}, err @@ -1143,7 +1143,7 @@ func (svc service) List(ctx context.Context, token string, pm PATSPageMeta) (PAT } return patsPage, nil } -func (svc service) Delete(ctx context.Context, token, patID string) error { +func (svc service) DeletePAT(ctx context.Context, token, patID string) error { key, err := svc.Identify(ctx, token) if err != nil { return err @@ -1153,7 +1153,7 @@ func (svc service) Delete(ctx context.Context, token, patID string) error { } return nil } -func (svc service) ResetSecret(ctx context.Context, token, patID string, duration time.Duration) (PAT, error) { +func (svc service) ResetPATSecret(ctx context.Context, token, patID string, duration time.Duration) (PAT, error) { key, err := svc.Identify(ctx, token) if err != nil { return PAT{}, err @@ -1169,7 +1169,7 @@ func (svc service) ResetSecret(ctx context.Context, token, patID string, duratio } return pat, nil } -func (svc service) RevokeSecret(ctx context.Context, token, patID string) error { +func (svc service) RevokePATSecret(ctx context.Context, token, patID string) error { key, err := svc.Identify(ctx, token) if err != nil { return err @@ -1181,7 +1181,7 @@ func (svc service) RevokeSecret(ctx context.Context, token, patID string) error return nil } -func (svc service) AddScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error) { +func (svc service) AddPATScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error) { key, err := svc.Identify(ctx, token) if err != nil { return Scope{}, err @@ -1193,7 +1193,7 @@ func (svc service) AddScopeEntry(ctx context.Context, token, patID string, platf } return scope, nil } -func (svc service) RemoveScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error) { +func (svc service) RemovePATScopeEntry(ctx context.Context, token, patID string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) (Scope, error) { key, err := svc.Identify(ctx, token) if err != nil { return Scope{}, err @@ -1204,7 +1204,7 @@ func (svc service) RemoveScopeEntry(ctx context.Context, token, patID string, pl } return scope, nil } -func (svc service) ClearAllScopeEntry(ctx context.Context, token, patID string) error { +func (svc service) ClearPATAllScopeEntry(ctx context.Context, token, patID string) error { key, err := svc.Identify(ctx, token) if err != nil { return err @@ -1215,7 +1215,7 @@ func (svc service) ClearAllScopeEntry(ctx context.Context, token, patID string) return nil } -func (svc service) TestCheckScopeEntry(ctx context.Context, paToken string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) error { +func (svc service) TestCheckPATScopeEntry(ctx context.Context, paToken string, platformEntityType PlatformEntityType, optionalDomainID string, optionalDomainEntityType DomainEntityType, operation OperationType, entityIDs ...string) error { res, err := svc.IdentifyPAT(ctx, paToken) if err != nil { return err diff --git a/auth/tracing/tracing.go b/auth/tracing/tracing.go index 455258342f1..3419abd759e 100644 --- a/auth/tracing/tracing.go +++ b/auth/tracing/tracing.go @@ -314,7 +314,7 @@ func (tm *tracingMiddleware) DeleteEntityPolicies(ctx context.Context, entityTyp return tm.svc.DeleteEntityPolicies(ctx, entityType, id) } -func (tm *tracingMiddleware) Create(ctx context.Context, token, name, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { +func (tm *tracingMiddleware) CreatePAT(ctx context.Context, token, name, description string, duration time.Duration, scope auth.Scope) (auth.PAT, error) { ctx, span := tm.tracer.Start(ctx, "create_pat", trace.WithAttributes( attribute.String("name", name), attribute.String("description", description), @@ -322,70 +322,70 @@ func (tm *tracingMiddleware) Create(ctx context.Context, token, name, descriptio attribute.String("scope", scope.String()), )) defer span.End() - return tm.svc.Create(ctx, token, name, description, duration, scope) + return tm.svc.CreatePAT(ctx, token, name, description, duration, scope) } -func (tm *tracingMiddleware) UpdateName(ctx context.Context, token, patID, name string) (auth.PAT, error) { +func (tm *tracingMiddleware) UpdatePATName(ctx context.Context, token, patID, name string) (auth.PAT, error) { ctx, span := tm.tracer.Start(ctx, "update_pat_name", trace.WithAttributes( attribute.String("pat_id", patID), attribute.String("name", name), )) defer span.End() - return tm.svc.UpdateName(ctx, token, patID, name) + return tm.svc.UpdatePATName(ctx, token, patID, name) } -func (tm *tracingMiddleware) UpdateDescription(ctx context.Context, token, patID, description string) (auth.PAT, error) { +func (tm *tracingMiddleware) UpdatePATDescription(ctx context.Context, token, patID, description string) (auth.PAT, error) { ctx, span := tm.tracer.Start(ctx, "update_pat_description", trace.WithAttributes( attribute.String("pat_id", patID), attribute.String("description", description), )) defer span.End() - return tm.svc.UpdateDescription(ctx, token, patID, description) + return tm.svc.UpdatePATDescription(ctx, token, patID, description) } -func (tm *tracingMiddleware) Retrieve(ctx context.Context, token, patID string) (auth.PAT, error) { +func (tm *tracingMiddleware) RetrievePAT(ctx context.Context, token, patID string) (auth.PAT, error) { ctx, span := tm.tracer.Start(ctx, "retrieve_pat", trace.WithAttributes( attribute.String("pat_id", patID), )) defer span.End() - return tm.svc.Retrieve(ctx, token, patID) + return tm.svc.RetrievePAT(ctx, token, patID) } -func (tm *tracingMiddleware) List(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { +func (tm *tracingMiddleware) ListPATS(ctx context.Context, token string, pm auth.PATSPageMeta) (auth.PATSPage, error) { ctx, span := tm.tracer.Start(ctx, "list_pat", trace.WithAttributes( attribute.Int64("limit", int64(pm.Limit)), attribute.Int64("offset", int64(pm.Offset)), )) defer span.End() - return tm.svc.List(ctx, token, pm) + return tm.svc.ListPATS(ctx, token, pm) } -func (tm *tracingMiddleware) Delete(ctx context.Context, token, patID string) error { +func (tm *tracingMiddleware) DeletePAT(ctx context.Context, token, patID string) error { ctx, span := tm.tracer.Start(ctx, "delete_pat", trace.WithAttributes( attribute.String("pat_id", patID), )) defer span.End() - return tm.svc.Delete(ctx, token, patID) + return tm.svc.DeletePAT(ctx, token, patID) } -func (tm *tracingMiddleware) ResetSecret(ctx context.Context, token, patID string, duration time.Duration) (auth.PAT, error) { +func (tm *tracingMiddleware) ResetPATSecret(ctx context.Context, token, patID string, duration time.Duration) (auth.PAT, error) { ctx, span := tm.tracer.Start(ctx, "reset_pat_secret", trace.WithAttributes( attribute.String("pat_id", patID), attribute.String("duration", duration.String()), )) defer span.End() - return tm.svc.ResetSecret(ctx, token, patID, duration) + return tm.svc.ResetPATSecret(ctx, token, patID, duration) } -func (tm *tracingMiddleware) RevokeSecret(ctx context.Context, token, patID string) error { +func (tm *tracingMiddleware) RevokePATSecret(ctx context.Context, token, patID string) error { ctx, span := tm.tracer.Start(ctx, "revoke_pat_secret", trace.WithAttributes( attribute.String("pat_id", patID), )) defer span.End() - return tm.svc.RevokeSecret(ctx, token, patID) + return tm.svc.RevokePATSecret(ctx, token, patID) } -func (tm *tracingMiddleware) AddScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { +func (tm *tracingMiddleware) AddPATScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { ctx, span := tm.tracer.Start(ctx, "add_pat_scope_entry", trace.WithAttributes( attribute.String("pat_id", patID), attribute.String("platform_entity", platformEntityType.String()), @@ -395,10 +395,10 @@ func (tm *tracingMiddleware) AddScopeEntry(ctx context.Context, token, patID str attribute.StringSlice("entities", entityIDs), )) defer span.End() - return tm.svc.AddScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return tm.svc.AddPATScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } -func (tm *tracingMiddleware) RemoveScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { +func (tm *tracingMiddleware) RemovePATScopeEntry(ctx context.Context, token, patID string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) (auth.Scope, error) { ctx, span := tm.tracer.Start(ctx, "remove_pat_scope_entry", trace.WithAttributes( attribute.String("pat_id", patID), attribute.String("platform_entity", platformEntityType.String()), @@ -408,18 +408,18 @@ func (tm *tracingMiddleware) RemoveScopeEntry(ctx context.Context, token, patID attribute.StringSlice("entities", entityIDs), )) defer span.End() - return tm.svc.RemoveScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return tm.svc.RemovePATScopeEntry(ctx, token, patID, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } -func (tm *tracingMiddleware) ClearAllScopeEntry(ctx context.Context, token, patID string) error { +func (tm *tracingMiddleware) ClearPATAllScopeEntry(ctx context.Context, token, patID string) error { ctx, span := tm.tracer.Start(ctx, "clear_pat_all_scope_entry", trace.WithAttributes( attribute.String("pat_id", patID), )) defer span.End() - return tm.svc.ClearAllScopeEntry(ctx, token, patID) + return tm.svc.ClearPATAllScopeEntry(ctx, token, patID) } -func (tm *tracingMiddleware) TestCheckScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { +func (tm *tracingMiddleware) TestCheckPATScopeEntry(ctx context.Context, paToken string, platformEntityType auth.PlatformEntityType, optionalDomainID string, optionalDomainEntityType auth.DomainEntityType, operation auth.OperationType, entityIDs ...string) error { ctx, span := tm.tracer.Start(ctx, "test_check_pat_scope_entry", trace.WithAttributes( attribute.String("personal_access_token", paToken), attribute.String("platform_entity", platformEntityType.String()), @@ -429,7 +429,7 @@ func (tm *tracingMiddleware) TestCheckScopeEntry(ctx context.Context, paToken st attribute.StringSlice("entities", entityIDs), )) defer span.End() - return tm.svc.TestCheckScopeEntry(ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) + return tm.svc.TestCheckPATScopeEntry(ctx, paToken, platformEntityType, optionalDomainID, optionalDomainEntityType, operation, entityIDs...) } func (tm *tracingMiddleware) IdentifyPAT(ctx context.Context, paToken string) (auth.PAT, error) { diff --git a/bootstrap/postgres/configs.go b/bootstrap/postgres/configs.go index 528f5f5456b..a30e61be36c 100644 --- a/bootstrap/postgres/configs.go +++ b/bootstrap/postgres/configs.go @@ -281,7 +281,7 @@ func (cr configRepository) Update(ctx context.Context, cfg bootstrap.Config) err } func (cr configRepository) UpdateCert(ctx context.Context, owner, thingID, clientCert, clientKey, caCert string) (bootstrap.Config, error) { - q := `UPDATE configs SET client_cert = :client_cert, client_key = :client_key, ca_cert = :ca_cert WHERE magistrala_thing = :magistrala_thing AND owner = :owner + q := `UPDATE configs SET client_cert = :client_cert, client_key = :client_key, ca_cert = :ca_cert WHERE magistrala_thing = :magistrala_thing AND owner = :owner RETURNING magistrala_thing, client_cert, client_key, ca_cert` dbcfg := dbConfig{ @@ -440,7 +440,7 @@ func (cr configRepository) UpdateChannel(ctx context.Context, c bootstrap.Channe return errors.Wrap(repoerr.ErrUpdateEntity, err) } - q := `UPDATE channels SET name = :name, metadata = :metadata, updated_at = :updated_at, updated_by = :updated_by + q := `UPDATE channels SET name = :name, metadata = :metadata, updated_at = :updated_at, updated_by = :updated_by WHERE magistrala_channel = :magistrala_channel` if _, err = cr.db.NamedExecContext(ctx, q, dbch); err != nil { return errors.Wrap(errUpdateChannels, err) diff --git a/cmd/auth/main.go b/cmd/auth/main.go index a1f103d3600..f53f41d93c3 100644 --- a/cmd/auth/main.go +++ b/cmd/auth/main.go @@ -25,11 +25,6 @@ import ( "github.com/absmach/magistrala/auth/spicedb" "github.com/absmach/magistrala/auth/tracing" boltclient "github.com/absmach/magistrala/internal/clients/bolt" - pgclient "github.com/absmach/magistrala/internal/clients/postgres" - "github.com/absmach/magistrala/internal/postgres" - "github.com/absmach/magistrala/internal/server" - grpcserver "github.com/absmach/magistrala/internal/server/grpc" - httpserver "github.com/absmach/magistrala/internal/server/http" mglog "github.com/absmach/magistrala/logger" "github.com/absmach/magistrala/pkg/jaeger" "github.com/absmach/magistrala/pkg/postgres" @@ -149,7 +144,7 @@ func main() { patsRepo := bolt.NewPATSRepository(client, boltDBConfig.Bucket) - svc := newService(db, tracer, cfg, dbConfig, logger, spicedbclient, patsRepo) + svc := newService(ctx, db, tracer, cfg, dbConfig, logger, spicedbclient, patsRepo) httpServerConfig := server.Config{Port: defSvcHTTPPort} if err := env.ParseWithOptions(&httpServerConfig, env.Options{Prefix: envPrefixHTTP}); err != nil { @@ -223,7 +218,7 @@ func initSchema(ctx context.Context, client *authzed.ClientWithExperimental, sch return nil } -func newService(db *sqlx.DB, tracer trace.Tracer, cfg config, dbConfig pgclient.Config, logger *slog.Logger, spicedbClient *authzed.ClientWithExperimental, pats auth.PATSRepository) auth.Service { +func newService(ctx context.Context, db *sqlx.DB, tracer trace.Tracer, cfg config, dbConfig pgclient.Config, logger *slog.Logger, spicedbClient *authzed.ClientWithExperimental, pats auth.PATSRepository) auth.Service { database := postgres.NewDatabase(db, dbConfig, tracer) keysRepo := apostgres.New(database) domainsRepo := apostgres.NewDomainRepository(database) diff --git a/go.mod b/go.mod index bcb4eeb6942..bb7f3c907d0 100644 --- a/go.mod +++ b/go.mod @@ -182,7 +182,7 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/otel/metric v1.26.0 // indirect + go.opentelemetry.io/otel/metric v1.27.0 // indirect go.opentelemetry.io/proto/otlp v1.2.0 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect diff --git a/go.sum b/go.sum index d223bace47c..c355952eb56 100644 --- a/go.sum +++ b/go.sum @@ -76,7 +76,6 @@ github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8Bzu github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= @@ -180,7 +179,6 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= @@ -600,8 +598,6 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201201195509-5d6afe98e0b7/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= @@ -669,8 +665,6 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= @@ -709,6 +703,7 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 h1:P8OJ/WCl/Xo4E4zoe4/bifHpSmmKwARqyqE4nW6J2GQ= google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:RGnPtTG7r4i8sPlNyDeikXF99hMM+hN6QMm4ooG9g2g= google.golang.org/genproto/googleapis/rpc v0.0.0-20240520151616-dc85e6b867a5 h1:Q2RxlXqh1cgzzUgV261vBO2jI5R/3DD1J2pM0nI4NhU= @@ -718,8 +713,18 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=