From 780a7cbeb7e4331819980a6b20a8a55e6aa61748 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Thu, 5 Oct 2023 00:37:45 +0530 Subject: [PATCH 01/27] feat(warden): added API for teamList --- internal/server/server.go | 2 + internal/server/v1/warden/handler.go | 26 ++++++++++++ internal/server/v1/warden/routes.go | 15 +++++++ internal/server/v1/warden/service.go | 60 ++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 internal/server/v1/warden/handler.go create mode 100644 internal/server/v1/warden/routes.go create mode 100644 internal/server/v1/warden/service.go diff --git a/internal/server/server.go b/internal/server/server.go index 0aa479d..a6a48e6 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -24,6 +24,7 @@ import ( kubernetesv1 "github.com/goto/dex/internal/server/v1/kubernetes" optimusv1 "github.com/goto/dex/internal/server/v1/optimus" projectsv1 "github.com/goto/dex/internal/server/v1/project" + warden "github.com/goto/dex/internal/server/v1/warden" ) // Serve initialises all the HTTP API routes, starts listening for requests at addr, and blocks until @@ -66,6 +67,7 @@ func Serve(ctx context.Context, addr string, r.Route("/dlq", dlqv1.Routes(entropyClient, gcsClient)) r.Route("/firehoses", firehosev1.Routes(entropyClient, shieldClient, alertSvc, compassClient, odinAddr, stencilAddr)) r.Route("/kubernetes", kubernetesv1.Routes(entropyClient)) + r.Route("/warden", warden.Routes()) }) logger.Info("starting server", zap.String("addr", addr)) diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/warden/handler.go new file mode 100644 index 0000000..55b5487 --- /dev/null +++ b/internal/server/v1/warden/handler.go @@ -0,0 +1,26 @@ +package warden + +import ( + "net/http" + + "github.com/goto/dex/internal/server/utils" +) + +type Handler struct { + service *Service +} + +func NewHandler(service *Service) *Handler { + return &Handler{service: service} +} + +func (h *Handler) teamList(w http.ResponseWriter, r *http.Request) { + teamListResp, err := h.service.TeamList(r.Context()) + if err != nil { + utils.WriteErr(w, err) + return + } + + utils.WriteJSON(w, http.StatusOK, teamListResp) + +} diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go new file mode 100644 index 0000000..bb39528 --- /dev/null +++ b/internal/server/v1/warden/routes.go @@ -0,0 +1,15 @@ +package warden + +import ( + chiv5 "github.com/go-chi/chi/v5" +) + +func Routes() func(r chiv5.Router) { + + service := NewService(nil) + handler := NewHandler(service) + return func(r chiv5.Router) { + + r.Get("/users/me/warden_teams", handler.teamList) + } +} diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go new file mode 100644 index 0000000..e9ce093 --- /dev/null +++ b/internal/server/v1/warden/service.go @@ -0,0 +1,60 @@ +package warden + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/google/uuid" + "github.com/goto/dex/internal/server/reqctx" +) + +const hostName = "https://go-cloud.golabs.io/api/v1/users/akarsh.satija@gojek.com/teams" + +type Service struct { + hostName string +} + +type Doer interface { + Do(req *http.Request) (*http.Response, error) +} + +func NewService(doer Doer) *Service { + return &Service{ + + hostName: hostName, + } +} + +func (c *Service) TeamList(ctx context.Context) (any, error) { + + reqCtx := reqctx.From(ctx) + + fmt.Println("Email:", reqCtx) + + resp, err := http.Get("https://go-cloud.golabs.io/api/v1/users/sudheer.pal@gojek.com/teams") + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var data any + err = json.NewDecoder(resp.Body).Decode(&data) + if err != nil { + return nil, err + } + + return data, nil + +} + +type TeamListResponse struct { + Success bool `json:"success"` + Data []Team `json:"data"` +} + +type Team struct { + Identifier uuid.UUID `json:"identifier"` + Name string `json:"name"` +} From 628335dcd9d2ac88264b6baac2f0f23b5772a2cf Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Thu, 5 Oct 2023 00:40:37 +0530 Subject: [PATCH 02/27] chore: format --- internal/server/v1/warden/handler.go | 1 - internal/server/v1/warden/routes.go | 2 -- internal/server/v1/warden/service.go | 4 +--- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/warden/handler.go index 55b5487..97e87ab 100644 --- a/internal/server/v1/warden/handler.go +++ b/internal/server/v1/warden/handler.go @@ -22,5 +22,4 @@ func (h *Handler) teamList(w http.ResponseWriter, r *http.Request) { } utils.WriteJSON(w, http.StatusOK, teamListResp) - } diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go index bb39528..e4bd0ee 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/warden/routes.go @@ -5,11 +5,9 @@ import ( ) func Routes() func(r chiv5.Router) { - service := NewService(nil) handler := NewHandler(service) return func(r chiv5.Router) { - r.Get("/users/me/warden_teams", handler.teamList) } } diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index e9ce093..b2aaee7 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -7,6 +7,7 @@ import ( "net/http" "github.com/google/uuid" + "github.com/goto/dex/internal/server/reqctx" ) @@ -22,13 +23,11 @@ type Doer interface { func NewService(doer Doer) *Service { return &Service{ - hostName: hostName, } } func (c *Service) TeamList(ctx context.Context) (any, error) { - reqCtx := reqctx.From(ctx) fmt.Println("Email:", reqCtx) @@ -46,7 +45,6 @@ func (c *Service) TeamList(ctx context.Context) (any, error) { } return data, nil - } type TeamListResponse struct { From 84f99ab079edab1ae37b2bd71104cf1aed18623b Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Thu, 5 Oct 2023 14:35:37 +0530 Subject: [PATCH 03/27] feat(warden): updated getTeam call --- go.mod | 2 +- internal/server/v1/warden/errors.go | 8 +++++ internal/server/v1/warden/handler.go | 9 ++++++ internal/server/v1/warden/routes.go | 2 +- internal/server/v1/warden/service.go | 45 +++++++++++++++++----------- 5 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 internal/server/v1/warden/errors.go diff --git a/go.mod b/go.mod index ed35962..a7f1699 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/go-openapi/strfmt v0.21.7 github.com/go-openapi/swag v0.22.4 github.com/go-openapi/validate v0.22.1 + github.com/google/uuid v1.3.1 github.com/goto/gojsondiff v0.0.0-20230828102327-0bcf3724fe2e github.com/goto/salt v0.3.3 github.com/goto/siren v0.6.6 @@ -75,7 +76,6 @@ require ( github.com/google/go-cmp v0.5.9 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/google/uuid v1.3.1 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gorilla/css v1.0.0 // indirect diff --git a/internal/server/v1/warden/errors.go b/internal/server/v1/warden/errors.go new file mode 100644 index 0000000..d4064c4 --- /dev/null +++ b/internal/server/v1/warden/errors.go @@ -0,0 +1,8 @@ +package warden + +import "errors" + +var ( + ErrTeamNotFound = errors.New("email is not registered on warden") + ErrUserNotFound = errors.New("user not authorized") +) diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/warden/handler.go index 97e87ab..ad7c415 100644 --- a/internal/server/v1/warden/handler.go +++ b/internal/server/v1/warden/handler.go @@ -16,6 +16,15 @@ func NewHandler(service *Service) *Handler { func (h *Handler) teamList(w http.ResponseWriter, r *http.Request) { teamListResp, err := h.service.TeamList(r.Context()) + + if err == ErrUserNotFound { + utils.WriteErrMsg(w, http.StatusUnauthorized, ErrUserNotFound.Error()) + return + } + if err == ErrTeamNotFound { + utils.WriteErrMsg(w, http.StatusNotFound, ErrTeamNotFound.Error()) + return + } if err != nil { utils.WriteErr(w, err) return diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go index e4bd0ee..b51dea8 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/warden/routes.go @@ -5,7 +5,7 @@ import ( ) func Routes() func(r chiv5.Router) { - service := NewService(nil) + service := NewService() handler := NewHandler(service) return func(r chiv5.Router) { r.Get("/users/me/warden_teams", handler.teamList) diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index b2aaee7..ae37fd6 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -3,7 +3,6 @@ package warden import ( "context" "encoding/json" - "fmt" "net/http" "github.com/google/uuid" @@ -11,48 +10,58 @@ import ( "github.com/goto/dex/internal/server/reqctx" ) -const hostName = "https://go-cloud.golabs.io/api/v1/users/akarsh.satija@gojek.com/teams" +const baseURL = "https://go-cloud.golabs.io" +const endpoint = "/api/v1" type Service struct { - hostName string } -type Doer interface { - Do(req *http.Request) (*http.Response, error) +func NewService() *Service { + return &Service{} } -func NewService(doer Doer) *Service { - return &Service{ - hostName: hostName, - } -} +func (c *Service) TeamList(ctx context.Context) (*TeamData, error) { -func (c *Service) TeamList(ctx context.Context) (any, error) { + userPath := "/users/" + teamsEndpoint := "/teams" reqCtx := reqctx.From(ctx) - fmt.Println("Email:", reqCtx) + if reqCtx.UserEmail == "" { + return nil, ErrUserNotFound + } + + url := baseURL + endpoint + userPath + reqCtx.UserEmail + teamsEndpoint + + resp, err := http.Get(url) - resp, err := http.Get("https://go-cloud.golabs.io/api/v1/users/sudheer.pal@gojek.com/teams") if err != nil { return nil, err } defer resp.Body.Close() - var data any + var data TeamListResponse err = json.NewDecoder(resp.Body).Decode(&data) if err != nil { return nil, err } - return data, nil + if data.Success { + return &data.Data, nil + } + + return nil, ErrTeamNotFound } type TeamListResponse struct { - Success bool `json:"success"` - Data []Team `json:"data"` + Success bool `json:"success"` + Data TeamData `json:"data"` +} + +type TeamData struct { + Teams []Team `json:"teams"` } type Team struct { - Identifier uuid.UUID `json:"identifier"` Name string `json:"name"` + Identifier uuid.UUID `json:"identifier"` } From 6a235a178b662755a3016dfa9251a3df7fb693d5 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Thu, 5 Oct 2023 15:09:15 +0530 Subject: [PATCH 04/27] feat(warden): updated error handling --- internal/server/v1/warden/handler.go | 5 +++-- internal/server/v1/warden/service.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/warden/handler.go index ad7c415..8acbd67 100644 --- a/internal/server/v1/warden/handler.go +++ b/internal/server/v1/warden/handler.go @@ -1,6 +1,7 @@ package warden import ( + "errors" "net/http" "github.com/goto/dex/internal/server/utils" @@ -17,11 +18,11 @@ func NewHandler(service *Service) *Handler { func (h *Handler) teamList(w http.ResponseWriter, r *http.Request) { teamListResp, err := h.service.TeamList(r.Context()) - if err == ErrUserNotFound { + if errors.Is(err, ErrUserNotFound) { utils.WriteErrMsg(w, http.StatusUnauthorized, ErrUserNotFound.Error()) return } - if err == ErrTeamNotFound { + if errors.Is(err, ErrTeamNotFound) { utils.WriteErrMsg(w, http.StatusNotFound, ErrTeamNotFound.Error()) return } diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index ae37fd6..29c1f0c 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -32,7 +32,7 @@ func (c *Service) TeamList(ctx context.Context) (*TeamData, error) { url := baseURL + endpoint + userPath + reqCtx.UserEmail + teamsEndpoint - resp, err := http.Get(url) + resp, err := http.Get(url) //nolint if err != nil { return nil, err From f7a73b911105a56d28d2ae25ac8c00a875644b29 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Thu, 5 Oct 2023 15:20:58 +0530 Subject: [PATCH 05/27] feat(warden): refactor --- internal/server/v1/warden/service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index 29c1f0c..2af8109 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -20,7 +20,7 @@ func NewService() *Service { return &Service{} } -func (c *Service) TeamList(ctx context.Context) (*TeamData, error) { +func (*Service) TeamList(ctx context.Context) (*TeamData, error) { userPath := "/users/" teamsEndpoint := "/teams" From f6ee8039eeb42f656a7a622b203eb4299a913fa4 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Thu, 5 Oct 2023 15:25:10 +0530 Subject: [PATCH 06/27] chore: format --- internal/server/v1/warden/service.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index 2af8109..a8aacfd 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -10,18 +10,18 @@ import ( "github.com/goto/dex/internal/server/reqctx" ) -const baseURL = "https://go-cloud.golabs.io" -const endpoint = "/api/v1" +const ( + baseURL = "https://go-cloud.golabs.io" + endpoint = "/api/v1" +) -type Service struct { -} +type Service struct{} func NewService() *Service { return &Service{} } func (*Service) TeamList(ctx context.Context) (*TeamData, error) { - userPath := "/users/" teamsEndpoint := "/teams" reqCtx := reqctx.From(ctx) @@ -33,7 +33,6 @@ func (*Service) TeamList(ctx context.Context) (*TeamData, error) { url := baseURL + endpoint + userPath + reqCtx.UserEmail + teamsEndpoint resp, err := http.Get(url) //nolint - if err != nil { return nil, err } From bb7415f60da8419e71d3f6cf8da2c369c3ed47d2 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Fri, 6 Oct 2023 10:37:16 +0530 Subject: [PATCH 07/27] chore: formatting --- internal/server/v1/warden/handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/warden/handler.go index 8acbd67..88e6100 100644 --- a/internal/server/v1/warden/handler.go +++ b/internal/server/v1/warden/handler.go @@ -7,15 +7,15 @@ import ( "github.com/goto/dex/internal/server/utils" ) -type Handler struct { +type handler struct { service *Service } -func NewHandler(service *Service) *Handler { - return &Handler{service: service} +func NewHandler(service *Service) *handler { + return &handler{service: service} } -func (h *Handler) teamList(w http.ResponseWriter, r *http.Request) { +func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { teamListResp, err := h.service.TeamList(r.Context()) if errors.Is(err, ErrUserNotFound) { From 49dd47dc123fc562951561eae38b0f5b58e8a0f8 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 9 Oct 2023 12:15:40 +0530 Subject: [PATCH 08/27] feat(warden): updateGroupMetaData with warden team --- go.mod | 2 +- internal/server/server.go | 2 +- internal/server/v1/warden/handler.go | 25 +++++++ internal/server/v1/warden/routes.go | 7 +- internal/server/v1/warden/service.go | 107 +++++++++++++++++++++++++-- 5 files changed, 131 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index a7f1699..ed35962 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/go-openapi/strfmt v0.21.7 github.com/go-openapi/swag v0.22.4 github.com/go-openapi/validate v0.22.1 - github.com/google/uuid v1.3.1 github.com/goto/gojsondiff v0.0.0-20230828102327-0bcf3724fe2e github.com/goto/salt v0.3.3 github.com/goto/siren v0.6.6 @@ -76,6 +75,7 @@ require ( github.com/google/go-cmp v0.5.9 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gorilla/css v1.0.0 // indirect diff --git a/internal/server/server.go b/internal/server/server.go index a6a48e6..91af550 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -67,7 +67,7 @@ func Serve(ctx context.Context, addr string, r.Route("/dlq", dlqv1.Routes(entropyClient, gcsClient)) r.Route("/firehoses", firehosev1.Routes(entropyClient, shieldClient, alertSvc, compassClient, odinAddr, stencilAddr)) r.Route("/kubernetes", kubernetesv1.Routes(entropyClient)) - r.Route("/warden", warden.Routes()) + r.Route("/warden", warden.Routes(shieldClient)) }) logger.Info("starting server", zap.String("addr", addr)) diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/warden/handler.go index 88e6100..ce1c064 100644 --- a/internal/server/v1/warden/handler.go +++ b/internal/server/v1/warden/handler.go @@ -4,6 +4,8 @@ import ( "errors" "net/http" + "github.com/go-chi/chi/v5" + "github.com/goto/dex/internal/server/utils" ) @@ -33,3 +35,26 @@ func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { utils.WriteJSON(w, http.StatusOK, teamListResp) } + +func (h *handler) updateGroupMetadata(w http.ResponseWriter, r *http.Request) { + groupID := chi.URLParam(r, "group_id") + + var body struct { + WardeTeamID string `json:"warden_team_id"` + } + if err := utils.ReadJSON(r, &body); err != nil { + utils.WriteErr(w, err) + return + } else if body.WardeTeamID == "" { + utils.WriteErrMsg(w, http.StatusBadRequest, "missing warden_team_id") + return + } + + resShield, err := h.service.UpdateGroupMetadata(r.Context(), groupID, body.WardeTeamID) + if err != nil { + utils.WriteErr(w, err) + return + } + + utils.WriteJSON(w, http.StatusOK, resShield) +} diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go index b51dea8..d26226c 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/warden/routes.go @@ -1,13 +1,16 @@ package warden import ( + shieldv1beta1rpc "buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc" chiv5 "github.com/go-chi/chi/v5" ) -func Routes() func(r chiv5.Router) { - service := NewService() +func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient) func(r chiv5.Router) { + service := NewService(shieldClient) handler := NewHandler(service) return func(r chiv5.Router) { r.Get("/users/me/warden_teams", handler.teamList) + + r.Patch("/groups/{group_id}/metadata", handler.updateGroupMetadata) } } diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index a8aacfd..92f5c76 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -4,26 +4,34 @@ import ( "context" "encoding/json" "net/http" + "time" - "github.com/google/uuid" + shieldv1beta1rpc "buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc" + shieldv1beta1 "buf.build/gen/go/gotocompany/proton/protocolbuffers/go/gotocompany/shield/v1beta1" + "google.golang.org/protobuf/types/known/structpb" "github.com/goto/dex/internal/server/reqctx" ) const ( - baseURL = "https://go-cloud.golabs.io" - endpoint = "/api/v1" + baseURL = "https://go-cloud.golabs.io" ) -type Service struct{} +type Service struct { + shieldClient shieldv1beta1rpc.ShieldServiceClient +} -func NewService() *Service { - return &Service{} +func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient) *Service { + return &Service{ + shieldClient: shieldClient, + } } func (*Service) TeamList(ctx context.Context) (*TeamData, error) { + endpoint := "/api/v1" userPath := "/users/" teamsEndpoint := "/teams" + reqCtx := reqctx.From(ctx) if reqCtx.UserEmail == "" { @@ -51,6 +59,81 @@ func (*Service) TeamList(ctx context.Context) (*TeamData, error) { return nil, ErrTeamNotFound } +func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { + shielTeam, err := c.TeamByUuid(ctx, wardenTeamID) + if err != nil { + return nil, err + } + + getGroupRes, err := c.shieldClient.GetGroup(ctx, &shieldv1beta1.GetGroupRequest{ + Id: groupID, + }) + if err != nil { + return nil, err + } + + group := getGroupRes.Group + + metaData := group.Metadata.AsMap() + if metaData == nil { + metaData = make(map[string]any) + } + + metaData["team-id"] = shielTeam.Identifier + metaData["product-group-id"] = shielTeam.ProductGroupID + + updatedMetaData, err := structpb.NewStruct(metaData) + if err != nil { + return nil, err + } + + UpdatedGroupRes, err := c.shieldClient.UpdateGroup(ctx, &shieldv1beta1.UpdateGroupRequest{ + Id: groupID, + Body: &shieldv1beta1.GroupRequestBody{ + Metadata: updatedMetaData, + Name: group.Name, + Slug: group.Slug, + OrgId: group.OrgId, + }, + }) + if err != nil { + return nil, err + } + + return UpdatedGroupRes.Group.Metadata.AsMap(), nil +} + +func (*Service) TeamByUuid(_ context.Context, uuid string) (*Team, error) { + endpoint := "/api/v2" + teamPath := "/teams/" + + url := baseURL + endpoint + teamPath + uuid + + resp, err := http.Get(url) //nolint + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var data TeamResponse + err = json.NewDecoder(resp.Body).Decode(&data) + if err != nil { + return nil, err + } + + if data.Success { + return &data.Data, nil + } + + return nil, ErrTeamNotFound +} + +type TeamResponse struct { + Success bool `json:"success"` + Data Team `json:"data"` + Message string `json:"message"` +} + type TeamListResponse struct { Success bool `json:"success"` Data TeamData `json:"data"` @@ -61,6 +144,14 @@ type TeamData struct { } type Team struct { - Name string `json:"name"` - Identifier uuid.UUID `json:"identifier"` + Name string `json:"name"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + OwnerID int `json:"owner_id"` + ParentTeamIdentifier string `json:"parent_team_identifier"` + Identifier string `json:"identifier"` + ProductGroupName string `json:"product_group_name"` + ProductGroupID string `json:"product_group_id"` + Labels any `json:"labels"` + ShortCode string `json:"short_code"` } From 6c4204585d0fe5a9a91f6d99709ae4db0c3d1be8 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 9 Oct 2023 12:20:11 +0530 Subject: [PATCH 09/27] chore: refactor --- internal/server/v1/warden/service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index 92f5c76..357a58c 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -103,11 +103,11 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID return UpdatedGroupRes.Group.Metadata.AsMap(), nil } -func (*Service) TeamByUuid(_ context.Context, uuid string) (*Team, error) { +func (*Service) TeamByUuid(_ context.Context, TeamByUUID string) (*Team, error) { endpoint := "/api/v2" teamPath := "/teams/" - url := baseURL + endpoint + teamPath + uuid + url := baseURL + endpoint + teamPath + TeamByUUID resp, err := http.Get(url) //nolint if err != nil { From 6351b57ce8b407f609825ce696d3b9936da8668f Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 9 Oct 2023 12:25:09 +0530 Subject: [PATCH 10/27] chore: lint resolved --- internal/server/v1/warden/service.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index 357a58c..942c9d3 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -60,7 +60,7 @@ func (*Service) TeamList(ctx context.Context) (*TeamData, error) { } func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { - shielTeam, err := c.TeamByUuid(ctx, wardenTeamID) + shielTeam, err := c.TeamByUUID(ctx, wardenTeamID) if err != nil { return nil, err } @@ -103,11 +103,11 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID return UpdatedGroupRes.Group.Metadata.AsMap(), nil } -func (*Service) TeamByUuid(_ context.Context, TeamByUUID string) (*Team, error) { +func (*Service) TeamByUUID(_ context.Context, teamByUUID string) (*Team, error) { endpoint := "/api/v2" teamPath := "/teams/" - url := baseURL + endpoint + teamPath + TeamByUUID + url := baseURL + endpoint + teamPath + teamByUUID resp, err := http.Get(url) //nolint if err != nil { From 2a07820963581e21842693fe8cac8c35064c4f06 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 9 Oct 2023 19:33:51 +0530 Subject: [PATCH 11/27] test(warden): added test for teamList, updateGroup --- Makefile | 14 +- internal/server/server.go | 2 +- internal/server/v1/warden/handler_test.go | 146 ++ internal/server/v1/warden/mocks/doer.go | 90 ++ internal/server/v1/warden/routes.go | 4 +- internal/server/v1/warden/service.go | 34 +- mocks/BlobObjectClient.go | 38 + mocks/BlobStorageClient.go | 36 + mocks/JobSpecificationServiceClient.go | 709 ++++++++++ mocks/ObjectIterator.go | 35 + mocks/ResourceServiceClient.go | 304 ++++ mocks/ShieldServiceClient.go | 1562 +++++++++++++++++++++ mocks/SirenServiceClient.go | 1303 +++++++++++++++++ 13 files changed, 4259 insertions(+), 18 deletions(-) create mode 100644 internal/server/v1/warden/handler_test.go create mode 100644 internal/server/v1/warden/mocks/doer.go diff --git a/Makefile b/Makefile index 5bc84a0..d4566b6 100644 --- a/Makefile +++ b/Makefile @@ -38,13 +38,13 @@ generate: @make format generate-mocks: - @mockery --srcpkg=buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/siren/v1beta1/sirenv1beta1grpc --name=SirenServiceClient - @mockery --srcpkg=buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc --name=ShieldServiceClient - @mockery --srcpkg=buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/optimus/core/v1beta1/corev1beta1grpc --name=JobSpecificationServiceClient - @mockery --srcpkg=buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/entropy/v1beta1/entropyv1beta1grpc --name=ResourceServiceClient - @mockery --srcpkg=./internal/server/gcs --name=BlobStorageClient - @mockery --srcpkg=./internal/server/gcs --name=BlobObjectClient - @mockery --srcpkg=./internal/server/gcs --name=ObjectIterator + @mockery --with-expecter --srcpkg=buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/siren/v1beta1/sirenv1beta1grpc --name=SirenServiceClient + @mockery --with-expecter --srcpkg=buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc --name=ShieldServiceClient + @mockery --with-expecter --srcpkg=buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/optimus/core/v1beta1/corev1beta1grpc --name=JobSpecificationServiceClient + @mockery --with-expecter --srcpkg=buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/entropy/v1beta1/entropyv1beta1grpc --name=ResourceServiceClient + @mockery --with-expecter --srcpkg=./internal/server/gcs --name=BlobStorageClient + @mockery --with-expecter --srcpkg=./internal/server/gcs --name=BlobObjectClient + @mockery --with-expecter --srcpkg=./internal/server/gcs --name=ObjectIterator clean: tidy @echo "Cleaning up build directories..." diff --git a/internal/server/server.go b/internal/server/server.go index 91af550..94a6dcd 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -67,7 +67,7 @@ func Serve(ctx context.Context, addr string, r.Route("/dlq", dlqv1.Routes(entropyClient, gcsClient)) r.Route("/firehoses", firehosev1.Routes(entropyClient, shieldClient, alertSvc, compassClient, odinAddr, stencilAddr)) r.Route("/kubernetes", kubernetesv1.Routes(entropyClient)) - r.Route("/warden", warden.Routes(shieldClient)) + r.Route("/warden", warden.Routes(shieldClient, http.DefaultClient)) }) logger.Info("starting server", zap.String("addr", addr)) diff --git a/internal/server/v1/warden/handler_test.go b/internal/server/v1/warden/handler_test.go new file mode 100644 index 0000000..edd0312 --- /dev/null +++ b/internal/server/v1/warden/handler_test.go @@ -0,0 +1,146 @@ +package warden + +import ( + "bytes" + "io" + "net/http" + "net/http/httptest" + "testing" + + shieldv1beta1 "buf.build/gen/go/gotocompany/proton/protocolbuffers/go/gotocompany/shield/v1beta1" + "github.com/go-chi/chi/v5" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "google.golang.org/protobuf/types/known/structpb" + + "github.com/goto/dex/internal/server/reqctx" + "github.com/goto/dex/internal/server/v1/warden/mocks" + shareMocks "github.com/goto/dex/mocks" +) + +func TestHandler_teamList(t *testing.T) { + t.Run("should return 200 OK", func(t *testing.T) { + doer := mocks.NewDoer(t) + doer.EXPECT().Do(mock.Anything).Return(&http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewBufferString(`{ + "success": true, + "errors": [], + "data": { + "teams": [ + { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + } + ] + }, + "status": "ok" + }`)), + }, nil) + + r := chi.NewRouter() + r.Use(reqctx.WithRequestCtx()) + r.Route("/dex/warden", Routes(nil, doer)) + + req, err := http.NewRequest(http.MethodGet, "/dex/warden/users/me/warden_teams", nil) + assert.NoError(t, err) + req.Header.Add("X-Auth-Email", "test@email.com") + + resp := httptest.NewRecorder() + r.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusOK, resp.Code) + assert.JSONEq(t, `{ "teams": [ + { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + } + ]}`, resp.Body.String()) + }) +} + +func TestHandler_updateGroup(t *testing.T) { + t.Run("should return 200 OK", func(t *testing.T) { + groupID := "e38527ee-a8cd-40f9-98a7-1f0bbd20909f" + metaData, _ := structpb.NewStruct(map[string]any{ + "privacy": "public", + }) + + updatedMetaData, _ := structpb.NewStruct(map[string]any{ + "privacy": "public", + "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + }) + + shieldClient := shareMocks.NewShieldServiceClient(t) + shieldClient.EXPECT().GetGroup(mock.Anything, &shieldv1beta1.GetGroupRequest{ + Id: groupID, + }).Return(&shieldv1beta1.GetGroupResponse{ + Group: &shieldv1beta1.Group{ + Id: groupID, Name: "test", Slug: "testSlug", OrgId: "123", Metadata: metaData, + }, + }, nil) + + shieldClient.EXPECT().UpdateGroup(mock.Anything, &shieldv1beta1.UpdateGroupRequest{ + Id: groupID, Body: &shieldv1beta1.GroupRequestBody{ + Metadata: updatedMetaData, Name: "test", Slug: "testSlug", OrgId: "123", + }, + }).Return(&shieldv1beta1.UpdateGroupResponse{Group: &shieldv1beta1.Group{ + Id: groupID, Name: "test", Slug: "testSlug", OrgId: "123", Metadata: updatedMetaData, + }}, nil) + + doer := mocks.NewDoer(t) + doer.EXPECT().Do(mock.Anything).Return(&http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewBufferString(`{ + "success": true, + "data": { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + }, + "errors": [] + }`)), + }, nil) + + r := chi.NewRouter() + r.Use(reqctx.WithRequestCtx()) + r.Route("/dex/warden", Routes(shieldClient, doer)) + + req, err := http.NewRequest(http.MethodPatch, "/dex/warden/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + assert.NoError(t, err) + + resp := httptest.NewRecorder() + r.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusOK, resp.Code) + assert.JSONEq(t, `{ + "privacy": "public", + "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b" + }`, resp.Body.String()) + }) +} diff --git a/internal/server/v1/warden/mocks/doer.go b/internal/server/v1/warden/mocks/doer.go new file mode 100644 index 0000000..ca5f969 --- /dev/null +++ b/internal/server/v1/warden/mocks/doer.go @@ -0,0 +1,90 @@ +// Code generated by mockery v2.30.1. DO NOT EDIT. + +package mocks + +import ( + http "net/http" + + mock "github.com/stretchr/testify/mock" +) + +// Doer is an autogenerated mock type for the Doer type +type Doer struct { + mock.Mock +} + +type Doer_Expecter struct { + mock *mock.Mock +} + +func (_m *Doer) EXPECT() *Doer_Expecter { + return &Doer_Expecter{mock: &_m.Mock} +} + +// Do provides a mock function with given fields: req +func (_m *Doer) Do(req *http.Request) (*http.Response, error) { + ret := _m.Called(req) + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(*http.Request) (*http.Response, error)); ok { + return rf(req) + } + if rf, ok := ret.Get(0).(func(*http.Request) *http.Response); ok { + r0 = rf(req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(*http.Request) error); ok { + r1 = rf(req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Doer_Do_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Do' +type Doer_Do_Call struct { + *mock.Call +} + +// Do is a helper method to define mock.On call +// - req *http.Request +func (_e *Doer_Expecter) Do(req interface{}) *Doer_Do_Call { + return &Doer_Do_Call{Call: _e.mock.On("Do", req)} +} + +func (_c *Doer_Do_Call) Run(run func(req *http.Request)) *Doer_Do_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*http.Request)) + }) + return _c +} + +func (_c *Doer_Do_Call) Return(_a0 *http.Response, _a1 error) *Doer_Do_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Doer_Do_Call) RunAndReturn(run func(*http.Request) (*http.Response, error)) *Doer_Do_Call { + _c.Call.Return(run) + return _c +} + +// NewDoer creates a new instance of Doer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDoer(t interface { + mock.TestingT + Cleanup(func()) +}) *Doer { + mock := &Doer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go index d26226c..ae83995 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/warden/routes.go @@ -5,8 +5,8 @@ import ( chiv5 "github.com/go-chi/chi/v5" ) -func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient) func(r chiv5.Router) { - service := NewService(shieldClient) +func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer Doer) func(r chiv5.Router) { + service := NewService(shieldClient, doer) handler := NewHandler(service) return func(r chiv5.Router) { r.Get("/users/me/warden_teams", handler.teamList) diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index 942c9d3..b236c5a 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -13,21 +13,29 @@ import ( "github.com/goto/dex/internal/server/reqctx" ) +//go:generate mockery --with-expecter --keeptree --case snake --name Doer + const ( baseURL = "https://go-cloud.golabs.io" ) type Service struct { shieldClient shieldv1beta1rpc.ShieldServiceClient + doer Doer +} + +type Doer interface { + Do(req *http.Request) (*http.Response, error) } -func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient) *Service { +func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer Doer) *Service { return &Service{ shieldClient: shieldClient, + doer: doer, } } -func (*Service) TeamList(ctx context.Context) (*TeamData, error) { +func (c *Service) TeamList(ctx context.Context) (*TeamData, error) { endpoint := "/api/v1" userPath := "/users/" teamsEndpoint := "/teams" @@ -40,7 +48,12 @@ func (*Service) TeamList(ctx context.Context) (*TeamData, error) { url := baseURL + endpoint + userPath + reqCtx.UserEmail + teamsEndpoint - resp, err := http.Get(url) //nolint + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + return nil, err + } + + resp, err := c.doer.Do(req) if err != nil { return nil, err } @@ -60,7 +73,7 @@ func (*Service) TeamList(ctx context.Context) (*TeamData, error) { } func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { - shielTeam, err := c.TeamByUUID(ctx, wardenTeamID) + wardenTeam, err := c.TeamByUUID(ctx, wardenTeamID) if err != nil { return nil, err } @@ -79,8 +92,8 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID metaData = make(map[string]any) } - metaData["team-id"] = shielTeam.Identifier - metaData["product-group-id"] = shielTeam.ProductGroupID + metaData["team-id"] = wardenTeam.Identifier + metaData["product-group-id"] = wardenTeam.ProductGroupID updatedMetaData, err := structpb.NewStruct(metaData) if err != nil { @@ -103,13 +116,18 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID return UpdatedGroupRes.Group.Metadata.AsMap(), nil } -func (*Service) TeamByUUID(_ context.Context, teamByUUID string) (*Team, error) { +func (c *Service) TeamByUUID(_ context.Context, teamByUUID string) (*Team, error) { endpoint := "/api/v2" teamPath := "/teams/" url := baseURL + endpoint + teamPath + teamByUUID - resp, err := http.Get(url) //nolint + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + return nil, err + } + + resp, err := c.doer.Do(req) if err != nil { return nil, err } diff --git a/mocks/BlobObjectClient.go b/mocks/BlobObjectClient.go index de9353f..ec3b04f 100644 --- a/mocks/BlobObjectClient.go +++ b/mocks/BlobObjectClient.go @@ -16,6 +16,14 @@ type BlobObjectClient struct { mock.Mock } +type BlobObjectClient_Expecter struct { + mock *mock.Mock +} + +func (_m *BlobObjectClient) EXPECT() *BlobObjectClient_Expecter { + return &BlobObjectClient_Expecter{mock: &_m.Mock} +} + // Objects provides a mock function with given fields: ctx, bucket, query func (_m *BlobObjectClient) Objects(ctx context.Context, bucket string, query *storage.Query) gcs.ObjectIterator { ret := _m.Called(ctx, bucket, query) @@ -32,6 +40,36 @@ func (_m *BlobObjectClient) Objects(ctx context.Context, bucket string, query *s return r0 } +// BlobObjectClient_Objects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Objects' +type BlobObjectClient_Objects_Call struct { + *mock.Call +} + +// Objects is a helper method to define mock.On call +// - ctx context.Context +// - bucket string +// - query *storage.Query +func (_e *BlobObjectClient_Expecter) Objects(ctx interface{}, bucket interface{}, query interface{}) *BlobObjectClient_Objects_Call { + return &BlobObjectClient_Objects_Call{Call: _e.mock.On("Objects", ctx, bucket, query)} +} + +func (_c *BlobObjectClient_Objects_Call) Run(run func(ctx context.Context, bucket string, query *storage.Query)) *BlobObjectClient_Objects_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(*storage.Query)) + }) + return _c +} + +func (_c *BlobObjectClient_Objects_Call) Return(_a0 gcs.ObjectIterator) *BlobObjectClient_Objects_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *BlobObjectClient_Objects_Call) RunAndReturn(run func(context.Context, string, *storage.Query) gcs.ObjectIterator) *BlobObjectClient_Objects_Call { + _c.Call.Return(run) + return _c +} + // NewBlobObjectClient creates a new instance of BlobObjectClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewBlobObjectClient(t interface { diff --git a/mocks/BlobStorageClient.go b/mocks/BlobStorageClient.go index 40dd970..cd99c85 100644 --- a/mocks/BlobStorageClient.go +++ b/mocks/BlobStorageClient.go @@ -14,6 +14,14 @@ type BlobStorageClient struct { mock.Mock } +type BlobStorageClient_Expecter struct { + mock *mock.Mock +} + +func (_m *BlobStorageClient) EXPECT() *BlobStorageClient_Expecter { + return &BlobStorageClient_Expecter{mock: &_m.Mock} +} + // ListDlqMetadata provides a mock function with given fields: bucketInfo func (_m *BlobStorageClient) ListDlqMetadata(bucketInfo gcs.BucketInfo) ([]models.DlqMetadata, error) { ret := _m.Called(bucketInfo) @@ -40,6 +48,34 @@ func (_m *BlobStorageClient) ListDlqMetadata(bucketInfo gcs.BucketInfo) ([]model return r0, r1 } +// BlobStorageClient_ListDlqMetadata_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListDlqMetadata' +type BlobStorageClient_ListDlqMetadata_Call struct { + *mock.Call +} + +// ListDlqMetadata is a helper method to define mock.On call +// - bucketInfo gcs.BucketInfo +func (_e *BlobStorageClient_Expecter) ListDlqMetadata(bucketInfo interface{}) *BlobStorageClient_ListDlqMetadata_Call { + return &BlobStorageClient_ListDlqMetadata_Call{Call: _e.mock.On("ListDlqMetadata", bucketInfo)} +} + +func (_c *BlobStorageClient_ListDlqMetadata_Call) Run(run func(bucketInfo gcs.BucketInfo)) *BlobStorageClient_ListDlqMetadata_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(gcs.BucketInfo)) + }) + return _c +} + +func (_c *BlobStorageClient_ListDlqMetadata_Call) Return(_a0 []models.DlqMetadata, _a1 error) *BlobStorageClient_ListDlqMetadata_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *BlobStorageClient_ListDlqMetadata_Call) RunAndReturn(run func(gcs.BucketInfo) ([]models.DlqMetadata, error)) *BlobStorageClient_ListDlqMetadata_Call { + _c.Call.Return(run) + return _c +} + // NewBlobStorageClient creates a new instance of BlobStorageClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewBlobStorageClient(t interface { diff --git a/mocks/JobSpecificationServiceClient.go b/mocks/JobSpecificationServiceClient.go index b22d610..1963c7b 100644 --- a/mocks/JobSpecificationServiceClient.go +++ b/mocks/JobSpecificationServiceClient.go @@ -18,6 +18,14 @@ type JobSpecificationServiceClient struct { mock.Mock } +type JobSpecificationServiceClient_Expecter struct { + mock *mock.Mock +} + +func (_m *JobSpecificationServiceClient) EXPECT() *JobSpecificationServiceClient_Expecter { + return &JobSpecificationServiceClient_Expecter{mock: &_m.Mock} +} + // AddJobSpecifications provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) AddJobSpecifications(ctx context.Context, in *corev1beta1.AddJobSpecificationsRequest, opts ...grpc.CallOption) (*corev1beta1.AddJobSpecificationsResponse, error) { _va := make([]interface{}, len(opts)) @@ -51,6 +59,43 @@ func (_m *JobSpecificationServiceClient) AddJobSpecifications(ctx context.Contex return r0, r1 } +// JobSpecificationServiceClient_AddJobSpecifications_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddJobSpecifications' +type JobSpecificationServiceClient_AddJobSpecifications_Call struct { + *mock.Call +} + +// AddJobSpecifications is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.AddJobSpecificationsRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) AddJobSpecifications(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_AddJobSpecifications_Call { + return &JobSpecificationServiceClient_AddJobSpecifications_Call{Call: _e.mock.On("AddJobSpecifications", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_AddJobSpecifications_Call) Run(run func(ctx context.Context, in *corev1beta1.AddJobSpecificationsRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_AddJobSpecifications_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.AddJobSpecificationsRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_AddJobSpecifications_Call) Return(_a0 *corev1beta1.AddJobSpecificationsResponse, _a1 error) *JobSpecificationServiceClient_AddJobSpecifications_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_AddJobSpecifications_Call) RunAndReturn(run func(context.Context, *corev1beta1.AddJobSpecificationsRequest, ...grpc.CallOption) (*corev1beta1.AddJobSpecificationsResponse, error)) *JobSpecificationServiceClient_AddJobSpecifications_Call { + _c.Call.Return(run) + return _c +} + // ChangeJobNamespace provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) ChangeJobNamespace(ctx context.Context, in *corev1beta1.ChangeJobNamespaceRequest, opts ...grpc.CallOption) (*corev1beta1.ChangeJobNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -84,6 +129,43 @@ func (_m *JobSpecificationServiceClient) ChangeJobNamespace(ctx context.Context, return r0, r1 } +// JobSpecificationServiceClient_ChangeJobNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeJobNamespace' +type JobSpecificationServiceClient_ChangeJobNamespace_Call struct { + *mock.Call +} + +// ChangeJobNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.ChangeJobNamespaceRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) ChangeJobNamespace(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_ChangeJobNamespace_Call { + return &JobSpecificationServiceClient_ChangeJobNamespace_Call{Call: _e.mock.On("ChangeJobNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_ChangeJobNamespace_Call) Run(run func(ctx context.Context, in *corev1beta1.ChangeJobNamespaceRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_ChangeJobNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.ChangeJobNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_ChangeJobNamespace_Call) Return(_a0 *corev1beta1.ChangeJobNamespaceResponse, _a1 error) *JobSpecificationServiceClient_ChangeJobNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_ChangeJobNamespace_Call) RunAndReturn(run func(context.Context, *corev1beta1.ChangeJobNamespaceRequest, ...grpc.CallOption) (*corev1beta1.ChangeJobNamespaceResponse, error)) *JobSpecificationServiceClient_ChangeJobNamespace_Call { + _c.Call.Return(run) + return _c +} + // CheckJobSpecification provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) CheckJobSpecification(ctx context.Context, in *corev1beta1.CheckJobSpecificationRequest, opts ...grpc.CallOption) (*corev1beta1.CheckJobSpecificationResponse, error) { _va := make([]interface{}, len(opts)) @@ -117,6 +199,43 @@ func (_m *JobSpecificationServiceClient) CheckJobSpecification(ctx context.Conte return r0, r1 } +// JobSpecificationServiceClient_CheckJobSpecification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckJobSpecification' +type JobSpecificationServiceClient_CheckJobSpecification_Call struct { + *mock.Call +} + +// CheckJobSpecification is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.CheckJobSpecificationRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) CheckJobSpecification(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_CheckJobSpecification_Call { + return &JobSpecificationServiceClient_CheckJobSpecification_Call{Call: _e.mock.On("CheckJobSpecification", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_CheckJobSpecification_Call) Run(run func(ctx context.Context, in *corev1beta1.CheckJobSpecificationRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_CheckJobSpecification_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.CheckJobSpecificationRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_CheckJobSpecification_Call) Return(_a0 *corev1beta1.CheckJobSpecificationResponse, _a1 error) *JobSpecificationServiceClient_CheckJobSpecification_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_CheckJobSpecification_Call) RunAndReturn(run func(context.Context, *corev1beta1.CheckJobSpecificationRequest, ...grpc.CallOption) (*corev1beta1.CheckJobSpecificationResponse, error)) *JobSpecificationServiceClient_CheckJobSpecification_Call { + _c.Call.Return(run) + return _c +} + // CheckJobSpecifications provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) CheckJobSpecifications(ctx context.Context, in *corev1beta1.CheckJobSpecificationsRequest, opts ...grpc.CallOption) (corev1beta1grpc.JobSpecificationService_CheckJobSpecificationsClient, error) { _va := make([]interface{}, len(opts)) @@ -150,6 +269,43 @@ func (_m *JobSpecificationServiceClient) CheckJobSpecifications(ctx context.Cont return r0, r1 } +// JobSpecificationServiceClient_CheckJobSpecifications_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckJobSpecifications' +type JobSpecificationServiceClient_CheckJobSpecifications_Call struct { + *mock.Call +} + +// CheckJobSpecifications is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.CheckJobSpecificationsRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) CheckJobSpecifications(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_CheckJobSpecifications_Call { + return &JobSpecificationServiceClient_CheckJobSpecifications_Call{Call: _e.mock.On("CheckJobSpecifications", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_CheckJobSpecifications_Call) Run(run func(ctx context.Context, in *corev1beta1.CheckJobSpecificationsRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_CheckJobSpecifications_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.CheckJobSpecificationsRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_CheckJobSpecifications_Call) Return(_a0 corev1beta1grpc.JobSpecificationService_CheckJobSpecificationsClient, _a1 error) *JobSpecificationServiceClient_CheckJobSpecifications_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_CheckJobSpecifications_Call) RunAndReturn(run func(context.Context, *corev1beta1.CheckJobSpecificationsRequest, ...grpc.CallOption) (corev1beta1grpc.JobSpecificationService_CheckJobSpecificationsClient, error)) *JobSpecificationServiceClient_CheckJobSpecifications_Call { + _c.Call.Return(run) + return _c +} + // CreateJobSpecification provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) CreateJobSpecification(ctx context.Context, in *corev1beta1.CreateJobSpecificationRequest, opts ...grpc.CallOption) (*corev1beta1.CreateJobSpecificationResponse, error) { _va := make([]interface{}, len(opts)) @@ -183,6 +339,43 @@ func (_m *JobSpecificationServiceClient) CreateJobSpecification(ctx context.Cont return r0, r1 } +// JobSpecificationServiceClient_CreateJobSpecification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateJobSpecification' +type JobSpecificationServiceClient_CreateJobSpecification_Call struct { + *mock.Call +} + +// CreateJobSpecification is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.CreateJobSpecificationRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) CreateJobSpecification(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_CreateJobSpecification_Call { + return &JobSpecificationServiceClient_CreateJobSpecification_Call{Call: _e.mock.On("CreateJobSpecification", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_CreateJobSpecification_Call) Run(run func(ctx context.Context, in *corev1beta1.CreateJobSpecificationRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_CreateJobSpecification_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.CreateJobSpecificationRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_CreateJobSpecification_Call) Return(_a0 *corev1beta1.CreateJobSpecificationResponse, _a1 error) *JobSpecificationServiceClient_CreateJobSpecification_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_CreateJobSpecification_Call) RunAndReturn(run func(context.Context, *corev1beta1.CreateJobSpecificationRequest, ...grpc.CallOption) (*corev1beta1.CreateJobSpecificationResponse, error)) *JobSpecificationServiceClient_CreateJobSpecification_Call { + _c.Call.Return(run) + return _c +} + // DeleteJobSpecification provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) DeleteJobSpecification(ctx context.Context, in *corev1beta1.DeleteJobSpecificationRequest, opts ...grpc.CallOption) (*corev1beta1.DeleteJobSpecificationResponse, error) { _va := make([]interface{}, len(opts)) @@ -216,6 +409,43 @@ func (_m *JobSpecificationServiceClient) DeleteJobSpecification(ctx context.Cont return r0, r1 } +// JobSpecificationServiceClient_DeleteJobSpecification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteJobSpecification' +type JobSpecificationServiceClient_DeleteJobSpecification_Call struct { + *mock.Call +} + +// DeleteJobSpecification is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.DeleteJobSpecificationRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) DeleteJobSpecification(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_DeleteJobSpecification_Call { + return &JobSpecificationServiceClient_DeleteJobSpecification_Call{Call: _e.mock.On("DeleteJobSpecification", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_DeleteJobSpecification_Call) Run(run func(ctx context.Context, in *corev1beta1.DeleteJobSpecificationRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_DeleteJobSpecification_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.DeleteJobSpecificationRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_DeleteJobSpecification_Call) Return(_a0 *corev1beta1.DeleteJobSpecificationResponse, _a1 error) *JobSpecificationServiceClient_DeleteJobSpecification_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_DeleteJobSpecification_Call) RunAndReturn(run func(context.Context, *corev1beta1.DeleteJobSpecificationRequest, ...grpc.CallOption) (*corev1beta1.DeleteJobSpecificationResponse, error)) *JobSpecificationServiceClient_DeleteJobSpecification_Call { + _c.Call.Return(run) + return _c +} + // DeployJobSpecification provides a mock function with given fields: ctx, opts func (_m *JobSpecificationServiceClient) DeployJobSpecification(ctx context.Context, opts ...grpc.CallOption) (corev1beta1grpc.JobSpecificationService_DeployJobSpecificationClient, error) { _va := make([]interface{}, len(opts)) @@ -249,6 +479,42 @@ func (_m *JobSpecificationServiceClient) DeployJobSpecification(ctx context.Cont return r0, r1 } +// JobSpecificationServiceClient_DeployJobSpecification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeployJobSpecification' +type JobSpecificationServiceClient_DeployJobSpecification_Call struct { + *mock.Call +} + +// DeployJobSpecification is a helper method to define mock.On call +// - ctx context.Context +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) DeployJobSpecification(ctx interface{}, opts ...interface{}) *JobSpecificationServiceClient_DeployJobSpecification_Call { + return &JobSpecificationServiceClient_DeployJobSpecification_Call{Call: _e.mock.On("DeployJobSpecification", + append([]interface{}{ctx}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_DeployJobSpecification_Call) Run(run func(ctx context.Context, opts ...grpc.CallOption)) *JobSpecificationServiceClient_DeployJobSpecification_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_DeployJobSpecification_Call) Return(_a0 corev1beta1grpc.JobSpecificationService_DeployJobSpecificationClient, _a1 error) *JobSpecificationServiceClient_DeployJobSpecification_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_DeployJobSpecification_Call) RunAndReturn(run func(context.Context, ...grpc.CallOption) (corev1beta1grpc.JobSpecificationService_DeployJobSpecificationClient, error)) *JobSpecificationServiceClient_DeployJobSpecification_Call { + _c.Call.Return(run) + return _c +} + // GetDeployJobsStatus provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) GetDeployJobsStatus(ctx context.Context, in *corev1beta1.GetDeployJobsStatusRequest, opts ...grpc.CallOption) (*corev1beta1.GetDeployJobsStatusResponse, error) { _va := make([]interface{}, len(opts)) @@ -282,6 +548,43 @@ func (_m *JobSpecificationServiceClient) GetDeployJobsStatus(ctx context.Context return r0, r1 } +// JobSpecificationServiceClient_GetDeployJobsStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDeployJobsStatus' +type JobSpecificationServiceClient_GetDeployJobsStatus_Call struct { + *mock.Call +} + +// GetDeployJobsStatus is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.GetDeployJobsStatusRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) GetDeployJobsStatus(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_GetDeployJobsStatus_Call { + return &JobSpecificationServiceClient_GetDeployJobsStatus_Call{Call: _e.mock.On("GetDeployJobsStatus", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_GetDeployJobsStatus_Call) Run(run func(ctx context.Context, in *corev1beta1.GetDeployJobsStatusRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_GetDeployJobsStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.GetDeployJobsStatusRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_GetDeployJobsStatus_Call) Return(_a0 *corev1beta1.GetDeployJobsStatusResponse, _a1 error) *JobSpecificationServiceClient_GetDeployJobsStatus_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_GetDeployJobsStatus_Call) RunAndReturn(run func(context.Context, *corev1beta1.GetDeployJobsStatusRequest, ...grpc.CallOption) (*corev1beta1.GetDeployJobsStatusResponse, error)) *JobSpecificationServiceClient_GetDeployJobsStatus_Call { + _c.Call.Return(run) + return _c +} + // GetJobSpecification provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) GetJobSpecification(ctx context.Context, in *corev1beta1.GetJobSpecificationRequest, opts ...grpc.CallOption) (*corev1beta1.GetJobSpecificationResponse, error) { _va := make([]interface{}, len(opts)) @@ -315,6 +618,43 @@ func (_m *JobSpecificationServiceClient) GetJobSpecification(ctx context.Context return r0, r1 } +// JobSpecificationServiceClient_GetJobSpecification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJobSpecification' +type JobSpecificationServiceClient_GetJobSpecification_Call struct { + *mock.Call +} + +// GetJobSpecification is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.GetJobSpecificationRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) GetJobSpecification(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_GetJobSpecification_Call { + return &JobSpecificationServiceClient_GetJobSpecification_Call{Call: _e.mock.On("GetJobSpecification", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_GetJobSpecification_Call) Run(run func(ctx context.Context, in *corev1beta1.GetJobSpecificationRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_GetJobSpecification_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.GetJobSpecificationRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_GetJobSpecification_Call) Return(_a0 *corev1beta1.GetJobSpecificationResponse, _a1 error) *JobSpecificationServiceClient_GetJobSpecification_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_GetJobSpecification_Call) RunAndReturn(run func(context.Context, *corev1beta1.GetJobSpecificationRequest, ...grpc.CallOption) (*corev1beta1.GetJobSpecificationResponse, error)) *JobSpecificationServiceClient_GetJobSpecification_Call { + _c.Call.Return(run) + return _c +} + // GetJobSpecifications provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) GetJobSpecifications(ctx context.Context, in *corev1beta1.GetJobSpecificationsRequest, opts ...grpc.CallOption) (*corev1beta1.GetJobSpecificationsResponse, error) { _va := make([]interface{}, len(opts)) @@ -348,6 +688,43 @@ func (_m *JobSpecificationServiceClient) GetJobSpecifications(ctx context.Contex return r0, r1 } +// JobSpecificationServiceClient_GetJobSpecifications_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJobSpecifications' +type JobSpecificationServiceClient_GetJobSpecifications_Call struct { + *mock.Call +} + +// GetJobSpecifications is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.GetJobSpecificationsRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) GetJobSpecifications(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_GetJobSpecifications_Call { + return &JobSpecificationServiceClient_GetJobSpecifications_Call{Call: _e.mock.On("GetJobSpecifications", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_GetJobSpecifications_Call) Run(run func(ctx context.Context, in *corev1beta1.GetJobSpecificationsRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_GetJobSpecifications_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.GetJobSpecificationsRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_GetJobSpecifications_Call) Return(_a0 *corev1beta1.GetJobSpecificationsResponse, _a1 error) *JobSpecificationServiceClient_GetJobSpecifications_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_GetJobSpecifications_Call) RunAndReturn(run func(context.Context, *corev1beta1.GetJobSpecificationsRequest, ...grpc.CallOption) (*corev1beta1.GetJobSpecificationsResponse, error)) *JobSpecificationServiceClient_GetJobSpecifications_Call { + _c.Call.Return(run) + return _c +} + // GetJobTask provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) GetJobTask(ctx context.Context, in *corev1beta1.GetJobTaskRequest, opts ...grpc.CallOption) (*corev1beta1.GetJobTaskResponse, error) { _va := make([]interface{}, len(opts)) @@ -381,6 +758,43 @@ func (_m *JobSpecificationServiceClient) GetJobTask(ctx context.Context, in *cor return r0, r1 } +// JobSpecificationServiceClient_GetJobTask_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJobTask' +type JobSpecificationServiceClient_GetJobTask_Call struct { + *mock.Call +} + +// GetJobTask is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.GetJobTaskRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) GetJobTask(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_GetJobTask_Call { + return &JobSpecificationServiceClient_GetJobTask_Call{Call: _e.mock.On("GetJobTask", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_GetJobTask_Call) Run(run func(ctx context.Context, in *corev1beta1.GetJobTaskRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_GetJobTask_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.GetJobTaskRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_GetJobTask_Call) Return(_a0 *corev1beta1.GetJobTaskResponse, _a1 error) *JobSpecificationServiceClient_GetJobTask_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_GetJobTask_Call) RunAndReturn(run func(context.Context, *corev1beta1.GetJobTaskRequest, ...grpc.CallOption) (*corev1beta1.GetJobTaskResponse, error)) *JobSpecificationServiceClient_GetJobTask_Call { + _c.Call.Return(run) + return _c +} + // GetWindow provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) GetWindow(ctx context.Context, in *corev1beta1.GetWindowRequest, opts ...grpc.CallOption) (*corev1beta1.GetWindowResponse, error) { _va := make([]interface{}, len(opts)) @@ -414,6 +828,43 @@ func (_m *JobSpecificationServiceClient) GetWindow(ctx context.Context, in *core return r0, r1 } +// JobSpecificationServiceClient_GetWindow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWindow' +type JobSpecificationServiceClient_GetWindow_Call struct { + *mock.Call +} + +// GetWindow is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.GetWindowRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) GetWindow(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_GetWindow_Call { + return &JobSpecificationServiceClient_GetWindow_Call{Call: _e.mock.On("GetWindow", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_GetWindow_Call) Run(run func(ctx context.Context, in *corev1beta1.GetWindowRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_GetWindow_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.GetWindowRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_GetWindow_Call) Return(_a0 *corev1beta1.GetWindowResponse, _a1 error) *JobSpecificationServiceClient_GetWindow_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_GetWindow_Call) RunAndReturn(run func(context.Context, *corev1beta1.GetWindowRequest, ...grpc.CallOption) (*corev1beta1.GetWindowResponse, error)) *JobSpecificationServiceClient_GetWindow_Call { + _c.Call.Return(run) + return _c +} + // JobInspect provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) JobInspect(ctx context.Context, in *corev1beta1.JobInspectRequest, opts ...grpc.CallOption) (*corev1beta1.JobInspectResponse, error) { _va := make([]interface{}, len(opts)) @@ -447,6 +898,43 @@ func (_m *JobSpecificationServiceClient) JobInspect(ctx context.Context, in *cor return r0, r1 } +// JobSpecificationServiceClient_JobInspect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'JobInspect' +type JobSpecificationServiceClient_JobInspect_Call struct { + *mock.Call +} + +// JobInspect is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.JobInspectRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) JobInspect(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_JobInspect_Call { + return &JobSpecificationServiceClient_JobInspect_Call{Call: _e.mock.On("JobInspect", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_JobInspect_Call) Run(run func(ctx context.Context, in *corev1beta1.JobInspectRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_JobInspect_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.JobInspectRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_JobInspect_Call) Return(_a0 *corev1beta1.JobInspectResponse, _a1 error) *JobSpecificationServiceClient_JobInspect_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_JobInspect_Call) RunAndReturn(run func(context.Context, *corev1beta1.JobInspectRequest, ...grpc.CallOption) (*corev1beta1.JobInspectResponse, error)) *JobSpecificationServiceClient_JobInspect_Call { + _c.Call.Return(run) + return _c +} + // ListJobSpecification provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) ListJobSpecification(ctx context.Context, in *corev1beta1.ListJobSpecificationRequest, opts ...grpc.CallOption) (*corev1beta1.ListJobSpecificationResponse, error) { _va := make([]interface{}, len(opts)) @@ -480,6 +968,43 @@ func (_m *JobSpecificationServiceClient) ListJobSpecification(ctx context.Contex return r0, r1 } +// JobSpecificationServiceClient_ListJobSpecification_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListJobSpecification' +type JobSpecificationServiceClient_ListJobSpecification_Call struct { + *mock.Call +} + +// ListJobSpecification is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.ListJobSpecificationRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) ListJobSpecification(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_ListJobSpecification_Call { + return &JobSpecificationServiceClient_ListJobSpecification_Call{Call: _e.mock.On("ListJobSpecification", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_ListJobSpecification_Call) Run(run func(ctx context.Context, in *corev1beta1.ListJobSpecificationRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_ListJobSpecification_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.ListJobSpecificationRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_ListJobSpecification_Call) Return(_a0 *corev1beta1.ListJobSpecificationResponse, _a1 error) *JobSpecificationServiceClient_ListJobSpecification_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_ListJobSpecification_Call) RunAndReturn(run func(context.Context, *corev1beta1.ListJobSpecificationRequest, ...grpc.CallOption) (*corev1beta1.ListJobSpecificationResponse, error)) *JobSpecificationServiceClient_ListJobSpecification_Call { + _c.Call.Return(run) + return _c +} + // RefreshJobs provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) RefreshJobs(ctx context.Context, in *corev1beta1.RefreshJobsRequest, opts ...grpc.CallOption) (corev1beta1grpc.JobSpecificationService_RefreshJobsClient, error) { _va := make([]interface{}, len(opts)) @@ -513,6 +1038,43 @@ func (_m *JobSpecificationServiceClient) RefreshJobs(ctx context.Context, in *co return r0, r1 } +// JobSpecificationServiceClient_RefreshJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RefreshJobs' +type JobSpecificationServiceClient_RefreshJobs_Call struct { + *mock.Call +} + +// RefreshJobs is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.RefreshJobsRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) RefreshJobs(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_RefreshJobs_Call { + return &JobSpecificationServiceClient_RefreshJobs_Call{Call: _e.mock.On("RefreshJobs", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_RefreshJobs_Call) Run(run func(ctx context.Context, in *corev1beta1.RefreshJobsRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_RefreshJobs_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.RefreshJobsRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_RefreshJobs_Call) Return(_a0 corev1beta1grpc.JobSpecificationService_RefreshJobsClient, _a1 error) *JobSpecificationServiceClient_RefreshJobs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_RefreshJobs_Call) RunAndReturn(run func(context.Context, *corev1beta1.RefreshJobsRequest, ...grpc.CallOption) (corev1beta1grpc.JobSpecificationService_RefreshJobsClient, error)) *JobSpecificationServiceClient_RefreshJobs_Call { + _c.Call.Return(run) + return _c +} + // ReplaceAllJobSpecifications provides a mock function with given fields: ctx, opts func (_m *JobSpecificationServiceClient) ReplaceAllJobSpecifications(ctx context.Context, opts ...grpc.CallOption) (corev1beta1grpc.JobSpecificationService_ReplaceAllJobSpecificationsClient, error) { _va := make([]interface{}, len(opts)) @@ -546,6 +1108,42 @@ func (_m *JobSpecificationServiceClient) ReplaceAllJobSpecifications(ctx context return r0, r1 } +// JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReplaceAllJobSpecifications' +type JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call struct { + *mock.Call +} + +// ReplaceAllJobSpecifications is a helper method to define mock.On call +// - ctx context.Context +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) ReplaceAllJobSpecifications(ctx interface{}, opts ...interface{}) *JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call { + return &JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call{Call: _e.mock.On("ReplaceAllJobSpecifications", + append([]interface{}{ctx}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call) Run(run func(ctx context.Context, opts ...grpc.CallOption)) *JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call) Return(_a0 corev1beta1grpc.JobSpecificationService_ReplaceAllJobSpecificationsClient, _a1 error) *JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call) RunAndReturn(run func(context.Context, ...grpc.CallOption) (corev1beta1grpc.JobSpecificationService_ReplaceAllJobSpecificationsClient, error)) *JobSpecificationServiceClient_ReplaceAllJobSpecifications_Call { + _c.Call.Return(run) + return _c +} + // SyncJobsState provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) SyncJobsState(ctx context.Context, in *corev1beta1.SyncJobsStateRequest, opts ...grpc.CallOption) (*corev1beta1.SyncJobsStateResponse, error) { _va := make([]interface{}, len(opts)) @@ -579,6 +1177,43 @@ func (_m *JobSpecificationServiceClient) SyncJobsState(ctx context.Context, in * return r0, r1 } +// JobSpecificationServiceClient_SyncJobsState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SyncJobsState' +type JobSpecificationServiceClient_SyncJobsState_Call struct { + *mock.Call +} + +// SyncJobsState is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.SyncJobsStateRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) SyncJobsState(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_SyncJobsState_Call { + return &JobSpecificationServiceClient_SyncJobsState_Call{Call: _e.mock.On("SyncJobsState", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_SyncJobsState_Call) Run(run func(ctx context.Context, in *corev1beta1.SyncJobsStateRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_SyncJobsState_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.SyncJobsStateRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_SyncJobsState_Call) Return(_a0 *corev1beta1.SyncJobsStateResponse, _a1 error) *JobSpecificationServiceClient_SyncJobsState_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_SyncJobsState_Call) RunAndReturn(run func(context.Context, *corev1beta1.SyncJobsStateRequest, ...grpc.CallOption) (*corev1beta1.SyncJobsStateResponse, error)) *JobSpecificationServiceClient_SyncJobsState_Call { + _c.Call.Return(run) + return _c +} + // UpdateJobSpecifications provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) UpdateJobSpecifications(ctx context.Context, in *corev1beta1.UpdateJobSpecificationsRequest, opts ...grpc.CallOption) (*corev1beta1.UpdateJobSpecificationsResponse, error) { _va := make([]interface{}, len(opts)) @@ -612,6 +1247,43 @@ func (_m *JobSpecificationServiceClient) UpdateJobSpecifications(ctx context.Con return r0, r1 } +// JobSpecificationServiceClient_UpdateJobSpecifications_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateJobSpecifications' +type JobSpecificationServiceClient_UpdateJobSpecifications_Call struct { + *mock.Call +} + +// UpdateJobSpecifications is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.UpdateJobSpecificationsRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) UpdateJobSpecifications(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_UpdateJobSpecifications_Call { + return &JobSpecificationServiceClient_UpdateJobSpecifications_Call{Call: _e.mock.On("UpdateJobSpecifications", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_UpdateJobSpecifications_Call) Run(run func(ctx context.Context, in *corev1beta1.UpdateJobSpecificationsRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_UpdateJobSpecifications_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.UpdateJobSpecificationsRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_UpdateJobSpecifications_Call) Return(_a0 *corev1beta1.UpdateJobSpecificationsResponse, _a1 error) *JobSpecificationServiceClient_UpdateJobSpecifications_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_UpdateJobSpecifications_Call) RunAndReturn(run func(context.Context, *corev1beta1.UpdateJobSpecificationsRequest, ...grpc.CallOption) (*corev1beta1.UpdateJobSpecificationsResponse, error)) *JobSpecificationServiceClient_UpdateJobSpecifications_Call { + _c.Call.Return(run) + return _c +} + // UpdateJobsState provides a mock function with given fields: ctx, in, opts func (_m *JobSpecificationServiceClient) UpdateJobsState(ctx context.Context, in *corev1beta1.UpdateJobsStateRequest, opts ...grpc.CallOption) (*corev1beta1.UpdateJobsStateResponse, error) { _va := make([]interface{}, len(opts)) @@ -645,6 +1317,43 @@ func (_m *JobSpecificationServiceClient) UpdateJobsState(ctx context.Context, in return r0, r1 } +// JobSpecificationServiceClient_UpdateJobsState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateJobsState' +type JobSpecificationServiceClient_UpdateJobsState_Call struct { + *mock.Call +} + +// UpdateJobsState is a helper method to define mock.On call +// - ctx context.Context +// - in *corev1beta1.UpdateJobsStateRequest +// - opts ...grpc.CallOption +func (_e *JobSpecificationServiceClient_Expecter) UpdateJobsState(ctx interface{}, in interface{}, opts ...interface{}) *JobSpecificationServiceClient_UpdateJobsState_Call { + return &JobSpecificationServiceClient_UpdateJobsState_Call{Call: _e.mock.On("UpdateJobsState", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *JobSpecificationServiceClient_UpdateJobsState_Call) Run(run func(ctx context.Context, in *corev1beta1.UpdateJobsStateRequest, opts ...grpc.CallOption)) *JobSpecificationServiceClient_UpdateJobsState_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*corev1beta1.UpdateJobsStateRequest), variadicArgs...) + }) + return _c +} + +func (_c *JobSpecificationServiceClient_UpdateJobsState_Call) Return(_a0 *corev1beta1.UpdateJobsStateResponse, _a1 error) *JobSpecificationServiceClient_UpdateJobsState_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *JobSpecificationServiceClient_UpdateJobsState_Call) RunAndReturn(run func(context.Context, *corev1beta1.UpdateJobsStateRequest, ...grpc.CallOption) (*corev1beta1.UpdateJobsStateResponse, error)) *JobSpecificationServiceClient_UpdateJobsState_Call { + _c.Call.Return(run) + return _c +} + // NewJobSpecificationServiceClient creates a new instance of JobSpecificationServiceClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewJobSpecificationServiceClient(t interface { diff --git a/mocks/ObjectIterator.go b/mocks/ObjectIterator.go index 431e90a..34ae7e4 100644 --- a/mocks/ObjectIterator.go +++ b/mocks/ObjectIterator.go @@ -12,6 +12,14 @@ type ObjectIterator struct { mock.Mock } +type ObjectIterator_Expecter struct { + mock *mock.Mock +} + +func (_m *ObjectIterator) EXPECT() *ObjectIterator_Expecter { + return &ObjectIterator_Expecter{mock: &_m.Mock} +} + // Next provides a mock function with given fields: func (_m *ObjectIterator) Next() (*storage.ObjectAttrs, error) { ret := _m.Called() @@ -38,6 +46,33 @@ func (_m *ObjectIterator) Next() (*storage.ObjectAttrs, error) { return r0, r1 } +// ObjectIterator_Next_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Next' +type ObjectIterator_Next_Call struct { + *mock.Call +} + +// Next is a helper method to define mock.On call +func (_e *ObjectIterator_Expecter) Next() *ObjectIterator_Next_Call { + return &ObjectIterator_Next_Call{Call: _e.mock.On("Next")} +} + +func (_c *ObjectIterator_Next_Call) Run(run func()) *ObjectIterator_Next_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ObjectIterator_Next_Call) Return(_a0 *storage.ObjectAttrs, _a1 error) *ObjectIterator_Next_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ObjectIterator_Next_Call) RunAndReturn(run func() (*storage.ObjectAttrs, error)) *ObjectIterator_Next_Call { + _c.Call.Return(run) + return _c +} + // NewObjectIterator creates a new instance of ObjectIterator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewObjectIterator(t interface { diff --git a/mocks/ResourceServiceClient.go b/mocks/ResourceServiceClient.go index 32bf703..909fd41 100644 --- a/mocks/ResourceServiceClient.go +++ b/mocks/ResourceServiceClient.go @@ -18,6 +18,14 @@ type ResourceServiceClient struct { mock.Mock } +type ResourceServiceClient_Expecter struct { + mock *mock.Mock +} + +func (_m *ResourceServiceClient) EXPECT() *ResourceServiceClient_Expecter { + return &ResourceServiceClient_Expecter{mock: &_m.Mock} +} + // ApplyAction provides a mock function with given fields: ctx, in, opts func (_m *ResourceServiceClient) ApplyAction(ctx context.Context, in *entropyv1beta1.ApplyActionRequest, opts ...grpc.CallOption) (*entropyv1beta1.ApplyActionResponse, error) { _va := make([]interface{}, len(opts)) @@ -51,6 +59,43 @@ func (_m *ResourceServiceClient) ApplyAction(ctx context.Context, in *entropyv1b return r0, r1 } +// ResourceServiceClient_ApplyAction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplyAction' +type ResourceServiceClient_ApplyAction_Call struct { + *mock.Call +} + +// ApplyAction is a helper method to define mock.On call +// - ctx context.Context +// - in *entropyv1beta1.ApplyActionRequest +// - opts ...grpc.CallOption +func (_e *ResourceServiceClient_Expecter) ApplyAction(ctx interface{}, in interface{}, opts ...interface{}) *ResourceServiceClient_ApplyAction_Call { + return &ResourceServiceClient_ApplyAction_Call{Call: _e.mock.On("ApplyAction", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ResourceServiceClient_ApplyAction_Call) Run(run func(ctx context.Context, in *entropyv1beta1.ApplyActionRequest, opts ...grpc.CallOption)) *ResourceServiceClient_ApplyAction_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*entropyv1beta1.ApplyActionRequest), variadicArgs...) + }) + return _c +} + +func (_c *ResourceServiceClient_ApplyAction_Call) Return(_a0 *entropyv1beta1.ApplyActionResponse, _a1 error) *ResourceServiceClient_ApplyAction_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ResourceServiceClient_ApplyAction_Call) RunAndReturn(run func(context.Context, *entropyv1beta1.ApplyActionRequest, ...grpc.CallOption) (*entropyv1beta1.ApplyActionResponse, error)) *ResourceServiceClient_ApplyAction_Call { + _c.Call.Return(run) + return _c +} + // CreateResource provides a mock function with given fields: ctx, in, opts func (_m *ResourceServiceClient) CreateResource(ctx context.Context, in *entropyv1beta1.CreateResourceRequest, opts ...grpc.CallOption) (*entropyv1beta1.CreateResourceResponse, error) { _va := make([]interface{}, len(opts)) @@ -84,6 +129,43 @@ func (_m *ResourceServiceClient) CreateResource(ctx context.Context, in *entropy return r0, r1 } +// ResourceServiceClient_CreateResource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateResource' +type ResourceServiceClient_CreateResource_Call struct { + *mock.Call +} + +// CreateResource is a helper method to define mock.On call +// - ctx context.Context +// - in *entropyv1beta1.CreateResourceRequest +// - opts ...grpc.CallOption +func (_e *ResourceServiceClient_Expecter) CreateResource(ctx interface{}, in interface{}, opts ...interface{}) *ResourceServiceClient_CreateResource_Call { + return &ResourceServiceClient_CreateResource_Call{Call: _e.mock.On("CreateResource", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ResourceServiceClient_CreateResource_Call) Run(run func(ctx context.Context, in *entropyv1beta1.CreateResourceRequest, opts ...grpc.CallOption)) *ResourceServiceClient_CreateResource_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*entropyv1beta1.CreateResourceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ResourceServiceClient_CreateResource_Call) Return(_a0 *entropyv1beta1.CreateResourceResponse, _a1 error) *ResourceServiceClient_CreateResource_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ResourceServiceClient_CreateResource_Call) RunAndReturn(run func(context.Context, *entropyv1beta1.CreateResourceRequest, ...grpc.CallOption) (*entropyv1beta1.CreateResourceResponse, error)) *ResourceServiceClient_CreateResource_Call { + _c.Call.Return(run) + return _c +} + // DeleteResource provides a mock function with given fields: ctx, in, opts func (_m *ResourceServiceClient) DeleteResource(ctx context.Context, in *entropyv1beta1.DeleteResourceRequest, opts ...grpc.CallOption) (*entropyv1beta1.DeleteResourceResponse, error) { _va := make([]interface{}, len(opts)) @@ -117,6 +199,43 @@ func (_m *ResourceServiceClient) DeleteResource(ctx context.Context, in *entropy return r0, r1 } +// ResourceServiceClient_DeleteResource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteResource' +type ResourceServiceClient_DeleteResource_Call struct { + *mock.Call +} + +// DeleteResource is a helper method to define mock.On call +// - ctx context.Context +// - in *entropyv1beta1.DeleteResourceRequest +// - opts ...grpc.CallOption +func (_e *ResourceServiceClient_Expecter) DeleteResource(ctx interface{}, in interface{}, opts ...interface{}) *ResourceServiceClient_DeleteResource_Call { + return &ResourceServiceClient_DeleteResource_Call{Call: _e.mock.On("DeleteResource", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ResourceServiceClient_DeleteResource_Call) Run(run func(ctx context.Context, in *entropyv1beta1.DeleteResourceRequest, opts ...grpc.CallOption)) *ResourceServiceClient_DeleteResource_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*entropyv1beta1.DeleteResourceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ResourceServiceClient_DeleteResource_Call) Return(_a0 *entropyv1beta1.DeleteResourceResponse, _a1 error) *ResourceServiceClient_DeleteResource_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ResourceServiceClient_DeleteResource_Call) RunAndReturn(run func(context.Context, *entropyv1beta1.DeleteResourceRequest, ...grpc.CallOption) (*entropyv1beta1.DeleteResourceResponse, error)) *ResourceServiceClient_DeleteResource_Call { + _c.Call.Return(run) + return _c +} + // GetLog provides a mock function with given fields: ctx, in, opts func (_m *ResourceServiceClient) GetLog(ctx context.Context, in *entropyv1beta1.GetLogRequest, opts ...grpc.CallOption) (entropyv1beta1grpc.ResourceService_GetLogClient, error) { _va := make([]interface{}, len(opts)) @@ -150,6 +269,43 @@ func (_m *ResourceServiceClient) GetLog(ctx context.Context, in *entropyv1beta1. return r0, r1 } +// ResourceServiceClient_GetLog_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLog' +type ResourceServiceClient_GetLog_Call struct { + *mock.Call +} + +// GetLog is a helper method to define mock.On call +// - ctx context.Context +// - in *entropyv1beta1.GetLogRequest +// - opts ...grpc.CallOption +func (_e *ResourceServiceClient_Expecter) GetLog(ctx interface{}, in interface{}, opts ...interface{}) *ResourceServiceClient_GetLog_Call { + return &ResourceServiceClient_GetLog_Call{Call: _e.mock.On("GetLog", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ResourceServiceClient_GetLog_Call) Run(run func(ctx context.Context, in *entropyv1beta1.GetLogRequest, opts ...grpc.CallOption)) *ResourceServiceClient_GetLog_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*entropyv1beta1.GetLogRequest), variadicArgs...) + }) + return _c +} + +func (_c *ResourceServiceClient_GetLog_Call) Return(_a0 entropyv1beta1grpc.ResourceService_GetLogClient, _a1 error) *ResourceServiceClient_GetLog_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ResourceServiceClient_GetLog_Call) RunAndReturn(run func(context.Context, *entropyv1beta1.GetLogRequest, ...grpc.CallOption) (entropyv1beta1grpc.ResourceService_GetLogClient, error)) *ResourceServiceClient_GetLog_Call { + _c.Call.Return(run) + return _c +} + // GetResource provides a mock function with given fields: ctx, in, opts func (_m *ResourceServiceClient) GetResource(ctx context.Context, in *entropyv1beta1.GetResourceRequest, opts ...grpc.CallOption) (*entropyv1beta1.GetResourceResponse, error) { _va := make([]interface{}, len(opts)) @@ -183,6 +339,43 @@ func (_m *ResourceServiceClient) GetResource(ctx context.Context, in *entropyv1b return r0, r1 } +// ResourceServiceClient_GetResource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetResource' +type ResourceServiceClient_GetResource_Call struct { + *mock.Call +} + +// GetResource is a helper method to define mock.On call +// - ctx context.Context +// - in *entropyv1beta1.GetResourceRequest +// - opts ...grpc.CallOption +func (_e *ResourceServiceClient_Expecter) GetResource(ctx interface{}, in interface{}, opts ...interface{}) *ResourceServiceClient_GetResource_Call { + return &ResourceServiceClient_GetResource_Call{Call: _e.mock.On("GetResource", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ResourceServiceClient_GetResource_Call) Run(run func(ctx context.Context, in *entropyv1beta1.GetResourceRequest, opts ...grpc.CallOption)) *ResourceServiceClient_GetResource_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*entropyv1beta1.GetResourceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ResourceServiceClient_GetResource_Call) Return(_a0 *entropyv1beta1.GetResourceResponse, _a1 error) *ResourceServiceClient_GetResource_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ResourceServiceClient_GetResource_Call) RunAndReturn(run func(context.Context, *entropyv1beta1.GetResourceRequest, ...grpc.CallOption) (*entropyv1beta1.GetResourceResponse, error)) *ResourceServiceClient_GetResource_Call { + _c.Call.Return(run) + return _c +} + // GetResourceRevisions provides a mock function with given fields: ctx, in, opts func (_m *ResourceServiceClient) GetResourceRevisions(ctx context.Context, in *entropyv1beta1.GetResourceRevisionsRequest, opts ...grpc.CallOption) (*entropyv1beta1.GetResourceRevisionsResponse, error) { _va := make([]interface{}, len(opts)) @@ -216,6 +409,43 @@ func (_m *ResourceServiceClient) GetResourceRevisions(ctx context.Context, in *e return r0, r1 } +// ResourceServiceClient_GetResourceRevisions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetResourceRevisions' +type ResourceServiceClient_GetResourceRevisions_Call struct { + *mock.Call +} + +// GetResourceRevisions is a helper method to define mock.On call +// - ctx context.Context +// - in *entropyv1beta1.GetResourceRevisionsRequest +// - opts ...grpc.CallOption +func (_e *ResourceServiceClient_Expecter) GetResourceRevisions(ctx interface{}, in interface{}, opts ...interface{}) *ResourceServiceClient_GetResourceRevisions_Call { + return &ResourceServiceClient_GetResourceRevisions_Call{Call: _e.mock.On("GetResourceRevisions", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ResourceServiceClient_GetResourceRevisions_Call) Run(run func(ctx context.Context, in *entropyv1beta1.GetResourceRevisionsRequest, opts ...grpc.CallOption)) *ResourceServiceClient_GetResourceRevisions_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*entropyv1beta1.GetResourceRevisionsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ResourceServiceClient_GetResourceRevisions_Call) Return(_a0 *entropyv1beta1.GetResourceRevisionsResponse, _a1 error) *ResourceServiceClient_GetResourceRevisions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ResourceServiceClient_GetResourceRevisions_Call) RunAndReturn(run func(context.Context, *entropyv1beta1.GetResourceRevisionsRequest, ...grpc.CallOption) (*entropyv1beta1.GetResourceRevisionsResponse, error)) *ResourceServiceClient_GetResourceRevisions_Call { + _c.Call.Return(run) + return _c +} + // ListResources provides a mock function with given fields: ctx, in, opts func (_m *ResourceServiceClient) ListResources(ctx context.Context, in *entropyv1beta1.ListResourcesRequest, opts ...grpc.CallOption) (*entropyv1beta1.ListResourcesResponse, error) { _va := make([]interface{}, len(opts)) @@ -249,6 +479,43 @@ func (_m *ResourceServiceClient) ListResources(ctx context.Context, in *entropyv return r0, r1 } +// ResourceServiceClient_ListResources_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListResources' +type ResourceServiceClient_ListResources_Call struct { + *mock.Call +} + +// ListResources is a helper method to define mock.On call +// - ctx context.Context +// - in *entropyv1beta1.ListResourcesRequest +// - opts ...grpc.CallOption +func (_e *ResourceServiceClient_Expecter) ListResources(ctx interface{}, in interface{}, opts ...interface{}) *ResourceServiceClient_ListResources_Call { + return &ResourceServiceClient_ListResources_Call{Call: _e.mock.On("ListResources", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ResourceServiceClient_ListResources_Call) Run(run func(ctx context.Context, in *entropyv1beta1.ListResourcesRequest, opts ...grpc.CallOption)) *ResourceServiceClient_ListResources_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*entropyv1beta1.ListResourcesRequest), variadicArgs...) + }) + return _c +} + +func (_c *ResourceServiceClient_ListResources_Call) Return(_a0 *entropyv1beta1.ListResourcesResponse, _a1 error) *ResourceServiceClient_ListResources_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ResourceServiceClient_ListResources_Call) RunAndReturn(run func(context.Context, *entropyv1beta1.ListResourcesRequest, ...grpc.CallOption) (*entropyv1beta1.ListResourcesResponse, error)) *ResourceServiceClient_ListResources_Call { + _c.Call.Return(run) + return _c +} + // UpdateResource provides a mock function with given fields: ctx, in, opts func (_m *ResourceServiceClient) UpdateResource(ctx context.Context, in *entropyv1beta1.UpdateResourceRequest, opts ...grpc.CallOption) (*entropyv1beta1.UpdateResourceResponse, error) { _va := make([]interface{}, len(opts)) @@ -282,6 +549,43 @@ func (_m *ResourceServiceClient) UpdateResource(ctx context.Context, in *entropy return r0, r1 } +// ResourceServiceClient_UpdateResource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateResource' +type ResourceServiceClient_UpdateResource_Call struct { + *mock.Call +} + +// UpdateResource is a helper method to define mock.On call +// - ctx context.Context +// - in *entropyv1beta1.UpdateResourceRequest +// - opts ...grpc.CallOption +func (_e *ResourceServiceClient_Expecter) UpdateResource(ctx interface{}, in interface{}, opts ...interface{}) *ResourceServiceClient_UpdateResource_Call { + return &ResourceServiceClient_UpdateResource_Call{Call: _e.mock.On("UpdateResource", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ResourceServiceClient_UpdateResource_Call) Run(run func(ctx context.Context, in *entropyv1beta1.UpdateResourceRequest, opts ...grpc.CallOption)) *ResourceServiceClient_UpdateResource_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*entropyv1beta1.UpdateResourceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ResourceServiceClient_UpdateResource_Call) Return(_a0 *entropyv1beta1.UpdateResourceResponse, _a1 error) *ResourceServiceClient_UpdateResource_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ResourceServiceClient_UpdateResource_Call) RunAndReturn(run func(context.Context, *entropyv1beta1.UpdateResourceRequest, ...grpc.CallOption) (*entropyv1beta1.UpdateResourceResponse, error)) *ResourceServiceClient_UpdateResource_Call { + _c.Call.Return(run) + return _c +} + // NewResourceServiceClient creates a new instance of ResourceServiceClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewResourceServiceClient(t interface { diff --git a/mocks/ShieldServiceClient.go b/mocks/ShieldServiceClient.go index 67fc2ea..89e325c 100644 --- a/mocks/ShieldServiceClient.go +++ b/mocks/ShieldServiceClient.go @@ -17,6 +17,14 @@ type ShieldServiceClient struct { mock.Mock } +type ShieldServiceClient_Expecter struct { + mock *mock.Mock +} + +func (_m *ShieldServiceClient) EXPECT() *ShieldServiceClient_Expecter { + return &ShieldServiceClient_Expecter{mock: &_m.Mock} +} + // CheckResourcePermission provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CheckResourcePermission(ctx context.Context, in *shieldv1beta1.CheckResourcePermissionRequest, opts ...grpc.CallOption) (*shieldv1beta1.CheckResourcePermissionResponse, error) { _va := make([]interface{}, len(opts)) @@ -50,6 +58,43 @@ func (_m *ShieldServiceClient) CheckResourcePermission(ctx context.Context, in * return r0, r1 } +// ShieldServiceClient_CheckResourcePermission_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckResourcePermission' +type ShieldServiceClient_CheckResourcePermission_Call struct { + *mock.Call +} + +// CheckResourcePermission is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CheckResourcePermissionRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CheckResourcePermission(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CheckResourcePermission_Call { + return &ShieldServiceClient_CheckResourcePermission_Call{Call: _e.mock.On("CheckResourcePermission", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CheckResourcePermission_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CheckResourcePermissionRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CheckResourcePermission_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CheckResourcePermissionRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CheckResourcePermission_Call) Return(_a0 *shieldv1beta1.CheckResourcePermissionResponse, _a1 error) *ShieldServiceClient_CheckResourcePermission_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CheckResourcePermission_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CheckResourcePermissionRequest, ...grpc.CallOption) (*shieldv1beta1.CheckResourcePermissionResponse, error)) *ShieldServiceClient_CheckResourcePermission_Call { + _c.Call.Return(run) + return _c +} + // CreateAction provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateAction(ctx context.Context, in *shieldv1beta1.CreateActionRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateActionResponse, error) { _va := make([]interface{}, len(opts)) @@ -83,6 +128,43 @@ func (_m *ShieldServiceClient) CreateAction(ctx context.Context, in *shieldv1bet return r0, r1 } +// ShieldServiceClient_CreateAction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAction' +type ShieldServiceClient_CreateAction_Call struct { + *mock.Call +} + +// CreateAction is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateActionRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateAction(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateAction_Call { + return &ShieldServiceClient_CreateAction_Call{Call: _e.mock.On("CreateAction", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateAction_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateActionRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateAction_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateActionRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateAction_Call) Return(_a0 *shieldv1beta1.CreateActionResponse, _a1 error) *ShieldServiceClient_CreateAction_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateAction_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateActionRequest, ...grpc.CallOption) (*shieldv1beta1.CreateActionResponse, error)) *ShieldServiceClient_CreateAction_Call { + _c.Call.Return(run) + return _c +} + // CreateGroup provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateGroup(ctx context.Context, in *shieldv1beta1.CreateGroupRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateGroupResponse, error) { _va := make([]interface{}, len(opts)) @@ -116,6 +198,43 @@ func (_m *ShieldServiceClient) CreateGroup(ctx context.Context, in *shieldv1beta return r0, r1 } +// ShieldServiceClient_CreateGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGroup' +type ShieldServiceClient_CreateGroup_Call struct { + *mock.Call +} + +// CreateGroup is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateGroupRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateGroup(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateGroup_Call { + return &ShieldServiceClient_CreateGroup_Call{Call: _e.mock.On("CreateGroup", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateGroup_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateGroupRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateGroupRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateGroup_Call) Return(_a0 *shieldv1beta1.CreateGroupResponse, _a1 error) *ShieldServiceClient_CreateGroup_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateGroup_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateGroupRequest, ...grpc.CallOption) (*shieldv1beta1.CreateGroupResponse, error)) *ShieldServiceClient_CreateGroup_Call { + _c.Call.Return(run) + return _c +} + // CreateMetadataKey provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateMetadataKey(ctx context.Context, in *shieldv1beta1.CreateMetadataKeyRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateMetadataKeyResponse, error) { _va := make([]interface{}, len(opts)) @@ -149,6 +268,43 @@ func (_m *ShieldServiceClient) CreateMetadataKey(ctx context.Context, in *shield return r0, r1 } +// ShieldServiceClient_CreateMetadataKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMetadataKey' +type ShieldServiceClient_CreateMetadataKey_Call struct { + *mock.Call +} + +// CreateMetadataKey is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateMetadataKeyRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateMetadataKey(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateMetadataKey_Call { + return &ShieldServiceClient_CreateMetadataKey_Call{Call: _e.mock.On("CreateMetadataKey", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateMetadataKey_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateMetadataKeyRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateMetadataKey_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateMetadataKeyRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateMetadataKey_Call) Return(_a0 *shieldv1beta1.CreateMetadataKeyResponse, _a1 error) *ShieldServiceClient_CreateMetadataKey_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateMetadataKey_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateMetadataKeyRequest, ...grpc.CallOption) (*shieldv1beta1.CreateMetadataKeyResponse, error)) *ShieldServiceClient_CreateMetadataKey_Call { + _c.Call.Return(run) + return _c +} + // CreateNamespace provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateNamespace(ctx context.Context, in *shieldv1beta1.CreateNamespaceRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -182,6 +338,43 @@ func (_m *ShieldServiceClient) CreateNamespace(ctx context.Context, in *shieldv1 return r0, r1 } +// ShieldServiceClient_CreateNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateNamespace' +type ShieldServiceClient_CreateNamespace_Call struct { + *mock.Call +} + +// CreateNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateNamespaceRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateNamespace(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateNamespace_Call { + return &ShieldServiceClient_CreateNamespace_Call{Call: _e.mock.On("CreateNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateNamespace_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateNamespaceRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateNamespace_Call) Return(_a0 *shieldv1beta1.CreateNamespaceResponse, _a1 error) *ShieldServiceClient_CreateNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateNamespace_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateNamespaceRequest, ...grpc.CallOption) (*shieldv1beta1.CreateNamespaceResponse, error)) *ShieldServiceClient_CreateNamespace_Call { + _c.Call.Return(run) + return _c +} + // CreateOrganization provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateOrganization(ctx context.Context, in *shieldv1beta1.CreateOrganizationRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateOrganizationResponse, error) { _va := make([]interface{}, len(opts)) @@ -215,6 +408,43 @@ func (_m *ShieldServiceClient) CreateOrganization(ctx context.Context, in *shiel return r0, r1 } +// ShieldServiceClient_CreateOrganization_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrganization' +type ShieldServiceClient_CreateOrganization_Call struct { + *mock.Call +} + +// CreateOrganization is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateOrganizationRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateOrganization(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateOrganization_Call { + return &ShieldServiceClient_CreateOrganization_Call{Call: _e.mock.On("CreateOrganization", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateOrganization_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateOrganizationRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateOrganization_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateOrganizationRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateOrganization_Call) Return(_a0 *shieldv1beta1.CreateOrganizationResponse, _a1 error) *ShieldServiceClient_CreateOrganization_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateOrganization_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateOrganizationRequest, ...grpc.CallOption) (*shieldv1beta1.CreateOrganizationResponse, error)) *ShieldServiceClient_CreateOrganization_Call { + _c.Call.Return(run) + return _c +} + // CreatePolicy provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreatePolicy(ctx context.Context, in *shieldv1beta1.CreatePolicyRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreatePolicyResponse, error) { _va := make([]interface{}, len(opts)) @@ -248,6 +478,43 @@ func (_m *ShieldServiceClient) CreatePolicy(ctx context.Context, in *shieldv1bet return r0, r1 } +// ShieldServiceClient_CreatePolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreatePolicy' +type ShieldServiceClient_CreatePolicy_Call struct { + *mock.Call +} + +// CreatePolicy is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreatePolicyRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreatePolicy(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreatePolicy_Call { + return &ShieldServiceClient_CreatePolicy_Call{Call: _e.mock.On("CreatePolicy", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreatePolicy_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreatePolicyRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreatePolicy_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreatePolicyRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreatePolicy_Call) Return(_a0 *shieldv1beta1.CreatePolicyResponse, _a1 error) *ShieldServiceClient_CreatePolicy_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreatePolicy_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreatePolicyRequest, ...grpc.CallOption) (*shieldv1beta1.CreatePolicyResponse, error)) *ShieldServiceClient_CreatePolicy_Call { + _c.Call.Return(run) + return _c +} + // CreateProject provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateProject(ctx context.Context, in *shieldv1beta1.CreateProjectRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateProjectResponse, error) { _va := make([]interface{}, len(opts)) @@ -281,6 +548,43 @@ func (_m *ShieldServiceClient) CreateProject(ctx context.Context, in *shieldv1be return r0, r1 } +// ShieldServiceClient_CreateProject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateProject' +type ShieldServiceClient_CreateProject_Call struct { + *mock.Call +} + +// CreateProject is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateProjectRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateProject(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateProject_Call { + return &ShieldServiceClient_CreateProject_Call{Call: _e.mock.On("CreateProject", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateProject_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateProjectRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateProject_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateProjectRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateProject_Call) Return(_a0 *shieldv1beta1.CreateProjectResponse, _a1 error) *ShieldServiceClient_CreateProject_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateProject_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateProjectRequest, ...grpc.CallOption) (*shieldv1beta1.CreateProjectResponse, error)) *ShieldServiceClient_CreateProject_Call { + _c.Call.Return(run) + return _c +} + // CreateRelation provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateRelation(ctx context.Context, in *shieldv1beta1.CreateRelationRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateRelationResponse, error) { _va := make([]interface{}, len(opts)) @@ -314,6 +618,43 @@ func (_m *ShieldServiceClient) CreateRelation(ctx context.Context, in *shieldv1b return r0, r1 } +// ShieldServiceClient_CreateRelation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRelation' +type ShieldServiceClient_CreateRelation_Call struct { + *mock.Call +} + +// CreateRelation is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateRelationRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateRelation(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateRelation_Call { + return &ShieldServiceClient_CreateRelation_Call{Call: _e.mock.On("CreateRelation", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateRelation_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateRelationRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateRelation_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateRelationRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateRelation_Call) Return(_a0 *shieldv1beta1.CreateRelationResponse, _a1 error) *ShieldServiceClient_CreateRelation_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateRelation_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateRelationRequest, ...grpc.CallOption) (*shieldv1beta1.CreateRelationResponse, error)) *ShieldServiceClient_CreateRelation_Call { + _c.Call.Return(run) + return _c +} + // CreateResource provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateResource(ctx context.Context, in *shieldv1beta1.CreateResourceRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateResourceResponse, error) { _va := make([]interface{}, len(opts)) @@ -347,6 +688,43 @@ func (_m *ShieldServiceClient) CreateResource(ctx context.Context, in *shieldv1b return r0, r1 } +// ShieldServiceClient_CreateResource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateResource' +type ShieldServiceClient_CreateResource_Call struct { + *mock.Call +} + +// CreateResource is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateResourceRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateResource(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateResource_Call { + return &ShieldServiceClient_CreateResource_Call{Call: _e.mock.On("CreateResource", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateResource_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateResourceRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateResource_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateResourceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateResource_Call) Return(_a0 *shieldv1beta1.CreateResourceResponse, _a1 error) *ShieldServiceClient_CreateResource_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateResource_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateResourceRequest, ...grpc.CallOption) (*shieldv1beta1.CreateResourceResponse, error)) *ShieldServiceClient_CreateResource_Call { + _c.Call.Return(run) + return _c +} + // CreateRole provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateRole(ctx context.Context, in *shieldv1beta1.CreateRoleRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateRoleResponse, error) { _va := make([]interface{}, len(opts)) @@ -380,6 +758,43 @@ func (_m *ShieldServiceClient) CreateRole(ctx context.Context, in *shieldv1beta1 return r0, r1 } +// ShieldServiceClient_CreateRole_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRole' +type ShieldServiceClient_CreateRole_Call struct { + *mock.Call +} + +// CreateRole is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateRoleRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateRole(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateRole_Call { + return &ShieldServiceClient_CreateRole_Call{Call: _e.mock.On("CreateRole", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateRole_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateRoleRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateRole_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateRoleRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateRole_Call) Return(_a0 *shieldv1beta1.CreateRoleResponse, _a1 error) *ShieldServiceClient_CreateRole_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateRole_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateRoleRequest, ...grpc.CallOption) (*shieldv1beta1.CreateRoleResponse, error)) *ShieldServiceClient_CreateRole_Call { + _c.Call.Return(run) + return _c +} + // CreateUser provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) CreateUser(ctx context.Context, in *shieldv1beta1.CreateUserRequest, opts ...grpc.CallOption) (*shieldv1beta1.CreateUserResponse, error) { _va := make([]interface{}, len(opts)) @@ -413,6 +828,43 @@ func (_m *ShieldServiceClient) CreateUser(ctx context.Context, in *shieldv1beta1 return r0, r1 } +// ShieldServiceClient_CreateUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateUser' +type ShieldServiceClient_CreateUser_Call struct { + *mock.Call +} + +// CreateUser is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.CreateUserRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) CreateUser(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_CreateUser_Call { + return &ShieldServiceClient_CreateUser_Call{Call: _e.mock.On("CreateUser", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_CreateUser_Call) Run(run func(ctx context.Context, in *shieldv1beta1.CreateUserRequest, opts ...grpc.CallOption)) *ShieldServiceClient_CreateUser_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.CreateUserRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_CreateUser_Call) Return(_a0 *shieldv1beta1.CreateUserResponse, _a1 error) *ShieldServiceClient_CreateUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_CreateUser_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.CreateUserRequest, ...grpc.CallOption) (*shieldv1beta1.CreateUserResponse, error)) *ShieldServiceClient_CreateUser_Call { + _c.Call.Return(run) + return _c +} + // DeleteRelation provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) DeleteRelation(ctx context.Context, in *shieldv1beta1.DeleteRelationRequest, opts ...grpc.CallOption) (*shieldv1beta1.DeleteRelationResponse, error) { _va := make([]interface{}, len(opts)) @@ -446,6 +898,43 @@ func (_m *ShieldServiceClient) DeleteRelation(ctx context.Context, in *shieldv1b return r0, r1 } +// ShieldServiceClient_DeleteRelation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRelation' +type ShieldServiceClient_DeleteRelation_Call struct { + *mock.Call +} + +// DeleteRelation is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.DeleteRelationRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) DeleteRelation(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_DeleteRelation_Call { + return &ShieldServiceClient_DeleteRelation_Call{Call: _e.mock.On("DeleteRelation", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_DeleteRelation_Call) Run(run func(ctx context.Context, in *shieldv1beta1.DeleteRelationRequest, opts ...grpc.CallOption)) *ShieldServiceClient_DeleteRelation_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.DeleteRelationRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_DeleteRelation_Call) Return(_a0 *shieldv1beta1.DeleteRelationResponse, _a1 error) *ShieldServiceClient_DeleteRelation_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_DeleteRelation_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.DeleteRelationRequest, ...grpc.CallOption) (*shieldv1beta1.DeleteRelationResponse, error)) *ShieldServiceClient_DeleteRelation_Call { + _c.Call.Return(run) + return _c +} + // GetCurrentUser provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) GetCurrentUser(ctx context.Context, in *shieldv1beta1.GetCurrentUserRequest, opts ...grpc.CallOption) (*shieldv1beta1.GetCurrentUserResponse, error) { _va := make([]interface{}, len(opts)) @@ -479,6 +968,43 @@ func (_m *ShieldServiceClient) GetCurrentUser(ctx context.Context, in *shieldv1b return r0, r1 } +// ShieldServiceClient_GetCurrentUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCurrentUser' +type ShieldServiceClient_GetCurrentUser_Call struct { + *mock.Call +} + +// GetCurrentUser is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.GetCurrentUserRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) GetCurrentUser(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_GetCurrentUser_Call { + return &ShieldServiceClient_GetCurrentUser_Call{Call: _e.mock.On("GetCurrentUser", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_GetCurrentUser_Call) Run(run func(ctx context.Context, in *shieldv1beta1.GetCurrentUserRequest, opts ...grpc.CallOption)) *ShieldServiceClient_GetCurrentUser_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.GetCurrentUserRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_GetCurrentUser_Call) Return(_a0 *shieldv1beta1.GetCurrentUserResponse, _a1 error) *ShieldServiceClient_GetCurrentUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_GetCurrentUser_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.GetCurrentUserRequest, ...grpc.CallOption) (*shieldv1beta1.GetCurrentUserResponse, error)) *ShieldServiceClient_GetCurrentUser_Call { + _c.Call.Return(run) + return _c +} + // GetGroup provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) GetGroup(ctx context.Context, in *shieldv1beta1.GetGroupRequest, opts ...grpc.CallOption) (*shieldv1beta1.GetGroupResponse, error) { _va := make([]interface{}, len(opts)) @@ -512,6 +1038,43 @@ func (_m *ShieldServiceClient) GetGroup(ctx context.Context, in *shieldv1beta1.G return r0, r1 } +// ShieldServiceClient_GetGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetGroup' +type ShieldServiceClient_GetGroup_Call struct { + *mock.Call +} + +// GetGroup is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.GetGroupRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) GetGroup(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_GetGroup_Call { + return &ShieldServiceClient_GetGroup_Call{Call: _e.mock.On("GetGroup", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_GetGroup_Call) Run(run func(ctx context.Context, in *shieldv1beta1.GetGroupRequest, opts ...grpc.CallOption)) *ShieldServiceClient_GetGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.GetGroupRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_GetGroup_Call) Return(_a0 *shieldv1beta1.GetGroupResponse, _a1 error) *ShieldServiceClient_GetGroup_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_GetGroup_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.GetGroupRequest, ...grpc.CallOption) (*shieldv1beta1.GetGroupResponse, error)) *ShieldServiceClient_GetGroup_Call { + _c.Call.Return(run) + return _c +} + // GetNamespace provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) GetNamespace(ctx context.Context, in *shieldv1beta1.GetNamespaceRequest, opts ...grpc.CallOption) (*shieldv1beta1.GetNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -545,6 +1108,43 @@ func (_m *ShieldServiceClient) GetNamespace(ctx context.Context, in *shieldv1bet return r0, r1 } +// ShieldServiceClient_GetNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNamespace' +type ShieldServiceClient_GetNamespace_Call struct { + *mock.Call +} + +// GetNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.GetNamespaceRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) GetNamespace(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_GetNamespace_Call { + return &ShieldServiceClient_GetNamespace_Call{Call: _e.mock.On("GetNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_GetNamespace_Call) Run(run func(ctx context.Context, in *shieldv1beta1.GetNamespaceRequest, opts ...grpc.CallOption)) *ShieldServiceClient_GetNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.GetNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_GetNamespace_Call) Return(_a0 *shieldv1beta1.GetNamespaceResponse, _a1 error) *ShieldServiceClient_GetNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_GetNamespace_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.GetNamespaceRequest, ...grpc.CallOption) (*shieldv1beta1.GetNamespaceResponse, error)) *ShieldServiceClient_GetNamespace_Call { + _c.Call.Return(run) + return _c +} + // GetOrganization provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) GetOrganization(ctx context.Context, in *shieldv1beta1.GetOrganizationRequest, opts ...grpc.CallOption) (*shieldv1beta1.GetOrganizationResponse, error) { _va := make([]interface{}, len(opts)) @@ -578,6 +1178,43 @@ func (_m *ShieldServiceClient) GetOrganization(ctx context.Context, in *shieldv1 return r0, r1 } +// ShieldServiceClient_GetOrganization_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganization' +type ShieldServiceClient_GetOrganization_Call struct { + *mock.Call +} + +// GetOrganization is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.GetOrganizationRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) GetOrganization(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_GetOrganization_Call { + return &ShieldServiceClient_GetOrganization_Call{Call: _e.mock.On("GetOrganization", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_GetOrganization_Call) Run(run func(ctx context.Context, in *shieldv1beta1.GetOrganizationRequest, opts ...grpc.CallOption)) *ShieldServiceClient_GetOrganization_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.GetOrganizationRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_GetOrganization_Call) Return(_a0 *shieldv1beta1.GetOrganizationResponse, _a1 error) *ShieldServiceClient_GetOrganization_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_GetOrganization_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.GetOrganizationRequest, ...grpc.CallOption) (*shieldv1beta1.GetOrganizationResponse, error)) *ShieldServiceClient_GetOrganization_Call { + _c.Call.Return(run) + return _c +} + // GetProject provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) GetProject(ctx context.Context, in *shieldv1beta1.GetProjectRequest, opts ...grpc.CallOption) (*shieldv1beta1.GetProjectResponse, error) { _va := make([]interface{}, len(opts)) @@ -611,6 +1248,43 @@ func (_m *ShieldServiceClient) GetProject(ctx context.Context, in *shieldv1beta1 return r0, r1 } +// ShieldServiceClient_GetProject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProject' +type ShieldServiceClient_GetProject_Call struct { + *mock.Call +} + +// GetProject is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.GetProjectRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) GetProject(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_GetProject_Call { + return &ShieldServiceClient_GetProject_Call{Call: _e.mock.On("GetProject", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_GetProject_Call) Run(run func(ctx context.Context, in *shieldv1beta1.GetProjectRequest, opts ...grpc.CallOption)) *ShieldServiceClient_GetProject_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.GetProjectRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_GetProject_Call) Return(_a0 *shieldv1beta1.GetProjectResponse, _a1 error) *ShieldServiceClient_GetProject_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_GetProject_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.GetProjectRequest, ...grpc.CallOption) (*shieldv1beta1.GetProjectResponse, error)) *ShieldServiceClient_GetProject_Call { + _c.Call.Return(run) + return _c +} + // GetRelation provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) GetRelation(ctx context.Context, in *shieldv1beta1.GetRelationRequest, opts ...grpc.CallOption) (*shieldv1beta1.GetRelationResponse, error) { _va := make([]interface{}, len(opts)) @@ -644,6 +1318,43 @@ func (_m *ShieldServiceClient) GetRelation(ctx context.Context, in *shieldv1beta return r0, r1 } +// ShieldServiceClient_GetRelation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRelation' +type ShieldServiceClient_GetRelation_Call struct { + *mock.Call +} + +// GetRelation is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.GetRelationRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) GetRelation(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_GetRelation_Call { + return &ShieldServiceClient_GetRelation_Call{Call: _e.mock.On("GetRelation", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_GetRelation_Call) Run(run func(ctx context.Context, in *shieldv1beta1.GetRelationRequest, opts ...grpc.CallOption)) *ShieldServiceClient_GetRelation_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.GetRelationRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_GetRelation_Call) Return(_a0 *shieldv1beta1.GetRelationResponse, _a1 error) *ShieldServiceClient_GetRelation_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_GetRelation_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.GetRelationRequest, ...grpc.CallOption) (*shieldv1beta1.GetRelationResponse, error)) *ShieldServiceClient_GetRelation_Call { + _c.Call.Return(run) + return _c +} + // GetResource provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) GetResource(ctx context.Context, in *shieldv1beta1.GetResourceRequest, opts ...grpc.CallOption) (*shieldv1beta1.GetResourceResponse, error) { _va := make([]interface{}, len(opts)) @@ -677,6 +1388,43 @@ func (_m *ShieldServiceClient) GetResource(ctx context.Context, in *shieldv1beta return r0, r1 } +// ShieldServiceClient_GetResource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetResource' +type ShieldServiceClient_GetResource_Call struct { + *mock.Call +} + +// GetResource is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.GetResourceRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) GetResource(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_GetResource_Call { + return &ShieldServiceClient_GetResource_Call{Call: _e.mock.On("GetResource", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_GetResource_Call) Run(run func(ctx context.Context, in *shieldv1beta1.GetResourceRequest, opts ...grpc.CallOption)) *ShieldServiceClient_GetResource_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.GetResourceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_GetResource_Call) Return(_a0 *shieldv1beta1.GetResourceResponse, _a1 error) *ShieldServiceClient_GetResource_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_GetResource_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.GetResourceRequest, ...grpc.CallOption) (*shieldv1beta1.GetResourceResponse, error)) *ShieldServiceClient_GetResource_Call { + _c.Call.Return(run) + return _c +} + // GetUser provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) GetUser(ctx context.Context, in *shieldv1beta1.GetUserRequest, opts ...grpc.CallOption) (*shieldv1beta1.GetUserResponse, error) { _va := make([]interface{}, len(opts)) @@ -710,6 +1458,43 @@ func (_m *ShieldServiceClient) GetUser(ctx context.Context, in *shieldv1beta1.Ge return r0, r1 } +// ShieldServiceClient_GetUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUser' +type ShieldServiceClient_GetUser_Call struct { + *mock.Call +} + +// GetUser is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.GetUserRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) GetUser(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_GetUser_Call { + return &ShieldServiceClient_GetUser_Call{Call: _e.mock.On("GetUser", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_GetUser_Call) Run(run func(ctx context.Context, in *shieldv1beta1.GetUserRequest, opts ...grpc.CallOption)) *ShieldServiceClient_GetUser_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.GetUserRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_GetUser_Call) Return(_a0 *shieldv1beta1.GetUserResponse, _a1 error) *ShieldServiceClient_GetUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_GetUser_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.GetUserRequest, ...grpc.CallOption) (*shieldv1beta1.GetUserResponse, error)) *ShieldServiceClient_GetUser_Call { + _c.Call.Return(run) + return _c +} + // ListActions provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListActions(ctx context.Context, in *shieldv1beta1.ListActionsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListActionsResponse, error) { _va := make([]interface{}, len(opts)) @@ -743,6 +1528,43 @@ func (_m *ShieldServiceClient) ListActions(ctx context.Context, in *shieldv1beta return r0, r1 } +// ShieldServiceClient_ListActions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListActions' +type ShieldServiceClient_ListActions_Call struct { + *mock.Call +} + +// ListActions is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListActionsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListActions(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListActions_Call { + return &ShieldServiceClient_ListActions_Call{Call: _e.mock.On("ListActions", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListActions_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListActionsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListActions_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListActionsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListActions_Call) Return(_a0 *shieldv1beta1.ListActionsResponse, _a1 error) *ShieldServiceClient_ListActions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListActions_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListActionsRequest, ...grpc.CallOption) (*shieldv1beta1.ListActionsResponse, error)) *ShieldServiceClient_ListActions_Call { + _c.Call.Return(run) + return _c +} + // ListGroupRelations provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListGroupRelations(ctx context.Context, in *shieldv1beta1.ListGroupRelationsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListGroupRelationsResponse, error) { _va := make([]interface{}, len(opts)) @@ -776,6 +1598,43 @@ func (_m *ShieldServiceClient) ListGroupRelations(ctx context.Context, in *shiel return r0, r1 } +// ShieldServiceClient_ListGroupRelations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListGroupRelations' +type ShieldServiceClient_ListGroupRelations_Call struct { + *mock.Call +} + +// ListGroupRelations is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListGroupRelationsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListGroupRelations(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListGroupRelations_Call { + return &ShieldServiceClient_ListGroupRelations_Call{Call: _e.mock.On("ListGroupRelations", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListGroupRelations_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListGroupRelationsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListGroupRelations_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListGroupRelationsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListGroupRelations_Call) Return(_a0 *shieldv1beta1.ListGroupRelationsResponse, _a1 error) *ShieldServiceClient_ListGroupRelations_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListGroupRelations_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListGroupRelationsRequest, ...grpc.CallOption) (*shieldv1beta1.ListGroupRelationsResponse, error)) *ShieldServiceClient_ListGroupRelations_Call { + _c.Call.Return(run) + return _c +} + // ListGroups provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListGroups(ctx context.Context, in *shieldv1beta1.ListGroupsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListGroupsResponse, error) { _va := make([]interface{}, len(opts)) @@ -809,6 +1668,43 @@ func (_m *ShieldServiceClient) ListGroups(ctx context.Context, in *shieldv1beta1 return r0, r1 } +// ShieldServiceClient_ListGroups_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListGroups' +type ShieldServiceClient_ListGroups_Call struct { + *mock.Call +} + +// ListGroups is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListGroupsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListGroups(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListGroups_Call { + return &ShieldServiceClient_ListGroups_Call{Call: _e.mock.On("ListGroups", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListGroups_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListGroupsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListGroups_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListGroupsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListGroups_Call) Return(_a0 *shieldv1beta1.ListGroupsResponse, _a1 error) *ShieldServiceClient_ListGroups_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListGroups_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListGroupsRequest, ...grpc.CallOption) (*shieldv1beta1.ListGroupsResponse, error)) *ShieldServiceClient_ListGroups_Call { + _c.Call.Return(run) + return _c +} + // ListNamespaces provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListNamespaces(ctx context.Context, in *shieldv1beta1.ListNamespacesRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListNamespacesResponse, error) { _va := make([]interface{}, len(opts)) @@ -842,6 +1738,43 @@ func (_m *ShieldServiceClient) ListNamespaces(ctx context.Context, in *shieldv1b return r0, r1 } +// ShieldServiceClient_ListNamespaces_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListNamespaces' +type ShieldServiceClient_ListNamespaces_Call struct { + *mock.Call +} + +// ListNamespaces is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListNamespacesRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListNamespaces(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListNamespaces_Call { + return &ShieldServiceClient_ListNamespaces_Call{Call: _e.mock.On("ListNamespaces", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListNamespaces_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListNamespacesRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListNamespaces_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListNamespacesRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListNamespaces_Call) Return(_a0 *shieldv1beta1.ListNamespacesResponse, _a1 error) *ShieldServiceClient_ListNamespaces_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListNamespaces_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListNamespacesRequest, ...grpc.CallOption) (*shieldv1beta1.ListNamespacesResponse, error)) *ShieldServiceClient_ListNamespaces_Call { + _c.Call.Return(run) + return _c +} + // ListOrganizationAdmins provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListOrganizationAdmins(ctx context.Context, in *shieldv1beta1.ListOrganizationAdminsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListOrganizationAdminsResponse, error) { _va := make([]interface{}, len(opts)) @@ -875,6 +1808,43 @@ func (_m *ShieldServiceClient) ListOrganizationAdmins(ctx context.Context, in *s return r0, r1 } +// ShieldServiceClient_ListOrganizationAdmins_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListOrganizationAdmins' +type ShieldServiceClient_ListOrganizationAdmins_Call struct { + *mock.Call +} + +// ListOrganizationAdmins is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListOrganizationAdminsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListOrganizationAdmins(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListOrganizationAdmins_Call { + return &ShieldServiceClient_ListOrganizationAdmins_Call{Call: _e.mock.On("ListOrganizationAdmins", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListOrganizationAdmins_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListOrganizationAdminsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListOrganizationAdmins_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListOrganizationAdminsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListOrganizationAdmins_Call) Return(_a0 *shieldv1beta1.ListOrganizationAdminsResponse, _a1 error) *ShieldServiceClient_ListOrganizationAdmins_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListOrganizationAdmins_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListOrganizationAdminsRequest, ...grpc.CallOption) (*shieldv1beta1.ListOrganizationAdminsResponse, error)) *ShieldServiceClient_ListOrganizationAdmins_Call { + _c.Call.Return(run) + return _c +} + // ListOrganizations provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListOrganizations(ctx context.Context, in *shieldv1beta1.ListOrganizationsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListOrganizationsResponse, error) { _va := make([]interface{}, len(opts)) @@ -908,6 +1878,43 @@ func (_m *ShieldServiceClient) ListOrganizations(ctx context.Context, in *shield return r0, r1 } +// ShieldServiceClient_ListOrganizations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListOrganizations' +type ShieldServiceClient_ListOrganizations_Call struct { + *mock.Call +} + +// ListOrganizations is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListOrganizationsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListOrganizations(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListOrganizations_Call { + return &ShieldServiceClient_ListOrganizations_Call{Call: _e.mock.On("ListOrganizations", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListOrganizations_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListOrganizationsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListOrganizations_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListOrganizationsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListOrganizations_Call) Return(_a0 *shieldv1beta1.ListOrganizationsResponse, _a1 error) *ShieldServiceClient_ListOrganizations_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListOrganizations_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListOrganizationsRequest, ...grpc.CallOption) (*shieldv1beta1.ListOrganizationsResponse, error)) *ShieldServiceClient_ListOrganizations_Call { + _c.Call.Return(run) + return _c +} + // ListPolicies provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListPolicies(ctx context.Context, in *shieldv1beta1.ListPoliciesRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListPoliciesResponse, error) { _va := make([]interface{}, len(opts)) @@ -941,6 +1948,43 @@ func (_m *ShieldServiceClient) ListPolicies(ctx context.Context, in *shieldv1bet return r0, r1 } +// ShieldServiceClient_ListPolicies_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListPolicies' +type ShieldServiceClient_ListPolicies_Call struct { + *mock.Call +} + +// ListPolicies is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListPoliciesRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListPolicies(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListPolicies_Call { + return &ShieldServiceClient_ListPolicies_Call{Call: _e.mock.On("ListPolicies", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListPolicies_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListPoliciesRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListPolicies_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListPoliciesRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListPolicies_Call) Return(_a0 *shieldv1beta1.ListPoliciesResponse, _a1 error) *ShieldServiceClient_ListPolicies_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListPolicies_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListPoliciesRequest, ...grpc.CallOption) (*shieldv1beta1.ListPoliciesResponse, error)) *ShieldServiceClient_ListPolicies_Call { + _c.Call.Return(run) + return _c +} + // ListProjectAdmins provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListProjectAdmins(ctx context.Context, in *shieldv1beta1.ListProjectAdminsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListProjectAdminsResponse, error) { _va := make([]interface{}, len(opts)) @@ -974,6 +2018,43 @@ func (_m *ShieldServiceClient) ListProjectAdmins(ctx context.Context, in *shield return r0, r1 } +// ShieldServiceClient_ListProjectAdmins_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListProjectAdmins' +type ShieldServiceClient_ListProjectAdmins_Call struct { + *mock.Call +} + +// ListProjectAdmins is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListProjectAdminsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListProjectAdmins(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListProjectAdmins_Call { + return &ShieldServiceClient_ListProjectAdmins_Call{Call: _e.mock.On("ListProjectAdmins", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListProjectAdmins_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListProjectAdminsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListProjectAdmins_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListProjectAdminsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListProjectAdmins_Call) Return(_a0 *shieldv1beta1.ListProjectAdminsResponse, _a1 error) *ShieldServiceClient_ListProjectAdmins_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListProjectAdmins_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListProjectAdminsRequest, ...grpc.CallOption) (*shieldv1beta1.ListProjectAdminsResponse, error)) *ShieldServiceClient_ListProjectAdmins_Call { + _c.Call.Return(run) + return _c +} + // ListProjects provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListProjects(ctx context.Context, in *shieldv1beta1.ListProjectsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListProjectsResponse, error) { _va := make([]interface{}, len(opts)) @@ -1007,6 +2088,43 @@ func (_m *ShieldServiceClient) ListProjects(ctx context.Context, in *shieldv1bet return r0, r1 } +// ShieldServiceClient_ListProjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListProjects' +type ShieldServiceClient_ListProjects_Call struct { + *mock.Call +} + +// ListProjects is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListProjectsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListProjects(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListProjects_Call { + return &ShieldServiceClient_ListProjects_Call{Call: _e.mock.On("ListProjects", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListProjects_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListProjectsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListProjects_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListProjectsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListProjects_Call) Return(_a0 *shieldv1beta1.ListProjectsResponse, _a1 error) *ShieldServiceClient_ListProjects_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListProjects_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListProjectsRequest, ...grpc.CallOption) (*shieldv1beta1.ListProjectsResponse, error)) *ShieldServiceClient_ListProjects_Call { + _c.Call.Return(run) + return _c +} + // ListRelations provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListRelations(ctx context.Context, in *shieldv1beta1.ListRelationsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListRelationsResponse, error) { _va := make([]interface{}, len(opts)) @@ -1040,6 +2158,43 @@ func (_m *ShieldServiceClient) ListRelations(ctx context.Context, in *shieldv1be return r0, r1 } +// ShieldServiceClient_ListRelations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRelations' +type ShieldServiceClient_ListRelations_Call struct { + *mock.Call +} + +// ListRelations is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListRelationsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListRelations(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListRelations_Call { + return &ShieldServiceClient_ListRelations_Call{Call: _e.mock.On("ListRelations", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListRelations_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListRelationsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListRelations_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListRelationsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListRelations_Call) Return(_a0 *shieldv1beta1.ListRelationsResponse, _a1 error) *ShieldServiceClient_ListRelations_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListRelations_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListRelationsRequest, ...grpc.CallOption) (*shieldv1beta1.ListRelationsResponse, error)) *ShieldServiceClient_ListRelations_Call { + _c.Call.Return(run) + return _c +} + // ListResources provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListResources(ctx context.Context, in *shieldv1beta1.ListResourcesRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListResourcesResponse, error) { _va := make([]interface{}, len(opts)) @@ -1073,6 +2228,43 @@ func (_m *ShieldServiceClient) ListResources(ctx context.Context, in *shieldv1be return r0, r1 } +// ShieldServiceClient_ListResources_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListResources' +type ShieldServiceClient_ListResources_Call struct { + *mock.Call +} + +// ListResources is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListResourcesRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListResources(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListResources_Call { + return &ShieldServiceClient_ListResources_Call{Call: _e.mock.On("ListResources", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListResources_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListResourcesRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListResources_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListResourcesRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListResources_Call) Return(_a0 *shieldv1beta1.ListResourcesResponse, _a1 error) *ShieldServiceClient_ListResources_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListResources_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListResourcesRequest, ...grpc.CallOption) (*shieldv1beta1.ListResourcesResponse, error)) *ShieldServiceClient_ListResources_Call { + _c.Call.Return(run) + return _c +} + // ListRoles provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListRoles(ctx context.Context, in *shieldv1beta1.ListRolesRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListRolesResponse, error) { _va := make([]interface{}, len(opts)) @@ -1106,6 +2298,43 @@ func (_m *ShieldServiceClient) ListRoles(ctx context.Context, in *shieldv1beta1. return r0, r1 } +// ShieldServiceClient_ListRoles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRoles' +type ShieldServiceClient_ListRoles_Call struct { + *mock.Call +} + +// ListRoles is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListRolesRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListRoles(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListRoles_Call { + return &ShieldServiceClient_ListRoles_Call{Call: _e.mock.On("ListRoles", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListRoles_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListRolesRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListRoles_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListRolesRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListRoles_Call) Return(_a0 *shieldv1beta1.ListRolesResponse, _a1 error) *ShieldServiceClient_ListRoles_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListRoles_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListRolesRequest, ...grpc.CallOption) (*shieldv1beta1.ListRolesResponse, error)) *ShieldServiceClient_ListRoles_Call { + _c.Call.Return(run) + return _c +} + // ListUserGroups provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListUserGroups(ctx context.Context, in *shieldv1beta1.ListUserGroupsRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListUserGroupsResponse, error) { _va := make([]interface{}, len(opts)) @@ -1139,6 +2368,43 @@ func (_m *ShieldServiceClient) ListUserGroups(ctx context.Context, in *shieldv1b return r0, r1 } +// ShieldServiceClient_ListUserGroups_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListUserGroups' +type ShieldServiceClient_ListUserGroups_Call struct { + *mock.Call +} + +// ListUserGroups is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListUserGroupsRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListUserGroups(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListUserGroups_Call { + return &ShieldServiceClient_ListUserGroups_Call{Call: _e.mock.On("ListUserGroups", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListUserGroups_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListUserGroupsRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListUserGroups_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListUserGroupsRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListUserGroups_Call) Return(_a0 *shieldv1beta1.ListUserGroupsResponse, _a1 error) *ShieldServiceClient_ListUserGroups_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListUserGroups_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListUserGroupsRequest, ...grpc.CallOption) (*shieldv1beta1.ListUserGroupsResponse, error)) *ShieldServiceClient_ListUserGroups_Call { + _c.Call.Return(run) + return _c +} + // ListUsers provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) ListUsers(ctx context.Context, in *shieldv1beta1.ListUsersRequest, opts ...grpc.CallOption) (*shieldv1beta1.ListUsersResponse, error) { _va := make([]interface{}, len(opts)) @@ -1172,6 +2438,43 @@ func (_m *ShieldServiceClient) ListUsers(ctx context.Context, in *shieldv1beta1. return r0, r1 } +// ShieldServiceClient_ListUsers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListUsers' +type ShieldServiceClient_ListUsers_Call struct { + *mock.Call +} + +// ListUsers is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.ListUsersRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) ListUsers(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_ListUsers_Call { + return &ShieldServiceClient_ListUsers_Call{Call: _e.mock.On("ListUsers", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_ListUsers_Call) Run(run func(ctx context.Context, in *shieldv1beta1.ListUsersRequest, opts ...grpc.CallOption)) *ShieldServiceClient_ListUsers_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.ListUsersRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_ListUsers_Call) Return(_a0 *shieldv1beta1.ListUsersResponse, _a1 error) *ShieldServiceClient_ListUsers_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_ListUsers_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.ListUsersRequest, ...grpc.CallOption) (*shieldv1beta1.ListUsersResponse, error)) *ShieldServiceClient_ListUsers_Call { + _c.Call.Return(run) + return _c +} + // UpdateCurrentUser provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) UpdateCurrentUser(ctx context.Context, in *shieldv1beta1.UpdateCurrentUserRequest, opts ...grpc.CallOption) (*shieldv1beta1.UpdateCurrentUserResponse, error) { _va := make([]interface{}, len(opts)) @@ -1205,6 +2508,43 @@ func (_m *ShieldServiceClient) UpdateCurrentUser(ctx context.Context, in *shield return r0, r1 } +// ShieldServiceClient_UpdateCurrentUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateCurrentUser' +type ShieldServiceClient_UpdateCurrentUser_Call struct { + *mock.Call +} + +// UpdateCurrentUser is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.UpdateCurrentUserRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) UpdateCurrentUser(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_UpdateCurrentUser_Call { + return &ShieldServiceClient_UpdateCurrentUser_Call{Call: _e.mock.On("UpdateCurrentUser", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_UpdateCurrentUser_Call) Run(run func(ctx context.Context, in *shieldv1beta1.UpdateCurrentUserRequest, opts ...grpc.CallOption)) *ShieldServiceClient_UpdateCurrentUser_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.UpdateCurrentUserRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_UpdateCurrentUser_Call) Return(_a0 *shieldv1beta1.UpdateCurrentUserResponse, _a1 error) *ShieldServiceClient_UpdateCurrentUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_UpdateCurrentUser_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.UpdateCurrentUserRequest, ...grpc.CallOption) (*shieldv1beta1.UpdateCurrentUserResponse, error)) *ShieldServiceClient_UpdateCurrentUser_Call { + _c.Call.Return(run) + return _c +} + // UpdateGroup provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) UpdateGroup(ctx context.Context, in *shieldv1beta1.UpdateGroupRequest, opts ...grpc.CallOption) (*shieldv1beta1.UpdateGroupResponse, error) { _va := make([]interface{}, len(opts)) @@ -1238,6 +2578,43 @@ func (_m *ShieldServiceClient) UpdateGroup(ctx context.Context, in *shieldv1beta return r0, r1 } +// ShieldServiceClient_UpdateGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateGroup' +type ShieldServiceClient_UpdateGroup_Call struct { + *mock.Call +} + +// UpdateGroup is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.UpdateGroupRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) UpdateGroup(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_UpdateGroup_Call { + return &ShieldServiceClient_UpdateGroup_Call{Call: _e.mock.On("UpdateGroup", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_UpdateGroup_Call) Run(run func(ctx context.Context, in *shieldv1beta1.UpdateGroupRequest, opts ...grpc.CallOption)) *ShieldServiceClient_UpdateGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.UpdateGroupRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_UpdateGroup_Call) Return(_a0 *shieldv1beta1.UpdateGroupResponse, _a1 error) *ShieldServiceClient_UpdateGroup_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_UpdateGroup_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.UpdateGroupRequest, ...grpc.CallOption) (*shieldv1beta1.UpdateGroupResponse, error)) *ShieldServiceClient_UpdateGroup_Call { + _c.Call.Return(run) + return _c +} + // UpdateNamespace provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) UpdateNamespace(ctx context.Context, in *shieldv1beta1.UpdateNamespaceRequest, opts ...grpc.CallOption) (*shieldv1beta1.UpdateNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -1271,6 +2648,43 @@ func (_m *ShieldServiceClient) UpdateNamespace(ctx context.Context, in *shieldv1 return r0, r1 } +// ShieldServiceClient_UpdateNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateNamespace' +type ShieldServiceClient_UpdateNamespace_Call struct { + *mock.Call +} + +// UpdateNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.UpdateNamespaceRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) UpdateNamespace(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_UpdateNamespace_Call { + return &ShieldServiceClient_UpdateNamespace_Call{Call: _e.mock.On("UpdateNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_UpdateNamespace_Call) Run(run func(ctx context.Context, in *shieldv1beta1.UpdateNamespaceRequest, opts ...grpc.CallOption)) *ShieldServiceClient_UpdateNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.UpdateNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_UpdateNamespace_Call) Return(_a0 *shieldv1beta1.UpdateNamespaceResponse, _a1 error) *ShieldServiceClient_UpdateNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_UpdateNamespace_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.UpdateNamespaceRequest, ...grpc.CallOption) (*shieldv1beta1.UpdateNamespaceResponse, error)) *ShieldServiceClient_UpdateNamespace_Call { + _c.Call.Return(run) + return _c +} + // UpdateOrganization provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) UpdateOrganization(ctx context.Context, in *shieldv1beta1.UpdateOrganizationRequest, opts ...grpc.CallOption) (*shieldv1beta1.UpdateOrganizationResponse, error) { _va := make([]interface{}, len(opts)) @@ -1304,6 +2718,43 @@ func (_m *ShieldServiceClient) UpdateOrganization(ctx context.Context, in *shiel return r0, r1 } +// ShieldServiceClient_UpdateOrganization_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateOrganization' +type ShieldServiceClient_UpdateOrganization_Call struct { + *mock.Call +} + +// UpdateOrganization is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.UpdateOrganizationRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) UpdateOrganization(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_UpdateOrganization_Call { + return &ShieldServiceClient_UpdateOrganization_Call{Call: _e.mock.On("UpdateOrganization", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_UpdateOrganization_Call) Run(run func(ctx context.Context, in *shieldv1beta1.UpdateOrganizationRequest, opts ...grpc.CallOption)) *ShieldServiceClient_UpdateOrganization_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.UpdateOrganizationRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_UpdateOrganization_Call) Return(_a0 *shieldv1beta1.UpdateOrganizationResponse, _a1 error) *ShieldServiceClient_UpdateOrganization_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_UpdateOrganization_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.UpdateOrganizationRequest, ...grpc.CallOption) (*shieldv1beta1.UpdateOrganizationResponse, error)) *ShieldServiceClient_UpdateOrganization_Call { + _c.Call.Return(run) + return _c +} + // UpdateProject provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) UpdateProject(ctx context.Context, in *shieldv1beta1.UpdateProjectRequest, opts ...grpc.CallOption) (*shieldv1beta1.UpdateProjectResponse, error) { _va := make([]interface{}, len(opts)) @@ -1337,6 +2788,43 @@ func (_m *ShieldServiceClient) UpdateProject(ctx context.Context, in *shieldv1be return r0, r1 } +// ShieldServiceClient_UpdateProject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateProject' +type ShieldServiceClient_UpdateProject_Call struct { + *mock.Call +} + +// UpdateProject is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.UpdateProjectRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) UpdateProject(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_UpdateProject_Call { + return &ShieldServiceClient_UpdateProject_Call{Call: _e.mock.On("UpdateProject", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_UpdateProject_Call) Run(run func(ctx context.Context, in *shieldv1beta1.UpdateProjectRequest, opts ...grpc.CallOption)) *ShieldServiceClient_UpdateProject_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.UpdateProjectRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_UpdateProject_Call) Return(_a0 *shieldv1beta1.UpdateProjectResponse, _a1 error) *ShieldServiceClient_UpdateProject_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_UpdateProject_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.UpdateProjectRequest, ...grpc.CallOption) (*shieldv1beta1.UpdateProjectResponse, error)) *ShieldServiceClient_UpdateProject_Call { + _c.Call.Return(run) + return _c +} + // UpdateResource provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) UpdateResource(ctx context.Context, in *shieldv1beta1.UpdateResourceRequest, opts ...grpc.CallOption) (*shieldv1beta1.UpdateResourceResponse, error) { _va := make([]interface{}, len(opts)) @@ -1370,6 +2858,43 @@ func (_m *ShieldServiceClient) UpdateResource(ctx context.Context, in *shieldv1b return r0, r1 } +// ShieldServiceClient_UpdateResource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateResource' +type ShieldServiceClient_UpdateResource_Call struct { + *mock.Call +} + +// UpdateResource is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.UpdateResourceRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) UpdateResource(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_UpdateResource_Call { + return &ShieldServiceClient_UpdateResource_Call{Call: _e.mock.On("UpdateResource", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_UpdateResource_Call) Run(run func(ctx context.Context, in *shieldv1beta1.UpdateResourceRequest, opts ...grpc.CallOption)) *ShieldServiceClient_UpdateResource_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.UpdateResourceRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_UpdateResource_Call) Return(_a0 *shieldv1beta1.UpdateResourceResponse, _a1 error) *ShieldServiceClient_UpdateResource_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_UpdateResource_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.UpdateResourceRequest, ...grpc.CallOption) (*shieldv1beta1.UpdateResourceResponse, error)) *ShieldServiceClient_UpdateResource_Call { + _c.Call.Return(run) + return _c +} + // UpdateUser provides a mock function with given fields: ctx, in, opts func (_m *ShieldServiceClient) UpdateUser(ctx context.Context, in *shieldv1beta1.UpdateUserRequest, opts ...grpc.CallOption) (*shieldv1beta1.UpdateUserResponse, error) { _va := make([]interface{}, len(opts)) @@ -1403,6 +2928,43 @@ func (_m *ShieldServiceClient) UpdateUser(ctx context.Context, in *shieldv1beta1 return r0, r1 } +// ShieldServiceClient_UpdateUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUser' +type ShieldServiceClient_UpdateUser_Call struct { + *mock.Call +} + +// UpdateUser is a helper method to define mock.On call +// - ctx context.Context +// - in *shieldv1beta1.UpdateUserRequest +// - opts ...grpc.CallOption +func (_e *ShieldServiceClient_Expecter) UpdateUser(ctx interface{}, in interface{}, opts ...interface{}) *ShieldServiceClient_UpdateUser_Call { + return &ShieldServiceClient_UpdateUser_Call{Call: _e.mock.On("UpdateUser", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *ShieldServiceClient_UpdateUser_Call) Run(run func(ctx context.Context, in *shieldv1beta1.UpdateUserRequest, opts ...grpc.CallOption)) *ShieldServiceClient_UpdateUser_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*shieldv1beta1.UpdateUserRequest), variadicArgs...) + }) + return _c +} + +func (_c *ShieldServiceClient_UpdateUser_Call) Return(_a0 *shieldv1beta1.UpdateUserResponse, _a1 error) *ShieldServiceClient_UpdateUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ShieldServiceClient_UpdateUser_Call) RunAndReturn(run func(context.Context, *shieldv1beta1.UpdateUserRequest, ...grpc.CallOption) (*shieldv1beta1.UpdateUserResponse, error)) *ShieldServiceClient_UpdateUser_Call { + _c.Call.Return(run) + return _c +} + // NewShieldServiceClient creates a new instance of ShieldServiceClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewShieldServiceClient(t interface { diff --git a/mocks/SirenServiceClient.go b/mocks/SirenServiceClient.go index 2687e09..cc14604 100644 --- a/mocks/SirenServiceClient.go +++ b/mocks/SirenServiceClient.go @@ -17,6 +17,14 @@ type SirenServiceClient struct { mock.Mock } +type SirenServiceClient_Expecter struct { + mock *mock.Mock +} + +func (_m *SirenServiceClient) EXPECT() *SirenServiceClient_Expecter { + return &SirenServiceClient_Expecter{mock: &_m.Mock} +} + // CreateAlerts provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) CreateAlerts(ctx context.Context, in *sirenv1beta1.CreateAlertsRequest, opts ...grpc.CallOption) (*sirenv1beta1.CreateAlertsResponse, error) { _va := make([]interface{}, len(opts)) @@ -50,6 +58,43 @@ func (_m *SirenServiceClient) CreateAlerts(ctx context.Context, in *sirenv1beta1 return r0, r1 } +// SirenServiceClient_CreateAlerts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAlerts' +type SirenServiceClient_CreateAlerts_Call struct { + *mock.Call +} + +// CreateAlerts is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.CreateAlertsRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) CreateAlerts(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_CreateAlerts_Call { + return &SirenServiceClient_CreateAlerts_Call{Call: _e.mock.On("CreateAlerts", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_CreateAlerts_Call) Run(run func(ctx context.Context, in *sirenv1beta1.CreateAlertsRequest, opts ...grpc.CallOption)) *SirenServiceClient_CreateAlerts_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.CreateAlertsRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_CreateAlerts_Call) Return(_a0 *sirenv1beta1.CreateAlertsResponse, _a1 error) *SirenServiceClient_CreateAlerts_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_CreateAlerts_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.CreateAlertsRequest, ...grpc.CallOption) (*sirenv1beta1.CreateAlertsResponse, error)) *SirenServiceClient_CreateAlerts_Call { + _c.Call.Return(run) + return _c +} + // CreateAlertsWithNamespace provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) CreateAlertsWithNamespace(ctx context.Context, in *sirenv1beta1.CreateAlertsWithNamespaceRequest, opts ...grpc.CallOption) (*sirenv1beta1.CreateAlertsWithNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -83,6 +128,43 @@ func (_m *SirenServiceClient) CreateAlertsWithNamespace(ctx context.Context, in return r0, r1 } +// SirenServiceClient_CreateAlertsWithNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAlertsWithNamespace' +type SirenServiceClient_CreateAlertsWithNamespace_Call struct { + *mock.Call +} + +// CreateAlertsWithNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.CreateAlertsWithNamespaceRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) CreateAlertsWithNamespace(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_CreateAlertsWithNamespace_Call { + return &SirenServiceClient_CreateAlertsWithNamespace_Call{Call: _e.mock.On("CreateAlertsWithNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_CreateAlertsWithNamespace_Call) Run(run func(ctx context.Context, in *sirenv1beta1.CreateAlertsWithNamespaceRequest, opts ...grpc.CallOption)) *SirenServiceClient_CreateAlertsWithNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.CreateAlertsWithNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_CreateAlertsWithNamespace_Call) Return(_a0 *sirenv1beta1.CreateAlertsWithNamespaceResponse, _a1 error) *SirenServiceClient_CreateAlertsWithNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_CreateAlertsWithNamespace_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.CreateAlertsWithNamespaceRequest, ...grpc.CallOption) (*sirenv1beta1.CreateAlertsWithNamespaceResponse, error)) *SirenServiceClient_CreateAlertsWithNamespace_Call { + _c.Call.Return(run) + return _c +} + // CreateNamespace provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) CreateNamespace(ctx context.Context, in *sirenv1beta1.CreateNamespaceRequest, opts ...grpc.CallOption) (*sirenv1beta1.CreateNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -116,6 +198,43 @@ func (_m *SirenServiceClient) CreateNamespace(ctx context.Context, in *sirenv1be return r0, r1 } +// SirenServiceClient_CreateNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateNamespace' +type SirenServiceClient_CreateNamespace_Call struct { + *mock.Call +} + +// CreateNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.CreateNamespaceRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) CreateNamespace(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_CreateNamespace_Call { + return &SirenServiceClient_CreateNamespace_Call{Call: _e.mock.On("CreateNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_CreateNamespace_Call) Run(run func(ctx context.Context, in *sirenv1beta1.CreateNamespaceRequest, opts ...grpc.CallOption)) *SirenServiceClient_CreateNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.CreateNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_CreateNamespace_Call) Return(_a0 *sirenv1beta1.CreateNamespaceResponse, _a1 error) *SirenServiceClient_CreateNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_CreateNamespace_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.CreateNamespaceRequest, ...grpc.CallOption) (*sirenv1beta1.CreateNamespaceResponse, error)) *SirenServiceClient_CreateNamespace_Call { + _c.Call.Return(run) + return _c +} + // CreateProvider provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) CreateProvider(ctx context.Context, in *sirenv1beta1.CreateProviderRequest, opts ...grpc.CallOption) (*sirenv1beta1.CreateProviderResponse, error) { _va := make([]interface{}, len(opts)) @@ -149,6 +268,43 @@ func (_m *SirenServiceClient) CreateProvider(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_CreateProvider_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateProvider' +type SirenServiceClient_CreateProvider_Call struct { + *mock.Call +} + +// CreateProvider is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.CreateProviderRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) CreateProvider(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_CreateProvider_Call { + return &SirenServiceClient_CreateProvider_Call{Call: _e.mock.On("CreateProvider", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_CreateProvider_Call) Run(run func(ctx context.Context, in *sirenv1beta1.CreateProviderRequest, opts ...grpc.CallOption)) *SirenServiceClient_CreateProvider_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.CreateProviderRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_CreateProvider_Call) Return(_a0 *sirenv1beta1.CreateProviderResponse, _a1 error) *SirenServiceClient_CreateProvider_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_CreateProvider_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.CreateProviderRequest, ...grpc.CallOption) (*sirenv1beta1.CreateProviderResponse, error)) *SirenServiceClient_CreateProvider_Call { + _c.Call.Return(run) + return _c +} + // CreateReceiver provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) CreateReceiver(ctx context.Context, in *sirenv1beta1.CreateReceiverRequest, opts ...grpc.CallOption) (*sirenv1beta1.CreateReceiverResponse, error) { _va := make([]interface{}, len(opts)) @@ -182,6 +338,43 @@ func (_m *SirenServiceClient) CreateReceiver(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_CreateReceiver_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateReceiver' +type SirenServiceClient_CreateReceiver_Call struct { + *mock.Call +} + +// CreateReceiver is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.CreateReceiverRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) CreateReceiver(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_CreateReceiver_Call { + return &SirenServiceClient_CreateReceiver_Call{Call: _e.mock.On("CreateReceiver", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_CreateReceiver_Call) Run(run func(ctx context.Context, in *sirenv1beta1.CreateReceiverRequest, opts ...grpc.CallOption)) *SirenServiceClient_CreateReceiver_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.CreateReceiverRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_CreateReceiver_Call) Return(_a0 *sirenv1beta1.CreateReceiverResponse, _a1 error) *SirenServiceClient_CreateReceiver_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_CreateReceiver_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.CreateReceiverRequest, ...grpc.CallOption) (*sirenv1beta1.CreateReceiverResponse, error)) *SirenServiceClient_CreateReceiver_Call { + _c.Call.Return(run) + return _c +} + // CreateSilence provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) CreateSilence(ctx context.Context, in *sirenv1beta1.CreateSilenceRequest, opts ...grpc.CallOption) (*sirenv1beta1.CreateSilenceResponse, error) { _va := make([]interface{}, len(opts)) @@ -215,6 +408,43 @@ func (_m *SirenServiceClient) CreateSilence(ctx context.Context, in *sirenv1beta return r0, r1 } +// SirenServiceClient_CreateSilence_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSilence' +type SirenServiceClient_CreateSilence_Call struct { + *mock.Call +} + +// CreateSilence is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.CreateSilenceRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) CreateSilence(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_CreateSilence_Call { + return &SirenServiceClient_CreateSilence_Call{Call: _e.mock.On("CreateSilence", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_CreateSilence_Call) Run(run func(ctx context.Context, in *sirenv1beta1.CreateSilenceRequest, opts ...grpc.CallOption)) *SirenServiceClient_CreateSilence_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.CreateSilenceRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_CreateSilence_Call) Return(_a0 *sirenv1beta1.CreateSilenceResponse, _a1 error) *SirenServiceClient_CreateSilence_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_CreateSilence_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.CreateSilenceRequest, ...grpc.CallOption) (*sirenv1beta1.CreateSilenceResponse, error)) *SirenServiceClient_CreateSilence_Call { + _c.Call.Return(run) + return _c +} + // CreateSubscription provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) CreateSubscription(ctx context.Context, in *sirenv1beta1.CreateSubscriptionRequest, opts ...grpc.CallOption) (*sirenv1beta1.CreateSubscriptionResponse, error) { _va := make([]interface{}, len(opts)) @@ -248,6 +478,43 @@ func (_m *SirenServiceClient) CreateSubscription(ctx context.Context, in *sirenv return r0, r1 } +// SirenServiceClient_CreateSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSubscription' +type SirenServiceClient_CreateSubscription_Call struct { + *mock.Call +} + +// CreateSubscription is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.CreateSubscriptionRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) CreateSubscription(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_CreateSubscription_Call { + return &SirenServiceClient_CreateSubscription_Call{Call: _e.mock.On("CreateSubscription", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_CreateSubscription_Call) Run(run func(ctx context.Context, in *sirenv1beta1.CreateSubscriptionRequest, opts ...grpc.CallOption)) *SirenServiceClient_CreateSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.CreateSubscriptionRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_CreateSubscription_Call) Return(_a0 *sirenv1beta1.CreateSubscriptionResponse, _a1 error) *SirenServiceClient_CreateSubscription_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_CreateSubscription_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.CreateSubscriptionRequest, ...grpc.CallOption) (*sirenv1beta1.CreateSubscriptionResponse, error)) *SirenServiceClient_CreateSubscription_Call { + _c.Call.Return(run) + return _c +} + // DeleteNamespace provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) DeleteNamespace(ctx context.Context, in *sirenv1beta1.DeleteNamespaceRequest, opts ...grpc.CallOption) (*sirenv1beta1.DeleteNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -281,6 +548,43 @@ func (_m *SirenServiceClient) DeleteNamespace(ctx context.Context, in *sirenv1be return r0, r1 } +// SirenServiceClient_DeleteNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteNamespace' +type SirenServiceClient_DeleteNamespace_Call struct { + *mock.Call +} + +// DeleteNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.DeleteNamespaceRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) DeleteNamespace(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_DeleteNamespace_Call { + return &SirenServiceClient_DeleteNamespace_Call{Call: _e.mock.On("DeleteNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_DeleteNamespace_Call) Run(run func(ctx context.Context, in *sirenv1beta1.DeleteNamespaceRequest, opts ...grpc.CallOption)) *SirenServiceClient_DeleteNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.DeleteNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_DeleteNamespace_Call) Return(_a0 *sirenv1beta1.DeleteNamespaceResponse, _a1 error) *SirenServiceClient_DeleteNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_DeleteNamespace_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.DeleteNamespaceRequest, ...grpc.CallOption) (*sirenv1beta1.DeleteNamespaceResponse, error)) *SirenServiceClient_DeleteNamespace_Call { + _c.Call.Return(run) + return _c +} + // DeleteProvider provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) DeleteProvider(ctx context.Context, in *sirenv1beta1.DeleteProviderRequest, opts ...grpc.CallOption) (*sirenv1beta1.DeleteProviderResponse, error) { _va := make([]interface{}, len(opts)) @@ -314,6 +618,43 @@ func (_m *SirenServiceClient) DeleteProvider(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_DeleteProvider_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteProvider' +type SirenServiceClient_DeleteProvider_Call struct { + *mock.Call +} + +// DeleteProvider is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.DeleteProviderRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) DeleteProvider(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_DeleteProvider_Call { + return &SirenServiceClient_DeleteProvider_Call{Call: _e.mock.On("DeleteProvider", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_DeleteProvider_Call) Run(run func(ctx context.Context, in *sirenv1beta1.DeleteProviderRequest, opts ...grpc.CallOption)) *SirenServiceClient_DeleteProvider_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.DeleteProviderRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_DeleteProvider_Call) Return(_a0 *sirenv1beta1.DeleteProviderResponse, _a1 error) *SirenServiceClient_DeleteProvider_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_DeleteProvider_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.DeleteProviderRequest, ...grpc.CallOption) (*sirenv1beta1.DeleteProviderResponse, error)) *SirenServiceClient_DeleteProvider_Call { + _c.Call.Return(run) + return _c +} + // DeleteReceiver provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) DeleteReceiver(ctx context.Context, in *sirenv1beta1.DeleteReceiverRequest, opts ...grpc.CallOption) (*sirenv1beta1.DeleteReceiverResponse, error) { _va := make([]interface{}, len(opts)) @@ -347,6 +688,43 @@ func (_m *SirenServiceClient) DeleteReceiver(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_DeleteReceiver_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteReceiver' +type SirenServiceClient_DeleteReceiver_Call struct { + *mock.Call +} + +// DeleteReceiver is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.DeleteReceiverRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) DeleteReceiver(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_DeleteReceiver_Call { + return &SirenServiceClient_DeleteReceiver_Call{Call: _e.mock.On("DeleteReceiver", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_DeleteReceiver_Call) Run(run func(ctx context.Context, in *sirenv1beta1.DeleteReceiverRequest, opts ...grpc.CallOption)) *SirenServiceClient_DeleteReceiver_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.DeleteReceiverRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_DeleteReceiver_Call) Return(_a0 *sirenv1beta1.DeleteReceiverResponse, _a1 error) *SirenServiceClient_DeleteReceiver_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_DeleteReceiver_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.DeleteReceiverRequest, ...grpc.CallOption) (*sirenv1beta1.DeleteReceiverResponse, error)) *SirenServiceClient_DeleteReceiver_Call { + _c.Call.Return(run) + return _c +} + // DeleteSubscription provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) DeleteSubscription(ctx context.Context, in *sirenv1beta1.DeleteSubscriptionRequest, opts ...grpc.CallOption) (*sirenv1beta1.DeleteSubscriptionResponse, error) { _va := make([]interface{}, len(opts)) @@ -380,6 +758,43 @@ func (_m *SirenServiceClient) DeleteSubscription(ctx context.Context, in *sirenv return r0, r1 } +// SirenServiceClient_DeleteSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteSubscription' +type SirenServiceClient_DeleteSubscription_Call struct { + *mock.Call +} + +// DeleteSubscription is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.DeleteSubscriptionRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) DeleteSubscription(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_DeleteSubscription_Call { + return &SirenServiceClient_DeleteSubscription_Call{Call: _e.mock.On("DeleteSubscription", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_DeleteSubscription_Call) Run(run func(ctx context.Context, in *sirenv1beta1.DeleteSubscriptionRequest, opts ...grpc.CallOption)) *SirenServiceClient_DeleteSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.DeleteSubscriptionRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_DeleteSubscription_Call) Return(_a0 *sirenv1beta1.DeleteSubscriptionResponse, _a1 error) *SirenServiceClient_DeleteSubscription_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_DeleteSubscription_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.DeleteSubscriptionRequest, ...grpc.CallOption) (*sirenv1beta1.DeleteSubscriptionResponse, error)) *SirenServiceClient_DeleteSubscription_Call { + _c.Call.Return(run) + return _c +} + // DeleteTemplate provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) DeleteTemplate(ctx context.Context, in *sirenv1beta1.DeleteTemplateRequest, opts ...grpc.CallOption) (*sirenv1beta1.DeleteTemplateResponse, error) { _va := make([]interface{}, len(opts)) @@ -413,6 +828,43 @@ func (_m *SirenServiceClient) DeleteTemplate(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_DeleteTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteTemplate' +type SirenServiceClient_DeleteTemplate_Call struct { + *mock.Call +} + +// DeleteTemplate is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.DeleteTemplateRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) DeleteTemplate(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_DeleteTemplate_Call { + return &SirenServiceClient_DeleteTemplate_Call{Call: _e.mock.On("DeleteTemplate", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_DeleteTemplate_Call) Run(run func(ctx context.Context, in *sirenv1beta1.DeleteTemplateRequest, opts ...grpc.CallOption)) *SirenServiceClient_DeleteTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.DeleteTemplateRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_DeleteTemplate_Call) Return(_a0 *sirenv1beta1.DeleteTemplateResponse, _a1 error) *SirenServiceClient_DeleteTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_DeleteTemplate_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.DeleteTemplateRequest, ...grpc.CallOption) (*sirenv1beta1.DeleteTemplateResponse, error)) *SirenServiceClient_DeleteTemplate_Call { + _c.Call.Return(run) + return _c +} + // ExpireSilence provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ExpireSilence(ctx context.Context, in *sirenv1beta1.ExpireSilenceRequest, opts ...grpc.CallOption) (*sirenv1beta1.ExpireSilenceResponse, error) { _va := make([]interface{}, len(opts)) @@ -446,6 +898,43 @@ func (_m *SirenServiceClient) ExpireSilence(ctx context.Context, in *sirenv1beta return r0, r1 } +// SirenServiceClient_ExpireSilence_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExpireSilence' +type SirenServiceClient_ExpireSilence_Call struct { + *mock.Call +} + +// ExpireSilence is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ExpireSilenceRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ExpireSilence(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ExpireSilence_Call { + return &SirenServiceClient_ExpireSilence_Call{Call: _e.mock.On("ExpireSilence", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ExpireSilence_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ExpireSilenceRequest, opts ...grpc.CallOption)) *SirenServiceClient_ExpireSilence_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ExpireSilenceRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ExpireSilence_Call) Return(_a0 *sirenv1beta1.ExpireSilenceResponse, _a1 error) *SirenServiceClient_ExpireSilence_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ExpireSilence_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ExpireSilenceRequest, ...grpc.CallOption) (*sirenv1beta1.ExpireSilenceResponse, error)) *SirenServiceClient_ExpireSilence_Call { + _c.Call.Return(run) + return _c +} + // GetNamespace provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) GetNamespace(ctx context.Context, in *sirenv1beta1.GetNamespaceRequest, opts ...grpc.CallOption) (*sirenv1beta1.GetNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -479,6 +968,43 @@ func (_m *SirenServiceClient) GetNamespace(ctx context.Context, in *sirenv1beta1 return r0, r1 } +// SirenServiceClient_GetNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNamespace' +type SirenServiceClient_GetNamespace_Call struct { + *mock.Call +} + +// GetNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.GetNamespaceRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) GetNamespace(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_GetNamespace_Call { + return &SirenServiceClient_GetNamespace_Call{Call: _e.mock.On("GetNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_GetNamespace_Call) Run(run func(ctx context.Context, in *sirenv1beta1.GetNamespaceRequest, opts ...grpc.CallOption)) *SirenServiceClient_GetNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.GetNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_GetNamespace_Call) Return(_a0 *sirenv1beta1.GetNamespaceResponse, _a1 error) *SirenServiceClient_GetNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_GetNamespace_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.GetNamespaceRequest, ...grpc.CallOption) (*sirenv1beta1.GetNamespaceResponse, error)) *SirenServiceClient_GetNamespace_Call { + _c.Call.Return(run) + return _c +} + // GetProvider provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) GetProvider(ctx context.Context, in *sirenv1beta1.GetProviderRequest, opts ...grpc.CallOption) (*sirenv1beta1.GetProviderResponse, error) { _va := make([]interface{}, len(opts)) @@ -512,6 +1038,43 @@ func (_m *SirenServiceClient) GetProvider(ctx context.Context, in *sirenv1beta1. return r0, r1 } +// SirenServiceClient_GetProvider_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProvider' +type SirenServiceClient_GetProvider_Call struct { + *mock.Call +} + +// GetProvider is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.GetProviderRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) GetProvider(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_GetProvider_Call { + return &SirenServiceClient_GetProvider_Call{Call: _e.mock.On("GetProvider", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_GetProvider_Call) Run(run func(ctx context.Context, in *sirenv1beta1.GetProviderRequest, opts ...grpc.CallOption)) *SirenServiceClient_GetProvider_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.GetProviderRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_GetProvider_Call) Return(_a0 *sirenv1beta1.GetProviderResponse, _a1 error) *SirenServiceClient_GetProvider_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_GetProvider_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.GetProviderRequest, ...grpc.CallOption) (*sirenv1beta1.GetProviderResponse, error)) *SirenServiceClient_GetProvider_Call { + _c.Call.Return(run) + return _c +} + // GetReceiver provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) GetReceiver(ctx context.Context, in *sirenv1beta1.GetReceiverRequest, opts ...grpc.CallOption) (*sirenv1beta1.GetReceiverResponse, error) { _va := make([]interface{}, len(opts)) @@ -545,6 +1108,43 @@ func (_m *SirenServiceClient) GetReceiver(ctx context.Context, in *sirenv1beta1. return r0, r1 } +// SirenServiceClient_GetReceiver_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetReceiver' +type SirenServiceClient_GetReceiver_Call struct { + *mock.Call +} + +// GetReceiver is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.GetReceiverRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) GetReceiver(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_GetReceiver_Call { + return &SirenServiceClient_GetReceiver_Call{Call: _e.mock.On("GetReceiver", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_GetReceiver_Call) Run(run func(ctx context.Context, in *sirenv1beta1.GetReceiverRequest, opts ...grpc.CallOption)) *SirenServiceClient_GetReceiver_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.GetReceiverRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_GetReceiver_Call) Return(_a0 *sirenv1beta1.GetReceiverResponse, _a1 error) *SirenServiceClient_GetReceiver_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_GetReceiver_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.GetReceiverRequest, ...grpc.CallOption) (*sirenv1beta1.GetReceiverResponse, error)) *SirenServiceClient_GetReceiver_Call { + _c.Call.Return(run) + return _c +} + // GetSilence provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) GetSilence(ctx context.Context, in *sirenv1beta1.GetSilenceRequest, opts ...grpc.CallOption) (*sirenv1beta1.GetSilenceResponse, error) { _va := make([]interface{}, len(opts)) @@ -578,6 +1178,43 @@ func (_m *SirenServiceClient) GetSilence(ctx context.Context, in *sirenv1beta1.G return r0, r1 } +// SirenServiceClient_GetSilence_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSilence' +type SirenServiceClient_GetSilence_Call struct { + *mock.Call +} + +// GetSilence is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.GetSilenceRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) GetSilence(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_GetSilence_Call { + return &SirenServiceClient_GetSilence_Call{Call: _e.mock.On("GetSilence", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_GetSilence_Call) Run(run func(ctx context.Context, in *sirenv1beta1.GetSilenceRequest, opts ...grpc.CallOption)) *SirenServiceClient_GetSilence_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.GetSilenceRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_GetSilence_Call) Return(_a0 *sirenv1beta1.GetSilenceResponse, _a1 error) *SirenServiceClient_GetSilence_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_GetSilence_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.GetSilenceRequest, ...grpc.CallOption) (*sirenv1beta1.GetSilenceResponse, error)) *SirenServiceClient_GetSilence_Call { + _c.Call.Return(run) + return _c +} + // GetSubscription provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) GetSubscription(ctx context.Context, in *sirenv1beta1.GetSubscriptionRequest, opts ...grpc.CallOption) (*sirenv1beta1.GetSubscriptionResponse, error) { _va := make([]interface{}, len(opts)) @@ -611,6 +1248,43 @@ func (_m *SirenServiceClient) GetSubscription(ctx context.Context, in *sirenv1be return r0, r1 } +// SirenServiceClient_GetSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSubscription' +type SirenServiceClient_GetSubscription_Call struct { + *mock.Call +} + +// GetSubscription is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.GetSubscriptionRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) GetSubscription(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_GetSubscription_Call { + return &SirenServiceClient_GetSubscription_Call{Call: _e.mock.On("GetSubscription", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_GetSubscription_Call) Run(run func(ctx context.Context, in *sirenv1beta1.GetSubscriptionRequest, opts ...grpc.CallOption)) *SirenServiceClient_GetSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.GetSubscriptionRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_GetSubscription_Call) Return(_a0 *sirenv1beta1.GetSubscriptionResponse, _a1 error) *SirenServiceClient_GetSubscription_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_GetSubscription_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.GetSubscriptionRequest, ...grpc.CallOption) (*sirenv1beta1.GetSubscriptionResponse, error)) *SirenServiceClient_GetSubscription_Call { + _c.Call.Return(run) + return _c +} + // GetTemplate provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) GetTemplate(ctx context.Context, in *sirenv1beta1.GetTemplateRequest, opts ...grpc.CallOption) (*sirenv1beta1.GetTemplateResponse, error) { _va := make([]interface{}, len(opts)) @@ -644,6 +1318,43 @@ func (_m *SirenServiceClient) GetTemplate(ctx context.Context, in *sirenv1beta1. return r0, r1 } +// SirenServiceClient_GetTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTemplate' +type SirenServiceClient_GetTemplate_Call struct { + *mock.Call +} + +// GetTemplate is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.GetTemplateRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) GetTemplate(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_GetTemplate_Call { + return &SirenServiceClient_GetTemplate_Call{Call: _e.mock.On("GetTemplate", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_GetTemplate_Call) Run(run func(ctx context.Context, in *sirenv1beta1.GetTemplateRequest, opts ...grpc.CallOption)) *SirenServiceClient_GetTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.GetTemplateRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_GetTemplate_Call) Return(_a0 *sirenv1beta1.GetTemplateResponse, _a1 error) *SirenServiceClient_GetTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_GetTemplate_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.GetTemplateRequest, ...grpc.CallOption) (*sirenv1beta1.GetTemplateResponse, error)) *SirenServiceClient_GetTemplate_Call { + _c.Call.Return(run) + return _c +} + // ListAlerts provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ListAlerts(ctx context.Context, in *sirenv1beta1.ListAlertsRequest, opts ...grpc.CallOption) (*sirenv1beta1.ListAlertsResponse, error) { _va := make([]interface{}, len(opts)) @@ -677,6 +1388,43 @@ func (_m *SirenServiceClient) ListAlerts(ctx context.Context, in *sirenv1beta1.L return r0, r1 } +// SirenServiceClient_ListAlerts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAlerts' +type SirenServiceClient_ListAlerts_Call struct { + *mock.Call +} + +// ListAlerts is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ListAlertsRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ListAlerts(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ListAlerts_Call { + return &SirenServiceClient_ListAlerts_Call{Call: _e.mock.On("ListAlerts", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ListAlerts_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ListAlertsRequest, opts ...grpc.CallOption)) *SirenServiceClient_ListAlerts_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ListAlertsRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ListAlerts_Call) Return(_a0 *sirenv1beta1.ListAlertsResponse, _a1 error) *SirenServiceClient_ListAlerts_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ListAlerts_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ListAlertsRequest, ...grpc.CallOption) (*sirenv1beta1.ListAlertsResponse, error)) *SirenServiceClient_ListAlerts_Call { + _c.Call.Return(run) + return _c +} + // ListNamespaces provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ListNamespaces(ctx context.Context, in *sirenv1beta1.ListNamespacesRequest, opts ...grpc.CallOption) (*sirenv1beta1.ListNamespacesResponse, error) { _va := make([]interface{}, len(opts)) @@ -710,6 +1458,43 @@ func (_m *SirenServiceClient) ListNamespaces(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_ListNamespaces_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListNamespaces' +type SirenServiceClient_ListNamespaces_Call struct { + *mock.Call +} + +// ListNamespaces is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ListNamespacesRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ListNamespaces(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ListNamespaces_Call { + return &SirenServiceClient_ListNamespaces_Call{Call: _e.mock.On("ListNamespaces", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ListNamespaces_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ListNamespacesRequest, opts ...grpc.CallOption)) *SirenServiceClient_ListNamespaces_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ListNamespacesRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ListNamespaces_Call) Return(_a0 *sirenv1beta1.ListNamespacesResponse, _a1 error) *SirenServiceClient_ListNamespaces_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ListNamespaces_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ListNamespacesRequest, ...grpc.CallOption) (*sirenv1beta1.ListNamespacesResponse, error)) *SirenServiceClient_ListNamespaces_Call { + _c.Call.Return(run) + return _c +} + // ListProviders provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ListProviders(ctx context.Context, in *sirenv1beta1.ListProvidersRequest, opts ...grpc.CallOption) (*sirenv1beta1.ListProvidersResponse, error) { _va := make([]interface{}, len(opts)) @@ -743,6 +1528,43 @@ func (_m *SirenServiceClient) ListProviders(ctx context.Context, in *sirenv1beta return r0, r1 } +// SirenServiceClient_ListProviders_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListProviders' +type SirenServiceClient_ListProviders_Call struct { + *mock.Call +} + +// ListProviders is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ListProvidersRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ListProviders(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ListProviders_Call { + return &SirenServiceClient_ListProviders_Call{Call: _e.mock.On("ListProviders", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ListProviders_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ListProvidersRequest, opts ...grpc.CallOption)) *SirenServiceClient_ListProviders_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ListProvidersRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ListProviders_Call) Return(_a0 *sirenv1beta1.ListProvidersResponse, _a1 error) *SirenServiceClient_ListProviders_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ListProviders_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ListProvidersRequest, ...grpc.CallOption) (*sirenv1beta1.ListProvidersResponse, error)) *SirenServiceClient_ListProviders_Call { + _c.Call.Return(run) + return _c +} + // ListReceivers provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ListReceivers(ctx context.Context, in *sirenv1beta1.ListReceiversRequest, opts ...grpc.CallOption) (*sirenv1beta1.ListReceiversResponse, error) { _va := make([]interface{}, len(opts)) @@ -776,6 +1598,43 @@ func (_m *SirenServiceClient) ListReceivers(ctx context.Context, in *sirenv1beta return r0, r1 } +// SirenServiceClient_ListReceivers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListReceivers' +type SirenServiceClient_ListReceivers_Call struct { + *mock.Call +} + +// ListReceivers is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ListReceiversRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ListReceivers(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ListReceivers_Call { + return &SirenServiceClient_ListReceivers_Call{Call: _e.mock.On("ListReceivers", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ListReceivers_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ListReceiversRequest, opts ...grpc.CallOption)) *SirenServiceClient_ListReceivers_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ListReceiversRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ListReceivers_Call) Return(_a0 *sirenv1beta1.ListReceiversResponse, _a1 error) *SirenServiceClient_ListReceivers_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ListReceivers_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ListReceiversRequest, ...grpc.CallOption) (*sirenv1beta1.ListReceiversResponse, error)) *SirenServiceClient_ListReceivers_Call { + _c.Call.Return(run) + return _c +} + // ListRules provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ListRules(ctx context.Context, in *sirenv1beta1.ListRulesRequest, opts ...grpc.CallOption) (*sirenv1beta1.ListRulesResponse, error) { _va := make([]interface{}, len(opts)) @@ -809,6 +1668,43 @@ func (_m *SirenServiceClient) ListRules(ctx context.Context, in *sirenv1beta1.Li return r0, r1 } +// SirenServiceClient_ListRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRules' +type SirenServiceClient_ListRules_Call struct { + *mock.Call +} + +// ListRules is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ListRulesRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ListRules(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ListRules_Call { + return &SirenServiceClient_ListRules_Call{Call: _e.mock.On("ListRules", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ListRules_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ListRulesRequest, opts ...grpc.CallOption)) *SirenServiceClient_ListRules_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ListRulesRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ListRules_Call) Return(_a0 *sirenv1beta1.ListRulesResponse, _a1 error) *SirenServiceClient_ListRules_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ListRules_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ListRulesRequest, ...grpc.CallOption) (*sirenv1beta1.ListRulesResponse, error)) *SirenServiceClient_ListRules_Call { + _c.Call.Return(run) + return _c +} + // ListSilences provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ListSilences(ctx context.Context, in *sirenv1beta1.ListSilencesRequest, opts ...grpc.CallOption) (*sirenv1beta1.ListSilencesResponse, error) { _va := make([]interface{}, len(opts)) @@ -842,6 +1738,43 @@ func (_m *SirenServiceClient) ListSilences(ctx context.Context, in *sirenv1beta1 return r0, r1 } +// SirenServiceClient_ListSilences_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSilences' +type SirenServiceClient_ListSilences_Call struct { + *mock.Call +} + +// ListSilences is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ListSilencesRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ListSilences(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ListSilences_Call { + return &SirenServiceClient_ListSilences_Call{Call: _e.mock.On("ListSilences", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ListSilences_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ListSilencesRequest, opts ...grpc.CallOption)) *SirenServiceClient_ListSilences_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ListSilencesRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ListSilences_Call) Return(_a0 *sirenv1beta1.ListSilencesResponse, _a1 error) *SirenServiceClient_ListSilences_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ListSilences_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ListSilencesRequest, ...grpc.CallOption) (*sirenv1beta1.ListSilencesResponse, error)) *SirenServiceClient_ListSilences_Call { + _c.Call.Return(run) + return _c +} + // ListSubscriptions provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ListSubscriptions(ctx context.Context, in *sirenv1beta1.ListSubscriptionsRequest, opts ...grpc.CallOption) (*sirenv1beta1.ListSubscriptionsResponse, error) { _va := make([]interface{}, len(opts)) @@ -875,6 +1808,43 @@ func (_m *SirenServiceClient) ListSubscriptions(ctx context.Context, in *sirenv1 return r0, r1 } +// SirenServiceClient_ListSubscriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSubscriptions' +type SirenServiceClient_ListSubscriptions_Call struct { + *mock.Call +} + +// ListSubscriptions is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ListSubscriptionsRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ListSubscriptions(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ListSubscriptions_Call { + return &SirenServiceClient_ListSubscriptions_Call{Call: _e.mock.On("ListSubscriptions", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ListSubscriptions_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ListSubscriptionsRequest, opts ...grpc.CallOption)) *SirenServiceClient_ListSubscriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ListSubscriptionsRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ListSubscriptions_Call) Return(_a0 *sirenv1beta1.ListSubscriptionsResponse, _a1 error) *SirenServiceClient_ListSubscriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ListSubscriptions_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ListSubscriptionsRequest, ...grpc.CallOption) (*sirenv1beta1.ListSubscriptionsResponse, error)) *SirenServiceClient_ListSubscriptions_Call { + _c.Call.Return(run) + return _c +} + // ListTemplates provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) ListTemplates(ctx context.Context, in *sirenv1beta1.ListTemplatesRequest, opts ...grpc.CallOption) (*sirenv1beta1.ListTemplatesResponse, error) { _va := make([]interface{}, len(opts)) @@ -908,6 +1878,43 @@ func (_m *SirenServiceClient) ListTemplates(ctx context.Context, in *sirenv1beta return r0, r1 } +// SirenServiceClient_ListTemplates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListTemplates' +type SirenServiceClient_ListTemplates_Call struct { + *mock.Call +} + +// ListTemplates is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.ListTemplatesRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) ListTemplates(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_ListTemplates_Call { + return &SirenServiceClient_ListTemplates_Call{Call: _e.mock.On("ListTemplates", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_ListTemplates_Call) Run(run func(ctx context.Context, in *sirenv1beta1.ListTemplatesRequest, opts ...grpc.CallOption)) *SirenServiceClient_ListTemplates_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.ListTemplatesRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_ListTemplates_Call) Return(_a0 *sirenv1beta1.ListTemplatesResponse, _a1 error) *SirenServiceClient_ListTemplates_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_ListTemplates_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.ListTemplatesRequest, ...grpc.CallOption) (*sirenv1beta1.ListTemplatesResponse, error)) *SirenServiceClient_ListTemplates_Call { + _c.Call.Return(run) + return _c +} + // NotifyReceiver provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) NotifyReceiver(ctx context.Context, in *sirenv1beta1.NotifyReceiverRequest, opts ...grpc.CallOption) (*sirenv1beta1.NotifyReceiverResponse, error) { _va := make([]interface{}, len(opts)) @@ -941,6 +1948,43 @@ func (_m *SirenServiceClient) NotifyReceiver(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_NotifyReceiver_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NotifyReceiver' +type SirenServiceClient_NotifyReceiver_Call struct { + *mock.Call +} + +// NotifyReceiver is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.NotifyReceiverRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) NotifyReceiver(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_NotifyReceiver_Call { + return &SirenServiceClient_NotifyReceiver_Call{Call: _e.mock.On("NotifyReceiver", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_NotifyReceiver_Call) Run(run func(ctx context.Context, in *sirenv1beta1.NotifyReceiverRequest, opts ...grpc.CallOption)) *SirenServiceClient_NotifyReceiver_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.NotifyReceiverRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_NotifyReceiver_Call) Return(_a0 *sirenv1beta1.NotifyReceiverResponse, _a1 error) *SirenServiceClient_NotifyReceiver_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_NotifyReceiver_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.NotifyReceiverRequest, ...grpc.CallOption) (*sirenv1beta1.NotifyReceiverResponse, error)) *SirenServiceClient_NotifyReceiver_Call { + _c.Call.Return(run) + return _c +} + // RenderTemplate provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) RenderTemplate(ctx context.Context, in *sirenv1beta1.RenderTemplateRequest, opts ...grpc.CallOption) (*sirenv1beta1.RenderTemplateResponse, error) { _va := make([]interface{}, len(opts)) @@ -974,6 +2018,43 @@ func (_m *SirenServiceClient) RenderTemplate(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_RenderTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RenderTemplate' +type SirenServiceClient_RenderTemplate_Call struct { + *mock.Call +} + +// RenderTemplate is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.RenderTemplateRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) RenderTemplate(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_RenderTemplate_Call { + return &SirenServiceClient_RenderTemplate_Call{Call: _e.mock.On("RenderTemplate", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_RenderTemplate_Call) Run(run func(ctx context.Context, in *sirenv1beta1.RenderTemplateRequest, opts ...grpc.CallOption)) *SirenServiceClient_RenderTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.RenderTemplateRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_RenderTemplate_Call) Return(_a0 *sirenv1beta1.RenderTemplateResponse, _a1 error) *SirenServiceClient_RenderTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_RenderTemplate_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.RenderTemplateRequest, ...grpc.CallOption) (*sirenv1beta1.RenderTemplateResponse, error)) *SirenServiceClient_RenderTemplate_Call { + _c.Call.Return(run) + return _c +} + // UpdateNamespace provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) UpdateNamespace(ctx context.Context, in *sirenv1beta1.UpdateNamespaceRequest, opts ...grpc.CallOption) (*sirenv1beta1.UpdateNamespaceResponse, error) { _va := make([]interface{}, len(opts)) @@ -1007,6 +2088,43 @@ func (_m *SirenServiceClient) UpdateNamespace(ctx context.Context, in *sirenv1be return r0, r1 } +// SirenServiceClient_UpdateNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateNamespace' +type SirenServiceClient_UpdateNamespace_Call struct { + *mock.Call +} + +// UpdateNamespace is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.UpdateNamespaceRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) UpdateNamespace(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_UpdateNamespace_Call { + return &SirenServiceClient_UpdateNamespace_Call{Call: _e.mock.On("UpdateNamespace", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_UpdateNamespace_Call) Run(run func(ctx context.Context, in *sirenv1beta1.UpdateNamespaceRequest, opts ...grpc.CallOption)) *SirenServiceClient_UpdateNamespace_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.UpdateNamespaceRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_UpdateNamespace_Call) Return(_a0 *sirenv1beta1.UpdateNamespaceResponse, _a1 error) *SirenServiceClient_UpdateNamespace_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_UpdateNamespace_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.UpdateNamespaceRequest, ...grpc.CallOption) (*sirenv1beta1.UpdateNamespaceResponse, error)) *SirenServiceClient_UpdateNamespace_Call { + _c.Call.Return(run) + return _c +} + // UpdateProvider provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) UpdateProvider(ctx context.Context, in *sirenv1beta1.UpdateProviderRequest, opts ...grpc.CallOption) (*sirenv1beta1.UpdateProviderResponse, error) { _va := make([]interface{}, len(opts)) @@ -1040,6 +2158,43 @@ func (_m *SirenServiceClient) UpdateProvider(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_UpdateProvider_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateProvider' +type SirenServiceClient_UpdateProvider_Call struct { + *mock.Call +} + +// UpdateProvider is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.UpdateProviderRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) UpdateProvider(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_UpdateProvider_Call { + return &SirenServiceClient_UpdateProvider_Call{Call: _e.mock.On("UpdateProvider", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_UpdateProvider_Call) Run(run func(ctx context.Context, in *sirenv1beta1.UpdateProviderRequest, opts ...grpc.CallOption)) *SirenServiceClient_UpdateProvider_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.UpdateProviderRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_UpdateProvider_Call) Return(_a0 *sirenv1beta1.UpdateProviderResponse, _a1 error) *SirenServiceClient_UpdateProvider_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_UpdateProvider_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.UpdateProviderRequest, ...grpc.CallOption) (*sirenv1beta1.UpdateProviderResponse, error)) *SirenServiceClient_UpdateProvider_Call { + _c.Call.Return(run) + return _c +} + // UpdateReceiver provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) UpdateReceiver(ctx context.Context, in *sirenv1beta1.UpdateReceiverRequest, opts ...grpc.CallOption) (*sirenv1beta1.UpdateReceiverResponse, error) { _va := make([]interface{}, len(opts)) @@ -1073,6 +2228,43 @@ func (_m *SirenServiceClient) UpdateReceiver(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_UpdateReceiver_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateReceiver' +type SirenServiceClient_UpdateReceiver_Call struct { + *mock.Call +} + +// UpdateReceiver is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.UpdateReceiverRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) UpdateReceiver(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_UpdateReceiver_Call { + return &SirenServiceClient_UpdateReceiver_Call{Call: _e.mock.On("UpdateReceiver", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_UpdateReceiver_Call) Run(run func(ctx context.Context, in *sirenv1beta1.UpdateReceiverRequest, opts ...grpc.CallOption)) *SirenServiceClient_UpdateReceiver_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.UpdateReceiverRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_UpdateReceiver_Call) Return(_a0 *sirenv1beta1.UpdateReceiverResponse, _a1 error) *SirenServiceClient_UpdateReceiver_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_UpdateReceiver_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.UpdateReceiverRequest, ...grpc.CallOption) (*sirenv1beta1.UpdateReceiverResponse, error)) *SirenServiceClient_UpdateReceiver_Call { + _c.Call.Return(run) + return _c +} + // UpdateRule provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) UpdateRule(ctx context.Context, in *sirenv1beta1.UpdateRuleRequest, opts ...grpc.CallOption) (*sirenv1beta1.UpdateRuleResponse, error) { _va := make([]interface{}, len(opts)) @@ -1106,6 +2298,43 @@ func (_m *SirenServiceClient) UpdateRule(ctx context.Context, in *sirenv1beta1.U return r0, r1 } +// SirenServiceClient_UpdateRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRule' +type SirenServiceClient_UpdateRule_Call struct { + *mock.Call +} + +// UpdateRule is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.UpdateRuleRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) UpdateRule(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_UpdateRule_Call { + return &SirenServiceClient_UpdateRule_Call{Call: _e.mock.On("UpdateRule", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_UpdateRule_Call) Run(run func(ctx context.Context, in *sirenv1beta1.UpdateRuleRequest, opts ...grpc.CallOption)) *SirenServiceClient_UpdateRule_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.UpdateRuleRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_UpdateRule_Call) Return(_a0 *sirenv1beta1.UpdateRuleResponse, _a1 error) *SirenServiceClient_UpdateRule_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_UpdateRule_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.UpdateRuleRequest, ...grpc.CallOption) (*sirenv1beta1.UpdateRuleResponse, error)) *SirenServiceClient_UpdateRule_Call { + _c.Call.Return(run) + return _c +} + // UpdateSubscription provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) UpdateSubscription(ctx context.Context, in *sirenv1beta1.UpdateSubscriptionRequest, opts ...grpc.CallOption) (*sirenv1beta1.UpdateSubscriptionResponse, error) { _va := make([]interface{}, len(opts)) @@ -1139,6 +2368,43 @@ func (_m *SirenServiceClient) UpdateSubscription(ctx context.Context, in *sirenv return r0, r1 } +// SirenServiceClient_UpdateSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateSubscription' +type SirenServiceClient_UpdateSubscription_Call struct { + *mock.Call +} + +// UpdateSubscription is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.UpdateSubscriptionRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) UpdateSubscription(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_UpdateSubscription_Call { + return &SirenServiceClient_UpdateSubscription_Call{Call: _e.mock.On("UpdateSubscription", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_UpdateSubscription_Call) Run(run func(ctx context.Context, in *sirenv1beta1.UpdateSubscriptionRequest, opts ...grpc.CallOption)) *SirenServiceClient_UpdateSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.UpdateSubscriptionRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_UpdateSubscription_Call) Return(_a0 *sirenv1beta1.UpdateSubscriptionResponse, _a1 error) *SirenServiceClient_UpdateSubscription_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_UpdateSubscription_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.UpdateSubscriptionRequest, ...grpc.CallOption) (*sirenv1beta1.UpdateSubscriptionResponse, error)) *SirenServiceClient_UpdateSubscription_Call { + _c.Call.Return(run) + return _c +} + // UpsertTemplate provides a mock function with given fields: ctx, in, opts func (_m *SirenServiceClient) UpsertTemplate(ctx context.Context, in *sirenv1beta1.UpsertTemplateRequest, opts ...grpc.CallOption) (*sirenv1beta1.UpsertTemplateResponse, error) { _va := make([]interface{}, len(opts)) @@ -1172,6 +2438,43 @@ func (_m *SirenServiceClient) UpsertTemplate(ctx context.Context, in *sirenv1bet return r0, r1 } +// SirenServiceClient_UpsertTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpsertTemplate' +type SirenServiceClient_UpsertTemplate_Call struct { + *mock.Call +} + +// UpsertTemplate is a helper method to define mock.On call +// - ctx context.Context +// - in *sirenv1beta1.UpsertTemplateRequest +// - opts ...grpc.CallOption +func (_e *SirenServiceClient_Expecter) UpsertTemplate(ctx interface{}, in interface{}, opts ...interface{}) *SirenServiceClient_UpsertTemplate_Call { + return &SirenServiceClient_UpsertTemplate_Call{Call: _e.mock.On("UpsertTemplate", + append([]interface{}{ctx, in}, opts...)...)} +} + +func (_c *SirenServiceClient_UpsertTemplate_Call) Run(run func(ctx context.Context, in *sirenv1beta1.UpsertTemplateRequest, opts ...grpc.CallOption)) *SirenServiceClient_UpsertTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]grpc.CallOption, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(grpc.CallOption) + } + } + run(args[0].(context.Context), args[1].(*sirenv1beta1.UpsertTemplateRequest), variadicArgs...) + }) + return _c +} + +func (_c *SirenServiceClient_UpsertTemplate_Call) Return(_a0 *sirenv1beta1.UpsertTemplateResponse, _a1 error) *SirenServiceClient_UpsertTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SirenServiceClient_UpsertTemplate_Call) RunAndReturn(run func(context.Context, *sirenv1beta1.UpsertTemplateRequest, ...grpc.CallOption) (*sirenv1beta1.UpsertTemplateResponse, error)) *SirenServiceClient_UpsertTemplate_Call { + _c.Call.Return(run) + return _c +} + // NewSirenServiceClient creates a new instance of SirenServiceClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewSirenServiceClient(t interface { From a32bc106f1f02e32b2ec6aede3c2abf6a77c8c40 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 9 Oct 2023 22:33:59 +0530 Subject: [PATCH 12/27] test(warden) : more test added --- internal/server/v1/warden/handler_test.go | 116 +++++++++++++++++++++- internal/server/v1/warden/service.go | 6 +- 2 files changed, 117 insertions(+), 5 deletions(-) diff --git a/internal/server/v1/warden/handler_test.go b/internal/server/v1/warden/handler_test.go index edd0312..be322f6 100644 --- a/internal/server/v1/warden/handler_test.go +++ b/internal/server/v1/warden/handler_test.go @@ -2,6 +2,7 @@ package warden import ( "bytes" + "context" "io" "net/http" "net/http/httptest" @@ -50,7 +51,7 @@ func TestHandler_teamList(t *testing.T) { r.Use(reqctx.WithRequestCtx()) r.Route("/dex/warden", Routes(nil, doer)) - req, err := http.NewRequest(http.MethodGet, "/dex/warden/users/me/warden_teams", nil) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/dex/warden/users/me/warden_teams", nil) assert.NoError(t, err) req.Header.Add("X-Auth-Email", "test@email.com") @@ -73,6 +74,63 @@ func TestHandler_teamList(t *testing.T) { } ]}`, resp.Body.String()) }) + + t.Run("should return 404 when user email is not present in warden", func(t *testing.T) { + doer := mocks.NewDoer(t) + doer.EXPECT().Do(mock.Anything).Return(&http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewBufferString(`{ + "success": false, + "errors": [], + "data": { + "teams": [ + { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + } + ] + }, + "status": "ok" + }`)), + }, nil) + + r := chi.NewRouter() + r.Use(reqctx.WithRequestCtx()) + r.Route("/dex/warden", Routes(nil, doer)) + + req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/dex/warden/users/me/warden_teams", nil) + assert.NoError(t, err) + req.Header.Add("X-Auth-Email", "test@email.com") + + resp := httptest.NewRecorder() + r.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusNotFound, resp.Code) + }) + + t.Run("should return not authorised when X-Auth-Email is not present is header", func(t *testing.T) { + doer := mocks.NewDoer(t) + + r := chi.NewRouter() + r.Use(reqctx.WithRequestCtx()) + r.Route("/dex/warden", Routes(nil, doer)) + + req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/dex/warden/users/me/warden_teams", nil) + assert.NoError(t, err) + + resp := httptest.NewRecorder() + r.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusUnauthorized, resp.Code) + }) } func TestHandler_updateGroup(t *testing.T) { @@ -130,7 +188,7 @@ func TestHandler_updateGroup(t *testing.T) { r.Use(reqctx.WithRequestCtx()) r.Route("/dex/warden", Routes(shieldClient, doer)) - req, err := http.NewRequest(http.MethodPatch, "/dex/warden/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/dex/warden/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) assert.NoError(t, err) resp := httptest.NewRecorder() @@ -143,4 +201,58 @@ func TestHandler_updateGroup(t *testing.T) { "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b" }`, resp.Body.String()) }) + + t.Run("should return 500 when warden_team_id is invalid", func(t *testing.T) { + shieldClient := shareMocks.NewShieldServiceClient(t) + + doer := mocks.NewDoer(t) + doer.EXPECT().Do(mock.Anything).Return(&http.Response{ + StatusCode: http.StatusOK, + Body: io.NopCloser(bytes.NewBufferString(`{ + "success": false, + "data": { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + }, + "errors": [] + }`)), + }, nil) + + r := chi.NewRouter() + r.Use(reqctx.WithRequestCtx()) + r.Route("/dex/warden", Routes(shieldClient, doer)) + + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/dex/warden/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + assert.NoError(t, err) + + resp := httptest.NewRecorder() + r.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusInternalServerError, resp.Code) + }) + + t.Run("should return error when warden_team_id is empty string", func(t *testing.T) { + shieldClient := shareMocks.NewShieldServiceClient(t) + doer := mocks.NewDoer(t) + + r := chi.NewRouter() + r.Use(reqctx.WithRequestCtx()) + r.Route("/dex/warden", Routes(shieldClient, doer)) + + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/dex/warden/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": ""}`)) + assert.NoError(t, err) + + resp := httptest.NewRecorder() + r.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusBadRequest, resp.Code) + }) } diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index b236c5a..c95d1d4 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -48,7 +48,7 @@ func (c *Service) TeamList(ctx context.Context) (*TeamData, error) { url := baseURL + endpoint + userPath + reqCtx.UserEmail + teamsEndpoint - req, err := http.NewRequest(http.MethodGet, url, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { return nil, err } @@ -116,13 +116,13 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID return UpdatedGroupRes.Group.Metadata.AsMap(), nil } -func (c *Service) TeamByUUID(_ context.Context, teamByUUID string) (*Team, error) { +func (c *Service) TeamByUUID(ctx context.Context, teamByUUID string) (*Team, error) { endpoint := "/api/v2" teamPath := "/teams/" url := baseURL + endpoint + teamPath + teamByUUID - req, err := http.NewRequest(http.MethodGet, url, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { return nil, err } From d34551827135da78b25ee4a8eeafd89757d14e76 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Tue, 10 Oct 2023 18:42:36 +0530 Subject: [PATCH 13/27] feat(warden): test, error refactored --- internal/server/v1/warden/errors.go | 3 +- internal/server/v1/warden/handler.go | 26 +- internal/server/v1/warden/handler_test.go | 292 +++++++++++----------- internal/server/v1/warden/routes.go | 2 +- internal/server/v1/warden/service.go | 22 +- 5 files changed, 171 insertions(+), 174 deletions(-) diff --git a/internal/server/v1/warden/errors.go b/internal/server/v1/warden/errors.go index d4064c4..3b18335 100644 --- a/internal/server/v1/warden/errors.go +++ b/internal/server/v1/warden/errors.go @@ -3,6 +3,5 @@ package warden import "errors" var ( - ErrTeamNotFound = errors.New("email is not registered on warden") - ErrUserNotFound = errors.New("user not authorized") + ErrEmailNotOnWarden = errors.New("email is not registered on warden") ) diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/warden/handler.go index ce1c064..83398d1 100644 --- a/internal/server/v1/warden/handler.go +++ b/internal/server/v1/warden/handler.go @@ -6,6 +6,7 @@ import ( "github.com/go-chi/chi/v5" + "github.com/goto/dex/internal/server/reqctx" "github.com/goto/dex/internal/server/utils" ) @@ -18,17 +19,22 @@ func NewHandler(service *Service) *handler { } func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { - teamListResp, err := h.service.TeamList(r.Context()) - if errors.Is(err, ErrUserNotFound) { - utils.WriteErrMsg(w, http.StatusUnauthorized, ErrUserNotFound.Error()) - return - } - if errors.Is(err, ErrTeamNotFound) { - utils.WriteErrMsg(w, http.StatusNotFound, ErrTeamNotFound.Error()) + reqCtx := reqctx.From(r.Context()) + const errEmailMissedInHeader = "user email not in header" + + if reqCtx.UserEmail == "" { + utils.WriteErrMsg(w, http.StatusUnauthorized, errEmailMissedInHeader) return } + + teamListResp, err := h.service.TeamList(r.Context(), reqCtx.UserEmail) + if err != nil { + if errors.Is(err, ErrEmailNotOnWarden) { + utils.WriteErrMsg(w, http.StatusNotFound, ErrEmailNotOnWarden.Error()) + return + } utils.WriteErr(w, err) return } @@ -40,17 +46,17 @@ func (h *handler) updateGroupMetadata(w http.ResponseWriter, r *http.Request) { groupID := chi.URLParam(r, "group_id") var body struct { - WardeTeamID string `json:"warden_team_id"` + WardenTeamID string `json:"warden_team_id"` } if err := utils.ReadJSON(r, &body); err != nil { utils.WriteErr(w, err) return - } else if body.WardeTeamID == "" { + } else if body.WardenTeamID == "" { utils.WriteErrMsg(w, http.StatusBadRequest, "missing warden_team_id") return } - resShield, err := h.service.UpdateGroupMetadata(r.Context(), groupID, body.WardeTeamID) + resShield, err := h.service.UpdateGroupMetadata(r.Context(), groupID, body.WardenTeamID) if err != nil { utils.WriteErr(w, err) return diff --git a/internal/server/v1/warden/handler_test.go b/internal/server/v1/warden/handler_test.go index be322f6..1cfd151 100644 --- a/internal/server/v1/warden/handler_test.go +++ b/internal/server/v1/warden/handler_test.go @@ -1,4 +1,4 @@ -package warden +package warden_test import ( "bytes" @@ -12,122 +12,123 @@ import ( "github.com/go-chi/chi/v5" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "google.golang.org/protobuf/types/known/structpb" "github.com/goto/dex/internal/server/reqctx" + "github.com/goto/dex/internal/server/v1/warden" "github.com/goto/dex/internal/server/v1/warden/mocks" shareMocks "github.com/goto/dex/mocks" ) func TestHandler_teamList(t *testing.T) { t.Run("should return 200 OK", func(t *testing.T) { + // mocked response from warden returning list of teams for a user email + wardenResponse := `{ + "success": true, + "errors": [], + "data": { + "teams": [ + { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + } + ]}, + "status": "ok" + }` + dexTeamListResonses := `{ + "teams": [ + { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + } + ]}` doer := mocks.NewDoer(t) doer.EXPECT().Do(mock.Anything).Return(&http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(bytes.NewBufferString(`{ - "success": true, - "errors": [], - "data": { - "teams": [ - { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - } - ] - }, - "status": "ok" - }`)), + Body: io.NopCloser(bytes.NewBufferString(wardenResponse)), }, nil) - r := chi.NewRouter() - r.Use(reqctx.WithRequestCtx()) - r.Route("/dex/warden", Routes(nil, doer)) - - req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/dex/warden/users/me/warden_teams", nil) - assert.NoError(t, err) - req.Header.Add("X-Auth-Email", "test@email.com") - resp := httptest.NewRecorder() - r.ServeHTTP(resp, req) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) + require.NoError(t, err) + req.Header.Add("X-Auth-Email", "test@email.com") + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + warden.Routes(nil, doer)(router) + router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) - assert.JSONEq(t, `{ "teams": [ - { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - } - ]}`, resp.Body.String()) + assert.JSONEq(t, dexTeamListResonses, resp.Body.String()) }) - t.Run("should return 404 when user email is not present in warden", func(t *testing.T) { + t.Run("should return 401 when user email is not present in warden", func(t *testing.T) { + wardenResponse := `{ + "success": false, + "errors": [], + "data": { + "teams": [ + { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + } + ]}, + "status": "ok" + }` + shieldClient := shareMocks.NewShieldServiceClient(t) doer := mocks.NewDoer(t) doer.EXPECT().Do(mock.Anything).Return(&http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(bytes.NewBufferString(`{ - "success": false, - "errors": [], - "data": { - "teams": [ - { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - } - ] - }, - "status": "ok" - }`)), + Body: io.NopCloser(bytes.NewBufferString(wardenResponse)), }, nil) - r := chi.NewRouter() - r.Use(reqctx.WithRequestCtx()) - r.Route("/dex/warden", Routes(nil, doer)) - - req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/dex/warden/users/me/warden_teams", nil) - assert.NoError(t, err) - req.Header.Add("X-Auth-Email", "test@email.com") - resp := httptest.NewRecorder() - r.ServeHTTP(resp, req) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) + require.NoError(t, err) + req.Header.Add("X-Auth-Email", "test@email.com") + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + warden.Routes(shieldClient, doer)(router) + router.ServeHTTP(resp, req) assert.Equal(t, http.StatusNotFound, resp.Code) }) - t.Run("should return not authorised when X-Auth-Email is not present is header", func(t *testing.T) { + t.Run("should return Unauthorized when X-Auth-Email is not present is header", func(t *testing.T) { + shieldClient := shareMocks.NewShieldServiceClient(t) doer := mocks.NewDoer(t) - r := chi.NewRouter() - r.Use(reqctx.WithRequestCtx()) - r.Route("/dex/warden", Routes(nil, doer)) - - req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/dex/warden/users/me/warden_teams", nil) - assert.NoError(t, err) - resp := httptest.NewRecorder() - r.ServeHTTP(resp, req) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) + require.NoError(t, err) + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + warden.Routes(shieldClient, doer)(router) + router.ServeHTTP(resp, req) assert.Equal(t, http.StatusUnauthorized, resp.Code) }) @@ -135,6 +136,29 @@ func TestHandler_teamList(t *testing.T) { func TestHandler_updateGroup(t *testing.T) { t.Run("should return 200 OK", func(t *testing.T) { + // mocked response from warden returning a team for a wardenUUID + wardenResponse := `{ + "success": true, + "data": { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + }, + "errors": [] + }` + + dexGroupMetadataResponse := `{ + "privacy": "public", + "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b" + }` groupID := "e38527ee-a8cd-40f9-98a7-1f0bbd20909f" metaData, _ := structpb.NewStruct(map[string]any{ "privacy": "public", @@ -166,75 +190,53 @@ func TestHandler_updateGroup(t *testing.T) { doer := mocks.NewDoer(t) doer.EXPECT().Do(mock.Anything).Return(&http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(bytes.NewBufferString(`{ - "success": true, - "data": { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - }, - "errors": [] - }`)), + Body: io.NopCloser(bytes.NewBufferString(wardenResponse)), }, nil) - r := chi.NewRouter() - r.Use(reqctx.WithRequestCtx()) - r.Route("/dex/warden", Routes(shieldClient, doer)) - - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/dex/warden/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) - assert.NoError(t, err) - resp := httptest.NewRecorder() - r.ServeHTTP(resp, req) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + require.NoError(t, err) + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + warden.Routes(shieldClient, doer)(router) + router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) - assert.JSONEq(t, `{ - "privacy": "public", - "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b" - }`, resp.Body.String()) + assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) }) t.Run("should return 500 when warden_team_id is invalid", func(t *testing.T) { + wardenResponse := `{ + "success": false, + "data": { + "name": "data_fabric", + "created_at": "2023-08-25T03:52:13.548Z", + "updated_at": "2023-08-25T03:52:13.548Z", + "owner_id": 433, + "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", + "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product_group_name": "data_engineering", + "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "labels": null, + "short_code": "T394" + }, + "errors": [] + }` shieldClient := shareMocks.NewShieldServiceClient(t) doer := mocks.NewDoer(t) doer.EXPECT().Do(mock.Anything).Return(&http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(bytes.NewBufferString(`{ - "success": false, - "data": { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - }, - "errors": [] - }`)), + Body: io.NopCloser(bytes.NewBufferString(wardenResponse)), }, nil) - r := chi.NewRouter() - r.Use(reqctx.WithRequestCtx()) - r.Route("/dex/warden", Routes(shieldClient, doer)) - - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/dex/warden/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) - assert.NoError(t, err) - resp := httptest.NewRecorder() - r.ServeHTTP(resp, req) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + require.NoError(t, err) + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + warden.Routes(shieldClient, doer)(router) + router.ServeHTTP(resp, req) assert.Equal(t, http.StatusInternalServerError, resp.Code) }) @@ -243,15 +245,13 @@ func TestHandler_updateGroup(t *testing.T) { shieldClient := shareMocks.NewShieldServiceClient(t) doer := mocks.NewDoer(t) - r := chi.NewRouter() - r.Use(reqctx.WithRequestCtx()) - r.Route("/dex/warden", Routes(shieldClient, doer)) - - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/dex/warden/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": ""}`)) - assert.NoError(t, err) - resp := httptest.NewRecorder() - r.ServeHTTP(resp, req) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": ""}`)) + require.NoError(t, err) + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + warden.Routes(shieldClient, doer)(router) + router.ServeHTTP(resp, req) assert.Equal(t, http.StatusBadRequest, resp.Code) }) diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go index ae83995..d84682f 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/warden/routes.go @@ -5,7 +5,7 @@ import ( chiv5 "github.com/go-chi/chi/v5" ) -func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer Doer) func(r chiv5.Router) { +func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HttpClient) func(r chiv5.Router) { service := NewService(shieldClient, doer) handler := NewHandler(service) return func(r chiv5.Router) { diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index c95d1d4..971fa81 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -9,8 +9,6 @@ import ( shieldv1beta1rpc "buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc" shieldv1beta1 "buf.build/gen/go/gotocompany/proton/protocolbuffers/go/gotocompany/shield/v1beta1" "google.golang.org/protobuf/types/known/structpb" - - "github.com/goto/dex/internal/server/reqctx" ) //go:generate mockery --with-expecter --keeptree --case snake --name Doer @@ -21,32 +19,26 @@ const ( type Service struct { shieldClient shieldv1beta1rpc.ShieldServiceClient - doer Doer + doer HttpClient } -type Doer interface { +type HttpClient interface { Do(req *http.Request) (*http.Response, error) } -func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer Doer) *Service { +func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HttpClient) *Service { return &Service{ shieldClient: shieldClient, doer: doer, } } -func (c *Service) TeamList(ctx context.Context) (*TeamData, error) { +func (c *Service) TeamList(ctx context.Context, userEmail string) (*TeamData, error) { endpoint := "/api/v1" userPath := "/users/" teamsEndpoint := "/teams" - reqCtx := reqctx.From(ctx) - - if reqCtx.UserEmail == "" { - return nil, ErrUserNotFound - } - - url := baseURL + endpoint + userPath + reqCtx.UserEmail + teamsEndpoint + url := baseURL + endpoint + userPath + userEmail + teamsEndpoint req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { @@ -69,7 +61,7 @@ func (c *Service) TeamList(ctx context.Context) (*TeamData, error) { return &data.Data, nil } - return nil, ErrTeamNotFound + return nil, ErrEmailNotOnWarden } func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { @@ -143,7 +135,7 @@ func (c *Service) TeamByUUID(ctx context.Context, teamByUUID string) (*Team, err return &data.Data, nil } - return nil, ErrTeamNotFound + return nil, ErrEmailNotOnWarden } type TeamResponse struct { From d3cd79b7999e09af74cee4297ace9d458bfcd237 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Tue, 10 Oct 2023 18:45:19 +0530 Subject: [PATCH 14/27] chore: format and lint resolved --- internal/server/v1/warden/errors.go | 4 +--- internal/server/v1/warden/handler.go | 2 -- internal/server/v1/warden/routes.go | 2 +- internal/server/v1/warden/service.go | 6 +++--- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/internal/server/v1/warden/errors.go b/internal/server/v1/warden/errors.go index 3b18335..93c3698 100644 --- a/internal/server/v1/warden/errors.go +++ b/internal/server/v1/warden/errors.go @@ -2,6 +2,4 @@ package warden import "errors" -var ( - ErrEmailNotOnWarden = errors.New("email is not registered on warden") -) +var ErrEmailNotOnWarden = errors.New("email is not registered on warden") diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/warden/handler.go index 83398d1..ee32230 100644 --- a/internal/server/v1/warden/handler.go +++ b/internal/server/v1/warden/handler.go @@ -19,7 +19,6 @@ func NewHandler(service *Service) *handler { } func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { - reqCtx := reqctx.From(r.Context()) const errEmailMissedInHeader = "user email not in header" @@ -29,7 +28,6 @@ func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { } teamListResp, err := h.service.TeamList(r.Context(), reqCtx.UserEmail) - if err != nil { if errors.Is(err, ErrEmailNotOnWarden) { utils.WriteErrMsg(w, http.StatusNotFound, ErrEmailNotOnWarden.Error()) diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go index d84682f..7b41613 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/warden/routes.go @@ -5,7 +5,7 @@ import ( chiv5 "github.com/go-chi/chi/v5" ) -func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HttpClient) func(r chiv5.Router) { +func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HTTPClient) func(r chiv5.Router) { service := NewService(shieldClient, doer) handler := NewHandler(service) return func(r chiv5.Router) { diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index 971fa81..05f65e5 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -19,14 +19,14 @@ const ( type Service struct { shieldClient shieldv1beta1rpc.ShieldServiceClient - doer HttpClient + doer HTTPClient } -type HttpClient interface { +type HTTPClient interface { Do(req *http.Request) (*http.Response, error) } -func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HttpClient) *Service { +func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HTTPClient) *Service { return &Service{ shieldClient: shieldClient, doer: doer, From d1f60e89958073a09bebc14ae342a325a7db5f22 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Wed, 11 Oct 2023 11:34:36 +0530 Subject: [PATCH 15/27] feat(warden): added warden host as a config --- cli/server/configs.go | 5 +++++ cli/server/server.go | 1 + internal/server/server.go | 3 ++- internal/server/v1/warden/handler_test.go | 12 ++++++------ internal/server/v1/warden/routes.go | 4 ++-- internal/server/v1/warden/service.go | 12 +++++------- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/cli/server/configs.go b/cli/server/configs.go index c7cc985..bdaff23 100644 --- a/cli/server/configs.go +++ b/cli/server/configs.go @@ -23,6 +23,11 @@ type serverConfig struct { Compass compassConfig `mapstructure:"compass"` Optimus optimusConfig `mapstructure:"optimus"` StencilAddr string `mapstructure:"stencil_addr"` + Warden wardenConfig `mapstructure:"warden"` +} + +type wardenConfig struct { + Addr string `mapstructure:"addr"` } type odinConfig struct { diff --git a/cli/server/server.go b/cli/server/server.go index 4cae414..fdef154 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -113,5 +113,6 @@ func runServer(baseCtx context.Context, nrApp *newrelic.Application, zapLog *zap &gcs.Client{StorageClient: gcsClient}, cfg.Odin.Addr, cfg.StencilAddr, + cfg.Warden.Addr, ) } diff --git a/internal/server/server.go b/internal/server/server.go index 94a6dcd..54611f5 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -39,6 +39,7 @@ func Serve(ctx context.Context, addr string, gcsClient gcs.BlobStorageClient, odinAddr string, stencilAddr string, + wardenAddr string, ) error { alertSvc := alertsv1.NewService(sirenClient) @@ -67,7 +68,7 @@ func Serve(ctx context.Context, addr string, r.Route("/dlq", dlqv1.Routes(entropyClient, gcsClient)) r.Route("/firehoses", firehosev1.Routes(entropyClient, shieldClient, alertSvc, compassClient, odinAddr, stencilAddr)) r.Route("/kubernetes", kubernetesv1.Routes(entropyClient)) - r.Route("/warden", warden.Routes(shieldClient, http.DefaultClient)) + r.Route("/warden", warden.Routes(shieldClient, http.DefaultClient, wardenAddr)) }) logger.Info("starting server", zap.String("addr", addr)) diff --git a/internal/server/v1/warden/handler_test.go b/internal/server/v1/warden/handler_test.go index 1cfd151..34f4293 100644 --- a/internal/server/v1/warden/handler_test.go +++ b/internal/server/v1/warden/handler_test.go @@ -71,7 +71,7 @@ func TestHandler_teamList(t *testing.T) { req.Header.Add("X-Auth-Email", "test@email.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(nil, doer)(router) + warden.Routes(nil, doer, "")(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) @@ -112,7 +112,7 @@ func TestHandler_teamList(t *testing.T) { req.Header.Add("X-Auth-Email", "test@email.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer)(router) + warden.Routes(shieldClient, doer, "")(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusNotFound, resp.Code) @@ -127,7 +127,7 @@ func TestHandler_teamList(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer)(router) + warden.Routes(shieldClient, doer, "")(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusUnauthorized, resp.Code) @@ -198,7 +198,7 @@ func TestHandler_updateGroup(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer)(router) + warden.Routes(shieldClient, doer, "")(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) @@ -235,7 +235,7 @@ func TestHandler_updateGroup(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer)(router) + warden.Routes(shieldClient, doer, "")(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusInternalServerError, resp.Code) @@ -250,7 +250,7 @@ func TestHandler_updateGroup(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer)(router) + warden.Routes(shieldClient, doer, "")(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusBadRequest, resp.Code) diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go index 7b41613..67de2d0 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/warden/routes.go @@ -5,8 +5,8 @@ import ( chiv5 "github.com/go-chi/chi/v5" ) -func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HTTPClient) func(r chiv5.Router) { - service := NewService(shieldClient, doer) +func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HTTPClient, wardenAddr string) func(r chiv5.Router) { + service := NewService(shieldClient, doer, wardenAddr) handler := NewHandler(service) return func(r chiv5.Router) { r.Get("/users/me/warden_teams", handler.teamList) diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index 05f65e5..a51cd3b 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -13,23 +13,21 @@ import ( //go:generate mockery --with-expecter --keeptree --case snake --name Doer -const ( - baseURL = "https://go-cloud.golabs.io" -) - type Service struct { shieldClient shieldv1beta1rpc.ShieldServiceClient doer HTTPClient + wardenAddr string } type HTTPClient interface { Do(req *http.Request) (*http.Response, error) } -func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HTTPClient) *Service { +func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HTTPClient, wardenAddr string) *Service { return &Service{ shieldClient: shieldClient, doer: doer, + wardenAddr: wardenAddr, } } @@ -38,7 +36,7 @@ func (c *Service) TeamList(ctx context.Context, userEmail string) (*TeamData, er userPath := "/users/" teamsEndpoint := "/teams" - url := baseURL + endpoint + userPath + userEmail + teamsEndpoint + url := c.wardenAddr + endpoint + userPath + userEmail + teamsEndpoint req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { @@ -112,7 +110,7 @@ func (c *Service) TeamByUUID(ctx context.Context, teamByUUID string) (*Team, err endpoint := "/api/v2" teamPath := "/teams/" - url := baseURL + endpoint + teamPath + teamByUUID + url := c.wardenAddr + endpoint + teamPath + teamByUUID req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { From 9f3e743bd46352154ae916faa636d8fa2f29f317 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Fri, 13 Oct 2023 01:40:42 +0530 Subject: [PATCH 16/27] feat(warden) : added warden client --- cli/server/server.go | 6 +- internal/server/server.go | 7 +- internal/server/v1/warden/handler_test.go | 16 +-- internal/server/v1/warden/routes.go | 6 +- internal/server/v1/warden/service.go | 113 ++++------------------ warden/client.go | 83 ++++++++++++++++ warden/warden.go | 40 ++++++++ 7 files changed, 165 insertions(+), 106 deletions(-) create mode 100644 warden/client.go create mode 100644 warden/warden.go diff --git a/cli/server/server.go b/cli/server/server.go index fdef154..19bc5c0 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -19,6 +19,7 @@ import ( "github.com/goto/dex/internal/server/gcs" "github.com/goto/dex/pkg/logger" "github.com/goto/dex/pkg/telemetry" + "github.com/goto/dex/warden" ) func Commands() *cobra.Command { @@ -104,6 +105,9 @@ func runServer(baseCtx context.Context, nrApp *newrelic.Application, zapLog *zap if err != nil { return err } + + wardenClient := warden.NewClient(cfg.Warden.Addr) + return server.Serve(ctx, cfg.Service.Addr(), nrApp, zapLog, shieldv1beta1.NewShieldServiceClient(shieldConn), entropyv1beta1.NewResourceServiceClient(entropyConn), @@ -113,6 +117,6 @@ func runServer(baseCtx context.Context, nrApp *newrelic.Application, zapLog *zap &gcs.Client{StorageClient: gcsClient}, cfg.Odin.Addr, cfg.StencilAddr, - cfg.Warden.Addr, + wardenClient, ) } diff --git a/internal/server/server.go b/internal/server/server.go index 54611f5..462094b 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -24,7 +24,8 @@ import ( kubernetesv1 "github.com/goto/dex/internal/server/v1/kubernetes" optimusv1 "github.com/goto/dex/internal/server/v1/optimus" projectsv1 "github.com/goto/dex/internal/server/v1/project" - warden "github.com/goto/dex/internal/server/v1/warden" + wardenV1 "github.com/goto/dex/internal/server/v1/warden" + "github.com/goto/dex/warden" ) // Serve initialises all the HTTP API routes, starts listening for requests at addr, and blocks until @@ -39,7 +40,7 @@ func Serve(ctx context.Context, addr string, gcsClient gcs.BlobStorageClient, odinAddr string, stencilAddr string, - wardenAddr string, + wardenClient *warden.Client, ) error { alertSvc := alertsv1.NewService(sirenClient) @@ -68,7 +69,7 @@ func Serve(ctx context.Context, addr string, r.Route("/dlq", dlqv1.Routes(entropyClient, gcsClient)) r.Route("/firehoses", firehosev1.Routes(entropyClient, shieldClient, alertSvc, compassClient, odinAddr, stencilAddr)) r.Route("/kubernetes", kubernetesv1.Routes(entropyClient)) - r.Route("/warden", warden.Routes(shieldClient, http.DefaultClient, wardenAddr)) + r.Route("/warden", wardenV1.Routes(shieldClient, wardenClient)) }) logger.Info("starting server", zap.String("addr", addr)) diff --git a/internal/server/v1/warden/handler_test.go b/internal/server/v1/warden/handler_test.go index 34f4293..68deadb 100644 --- a/internal/server/v1/warden/handler_test.go +++ b/internal/server/v1/warden/handler_test.go @@ -71,7 +71,7 @@ func TestHandler_teamList(t *testing.T) { req.Header.Add("X-Auth-Email", "test@email.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(nil, doer, "")(router) + warden.Routes(nil, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) @@ -112,7 +112,7 @@ func TestHandler_teamList(t *testing.T) { req.Header.Add("X-Auth-Email", "test@email.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer, "")(router) + warden.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusNotFound, resp.Code) @@ -120,14 +120,14 @@ func TestHandler_teamList(t *testing.T) { t.Run("should return Unauthorized when X-Auth-Email is not present is header", func(t *testing.T) { shieldClient := shareMocks.NewShieldServiceClient(t) - doer := mocks.NewDoer(t) + // doer := mocks.NewDoer(t) resp := httptest.NewRecorder() req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer, "")(router) + warden.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusUnauthorized, resp.Code) @@ -198,7 +198,7 @@ func TestHandler_updateGroup(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer, "")(router) + warden.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) @@ -235,7 +235,7 @@ func TestHandler_updateGroup(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer, "")(router) + warden.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusInternalServerError, resp.Code) @@ -243,14 +243,14 @@ func TestHandler_updateGroup(t *testing.T) { t.Run("should return error when warden_team_id is empty string", func(t *testing.T) { shieldClient := shareMocks.NewShieldServiceClient(t) - doer := mocks.NewDoer(t) + // doer := mocks.NewDoer(t) resp := httptest.NewRecorder() req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": ""}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, doer, "")(router) + warden.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusBadRequest, resp.Code) diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/warden/routes.go index 67de2d0..d6909df 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/warden/routes.go @@ -3,10 +3,12 @@ package warden import ( shieldv1beta1rpc "buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc" chiv5 "github.com/go-chi/chi/v5" + + "github.com/goto/dex/warden" ) -func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HTTPClient, wardenAddr string) func(r chiv5.Router) { - service := NewService(shieldClient, doer, wardenAddr) +func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient *warden.Client) func(r chiv5.Router) { + service := NewService(shieldClient, wardenClient) handler := NewHandler(service) return func(r chiv5.Router) { r.Get("/users/me/warden_teams", handler.teamList) diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/warden/service.go index a51cd3b..a1c8d72 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/warden/service.go @@ -2,66 +2,28 @@ package warden import ( "context" - "encoding/json" - "net/http" - "time" shieldv1beta1rpc "buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc" shieldv1beta1 "buf.build/gen/go/gotocompany/proton/protocolbuffers/go/gotocompany/shield/v1beta1" "google.golang.org/protobuf/types/known/structpb" + + "github.com/goto/dex/warden" ) //go:generate mockery --with-expecter --keeptree --case snake --name Doer type Service struct { shieldClient shieldv1beta1rpc.ShieldServiceClient - doer HTTPClient - wardenAddr string -} - -type HTTPClient interface { - Do(req *http.Request) (*http.Response, error) + wardenClient *warden.Client } -func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, doer HTTPClient, wardenAddr string) *Service { +func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient *warden.Client) *Service { return &Service{ shieldClient: shieldClient, - doer: doer, - wardenAddr: wardenAddr, + wardenClient: wardenClient, } } -func (c *Service) TeamList(ctx context.Context, userEmail string) (*TeamData, error) { - endpoint := "/api/v1" - userPath := "/users/" - teamsEndpoint := "/teams" - - url := c.wardenAddr + endpoint + userPath + userEmail + teamsEndpoint - - req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) - if err != nil { - return nil, err - } - - resp, err := c.doer.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - var data TeamListResponse - err = json.NewDecoder(resp.Body).Decode(&data) - if err != nil { - return nil, err - } - - if data.Success { - return &data.Data, nil - } - - return nil, ErrEmailNotOnWarden -} - func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { wardenTeam, err := c.TeamByUUID(ctx, wardenTeamID) if err != nil { @@ -82,8 +44,8 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID metaData = make(map[string]any) } - metaData["team-id"] = wardenTeam.Identifier - metaData["product-group-id"] = wardenTeam.ProductGroupID + metaData["team-id"] = wardenTeam.Data.Identifier + metaData["product-group-id"] = wardenTeam.Data.ProductGroupID updatedMetaData, err := structpb.NewStruct(metaData) if err != nil { @@ -106,60 +68,27 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID return UpdatedGroupRes.Group.Metadata.AsMap(), nil } -func (c *Service) TeamByUUID(ctx context.Context, teamByUUID string) (*Team, error) { - endpoint := "/api/v2" - teamPath := "/teams/" - - url := c.wardenAddr + endpoint + teamPath + teamByUUID - - req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) +func (svc *Service) TeamList(ctx context.Context, userEmail string) ([]warden.Team, error) { + teams, err := svc.wardenClient.ListUserTeams(ctx, warden.TeamListRequest{ + Email: userEmail, + }) if err != nil { return nil, err } - resp, err := c.doer.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() + return teams, nil +} - var data TeamResponse - err = json.NewDecoder(resp.Body).Decode(&data) +func (svc *Service) TeamByUUID(ctx context.Context, teamByUUID string) (*warden.TeamResponse, error) { + team, err := svc.wardenClient.WardenTeamByUUID(ctx, warden.TeamByUUIDRequest{ + TeamUUID: teamByUUID, + }) if err != nil { return nil, err } - if data.Success { - return &data.Data, nil - } - - return nil, ErrEmailNotOnWarden -} - -type TeamResponse struct { - Success bool `json:"success"` - Data Team `json:"data"` - Message string `json:"message"` -} - -type TeamListResponse struct { - Success bool `json:"success"` - Data TeamData `json:"data"` -} - -type TeamData struct { - Teams []Team `json:"teams"` -} - -type Team struct { - Name string `json:"name"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` - OwnerID int `json:"owner_id"` - ParentTeamIdentifier string `json:"parent_team_identifier"` - Identifier string `json:"identifier"` - ProductGroupName string `json:"product_group_name"` - ProductGroupID string `json:"product_group_id"` - Labels any `json:"labels"` - ShortCode string `json:"short_code"` + return &warden.TeamResponse{ + Success: true, + Data: *team, + }, nil } diff --git a/warden/client.go b/warden/client.go new file mode 100644 index 0000000..5cd0b72 --- /dev/null +++ b/warden/client.go @@ -0,0 +1,83 @@ +package warden + +import ( + "context" + "encoding/json" + "fmt" + "net/http" +) + +type Client struct { + BaseURL string + Client *http.Client +} + +func NewClient(baseURL string) *Client { + return &Client{ + BaseURL: baseURL, + Client: &http.Client{}, + } +} + +func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team, error) { + const ( + endpoint = "/api/v1" + userPath = "/users/" + teamsEndpoint = "/teams" + ) + url := fmt.Sprintf("%s%s%s%s%s", c.BaseURL, endpoint, userPath, req.Email, teamsEndpoint) + fmt.Println("URL: ", url) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + if err != nil { + return nil, err + } + + resp, err := c.Client.Do(httpReq) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("failed to fetch teams: %v", resp.Status) + } + + var data TeamListResponse + err = json.NewDecoder(resp.Body).Decode(&data) + if err != nil { + return nil, err + } + + return data.Data.Teams, nil +} + +func (c *Client) WardenTeamByUUID(ctx context.Context, req TeamByUUIDRequest) (*Team, error) { + const ( + endpoint = "/api/v2" + teamPath = "/teams/" + ) + + url := fmt.Sprintf("%s%s%s%s", c.BaseURL, endpoint, teamPath, req.TeamUUID) + httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + if err != nil { + return nil, err + } + + resp, err := c.Client.Do(httpReq) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("failed to fetch team: %v", resp.Status) + } + + var data TeamResponse + err = json.NewDecoder(resp.Body).Decode(&data) + if err != nil { + return nil, err + } + + return &data.Data, nil +} diff --git a/warden/warden.go b/warden/warden.go new file mode 100644 index 0000000..fb484a2 --- /dev/null +++ b/warden/warden.go @@ -0,0 +1,40 @@ +package warden + +import ( + "time" +) + +type Team struct { + Name string `json:"name"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` + OwnerID int `json:"owner_id"` + ParentTeamIdentifier string `json:"parent_team_identifier"` + Identifier string `json:"identifier"` + ProductGroupName string `json:"product_group_name"` + ProductGroupID string `json:"product_group_id"` + Labels any `json:"labels"` + ShortCode string `json:"short_code"` +} + +type TeamResponse struct { + Success bool `json:"success"` + Data Team `json:"data"` +} + +type TeamListResponse struct { + Success bool `json:"success"` + Data TeamsData `json:"data"` +} + +type TeamsData struct { + Teams []Team `json:"teams"` +} + +type TeamListRequest struct { + Email string +} + +type TeamByUUIDRequest struct { + TeamUUID string +} From 5b465ef4bf35e57adfa977a25907c92652d27e1c Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Fri, 13 Oct 2023 01:55:16 +0530 Subject: [PATCH 17/27] feat(warden): replaced warden route by iam --- internal/server/server.go | 4 ++-- internal/server/v1/{warden => iam}/errors.go | 2 +- internal/server/v1/{warden => iam}/handler.go | 2 +- .../server/v1/{warden => iam}/handler_test.go | 16 ++++++++-------- internal/server/v1/{warden => iam}/routes.go | 2 +- internal/server/v1/{warden => iam}/service.go | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) rename internal/server/v1/{warden => iam}/errors.go (85%) rename internal/server/v1/{warden => iam}/handler.go (98%) rename internal/server/v1/{warden => iam}/handler_test.go (96%) rename internal/server/v1/{warden => iam}/routes.go (97%) rename internal/server/v1/{warden => iam}/service.go (99%) diff --git a/internal/server/server.go b/internal/server/server.go index 462094b..5987691 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -21,10 +21,10 @@ import ( alertsv1 "github.com/goto/dex/internal/server/v1/alert" dlqv1 "github.com/goto/dex/internal/server/v1/dlq" firehosev1 "github.com/goto/dex/internal/server/v1/firehose" + iamv1 "github.com/goto/dex/internal/server/v1/iam" kubernetesv1 "github.com/goto/dex/internal/server/v1/kubernetes" optimusv1 "github.com/goto/dex/internal/server/v1/optimus" projectsv1 "github.com/goto/dex/internal/server/v1/project" - wardenV1 "github.com/goto/dex/internal/server/v1/warden" "github.com/goto/dex/warden" ) @@ -69,7 +69,7 @@ func Serve(ctx context.Context, addr string, r.Route("/dlq", dlqv1.Routes(entropyClient, gcsClient)) r.Route("/firehoses", firehosev1.Routes(entropyClient, shieldClient, alertSvc, compassClient, odinAddr, stencilAddr)) r.Route("/kubernetes", kubernetesv1.Routes(entropyClient)) - r.Route("/warden", wardenV1.Routes(shieldClient, wardenClient)) + r.Route("/iam", iamv1.Routes(shieldClient, wardenClient)) }) logger.Info("starting server", zap.String("addr", addr)) diff --git a/internal/server/v1/warden/errors.go b/internal/server/v1/iam/errors.go similarity index 85% rename from internal/server/v1/warden/errors.go rename to internal/server/v1/iam/errors.go index 93c3698..6f72717 100644 --- a/internal/server/v1/warden/errors.go +++ b/internal/server/v1/iam/errors.go @@ -1,4 +1,4 @@ -package warden +package iam import "errors" diff --git a/internal/server/v1/warden/handler.go b/internal/server/v1/iam/handler.go similarity index 98% rename from internal/server/v1/warden/handler.go rename to internal/server/v1/iam/handler.go index ee32230..42d8ff9 100644 --- a/internal/server/v1/warden/handler.go +++ b/internal/server/v1/iam/handler.go @@ -1,4 +1,4 @@ -package warden +package iam import ( "errors" diff --git a/internal/server/v1/warden/handler_test.go b/internal/server/v1/iam/handler_test.go similarity index 96% rename from internal/server/v1/warden/handler_test.go rename to internal/server/v1/iam/handler_test.go index 68deadb..b36ea75 100644 --- a/internal/server/v1/warden/handler_test.go +++ b/internal/server/v1/iam/handler_test.go @@ -1,4 +1,4 @@ -package warden_test +package iam_test import ( "bytes" @@ -16,7 +16,7 @@ import ( "google.golang.org/protobuf/types/known/structpb" "github.com/goto/dex/internal/server/reqctx" - "github.com/goto/dex/internal/server/v1/warden" + "github.com/goto/dex/internal/server/v1/iam" "github.com/goto/dex/internal/server/v1/warden/mocks" shareMocks "github.com/goto/dex/mocks" ) @@ -71,7 +71,7 @@ func TestHandler_teamList(t *testing.T) { req.Header.Add("X-Auth-Email", "test@email.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(nil, nil)(router) + iam.Routes(nil, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) @@ -112,7 +112,7 @@ func TestHandler_teamList(t *testing.T) { req.Header.Add("X-Auth-Email", "test@email.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, nil)(router) + iam.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusNotFound, resp.Code) @@ -127,7 +127,7 @@ func TestHandler_teamList(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, nil)(router) + iam.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusUnauthorized, resp.Code) @@ -198,7 +198,7 @@ func TestHandler_updateGroup(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, nil)(router) + iam.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) @@ -235,7 +235,7 @@ func TestHandler_updateGroup(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, nil)(router) + iam.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusInternalServerError, resp.Code) @@ -250,7 +250,7 @@ func TestHandler_updateGroup(t *testing.T) { require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - warden.Routes(shieldClient, nil)(router) + iam.Routes(shieldClient, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusBadRequest, resp.Code) diff --git a/internal/server/v1/warden/routes.go b/internal/server/v1/iam/routes.go similarity index 97% rename from internal/server/v1/warden/routes.go rename to internal/server/v1/iam/routes.go index d6909df..2b5d191 100644 --- a/internal/server/v1/warden/routes.go +++ b/internal/server/v1/iam/routes.go @@ -1,4 +1,4 @@ -package warden +package iam import ( shieldv1beta1rpc "buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc" diff --git a/internal/server/v1/warden/service.go b/internal/server/v1/iam/service.go similarity index 99% rename from internal/server/v1/warden/service.go rename to internal/server/v1/iam/service.go index a1c8d72..e217da7 100644 --- a/internal/server/v1/warden/service.go +++ b/internal/server/v1/iam/service.go @@ -1,4 +1,4 @@ -package warden +package iam import ( "context" From d69a46d7d5a394b6f15e688811305b6ecd06ea7e Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Fri, 13 Oct 2023 19:28:23 +0530 Subject: [PATCH 18/27] feat(warden): updated tests --- internal/server/v1/iam/errors.go | 5 - internal/server/v1/iam/handler.go | 9 +- internal/server/v1/iam/handler_test.go | 311 +++++++++++------- internal/server/v1/iam/mocks/warden_client.go | 148 +++++++++ internal/server/v1/iam/routes.go | 4 +- internal/server/v1/iam/service.go | 61 ++-- internal/server/v1/warden/mocks/doer.go | 90 ----- warden/client.go | 20 +- warden/warden.go | 8 +- 9 files changed, 387 insertions(+), 269 deletions(-) delete mode 100644 internal/server/v1/iam/errors.go create mode 100644 internal/server/v1/iam/mocks/warden_client.go delete mode 100644 internal/server/v1/warden/mocks/doer.go diff --git a/internal/server/v1/iam/errors.go b/internal/server/v1/iam/errors.go deleted file mode 100644 index 6f72717..0000000 --- a/internal/server/v1/iam/errors.go +++ /dev/null @@ -1,5 +0,0 @@ -package iam - -import "errors" - -var ErrEmailNotOnWarden = errors.New("email is not registered on warden") diff --git a/internal/server/v1/iam/handler.go b/internal/server/v1/iam/handler.go index 42d8ff9..81af7ee 100644 --- a/internal/server/v1/iam/handler.go +++ b/internal/server/v1/iam/handler.go @@ -1,7 +1,6 @@ package iam import ( - "errors" "net/http" "github.com/go-chi/chi/v5" @@ -29,15 +28,13 @@ func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { teamListResp, err := h.service.TeamList(r.Context(), reqCtx.UserEmail) if err != nil { - if errors.Is(err, ErrEmailNotOnWarden) { - utils.WriteErrMsg(w, http.StatusNotFound, ErrEmailNotOnWarden.Error()) - return - } utils.WriteErr(w, err) return } - utils.WriteJSON(w, http.StatusOK, teamListResp) + utils.WriteJSON(w, http.StatusOK, map[string]any{ + "teams": teamListResp, + }) } func (h *handler) updateGroupMetadata(w http.ResponseWriter, r *http.Request) { diff --git a/internal/server/v1/iam/handler_test.go b/internal/server/v1/iam/handler_test.go index b36ea75..3002ae6 100644 --- a/internal/server/v1/iam/handler_test.go +++ b/internal/server/v1/iam/handler_test.go @@ -3,10 +3,10 @@ package iam_test import ( "bytes" "context" - "io" "net/http" "net/http/httptest" "testing" + "time" shieldv1beta1 "buf.build/gen/go/gotocompany/proton/protocolbuffers/go/gotocompany/shield/v1beta1" "github.com/go-chi/chi/v5" @@ -17,39 +17,20 @@ import ( "github.com/goto/dex/internal/server/reqctx" "github.com/goto/dex/internal/server/v1/iam" - "github.com/goto/dex/internal/server/v1/warden/mocks" + "github.com/goto/dex/internal/server/v1/iam/mocks" shareMocks "github.com/goto/dex/mocks" + "github.com/goto/dex/pkg/errors" + "github.com/goto/dex/warden" ) func TestHandler_teamList(t *testing.T) { - t.Run("should return 200 OK", func(t *testing.T) { - // mocked response from warden returning list of teams for a user email - wardenResponse := `{ - "success": true, - "errors": [], - "data": { - "teams": [ - { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - } - ]}, - "status": "ok" - }` + t.Run("success", func(t *testing.T) { dexTeamListResonses := `{ "teams": [ { "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", + "created_at": "2023-10-13T14:42:58+05:30", + "updated_at": "2023-10-13T14:42:58+05:30", "owner_id": 433, "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", @@ -59,75 +40,83 @@ func TestHandler_teamList(t *testing.T) { "short_code": "T394" } ]}` - doer := mocks.NewDoer(t) - doer.EXPECT().Do(mock.Anything).Return(&http.Response{ - StatusCode: http.StatusOK, - Body: io.NopCloser(bytes.NewBufferString(wardenResponse)), + wardenClient := mocks.NewWardenClient(t) + frozenTime := time.Unix(1697188378, 0) + wardenClient.EXPECT().ListUserTeams(mock.Anything, warden.TeamListRequest{ + Email: "test@domain.com", + }).Return([]warden.Team{ + { + Name: "data_fabric", + CreatedAt: frozenTime, + UpdatedAt: frozenTime, + OwnerID: 433, + ParentTeamIdentifier: "2079834a-05c4-420d-bfc8-44b934adea9f", + Identifier: "b5aea046-dab3-4dac-b1ea-e1eef423226b", + ProductGroupName: "data_engineering", + ProductGroupID: "2079834a-05c4-420d-bfc8-44b934adea9f", + Labels: nil, + ShortCode: "T394", + }, }, nil) resp := httptest.NewRecorder() req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) require.NoError(t, err) - req.Header.Add("X-Auth-Email", "test@email.com") + req.Header.Add("X-Auth-Email", "test@domain.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - iam.Routes(nil, nil)(router) + iam.Routes(nil, wardenClient)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) assert.JSONEq(t, dexTeamListResonses, resp.Body.String()) }) - t.Run("should return 401 when user email is not present in warden", func(t *testing.T) { - wardenResponse := `{ - "success": false, - "errors": [], - "data": { - "teams": [ - { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - } - ]}, - "status": "ok" - }` - shieldClient := shareMocks.NewShieldServiceClient(t) - doer := mocks.NewDoer(t) - doer.EXPECT().Do(mock.Anything).Return(&http.Response{ - StatusCode: http.StatusOK, - Body: io.NopCloser(bytes.NewBufferString(wardenResponse)), - }, nil) + t.Run("emailNotFound", func(t *testing.T) { + wardenClient := mocks.NewWardenClient(t) + wardenClient.EXPECT().ListUserTeams(mock.Anything, warden.TeamListRequest{ + Email: "test@domain.com", + }).Return(nil, errors.ErrNotFound) resp := httptest.NewRecorder() req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) require.NoError(t, err) - req.Header.Add("X-Auth-Email", "test@email.com") + req.Header.Add("X-Auth-Email", "test@domain.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - iam.Routes(shieldClient, nil)(router) + iam.Routes(nil, wardenClient)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusNotFound, resp.Code) + assert.JSONEq(t, `{"code":"not_found", "message":"Requested entity not found", "op":"", "status":404}`, resp.Body.String()) }) - t.Run("should return Unauthorized when X-Auth-Email is not present is header", func(t *testing.T) { - shieldClient := shareMocks.NewShieldServiceClient(t) - // doer := mocks.NewDoer(t) + t.Run("wardenClientFailure", func(t *testing.T) { + wardenClient := mocks.NewWardenClient(t) + wardenClient.EXPECT().ListUserTeams(mock.Anything, warden.TeamListRequest{ + Email: "test@domain.com", + }).Return(nil, errors.ErrInternal) resp := httptest.NewRecorder() req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) require.NoError(t, err) + req.Header.Add("X-Auth-Email", "test@domain.com") router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - iam.Routes(shieldClient, nil)(router) + iam.Routes(nil, wardenClient)(router) + router.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusInternalServerError, resp.Code) + assert.JSONEq(t, `{"code":"internal_error", "message":"Some unexpected error occurred", "op":"", "status":500}`, resp.Body.String()) + }) + + t.Run("missingEmail", func(t *testing.T) { + resp := httptest.NewRecorder() + req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) + require.NoError(t, err) + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + iam.Routes(nil, nil)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusUnauthorized, resp.Code) @@ -135,30 +124,12 @@ func TestHandler_teamList(t *testing.T) { } func TestHandler_updateGroup(t *testing.T) { - t.Run("should return 200 OK", func(t *testing.T) { - // mocked response from warden returning a team for a wardenUUID - wardenResponse := `{ - "success": true, - "data": { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - }, - "errors": [] - }` - + t.Run("success", func(t *testing.T) { dexGroupMetadataResponse := `{ - "privacy": "public", - "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b" - }` + "privacy": "public", + "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b" + }` groupID := "e38527ee-a8cd-40f9-98a7-1f0bbd20909f" metaData, _ := structpb.NewStruct(map[string]any{ "privacy": "public", @@ -170,6 +141,23 @@ func TestHandler_updateGroup(t *testing.T) { "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", }) + wardenClient := mocks.NewWardenClient(t) + frozenTime := time.Unix(1697188378, 0) + wardenClient.EXPECT().TeamByUUID(mock.Anything, warden.TeamByUUIDRequest{ + TeamUUID: "123", + }).Return(&warden.Team{ + Name: "data_fabric", + CreatedAt: frozenTime, + UpdatedAt: frozenTime, + OwnerID: 433, + ParentTeamIdentifier: "2079834a-05c4-420d-bfc8-44b934adea9f", + Identifier: "b5aea046-dab3-4dac-b1ea-e1eef423226b", + ProductGroupName: "data_engineering", + ProductGroupID: "2079834a-05c4-420d-bfc8-44b934adea9f", + Labels: nil, + ShortCode: "T394", + }, nil) + shieldClient := shareMocks.NewShieldServiceClient(t) shieldClient.EXPECT().GetGroup(mock.Anything, &shieldv1beta1.GetGroupRequest{ Id: groupID, @@ -187,72 +175,151 @@ func TestHandler_updateGroup(t *testing.T) { Id: groupID, Name: "test", Slug: "testSlug", OrgId: "123", Metadata: updatedMetaData, }}, nil) - doer := mocks.NewDoer(t) - doer.EXPECT().Do(mock.Anything).Return(&http.Response{ - StatusCode: http.StatusOK, - Body: io.NopCloser(bytes.NewBufferString(wardenResponse)), - }, nil) - resp := httptest.NewRecorder() req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - iam.Routes(shieldClient, nil)(router) + iam.Routes(shieldClient, wardenClient)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusOK, resp.Code) assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) }) - t.Run("should return 500 when warden_team_id is invalid", func(t *testing.T) { - wardenResponse := `{ - "success": false, - "data": { - "name": "data_fabric", - "created_at": "2023-08-25T03:52:13.548Z", - "updated_at": "2023-08-25T03:52:13.548Z", - "owner_id": 433, - "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", - "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product_group_name": "data_engineering", - "product_group_id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "labels": null, - "short_code": "T394" - }, - "errors": [] - }` + t.Run("missingWardenTeamID", func(t *testing.T) { + // response return by handler + dexGroupMetadataResponse := `{"code":"", "message":"missing warden_team_id", "op":"", "status":400}` + + resp := httptest.NewRecorder() + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{}`)) + require.NoError(t, err) + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + iam.Routes(nil, nil)(router) + router.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusBadRequest, resp.Code) + assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) + }) + + t.Run("wardenIdNotFound", func(t *testing.T) { + // response returned by warden client + dexGroupMetadataResponse := `{"code":"not_found", "message":"Requested entity not found", "op":"", "status":404}` + + wardenClient := mocks.NewWardenClient(t) + wardenClient.EXPECT().TeamByUUID(mock.Anything, warden.TeamByUUIDRequest{ + TeamUUID: "123", + }).Return(nil, errors.ErrNotFound) + shieldClient := shareMocks.NewShieldServiceClient(t) - doer := mocks.NewDoer(t) - doer.EXPECT().Do(mock.Anything).Return(&http.Response{ - StatusCode: http.StatusOK, - Body: io.NopCloser(bytes.NewBufferString(wardenResponse)), + resp := httptest.NewRecorder() + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + require.NoError(t, err) + router := chi.NewRouter() + router.Use(reqctx.WithRequestCtx()) + iam.Routes(shieldClient, wardenClient)(router) + router.ServeHTTP(resp, req) + + assert.Equal(t, http.StatusNotFound, resp.Code) + assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) + }) + + t.Run("ShieldGetGroupFailure", func(t *testing.T) { + // response returned by shield client + dexGroupMetadataResponse := `{"code":"internal_error", "message":"Some unexpected error occurred", "op":"", "status":500}` + groupID := "e38527ee-a8cd-40f9-98a7-1f0bbd20909f" + + wardenClient := mocks.NewWardenClient(t) + frozenTime := time.Unix(1697188378, 0) + wardenClient.EXPECT().TeamByUUID(mock.Anything, warden.TeamByUUIDRequest{ + TeamUUID: "123", + }).Return(&warden.Team{ + Name: "data_fabric", + CreatedAt: frozenTime, + UpdatedAt: frozenTime, + OwnerID: 433, + ParentTeamIdentifier: "2079834a-05c4-420d-bfc8-44b934adea9f", + Identifier: "b5aea046-dab3-4dac-b1ea-e1eef423226b", + ProductGroupName: "data_engineering", + ProductGroupID: "2079834a-05c4-420d-bfc8-44b934adea9f", + Labels: nil, + ShortCode: "T394", }, nil) + shieldClient := shareMocks.NewShieldServiceClient(t) + shieldClient.EXPECT().GetGroup(mock.Anything, &shieldv1beta1.GetGroupRequest{ + Id: groupID, + }).Return(nil, errors.ErrInternal) + resp := httptest.NewRecorder() req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - iam.Routes(shieldClient, nil)(router) + iam.Routes(shieldClient, wardenClient)(router) router.ServeHTTP(resp, req) assert.Equal(t, http.StatusInternalServerError, resp.Code) + assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) }) - t.Run("should return error when warden_team_id is empty string", func(t *testing.T) { + t.Run("ShielUpdateGroupFailure", func(t *testing.T) { + // response returned by shield client + dexGroupMetadataResponse := `{"code":"internal_error", "message":"Some unexpected error occurred", "op":"", "status":500}` + groupID := "e38527ee-a8cd-40f9-98a7-1f0bbd20909f" + metaData, _ := structpb.NewStruct(map[string]any{ + "privacy": "public", + }) + + updatedMetaData, _ := structpb.NewStruct(map[string]any{ + "privacy": "public", + "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + }) + + wardenClient := mocks.NewWardenClient(t) + frozenTime := time.Unix(1697188378, 0) + wardenClient.EXPECT().TeamByUUID(mock.Anything, warden.TeamByUUIDRequest{ + TeamUUID: "123", + }).Return(&warden.Team{ + Name: "data_fabric", + CreatedAt: frozenTime, + UpdatedAt: frozenTime, + OwnerID: 433, + ParentTeamIdentifier: "2079834a-05c4-420d-bfc8-44b934adea9f", + Identifier: "b5aea046-dab3-4dac-b1ea-e1eef423226b", + ProductGroupName: "data_engineering", + ProductGroupID: "2079834a-05c4-420d-bfc8-44b934adea9f", + Labels: nil, + ShortCode: "T394", + }, nil) + shieldClient := shareMocks.NewShieldServiceClient(t) - // doer := mocks.NewDoer(t) + shieldClient.EXPECT().GetGroup(mock.Anything, &shieldv1beta1.GetGroupRequest{ + Id: groupID, + }).Return(&shieldv1beta1.GetGroupResponse{ + Group: &shieldv1beta1.Group{ + Id: groupID, Name: "test", Slug: "testSlug", OrgId: "123", Metadata: metaData, + }, + }, nil) + + shieldClient.EXPECT().UpdateGroup(mock.Anything, &shieldv1beta1.UpdateGroupRequest{ + Id: groupID, Body: &shieldv1beta1.GroupRequestBody{ + Metadata: updatedMetaData, Name: "test", Slug: "testSlug", OrgId: "123", + }, + }).Return(nil, errors.ErrInternal) resp := httptest.NewRecorder() - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": ""}`)) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) - iam.Routes(shieldClient, nil)(router) + iam.Routes(shieldClient, wardenClient)(router) router.ServeHTTP(resp, req) - assert.Equal(t, http.StatusBadRequest, resp.Code) + assert.Equal(t, http.StatusInternalServerError, resp.Code) + assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) }) } diff --git a/internal/server/v1/iam/mocks/warden_client.go b/internal/server/v1/iam/mocks/warden_client.go new file mode 100644 index 0000000..4434286 --- /dev/null +++ b/internal/server/v1/iam/mocks/warden_client.go @@ -0,0 +1,148 @@ +// Code generated by mockery v2.30.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + + warden "github.com/goto/dex/warden" +) + +// WardenClient is an autogenerated mock type for the WardenClient type +type WardenClient struct { + mock.Mock +} + +type WardenClient_Expecter struct { + mock *mock.Mock +} + +func (_m *WardenClient) EXPECT() *WardenClient_Expecter { + return &WardenClient_Expecter{mock: &_m.Mock} +} + +// ListUserTeams provides a mock function with given fields: ctx, req +func (_m *WardenClient) ListUserTeams(ctx context.Context, req warden.TeamListRequest) ([]warden.Team, error) { + ret := _m.Called(ctx, req) + + var r0 []warden.Team + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, warden.TeamListRequest) ([]warden.Team, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, warden.TeamListRequest) []warden.Team); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]warden.Team) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, warden.TeamListRequest) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// WardenClient_ListUserTeams_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListUserTeams' +type WardenClient_ListUserTeams_Call struct { + *mock.Call +} + +// ListUserTeams is a helper method to define mock.On call +// - ctx context.Context +// - req warden.TeamListRequest +func (_e *WardenClient_Expecter) ListUserTeams(ctx interface{}, req interface{}) *WardenClient_ListUserTeams_Call { + return &WardenClient_ListUserTeams_Call{Call: _e.mock.On("ListUserTeams", ctx, req)} +} + +func (_c *WardenClient_ListUserTeams_Call) Run(run func(ctx context.Context, req warden.TeamListRequest)) *WardenClient_ListUserTeams_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(warden.TeamListRequest)) + }) + return _c +} + +func (_c *WardenClient_ListUserTeams_Call) Return(_a0 []warden.Team, _a1 error) *WardenClient_ListUserTeams_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *WardenClient_ListUserTeams_Call) RunAndReturn(run func(context.Context, warden.TeamListRequest) ([]warden.Team, error)) *WardenClient_ListUserTeams_Call { + _c.Call.Return(run) + return _c +} + +// TeamByUUID provides a mock function with given fields: ctx, req +func (_m *WardenClient) TeamByUUID(ctx context.Context, req warden.TeamByUUIDRequest) (*warden.Team, error) { + ret := _m.Called(ctx, req) + + var r0 *warden.Team + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, warden.TeamByUUIDRequest) (*warden.Team, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, warden.TeamByUUIDRequest) *warden.Team); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*warden.Team) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, warden.TeamByUUIDRequest) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// WardenClient_TeamByUUID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TeamByUUID' +type WardenClient_TeamByUUID_Call struct { + *mock.Call +} + +// TeamByUUID is a helper method to define mock.On call +// - ctx context.Context +// - req warden.TeamByUUIDRequest +func (_e *WardenClient_Expecter) TeamByUUID(ctx interface{}, req interface{}) *WardenClient_TeamByUUID_Call { + return &WardenClient_TeamByUUID_Call{Call: _e.mock.On("TeamByUUID", ctx, req)} +} + +func (_c *WardenClient_TeamByUUID_Call) Run(run func(ctx context.Context, req warden.TeamByUUIDRequest)) *WardenClient_TeamByUUID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(warden.TeamByUUIDRequest)) + }) + return _c +} + +func (_c *WardenClient_TeamByUUID_Call) Return(_a0 *warden.Team, _a1 error) *WardenClient_TeamByUUID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *WardenClient_TeamByUUID_Call) RunAndReturn(run func(context.Context, warden.TeamByUUIDRequest) (*warden.Team, error)) *WardenClient_TeamByUUID_Call { + _c.Call.Return(run) + return _c +} + +// NewWardenClient creates a new instance of WardenClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewWardenClient(t interface { + mock.TestingT + Cleanup(func()) +}) *WardenClient { + mock := &WardenClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/server/v1/iam/routes.go b/internal/server/v1/iam/routes.go index 2b5d191..f22b97e 100644 --- a/internal/server/v1/iam/routes.go +++ b/internal/server/v1/iam/routes.go @@ -3,11 +3,9 @@ package iam import ( shieldv1beta1rpc "buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc" chiv5 "github.com/go-chi/chi/v5" - - "github.com/goto/dex/warden" ) -func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient *warden.Client) func(r chiv5.Router) { +func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient WardenClient) func(r chiv5.Router) { service := NewService(shieldClient, wardenClient) handler := NewHandler(service) return func(r chiv5.Router) { diff --git a/internal/server/v1/iam/service.go b/internal/server/v1/iam/service.go index e217da7..ce27c53 100644 --- a/internal/server/v1/iam/service.go +++ b/internal/server/v1/iam/service.go @@ -10,27 +10,45 @@ import ( "github.com/goto/dex/warden" ) -//go:generate mockery --with-expecter --keeptree --case snake --name Doer +//go:generate mockery --with-expecter --keeptree --case snake --name WardenClient type Service struct { shieldClient shieldv1beta1rpc.ShieldServiceClient - wardenClient *warden.Client + wardenClient WardenClient } -func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient *warden.Client) *Service { +type WardenClient interface { + ListUserTeams(ctx context.Context, req warden.TeamListRequest) ([]warden.Team, error) + TeamByUUID(ctx context.Context, req warden.TeamByUUIDRequest) (*warden.Team, error) +} + +func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient WardenClient) *Service { return &Service{ shieldClient: shieldClient, wardenClient: wardenClient, } } -func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { - wardenTeam, err := c.TeamByUUID(ctx, wardenTeamID) +func (svc *Service) TeamList(ctx context.Context, userEmail string) ([]warden.Team, error) { + teams, err := svc.wardenClient.ListUserTeams(ctx, warden.TeamListRequest{ + Email: userEmail, + }) + if err != nil { + return nil, err + } + + return teams, nil +} + +func (svc *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { + team, err := svc.wardenClient.TeamByUUID(ctx, warden.TeamByUUIDRequest{ + TeamUUID: wardenTeamID, + }) if err != nil { return nil, err } - getGroupRes, err := c.shieldClient.GetGroup(ctx, &shieldv1beta1.GetGroupRequest{ + getGroupRes, err := svc.shieldClient.GetGroup(ctx, &shieldv1beta1.GetGroupRequest{ Id: groupID, }) if err != nil { @@ -44,15 +62,15 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID metaData = make(map[string]any) } - metaData["team-id"] = wardenTeam.Data.Identifier - metaData["product-group-id"] = wardenTeam.Data.ProductGroupID + metaData["team-id"] = team.Identifier + metaData["product-group-id"] = team.ProductGroupID updatedMetaData, err := structpb.NewStruct(metaData) if err != nil { return nil, err } - UpdatedGroupRes, err := c.shieldClient.UpdateGroup(ctx, &shieldv1beta1.UpdateGroupRequest{ + UpdatedGroupRes, err := svc.shieldClient.UpdateGroup(ctx, &shieldv1beta1.UpdateGroupRequest{ Id: groupID, Body: &shieldv1beta1.GroupRequestBody{ Metadata: updatedMetaData, @@ -67,28 +85,3 @@ func (c *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID return UpdatedGroupRes.Group.Metadata.AsMap(), nil } - -func (svc *Service) TeamList(ctx context.Context, userEmail string) ([]warden.Team, error) { - teams, err := svc.wardenClient.ListUserTeams(ctx, warden.TeamListRequest{ - Email: userEmail, - }) - if err != nil { - return nil, err - } - - return teams, nil -} - -func (svc *Service) TeamByUUID(ctx context.Context, teamByUUID string) (*warden.TeamResponse, error) { - team, err := svc.wardenClient.WardenTeamByUUID(ctx, warden.TeamByUUIDRequest{ - TeamUUID: teamByUUID, - }) - if err != nil { - return nil, err - } - - return &warden.TeamResponse{ - Success: true, - Data: *team, - }, nil -} diff --git a/internal/server/v1/warden/mocks/doer.go b/internal/server/v1/warden/mocks/doer.go deleted file mode 100644 index ca5f969..0000000 --- a/internal/server/v1/warden/mocks/doer.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by mockery v2.30.1. DO NOT EDIT. - -package mocks - -import ( - http "net/http" - - mock "github.com/stretchr/testify/mock" -) - -// Doer is an autogenerated mock type for the Doer type -type Doer struct { - mock.Mock -} - -type Doer_Expecter struct { - mock *mock.Mock -} - -func (_m *Doer) EXPECT() *Doer_Expecter { - return &Doer_Expecter{mock: &_m.Mock} -} - -// Do provides a mock function with given fields: req -func (_m *Doer) Do(req *http.Request) (*http.Response, error) { - ret := _m.Called(req) - - var r0 *http.Response - var r1 error - if rf, ok := ret.Get(0).(func(*http.Request) (*http.Response, error)); ok { - return rf(req) - } - if rf, ok := ret.Get(0).(func(*http.Request) *http.Response); ok { - r0 = rf(req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*http.Response) - } - } - - if rf, ok := ret.Get(1).(func(*http.Request) error); ok { - r1 = rf(req) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Doer_Do_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Do' -type Doer_Do_Call struct { - *mock.Call -} - -// Do is a helper method to define mock.On call -// - req *http.Request -func (_e *Doer_Expecter) Do(req interface{}) *Doer_Do_Call { - return &Doer_Do_Call{Call: _e.mock.On("Do", req)} -} - -func (_c *Doer_Do_Call) Run(run func(req *http.Request)) *Doer_Do_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request)) - }) - return _c -} - -func (_c *Doer_Do_Call) Return(_a0 *http.Response, _a1 error) *Doer_Do_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *Doer_Do_Call) RunAndReturn(run func(*http.Request) (*http.Response, error)) *Doer_Do_Call { - _c.Call.Return(run) - return _c -} - -// NewDoer creates a new instance of Doer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewDoer(t interface { - mock.TestingT - Cleanup(func()) -}) *Doer { - mock := &Doer{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/warden/client.go b/warden/client.go index 5cd0b72..a13e028 100644 --- a/warden/client.go +++ b/warden/client.go @@ -5,6 +5,8 @@ import ( "encoding/json" "fmt" "net/http" + + "github.com/goto/dex/pkg/errors" ) type Client struct { @@ -39,10 +41,14 @@ func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("failed to fetch teams: %v", resp.Status) + if resp.StatusCode == http.StatusNotFound { + return nil, errors.ErrNotFound.WithMsgf("user with email %s not found", req.Email) + } + + return nil, errors.ErrInternal.WithMsgf("failed to fetch teams: %v", resp.Status) } - var data TeamListResponse + var data teamListResponse err = json.NewDecoder(resp.Body).Decode(&data) if err != nil { return nil, err @@ -51,7 +57,7 @@ func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team return data.Data.Teams, nil } -func (c *Client) WardenTeamByUUID(ctx context.Context, req TeamByUUIDRequest) (*Team, error) { +func (c *Client) TeamByUUID(ctx context.Context, req TeamByUUIDRequest) (*Team, error) { const ( endpoint = "/api/v2" teamPath = "/teams/" @@ -70,10 +76,14 @@ func (c *Client) WardenTeamByUUID(ctx context.Context, req TeamByUUIDRequest) (* defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("failed to fetch team: %v", resp.Status) + if resp.StatusCode == http.StatusNotFound { + return nil, errors.ErrNotFound.WithMsgf("team with uuid %s not found", req.TeamUUID) + } + + return nil, errors.ErrInternal.WithMsgf("failed to fetch teams: %v", resp.Status) } - var data TeamResponse + var data teamResponse err = json.NewDecoder(resp.Body).Decode(&data) if err != nil { return nil, err diff --git a/warden/warden.go b/warden/warden.go index fb484a2..4923e92 100644 --- a/warden/warden.go +++ b/warden/warden.go @@ -17,17 +17,17 @@ type Team struct { ShortCode string `json:"short_code"` } -type TeamResponse struct { +type teamResponse struct { Success bool `json:"success"` Data Team `json:"data"` } -type TeamListResponse struct { +type teamListResponse struct { Success bool `json:"success"` - Data TeamsData `json:"data"` + Data teamsData `json:"data"` } -type TeamsData struct { +type teamsData struct { Teams []Team `json:"teams"` } From cb35f9710acd25749dc98fb5880b8d749a1030dc Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 16 Oct 2023 10:31:32 +0530 Subject: [PATCH 19/27] feat(warden): updated test names --- internal/server/v1/iam/handler_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/server/v1/iam/handler_test.go b/internal/server/v1/iam/handler_test.go index 3002ae6..1aa4aca 100644 --- a/internal/server/v1/iam/handler_test.go +++ b/internal/server/v1/iam/handler_test.go @@ -24,7 +24,7 @@ import ( ) func TestHandler_teamList(t *testing.T) { - t.Run("success", func(t *testing.T) { + t.Run("Success", func(t *testing.T) { dexTeamListResonses := `{ "teams": [ { @@ -72,7 +72,7 @@ func TestHandler_teamList(t *testing.T) { assert.JSONEq(t, dexTeamListResonses, resp.Body.String()) }) - t.Run("emailNotFound", func(t *testing.T) { + t.Run("EmailNotFound", func(t *testing.T) { wardenClient := mocks.NewWardenClient(t) wardenClient.EXPECT().ListUserTeams(mock.Anything, warden.TeamListRequest{ Email: "test@domain.com", @@ -91,7 +91,7 @@ func TestHandler_teamList(t *testing.T) { assert.JSONEq(t, `{"code":"not_found", "message":"Requested entity not found", "op":"", "status":404}`, resp.Body.String()) }) - t.Run("wardenClientFailure", func(t *testing.T) { + t.Run("WardenClientFailure", func(t *testing.T) { wardenClient := mocks.NewWardenClient(t) wardenClient.EXPECT().ListUserTeams(mock.Anything, warden.TeamListRequest{ Email: "test@domain.com", @@ -110,7 +110,7 @@ func TestHandler_teamList(t *testing.T) { assert.JSONEq(t, `{"code":"internal_error", "message":"Some unexpected error occurred", "op":"", "status":500}`, resp.Body.String()) }) - t.Run("missingEmail", func(t *testing.T) { + t.Run("MissingEmail", func(t *testing.T) { resp := httptest.NewRecorder() req, err := http.NewRequestWithContext(context.TODO(), http.MethodGet, "/users/me/warden_teams", nil) require.NoError(t, err) @@ -124,7 +124,7 @@ func TestHandler_teamList(t *testing.T) { } func TestHandler_updateGroup(t *testing.T) { - t.Run("success", func(t *testing.T) { + t.Run("Success", func(t *testing.T) { dexGroupMetadataResponse := `{ "privacy": "public", "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", @@ -187,7 +187,7 @@ func TestHandler_updateGroup(t *testing.T) { assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) }) - t.Run("missingWardenTeamID", func(t *testing.T) { + t.Run("MissingWardenTeamID", func(t *testing.T) { // response return by handler dexGroupMetadataResponse := `{"code":"", "message":"missing warden_team_id", "op":"", "status":400}` @@ -203,7 +203,7 @@ func TestHandler_updateGroup(t *testing.T) { assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) }) - t.Run("wardenIdNotFound", func(t *testing.T) { + t.Run("WardenIdNotFound", func(t *testing.T) { // response returned by warden client dexGroupMetadataResponse := `{"code":"not_found", "message":"Requested entity not found", "op":"", "status":404}` From 97f59b2064c9dca3159288f2f6fe7c9ef50d11c5 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 16 Oct 2023 14:45:33 +0530 Subject: [PATCH 20/27] feat(warden): updated unit test timezone --- internal/server/v1/iam/handler_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/server/v1/iam/handler_test.go b/internal/server/v1/iam/handler_test.go index 1aa4aca..a362213 100644 --- a/internal/server/v1/iam/handler_test.go +++ b/internal/server/v1/iam/handler_test.go @@ -23,14 +23,14 @@ import ( "github.com/goto/dex/warden" ) -func TestHandler_teamList(t *testing.T) { +func TestHandlerTeamList(t *testing.T) { t.Run("Success", func(t *testing.T) { dexTeamListResonses := `{ "teams": [ { "name": "data_fabric", - "created_at": "2023-10-13T14:42:58+05:30", - "updated_at": "2023-10-13T14:42:58+05:30", + "created_at": "2023-10-13T09:12:58Z", + "updated_at": "2023-10-13T09:12:58Z", "owner_id": 433, "parent_team_identifier": "2079834a-05c4-420d-bfc8-44b934adea9f", "identifier": "b5aea046-dab3-4dac-b1ea-e1eef423226b", @@ -41,7 +41,7 @@ func TestHandler_teamList(t *testing.T) { } ]}` wardenClient := mocks.NewWardenClient(t) - frozenTime := time.Unix(1697188378, 0) + frozenTime := time.Unix(1697188378, 0).UTC() wardenClient.EXPECT().ListUserTeams(mock.Anything, warden.TeamListRequest{ Email: "test@domain.com", }).Return([]warden.Team{ @@ -123,7 +123,7 @@ func TestHandler_teamList(t *testing.T) { }) } -func TestHandler_updateGroup(t *testing.T) { +func TestHandlerUpdateGroup(t *testing.T) { t.Run("Success", func(t *testing.T) { dexGroupMetadataResponse := `{ "privacy": "public", @@ -142,7 +142,7 @@ func TestHandler_updateGroup(t *testing.T) { }) wardenClient := mocks.NewWardenClient(t) - frozenTime := time.Unix(1697188378, 0) + frozenTime := time.Unix(1697188378, 0).UTC() wardenClient.EXPECT().TeamByUUID(mock.Anything, warden.TeamByUUIDRequest{ TeamUUID: "123", }).Return(&warden.Team{ @@ -232,7 +232,7 @@ func TestHandler_updateGroup(t *testing.T) { groupID := "e38527ee-a8cd-40f9-98a7-1f0bbd20909f" wardenClient := mocks.NewWardenClient(t) - frozenTime := time.Unix(1697188378, 0) + frozenTime := time.Unix(1697188378, 0).UTC() wardenClient.EXPECT().TeamByUUID(mock.Anything, warden.TeamByUUIDRequest{ TeamUUID: "123", }).Return(&warden.Team{ @@ -280,7 +280,7 @@ func TestHandler_updateGroup(t *testing.T) { }) wardenClient := mocks.NewWardenClient(t) - frozenTime := time.Unix(1697188378, 0) + frozenTime := time.Unix(1697188378, 0).UTC() wardenClient.EXPECT().TeamByUUID(mock.Anything, warden.TeamByUUIDRequest{ TeamUUID: "123", }).Return(&warden.Team{ From e885442d7c141562a382528a74d468ae8cd9180e Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 16 Oct 2023 17:10:57 +0530 Subject: [PATCH 21/27] feat(warden): added team-name & product-group-name --- internal/server/v1/iam/handler_test.go | 22 ++++++++++++++-------- internal/server/v1/iam/service.go | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/internal/server/v1/iam/handler_test.go b/internal/server/v1/iam/handler_test.go index a362213..e172a70 100644 --- a/internal/server/v1/iam/handler_test.go +++ b/internal/server/v1/iam/handler_test.go @@ -128,7 +128,9 @@ func TestHandlerUpdateGroup(t *testing.T) { dexGroupMetadataResponse := `{ "privacy": "public", "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", - "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b" + "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "team-name": "data_fabric", + "product-group-name": "data_engineering" }` groupID := "e38527ee-a8cd-40f9-98a7-1f0bbd20909f" metaData, _ := structpb.NewStruct(map[string]any{ @@ -136,9 +138,11 @@ func TestHandlerUpdateGroup(t *testing.T) { }) updatedMetaData, _ := structpb.NewStruct(map[string]any{ - "privacy": "public", - "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "privacy": "public", + "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "team-name": "data_fabric", + "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "product-group-name": "data_engineering", }) wardenClient := mocks.NewWardenClient(t) @@ -265,7 +269,7 @@ func TestHandlerUpdateGroup(t *testing.T) { assert.JSONEq(t, dexGroupMetadataResponse, resp.Body.String()) }) - t.Run("ShielUpdateGroupFailure", func(t *testing.T) { + t.Run("ShieldUpdateGroupFailure", func(t *testing.T) { // response returned by shield client dexGroupMetadataResponse := `{"code":"internal_error", "message":"Some unexpected error occurred", "op":"", "status":500}` groupID := "e38527ee-a8cd-40f9-98a7-1f0bbd20909f" @@ -274,9 +278,11 @@ func TestHandlerUpdateGroup(t *testing.T) { }) updatedMetaData, _ := structpb.NewStruct(map[string]any{ - "privacy": "public", - "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b", - "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "privacy": "public", + "team-id": "b5aea046-dab3-4dac-b1ea-e1eef423226b", + "team-name": "data_fabric", + "product-group-id": "2079834a-05c4-420d-bfc8-44b934adea9f", + "product-group-name": "data_engineering", }) wardenClient := mocks.NewWardenClient(t) diff --git a/internal/server/v1/iam/service.go b/internal/server/v1/iam/service.go index ce27c53..278cae7 100644 --- a/internal/server/v1/iam/service.go +++ b/internal/server/v1/iam/service.go @@ -63,7 +63,9 @@ func (svc *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeam } metaData["team-id"] = team.Identifier + metaData["team-name"] = team.Name metaData["product-group-id"] = team.ProductGroupID + metaData["product-group-name"] = team.ProductGroupName updatedMetaData, err := structpb.NewStruct(metaData) if err != nil { From d2968d8cfbe8824fcc91a61ce23edd64c84b8bd3 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Tue, 17 Oct 2023 10:52:47 +0530 Subject: [PATCH 22/27] feat(warden): route updated --- internal/server/v1/iam/handler_test.go | 10 +++++----- internal/server/v1/iam/routes.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/server/v1/iam/handler_test.go b/internal/server/v1/iam/handler_test.go index e172a70..a2741c3 100644 --- a/internal/server/v1/iam/handler_test.go +++ b/internal/server/v1/iam/handler_test.go @@ -180,7 +180,7 @@ func TestHandlerUpdateGroup(t *testing.T) { }}, nil) resp := httptest.NewRecorder() - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPut, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata/warden", bytes.NewBufferString(`{"warden_team_id": "123"}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) @@ -196,7 +196,7 @@ func TestHandlerUpdateGroup(t *testing.T) { dexGroupMetadataResponse := `{"code":"", "message":"missing warden_team_id", "op":"", "status":400}` resp := httptest.NewRecorder() - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{}`)) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPut, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata/warden", bytes.NewBufferString(`{}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) @@ -219,7 +219,7 @@ func TestHandlerUpdateGroup(t *testing.T) { shieldClient := shareMocks.NewShieldServiceClient(t) resp := httptest.NewRecorder() - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPut, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata/warden", bytes.NewBufferString(`{"warden_team_id": "123"}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) @@ -258,7 +258,7 @@ func TestHandlerUpdateGroup(t *testing.T) { }).Return(nil, errors.ErrInternal) resp := httptest.NewRecorder() - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPut, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata/warden", bytes.NewBufferString(`{"warden_team_id": "123"}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) @@ -318,7 +318,7 @@ func TestHandlerUpdateGroup(t *testing.T) { }).Return(nil, errors.ErrInternal) resp := httptest.NewRecorder() - req, err := http.NewRequestWithContext(context.TODO(), http.MethodPatch, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata", bytes.NewBufferString(`{"warden_team_id": "123"}`)) + req, err := http.NewRequestWithContext(context.TODO(), http.MethodPut, "/groups/e38527ee-a8cd-40f9-98a7-1f0bbd20909f/metadata/warden", bytes.NewBufferString(`{"warden_team_id": "123"}`)) require.NoError(t, err) router := chi.NewRouter() router.Use(reqctx.WithRequestCtx()) diff --git a/internal/server/v1/iam/routes.go b/internal/server/v1/iam/routes.go index f22b97e..c30b616 100644 --- a/internal/server/v1/iam/routes.go +++ b/internal/server/v1/iam/routes.go @@ -11,6 +11,6 @@ func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient Ward return func(r chiv5.Router) { r.Get("/users/me/warden_teams", handler.teamList) - r.Patch("/groups/{group_id}/metadata", handler.updateGroupMetadata) + r.Put("/groups/{group_id}/metadata/warden", handler.updateGroupMetadata) } } From c284a9edf0902f4c21ef312beed01bdf5978ba39 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Fri, 20 Oct 2023 14:22:02 +0530 Subject: [PATCH 23/27] feat(warden): updated errors --- internal/server/v1/iam/handler.go | 8 ++++---- internal/server/v1/iam/routes.go | 4 ++-- internal/server/v1/iam/service.go | 15 ++++++++------- warden/client.go | 18 +++--------------- warden/error.go | 8 ++++++++ warden/warden.go | 16 ++++++++-------- 6 files changed, 33 insertions(+), 36 deletions(-) create mode 100644 warden/error.go diff --git a/internal/server/v1/iam/handler.go b/internal/server/v1/iam/handler.go index 81af7ee..d92e165 100644 --- a/internal/server/v1/iam/handler.go +++ b/internal/server/v1/iam/handler.go @@ -17,7 +17,7 @@ func NewHandler(service *Service) *handler { return &handler{service: service} } -func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { +func (h *handler) listUserWardenTeams(w http.ResponseWriter, r *http.Request) { reqCtx := reqctx.From(r.Context()) const errEmailMissedInHeader = "user email not in header" @@ -26,7 +26,7 @@ func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { return } - teamListResp, err := h.service.TeamList(r.Context(), reqCtx.UserEmail) + teamListResp, err := h.service.UserWardenTeamList(r.Context(), reqCtx.UserEmail) if err != nil { utils.WriteErr(w, err) return @@ -37,7 +37,7 @@ func (h *handler) teamList(w http.ResponseWriter, r *http.Request) { }) } -func (h *handler) updateGroupMetadata(w http.ResponseWriter, r *http.Request) { +func (h *handler) linkGroupToWarden(w http.ResponseWriter, r *http.Request) { groupID := chi.URLParam(r, "group_id") var body struct { @@ -51,7 +51,7 @@ func (h *handler) updateGroupMetadata(w http.ResponseWriter, r *http.Request) { return } - resShield, err := h.service.UpdateGroupMetadata(r.Context(), groupID, body.WardenTeamID) + resShield, err := h.service.LinkGroupToWarden(r.Context(), groupID, body.WardenTeamID) if err != nil { utils.WriteErr(w, err) return diff --git a/internal/server/v1/iam/routes.go b/internal/server/v1/iam/routes.go index c30b616..38cf301 100644 --- a/internal/server/v1/iam/routes.go +++ b/internal/server/v1/iam/routes.go @@ -9,8 +9,8 @@ func Routes(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient Ward service := NewService(shieldClient, wardenClient) handler := NewHandler(service) return func(r chiv5.Router) { - r.Get("/users/me/warden_teams", handler.teamList) + r.Get("/users/me/warden_teams", handler.listUserWardenTeams) - r.Put("/groups/{group_id}/metadata/warden", handler.updateGroupMetadata) + r.Put("/groups/{group_id}/metadata/warden", handler.linkGroupToWarden) } } diff --git a/internal/server/v1/iam/service.go b/internal/server/v1/iam/service.go index 278cae7..20d2075 100644 --- a/internal/server/v1/iam/service.go +++ b/internal/server/v1/iam/service.go @@ -2,6 +2,7 @@ package iam import ( "context" + "fmt" shieldv1beta1rpc "buf.build/gen/go/gotocompany/proton/grpc/go/gotocompany/shield/v1beta1/shieldv1beta1grpc" shieldv1beta1 "buf.build/gen/go/gotocompany/proton/protocolbuffers/go/gotocompany/shield/v1beta1" @@ -29,7 +30,7 @@ func NewService(shieldClient shieldv1beta1rpc.ShieldServiceClient, wardenClient } } -func (svc *Service) TeamList(ctx context.Context, userEmail string) ([]warden.Team, error) { +func (svc *Service) UserWardenTeamList(ctx context.Context, userEmail string) ([]warden.Team, error) { teams, err := svc.wardenClient.ListUserTeams(ctx, warden.TeamListRequest{ Email: userEmail, }) @@ -40,7 +41,7 @@ func (svc *Service) TeamList(ctx context.Context, userEmail string) ([]warden.Te return teams, nil } -func (svc *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { +func (svc *Service) LinkGroupToWarden(ctx context.Context, groupID, wardenTeamID string) (map[string]any, error) { team, err := svc.wardenClient.TeamByUUID(ctx, warden.TeamByUUIDRequest{ TeamUUID: wardenTeamID, }) @@ -52,7 +53,7 @@ func (svc *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeam Id: groupID, }) if err != nil { - return nil, err + return nil, fmt.Errorf("error getting shield group: %w", err) } group := getGroupRes.Group @@ -69,10 +70,10 @@ func (svc *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeam updatedMetaData, err := structpb.NewStruct(metaData) if err != nil { - return nil, err + return nil, fmt.Errorf("error creating metadata struct: %w", err) } - UpdatedGroupRes, err := svc.shieldClient.UpdateGroup(ctx, &shieldv1beta1.UpdateGroupRequest{ + updatedGroupRes, err := svc.shieldClient.UpdateGroup(ctx, &shieldv1beta1.UpdateGroupRequest{ Id: groupID, Body: &shieldv1beta1.GroupRequestBody{ Metadata: updatedMetaData, @@ -82,8 +83,8 @@ func (svc *Service) UpdateGroupMetadata(ctx context.Context, groupID, wardenTeam }, }) if err != nil { - return nil, err + return nil, fmt.Errorf("error updating group: %w", err) } - return UpdatedGroupRes.Group.Metadata.AsMap(), nil + return updatedGroupRes.Group.Metadata.AsMap(), nil } diff --git a/warden/client.go b/warden/client.go index a13e028..60e1e8a 100644 --- a/warden/client.go +++ b/warden/client.go @@ -22,13 +22,7 @@ func NewClient(baseURL string) *Client { } func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team, error) { - const ( - endpoint = "/api/v1" - userPath = "/users/" - teamsEndpoint = "/teams" - ) - url := fmt.Sprintf("%s%s%s%s%s", c.BaseURL, endpoint, userPath, req.Email, teamsEndpoint) - fmt.Println("URL: ", url) + url := fmt.Sprintf("%s/api/v1/users/%s/teams", c.BaseURL, req.Email) httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { return nil, err @@ -51,19 +45,13 @@ func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team var data teamListResponse err = json.NewDecoder(resp.Body).Decode(&data) if err != nil { - return nil, err + return nil, fmt.Errorf("error decoding warden teamListResponse: %w", err) } - return data.Data.Teams, nil } func (c *Client) TeamByUUID(ctx context.Context, req TeamByUUIDRequest) (*Team, error) { - const ( - endpoint = "/api/v2" - teamPath = "/teams/" - ) - - url := fmt.Sprintf("%s%s%s%s", c.BaseURL, endpoint, teamPath, req.TeamUUID) + url := fmt.Sprintf("%s/api/v2/teams/%s", c.BaseURL, req.TeamUUID) httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { return nil, err diff --git a/warden/error.go b/warden/error.go new file mode 100644 index 0000000..a3e68ea --- /dev/null +++ b/warden/error.go @@ -0,0 +1,8 @@ +package warden + +import "github.com/goto/dex/pkg/errors" + +var ( + ErrOptimusHostNotFound = errors.New("No Optimus jobs found in this project") + ErrOptimusHostInvalid = errors.New("Optimus host is not valid") +) diff --git a/warden/warden.go b/warden/warden.go index 4923e92..2661c42 100644 --- a/warden/warden.go +++ b/warden/warden.go @@ -17,6 +17,14 @@ type Team struct { ShortCode string `json:"short_code"` } +type TeamListRequest struct { + Email string +} + +type TeamByUUIDRequest struct { + TeamUUID string +} + type teamResponse struct { Success bool `json:"success"` Data Team `json:"data"` @@ -30,11 +38,3 @@ type teamListResponse struct { type teamsData struct { Teams []Team `json:"teams"` } - -type TeamListRequest struct { - Email string -} - -type TeamByUUIDRequest struct { - TeamUUID string -} From 4677041762e3be87cdd15c0ad0b956b80fe8981f Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 23 Oct 2023 13:09:47 +0530 Subject: [PATCH 24/27] feat(warden): error handled --- internal/server/v1/iam/service.go | 4 ++-- warden/client.go | 32 ++++++++++++++++++++----------- warden/error.go | 6 +++--- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/internal/server/v1/iam/service.go b/internal/server/v1/iam/service.go index 20d2075..3327329 100644 --- a/internal/server/v1/iam/service.go +++ b/internal/server/v1/iam/service.go @@ -35,7 +35,7 @@ func (svc *Service) UserWardenTeamList(ctx context.Context, userEmail string) ([ Email: userEmail, }) if err != nil { - return nil, err + return nil, fmt.Errorf("error listing user teams: %w", err) } return teams, nil @@ -46,7 +46,7 @@ func (svc *Service) LinkGroupToWarden(ctx context.Context, groupID, wardenTeamID TeamUUID: wardenTeamID, }) if err != nil { - return nil, err + return nil, fmt.Errorf("error getting warden team: %w", err) } getGroupRes, err := svc.shieldClient.GetGroup(ctx, &shieldv1beta1.GetGroupRequest{ diff --git a/warden/client.go b/warden/client.go index 60e1e8a..8dfd393 100644 --- a/warden/client.go +++ b/warden/client.go @@ -3,10 +3,10 @@ package warden import ( "context" "encoding/json" + "errors" "fmt" + "io" "net/http" - - "github.com/goto/dex/pkg/errors" ) type Client struct { @@ -25,21 +25,26 @@ func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team url := fmt.Sprintf("%s/api/v1/users/%s/teams", c.BaseURL, req.Email) httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { - return nil, err + return nil, fmt.Errorf("error creating request: %w", err) } resp, err := c.Client.Do(httpReq) if err != nil { - return nil, err + return nil, fmt.Errorf("error sending request: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { if resp.StatusCode == http.StatusNotFound { - return nil, errors.ErrNotFound.WithMsgf("user with email %s not found", req.Email) + return nil, ErrUserEmailNotFound } - return nil, errors.ErrInternal.WithMsgf("failed to fetch teams: %v", resp.Status) + bodyBytes, err := io.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + bodyString := string(bodyBytes) + return nil, errors.New(fmt.Errorf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString).Error()) } var data teamListResponse @@ -54,27 +59,32 @@ func (c *Client) TeamByUUID(ctx context.Context, req TeamByUUIDRequest) (*Team, url := fmt.Sprintf("%s/api/v2/teams/%s", c.BaseURL, req.TeamUUID) httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) if err != nil { - return nil, err + return nil, fmt.Errorf("error creating request: %w", err) } resp, err := c.Client.Do(httpReq) if err != nil { - return nil, err + return nil, fmt.Errorf("error sending request: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { if resp.StatusCode == http.StatusNotFound { - return nil, errors.ErrNotFound.WithMsgf("team with uuid %s not found", req.TeamUUID) + return nil, ErrTeamUUIDNotFound } - return nil, errors.ErrInternal.WithMsgf("failed to fetch teams: %v", resp.Status) + bodyBytes, err := io.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + bodyString := string(bodyBytes) + return nil, errors.New(fmt.Errorf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString).Error()) } var data teamResponse err = json.NewDecoder(resp.Body).Decode(&data) if err != nil { - return nil, err + return nil, fmt.Errorf("error decoding teamResponse: %w", err) } return &data.Data, nil diff --git a/warden/error.go b/warden/error.go index a3e68ea..fcd1dea 100644 --- a/warden/error.go +++ b/warden/error.go @@ -1,8 +1,8 @@ package warden -import "github.com/goto/dex/pkg/errors" +import "errors" var ( - ErrOptimusHostNotFound = errors.New("No Optimus jobs found in this project") - ErrOptimusHostInvalid = errors.New("Optimus host is not valid") + ErrUserEmailNotFound = errors.New("user email not found") + ErrTeamUUIDNotFound = errors.New("team with uuid not found") ) From 05abd064508530e1526ec6b99b593aa141855e68 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 23 Oct 2023 13:17:07 +0530 Subject: [PATCH 25/27] feat(warden): error handling --- warden/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/warden/client.go b/warden/client.go index 8dfd393..f971e93 100644 --- a/warden/client.go +++ b/warden/client.go @@ -44,7 +44,7 @@ func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team return nil, fmt.Errorf("error reading response body: %w", err) } bodyString := string(bodyBytes) - return nil, errors.New(fmt.Errorf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString).Error()) + return nil, errors.New(fmt.Sprintf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString)) } var data teamListResponse @@ -78,7 +78,7 @@ func (c *Client) TeamByUUID(ctx context.Context, req TeamByUUIDRequest) (*Team, return nil, fmt.Errorf("error reading response body: %w", err) } bodyString := string(bodyBytes) - return nil, errors.New(fmt.Errorf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString).Error()) + return nil, errors.New(fmt.Sprintf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString)) } var data teamResponse From 7860372df8965eee6a27d0bb0877d9e2ff08dace Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 23 Oct 2023 13:24:06 +0530 Subject: [PATCH 26/27] feat(warden): error updated. --- warden/client.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/warden/client.go b/warden/client.go index f971e93..d2bdbf1 100644 --- a/warden/client.go +++ b/warden/client.go @@ -3,7 +3,6 @@ package warden import ( "context" "encoding/json" - "errors" "fmt" "io" "net/http" @@ -44,7 +43,9 @@ func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team return nil, fmt.Errorf("error reading response body: %w", err) } bodyString := string(bodyBytes) - return nil, errors.New(fmt.Sprintf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString)) + // return nil, errors.New(fmt.Sprintf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString)) + return nil, fmt.Errorf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString) + } var data teamListResponse @@ -78,7 +79,8 @@ func (c *Client) TeamByUUID(ctx context.Context, req TeamByUUIDRequest) (*Team, return nil, fmt.Errorf("error reading response body: %w", err) } bodyString := string(bodyBytes) - return nil, errors.New(fmt.Sprintf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString)) + // return nil, errors.New(fmt.Sprintf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString)) + return nil, fmt.Errorf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString) } var data teamResponse From b1830bd7e6d84180762095789b06d89a75d12d59 Mon Sep 17 00:00:00 2001 From: Sudheer Pal Date: Mon, 23 Oct 2023 16:03:10 +0530 Subject: [PATCH 27/27] feat(warden): client error handling updated --- dex | 1 + warden/client.go | 7 ++----- warden/error.go | 1 + 3 files changed, 4 insertions(+), 5 deletions(-) create mode 160000 dex diff --git a/dex b/dex new file mode 160000 index 0000000..7860372 --- /dev/null +++ b/dex @@ -0,0 +1 @@ +Subproject commit 7860372df8965eee6a27d0bb0877d9e2ff08dace diff --git a/warden/client.go b/warden/client.go index d2bdbf1..7f844ee 100644 --- a/warden/client.go +++ b/warden/client.go @@ -43,9 +43,7 @@ func (c *Client) ListUserTeams(ctx context.Context, req TeamListRequest) ([]Team return nil, fmt.Errorf("error reading response body: %w", err) } bodyString := string(bodyBytes) - // return nil, errors.New(fmt.Sprintf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString)) - return nil, fmt.Errorf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString) - + return nil, fmt.Errorf("%w: %d: %s", ErrNon200, resp.StatusCode, bodyString) } var data teamListResponse @@ -79,8 +77,7 @@ func (c *Client) TeamByUUID(ctx context.Context, req TeamByUUIDRequest) (*Team, return nil, fmt.Errorf("error reading response body: %w", err) } bodyString := string(bodyBytes) - // return nil, errors.New(fmt.Sprintf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString)) - return nil, fmt.Errorf("got non-200 http status code=(%d) body=%s", resp.StatusCode, bodyString) + return nil, fmt.Errorf("%w: %d: %s", ErrNon200, resp.StatusCode, bodyString) } var data teamResponse diff --git a/warden/error.go b/warden/error.go index fcd1dea..6e71254 100644 --- a/warden/error.go +++ b/warden/error.go @@ -5,4 +5,5 @@ import "errors" var ( ErrUserEmailNotFound = errors.New("user email not found") ErrTeamUUIDNotFound = errors.New("team with uuid not found") + ErrNon200 = errors.New("got non-200 when hitting warden API") )