From 4876d47ade49e36b28e63ebca9f8c85bee57c7f6 Mon Sep 17 00:00:00 2001 From: Harold Wanyama Date: Tue, 18 Jun 2024 20:33:03 +0300 Subject: [PATCH] [#4357,#4348] Bug/LF Users - Handled exception case for users that dont exist - Updated response with ccla,icla,ccla_requires_icla fields Signed-off-by: Harold Wanyama --- cla-backend-go/company/mocks/mock_service.go | 346 ++++++++++++ cla-backend-go/company/service.go | 8 +- cla-backend-go/project/mocks/mock_service.go | 249 ++++++++ cla-backend-go/signatures/service.go | 4 +- cla-backend-go/swagger/cla.v2.yaml | 17 + .../v2/signatures/mock_users/mock_service.go | 247 ++++++++ .../mock_v1_signatures/mock_service.go | 534 ++++++++++++++++++ cla-backend-go/v2/signatures/service.go | 85 ++- cla-backend-go/v2/signatures/service_test.go | 201 +++++++ 9 files changed, 1673 insertions(+), 18 deletions(-) create mode 100644 cla-backend-go/company/mocks/mock_service.go create mode 100644 cla-backend-go/project/mocks/mock_service.go create mode 100644 cla-backend-go/v2/signatures/mock_users/mock_service.go create mode 100644 cla-backend-go/v2/signatures/mock_v1_signatures/mock_service.go create mode 100644 cla-backend-go/v2/signatures/service_test.go diff --git a/cla-backend-go/company/mocks/mock_service.go b/cla-backend-go/company/mocks/mock_service.go new file mode 100644 index 000000000..7e483727e --- /dev/null +++ b/cla-backend-go/company/mocks/mock_service.go @@ -0,0 +1,346 @@ +// Copyright The Linux Foundation and each contributor to CommunityBridge. +// SPDX-License-Identifier: MIT + +// Code generated by MockGen. DO NOT EDIT. +// Source: company/service.go + +// Package mock_company is a generated GoMock package. +package mock_company + +import ( + context "context" + reflect "reflect" + + company "github.com/communitybridge/easycla/cla-backend-go/company" + models "github.com/communitybridge/easycla/cla-backend-go/gen/v1/models" + gomock "github.com/golang/mock/gomock" +) + +// MockIService is a mock of IService interface. +type MockIService struct { + ctrl *gomock.Controller + recorder *MockIServiceMockRecorder +} + +// MockIServiceMockRecorder is the mock recorder for MockIService. +type MockIServiceMockRecorder struct { + mock *MockIService +} + +// NewMockIService creates a new mock instance. +func NewMockIService(ctrl *gomock.Controller) *MockIService { + mock := &MockIService{ctrl: ctrl} + mock.recorder = &MockIServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockIService) EXPECT() *MockIServiceMockRecorder { + return m.recorder +} + +// AddPendingCompanyInviteRequest mocks base method. +func (m *MockIService) AddPendingCompanyInviteRequest(ctx context.Context, companyID, userID string) (*company.InviteModel, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddPendingCompanyInviteRequest", ctx, companyID, userID) + ret0, _ := ret[0].(*company.InviteModel) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AddPendingCompanyInviteRequest indicates an expected call of AddPendingCompanyInviteRequest. +func (mr *MockIServiceMockRecorder) AddPendingCompanyInviteRequest(ctx, companyID, userID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddPendingCompanyInviteRequest", reflect.TypeOf((*MockIService)(nil).AddPendingCompanyInviteRequest), ctx, companyID, userID) +} + +// AddUserToCompanyAccessList mocks base method. +func (m *MockIService) AddUserToCompanyAccessList(ctx context.Context, companyID, lfid string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddUserToCompanyAccessList", ctx, companyID, lfid) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddUserToCompanyAccessList indicates an expected call of AddUserToCompanyAccessList. +func (mr *MockIServiceMockRecorder) AddUserToCompanyAccessList(ctx, companyID, lfid interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddUserToCompanyAccessList", reflect.TypeOf((*MockIService)(nil).AddUserToCompanyAccessList), ctx, companyID, lfid) +} + +// ApproveCompanyAccessRequest mocks base method. +func (m *MockIService) ApproveCompanyAccessRequest(ctx context.Context, companyInviteID string) (*company.InviteModel, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ApproveCompanyAccessRequest", ctx, companyInviteID) + ret0, _ := ret[0].(*company.InviteModel) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ApproveCompanyAccessRequest indicates an expected call of ApproveCompanyAccessRequest. +func (mr *MockIServiceMockRecorder) ApproveCompanyAccessRequest(ctx, companyInviteID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApproveCompanyAccessRequest", reflect.TypeOf((*MockIService)(nil).ApproveCompanyAccessRequest), ctx, companyInviteID) +} + +// CreateOrgFromExternalID mocks base method. +func (m *MockIService) CreateOrgFromExternalID(ctx context.Context, signingEntityName, companySFID string) (*models.Company, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateOrgFromExternalID", ctx, signingEntityName, companySFID) + ret0, _ := ret[0].(*models.Company) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateOrgFromExternalID indicates an expected call of CreateOrgFromExternalID. +func (mr *MockIServiceMockRecorder) CreateOrgFromExternalID(ctx, signingEntityName, companySFID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrgFromExternalID", reflect.TypeOf((*MockIService)(nil).CreateOrgFromExternalID), ctx, signingEntityName, companySFID) +} + +// GetCompanies mocks base method. +func (m *MockIService) GetCompanies(ctx context.Context) (*models.Companies, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompanies", ctx) + ret0, _ := ret[0].(*models.Companies) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompanies indicates an expected call of GetCompanies. +func (mr *MockIServiceMockRecorder) GetCompanies(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompanies", reflect.TypeOf((*MockIService)(nil).GetCompanies), ctx) +} + +// GetCompaniesByExternalID mocks base method. +func (m *MockIService) GetCompaniesByExternalID(ctx context.Context, companySFID string, includeChildCompanies bool) ([]*models.Company, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompaniesByExternalID", ctx, companySFID, includeChildCompanies) + ret0, _ := ret[0].([]*models.Company) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompaniesByExternalID indicates an expected call of GetCompaniesByExternalID. +func (mr *MockIServiceMockRecorder) GetCompaniesByExternalID(ctx, companySFID, includeChildCompanies interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompaniesByExternalID", reflect.TypeOf((*MockIService)(nil).GetCompaniesByExternalID), ctx, companySFID, includeChildCompanies) +} + +// GetCompaniesByUserManager mocks base method. +func (m *MockIService) GetCompaniesByUserManager(ctx context.Context, userID string) (*models.Companies, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompaniesByUserManager", ctx, userID) + ret0, _ := ret[0].(*models.Companies) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompaniesByUserManager indicates an expected call of GetCompaniesByUserManager. +func (mr *MockIServiceMockRecorder) GetCompaniesByUserManager(ctx, userID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompaniesByUserManager", reflect.TypeOf((*MockIService)(nil).GetCompaniesByUserManager), ctx, userID) +} + +// GetCompaniesByUserManagerWithInvites mocks base method. +func (m *MockIService) GetCompaniesByUserManagerWithInvites(ctx context.Context, userID string) (*models.CompaniesWithInvites, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompaniesByUserManagerWithInvites", ctx, userID) + ret0, _ := ret[0].(*models.CompaniesWithInvites) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompaniesByUserManagerWithInvites indicates an expected call of GetCompaniesByUserManagerWithInvites. +func (mr *MockIServiceMockRecorder) GetCompaniesByUserManagerWithInvites(ctx, userID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompaniesByUserManagerWithInvites", reflect.TypeOf((*MockIService)(nil).GetCompaniesByUserManagerWithInvites), ctx, userID) +} + +// GetCompany mocks base method. +func (m *MockIService) GetCompany(ctx context.Context, companyID string) (*models.Company, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompany", ctx, companyID) + ret0, _ := ret[0].(*models.Company) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompany indicates an expected call of GetCompany. +func (mr *MockIServiceMockRecorder) GetCompany(ctx, companyID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompany", reflect.TypeOf((*MockIService)(nil).GetCompany), ctx, companyID) +} + +// GetCompanyByExternalID mocks base method. +func (m *MockIService) GetCompanyByExternalID(ctx context.Context, companySFID string) (*models.Company, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompanyByExternalID", ctx, companySFID) + ret0, _ := ret[0].(*models.Company) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompanyByExternalID indicates an expected call of GetCompanyByExternalID. +func (mr *MockIServiceMockRecorder) GetCompanyByExternalID(ctx, companySFID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompanyByExternalID", reflect.TypeOf((*MockIService)(nil).GetCompanyByExternalID), ctx, companySFID) +} + +// GetCompanyBySigningEntityName mocks base method. +func (m *MockIService) GetCompanyBySigningEntityName(ctx context.Context, signingEntityName, companySFID string) (*models.Company, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompanyBySigningEntityName", ctx, signingEntityName, companySFID) + ret0, _ := ret[0].(*models.Company) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompanyBySigningEntityName indicates an expected call of GetCompanyBySigningEntityName. +func (mr *MockIServiceMockRecorder) GetCompanyBySigningEntityName(ctx, signingEntityName, companySFID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompanyBySigningEntityName", reflect.TypeOf((*MockIService)(nil).GetCompanyBySigningEntityName), ctx, signingEntityName, companySFID) +} + +// GetCompanyInviteRequests mocks base method. +func (m *MockIService) GetCompanyInviteRequests(ctx context.Context, companyID string, status *string) ([]models.CompanyInviteUser, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompanyInviteRequests", ctx, companyID, status) + ret0, _ := ret[0].([]models.CompanyInviteUser) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompanyInviteRequests indicates an expected call of GetCompanyInviteRequests. +func (mr *MockIServiceMockRecorder) GetCompanyInviteRequests(ctx, companyID, status interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompanyInviteRequests", reflect.TypeOf((*MockIService)(nil).GetCompanyInviteRequests), ctx, companyID, status) +} + +// GetCompanyUserInviteRequests mocks base method. +func (m *MockIService) GetCompanyUserInviteRequests(ctx context.Context, companyID, userID string) (*models.CompanyInviteUser, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompanyUserInviteRequests", ctx, companyID, userID) + ret0, _ := ret[0].(*models.CompanyInviteUser) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompanyUserInviteRequests indicates an expected call of GetCompanyUserInviteRequests. +func (mr *MockIServiceMockRecorder) GetCompanyUserInviteRequests(ctx, companyID, userID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompanyUserInviteRequests", reflect.TypeOf((*MockIService)(nil).GetCompanyUserInviteRequests), ctx, companyID, userID) +} + +// IsCCLAEnabledForCompany mocks base method. +func (m *MockIService) IsCCLAEnabledForCompany(ctx context.Context, companySFID string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsCCLAEnabledForCompany", ctx, companySFID) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsCCLAEnabledForCompany indicates an expected call of IsCCLAEnabledForCompany. +func (mr *MockIServiceMockRecorder) IsCCLAEnabledForCompany(ctx, companySFID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsCCLAEnabledForCompany", reflect.TypeOf((*MockIService)(nil).IsCCLAEnabledForCompany), ctx, companySFID) +} + +// RejectCompanyAccessRequest mocks base method. +func (m *MockIService) RejectCompanyAccessRequest(ctx context.Context, companyInviteID string) (*company.InviteModel, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RejectCompanyAccessRequest", ctx, companyInviteID) + ret0, _ := ret[0].(*company.InviteModel) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RejectCompanyAccessRequest indicates an expected call of RejectCompanyAccessRequest. +func (mr *MockIServiceMockRecorder) RejectCompanyAccessRequest(ctx, companyInviteID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RejectCompanyAccessRequest", reflect.TypeOf((*MockIService)(nil).RejectCompanyAccessRequest), ctx, companyInviteID) +} + +// SearchCompanyByName mocks base method. +func (m *MockIService) SearchCompanyByName(ctx context.Context, companyName, nextKey string) (*models.Companies, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SearchCompanyByName", ctx, companyName, nextKey) + ret0, _ := ret[0].(*models.Companies) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SearchCompanyByName indicates an expected call of SearchCompanyByName. +func (mr *MockIServiceMockRecorder) SearchCompanyByName(ctx, companyName, nextKey interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchCompanyByName", reflect.TypeOf((*MockIService)(nil).SearchCompanyByName), ctx, companyName, nextKey) +} + +// SearchOrganizationByName mocks base method. +func (m *MockIService) SearchOrganizationByName(ctx context.Context, orgName, websiteName string, includeSigningEntityName bool, filter string) (*models.OrgList, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SearchOrganizationByName", ctx, orgName, websiteName, includeSigningEntityName, filter) + ret0, _ := ret[0].(*models.OrgList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SearchOrganizationByName indicates an expected call of SearchOrganizationByName. +func (mr *MockIServiceMockRecorder) SearchOrganizationByName(ctx, orgName, websiteName, includeSigningEntityName, filter interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchOrganizationByName", reflect.TypeOf((*MockIService)(nil).SearchOrganizationByName), ctx, orgName, websiteName, includeSigningEntityName, filter) +} + +// getPreferredNameAndEmail mocks base method. +func (m *MockIService) getPreferredNameAndEmail(ctx context.Context, lfid string) (string, string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "getPreferredNameAndEmail", ctx, lfid) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// getPreferredNameAndEmail indicates an expected call of getPreferredNameAndEmail. +func (mr *MockIServiceMockRecorder) getPreferredNameAndEmail(ctx, lfid interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getPreferredNameAndEmail", reflect.TypeOf((*MockIService)(nil).getPreferredNameAndEmail), ctx, lfid) +} + +// sendRequestAccessEmail mocks base method. +func (m *MockIService) sendRequestAccessEmail(ctx context.Context, companyModel *models.Company, requesterName, requesterEmail, recipientName, recipientAddress string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "sendRequestAccessEmail", ctx, companyModel, requesterName, requesterEmail, recipientName, recipientAddress) +} + +// sendRequestAccessEmail indicates an expected call of sendRequestAccessEmail. +func (mr *MockIServiceMockRecorder) sendRequestAccessEmail(ctx, companyModel, requesterName, requesterEmail, recipientName, recipientAddress interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "sendRequestAccessEmail", reflect.TypeOf((*MockIService)(nil).sendRequestAccessEmail), ctx, companyModel, requesterName, requesterEmail, recipientName, recipientAddress) +} + +// sendRequestApprovedEmailToRecipient mocks base method. +func (m *MockIService) sendRequestApprovedEmailToRecipient(ctx context.Context, companyModel *models.Company, recipientName, recipientAddress string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "sendRequestApprovedEmailToRecipient", ctx, companyModel, recipientName, recipientAddress) +} + +// sendRequestApprovedEmailToRecipient indicates an expected call of sendRequestApprovedEmailToRecipient. +func (mr *MockIServiceMockRecorder) sendRequestApprovedEmailToRecipient(ctx, companyModel, recipientName, recipientAddress interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "sendRequestApprovedEmailToRecipient", reflect.TypeOf((*MockIService)(nil).sendRequestApprovedEmailToRecipient), ctx, companyModel, recipientName, recipientAddress) +} + +// sendRequestRejectedEmailToRecipient mocks base method. +func (m *MockIService) sendRequestRejectedEmailToRecipient(ctx context.Context, companyModel *models.Company, recipientName, recipientAddress string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "sendRequestRejectedEmailToRecipient", ctx, companyModel, recipientName, recipientAddress) +} + +// sendRequestRejectedEmailToRecipient indicates an expected call of sendRequestRejectedEmailToRecipient. +func (mr *MockIServiceMockRecorder) sendRequestRejectedEmailToRecipient(ctx, companyModel, recipientName, recipientAddress interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "sendRequestRejectedEmailToRecipient", reflect.TypeOf((*MockIService)(nil).sendRequestRejectedEmailToRecipient), ctx, companyModel, recipientName, recipientAddress) +} diff --git a/cla-backend-go/company/service.go b/cla-backend-go/company/service.go index a52e61410..87dfb59c6 100644 --- a/cla-backend-go/company/service.go +++ b/cla-backend-go/company/service.go @@ -62,10 +62,10 @@ type IService interface { // nolint // calls org service SearchOrganizationByName(ctx context.Context, orgName string, websiteName string, includeSigningEntityName bool, filter string) (*models.OrgList, error) - sendRequestAccessEmail(ctx context.Context, companyModel *models.Company, requesterName, requesterEmail, recipientName, recipientAddress string) - sendRequestApprovedEmailToRecipient(ctx context.Context, companyModel *models.Company, recipientName, recipientAddress string) - sendRequestRejectedEmailToRecipient(ctx context.Context, companyModel *models.Company, recipientName, recipientAddress string) - getPreferredNameAndEmail(ctx context.Context, lfid string) (string, string, error) + // sendRequestAccessEmail(ctx context.Context, companyModel *models.Company, requesterName, requesterEmail, recipientName, recipientAddress string) + // sendRequestApprovedEmailToRecipient(ctx context.Context, companyModel *models.Company, recipientName, recipientAddress string) + // sendRequestRejectedEmailToRecipient(ctx context.Context, companyModel *models.Company, recipientName, recipientAddress string) + // getPreferredNameAndEmail(ctx context.Context, lfid string) (string, string, error) } // NewService creates a new company service object diff --git a/cla-backend-go/project/mocks/mock_service.go b/cla-backend-go/project/mocks/mock_service.go new file mode 100644 index 000000000..ab02a40e1 --- /dev/null +++ b/cla-backend-go/project/mocks/mock_service.go @@ -0,0 +1,249 @@ +// Copyright The Linux Foundation and each contributor to CommunityBridge. +// SPDX-License-Identifier: MIT + +// Code generated by MockGen. DO NOT EDIT. +// Source: project/service/service.go + +// Package mock_service is a generated GoMock package. +package mock_service + +import ( + context "context" + reflect "reflect" + + models "github.com/communitybridge/easycla/cla-backend-go/gen/v1/models" + project "github.com/communitybridge/easycla/cla-backend-go/gen/v1/restapi/operations/project" + gomock "github.com/golang/mock/gomock" +) + +// MockService is a mock of Service interface. +type MockService struct { + ctrl *gomock.Controller + recorder *MockServiceMockRecorder +} + +// MockServiceMockRecorder is the mock recorder for MockService. +type MockServiceMockRecorder struct { + mock *MockService +} + +// NewMockService creates a new mock instance. +func NewMockService(ctrl *gomock.Controller) *MockService { + mock := &MockService{ctrl: ctrl} + mock.recorder = &MockServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockService) EXPECT() *MockServiceMockRecorder { + return m.recorder +} + +// CreateCLAGroup mocks base method. +func (m *MockService) CreateCLAGroup(ctx context.Context, project *models.ClaGroup) (*models.ClaGroup, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateCLAGroup", ctx, project) + ret0, _ := ret[0].(*models.ClaGroup) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateCLAGroup indicates an expected call of CreateCLAGroup. +func (mr *MockServiceMockRecorder) CreateCLAGroup(ctx, project interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateCLAGroup", reflect.TypeOf((*MockService)(nil).CreateCLAGroup), ctx, project) +} + +// DeleteCLAGroup mocks base method. +func (m *MockService) DeleteCLAGroup(ctx context.Context, claGroupID string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteCLAGroup", ctx, claGroupID) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteCLAGroup indicates an expected call of DeleteCLAGroup. +func (mr *MockServiceMockRecorder) DeleteCLAGroup(ctx, claGroupID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteCLAGroup", reflect.TypeOf((*MockService)(nil).DeleteCLAGroup), ctx, claGroupID) +} + +// GetCLAGroupByID mocks base method. +func (m *MockService) GetCLAGroupByID(ctx context.Context, claGroupID string) (*models.ClaGroup, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCLAGroupByID", ctx, claGroupID) + ret0, _ := ret[0].(*models.ClaGroup) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCLAGroupByID indicates an expected call of GetCLAGroupByID. +func (mr *MockServiceMockRecorder) GetCLAGroupByID(ctx, claGroupID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCLAGroupByID", reflect.TypeOf((*MockService)(nil).GetCLAGroupByID), ctx, claGroupID) +} + +// GetCLAGroupByName mocks base method. +func (m *MockService) GetCLAGroupByName(ctx context.Context, projectName string) (*models.ClaGroup, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCLAGroupByName", ctx, projectName) + ret0, _ := ret[0].(*models.ClaGroup) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCLAGroupByName indicates an expected call of GetCLAGroupByName. +func (mr *MockServiceMockRecorder) GetCLAGroupByName(ctx, projectName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCLAGroupByName", reflect.TypeOf((*MockService)(nil).GetCLAGroupByName), ctx, projectName) +} + +// GetCLAGroupCurrentCCLATemplateURLByID mocks base method. +func (m *MockService) GetCLAGroupCurrentCCLATemplateURLByID(ctx context.Context, claGroupID string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCLAGroupCurrentCCLATemplateURLByID", ctx, claGroupID) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCLAGroupCurrentCCLATemplateURLByID indicates an expected call of GetCLAGroupCurrentCCLATemplateURLByID. +func (mr *MockServiceMockRecorder) GetCLAGroupCurrentCCLATemplateURLByID(ctx, claGroupID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCLAGroupCurrentCCLATemplateURLByID", reflect.TypeOf((*MockService)(nil).GetCLAGroupCurrentCCLATemplateURLByID), ctx, claGroupID) +} + +// GetCLAGroupCurrentICLATemplateURLByID mocks base method. +func (m *MockService) GetCLAGroupCurrentICLATemplateURLByID(ctx context.Context, claGroupID string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCLAGroupCurrentICLATemplateURLByID", ctx, claGroupID) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCLAGroupCurrentICLATemplateURLByID indicates an expected call of GetCLAGroupCurrentICLATemplateURLByID. +func (mr *MockServiceMockRecorder) GetCLAGroupCurrentICLATemplateURLByID(ctx, claGroupID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCLAGroupCurrentICLATemplateURLByID", reflect.TypeOf((*MockService)(nil).GetCLAGroupCurrentICLATemplateURLByID), ctx, claGroupID) +} + +// GetCLAGroups mocks base method. +func (m *MockService) GetCLAGroups(ctx context.Context, params *project.GetProjectsParams) (*models.ClaGroups, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCLAGroups", ctx, params) + ret0, _ := ret[0].(*models.ClaGroups) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCLAGroups indicates an expected call of GetCLAGroups. +func (mr *MockServiceMockRecorder) GetCLAGroups(ctx, params interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCLAGroups", reflect.TypeOf((*MockService)(nil).GetCLAGroups), ctx, params) +} + +// GetCLAGroupsByExternalID mocks base method. +func (m *MockService) GetCLAGroupsByExternalID(ctx context.Context, params *project.GetProjectsByExternalIDParams) (*models.ClaGroups, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCLAGroupsByExternalID", ctx, params) + ret0, _ := ret[0].(*models.ClaGroups) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCLAGroupsByExternalID indicates an expected call of GetCLAGroupsByExternalID. +func (mr *MockServiceMockRecorder) GetCLAGroupsByExternalID(ctx, params interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCLAGroupsByExternalID", reflect.TypeOf((*MockService)(nil).GetCLAGroupsByExternalID), ctx, params) +} + +// GetCLAGroupsByExternalSFID mocks base method. +func (m *MockService) GetCLAGroupsByExternalSFID(ctx context.Context, projectSFID string) (*models.ClaGroups, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCLAGroupsByExternalSFID", ctx, projectSFID) + ret0, _ := ret[0].(*models.ClaGroups) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCLAGroupsByExternalSFID indicates an expected call of GetCLAGroupsByExternalSFID. +func (mr *MockServiceMockRecorder) GetCLAGroupsByExternalSFID(ctx, projectSFID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCLAGroupsByExternalSFID", reflect.TypeOf((*MockService)(nil).GetCLAGroupsByExternalSFID), ctx, projectSFID) +} + +// GetCLAManagers mocks base method. +func (m *MockService) GetCLAManagers(ctx context.Context, claGroupID string) ([]*models.ClaManagerUser, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCLAManagers", ctx, claGroupID) + ret0, _ := ret[0].([]*models.ClaManagerUser) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCLAManagers indicates an expected call of GetCLAManagers. +func (mr *MockServiceMockRecorder) GetCLAManagers(ctx, claGroupID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCLAManagers", reflect.TypeOf((*MockService)(nil).GetCLAManagers), ctx, claGroupID) +} + +// GetClaGroupByProjectSFID mocks base method. +func (m *MockService) GetClaGroupByProjectSFID(ctx context.Context, projectSFID string, loadRepoDetails bool) (*models.ClaGroup, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetClaGroupByProjectSFID", ctx, projectSFID, loadRepoDetails) + ret0, _ := ret[0].(*models.ClaGroup) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetClaGroupByProjectSFID indicates an expected call of GetClaGroupByProjectSFID. +func (mr *MockServiceMockRecorder) GetClaGroupByProjectSFID(ctx, projectSFID, loadRepoDetails interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetClaGroupByProjectSFID", reflect.TypeOf((*MockService)(nil).GetClaGroupByProjectSFID), ctx, projectSFID, loadRepoDetails) +} + +// GetClaGroupsByFoundationSFID mocks base method. +func (m *MockService) GetClaGroupsByFoundationSFID(ctx context.Context, foundationSFID string, loadRepoDetails bool) (*models.ClaGroups, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetClaGroupsByFoundationSFID", ctx, foundationSFID, loadRepoDetails) + ret0, _ := ret[0].(*models.ClaGroups) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetClaGroupsByFoundationSFID indicates an expected call of GetClaGroupsByFoundationSFID. +func (mr *MockServiceMockRecorder) GetClaGroupsByFoundationSFID(ctx, foundationSFID, loadRepoDetails interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetClaGroupsByFoundationSFID", reflect.TypeOf((*MockService)(nil).GetClaGroupsByFoundationSFID), ctx, foundationSFID, loadRepoDetails) +} + +// SignedAtFoundationLevel mocks base method. +func (m *MockService) SignedAtFoundationLevel(ctx context.Context, foundationSFID string) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SignedAtFoundationLevel", ctx, foundationSFID) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SignedAtFoundationLevel indicates an expected call of SignedAtFoundationLevel. +func (mr *MockServiceMockRecorder) SignedAtFoundationLevel(ctx, foundationSFID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SignedAtFoundationLevel", reflect.TypeOf((*MockService)(nil).SignedAtFoundationLevel), ctx, foundationSFID) +} + +// UpdateCLAGroup mocks base method. +func (m *MockService) UpdateCLAGroup(ctx context.Context, claGroupModel *models.ClaGroup) (*models.ClaGroup, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateCLAGroup", ctx, claGroupModel) + ret0, _ := ret[0].(*models.ClaGroup) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateCLAGroup indicates an expected call of UpdateCLAGroup. +func (mr *MockServiceMockRecorder) UpdateCLAGroup(ctx, claGroupModel interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateCLAGroup", reflect.TypeOf((*MockService)(nil).UpdateCLAGroup), ctx, claGroupModel) +} diff --git a/cla-backend-go/signatures/service.go b/cla-backend-go/signatures/service.go index 488d20c12..5feae4a02 100644 --- a/cla-backend-go/signatures/service.go +++ b/cla-backend-go/signatures/service.go @@ -72,10 +72,10 @@ type SignatureService interface { GetClaGroupCCLASignatures(ctx context.Context, claGroupID string, approved, signed *bool) (*models.Signatures, error) GetClaGroupCorporateContributors(ctx context.Context, claGroupID string, companyID *string, pageSize *int64, nextKey *string, searchTerm *string) (*models.CorporateContributorList, error) - createOrGetEmployeeModels(ctx context.Context, claGroupModel *models.ClaGroup, companyModel *models.Company, corporateSignatureModel *models.Signature) ([]*models.User, error) + // createOrGetEmployeeModels(ctx context.Context, claGroupModel *models.ClaGroup, companyModel *models.Company, corporateSignatureModel *models.Signature) ([]*models.User, error) CreateOrUpdateEmployeeSignature(ctx context.Context, claGroupModel *models.ClaGroup, companyModel *models.Company, corporateSignatureModel *models.Signature) ([]*models.User, error) UpdateEnvelopeDetails(ctx context.Context, signatureID, envelopeID string, signURL *string) (*models.Signature, error) - handleGitHubStatusUpdate(ctx context.Context, employeeUserModel *models.User) error + // handleGitHubStatusUpdate(ctx context.Context, employeeUserModel *models.User) error ProcessEmployeeSignature(ctx context.Context, companyModel *models.Company, claGroupModel *models.ClaGroup, user *models.User) (*bool, error) } diff --git a/cla-backend-go/swagger/cla.v2.yaml b/cla-backend-go/swagger/cla.v2.yaml index 428aab844..f84d6ee3a 100644 --- a/cla-backend-go/swagger/cla.v2.yaml +++ b/cla-backend-go/swagger/cla.v2.yaml @@ -6176,5 +6176,22 @@ definitions: companyID: type: string description: The ID of the company associated with the User (optional) + CCLARequiresICLA: + type: boolean + description: Flag ensuring user signs ICLA and is acknowledged the company + x-omitempty: false + companyAffiliation: + type: boolean + description: User is affiliated with a company (use case when user has no companyID attribute) + x-omitempty: false + ICLA: + type: boolean + description: User has an ICLA signature + x-omitempty: false + CCLA: + type: boolean + description: Flag to indicate if user has been company acknowledged and approved + x-omitempty: false + diff --git a/cla-backend-go/v2/signatures/mock_users/mock_service.go b/cla-backend-go/v2/signatures/mock_users/mock_service.go new file mode 100644 index 000000000..822185c25 --- /dev/null +++ b/cla-backend-go/v2/signatures/mock_users/mock_service.go @@ -0,0 +1,247 @@ +// Copyright The Linux Foundation and each contributor to CommunityBridge. +// SPDX-License-Identifier: MIT + +// Code generated by MockGen. DO NOT EDIT. +// Source: users/service.go + +// Package mock_users is a generated GoMock package. +package mock_users + +import ( + reflect "reflect" + + models "github.com/communitybridge/easycla/cla-backend-go/gen/v1/models" + user "github.com/communitybridge/easycla/cla-backend-go/user" + gomock "github.com/golang/mock/gomock" +) + +// MockService is a mock of Service interface. +type MockService struct { + ctrl *gomock.Controller + recorder *MockServiceMockRecorder +} + +// MockServiceMockRecorder is the mock recorder for MockService. +type MockServiceMockRecorder struct { + mock *MockService +} + +// NewMockService creates a new mock instance. +func NewMockService(ctrl *gomock.Controller) *MockService { + mock := &MockService{ctrl: ctrl} + mock.recorder = &MockServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockService) EXPECT() *MockServiceMockRecorder { + return m.recorder +} + +// CreateUser mocks base method. +func (m *MockService) CreateUser(user *models.User, claUser *user.CLAUser) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateUser", user, claUser) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateUser indicates an expected call of CreateUser. +func (mr *MockServiceMockRecorder) CreateUser(user, claUser interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateUser", reflect.TypeOf((*MockService)(nil).CreateUser), user, claUser) +} + +// Delete mocks base method. +func (m *MockService) Delete(userID string, claUser *user.CLAUser) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", userID, claUser) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockServiceMockRecorder) Delete(userID, claUser interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockService)(nil).Delete), userID, claUser) +} + +// GetUser mocks base method. +func (m *MockService) GetUser(userID string) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUser", userID) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUser indicates an expected call of GetUser. +func (mr *MockServiceMockRecorder) GetUser(userID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUser", reflect.TypeOf((*MockService)(nil).GetUser), userID) +} + +// GetUserByEmail mocks base method. +func (m *MockService) GetUserByEmail(userEmail string) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserByEmail", userEmail) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUserByEmail indicates an expected call of GetUserByEmail. +func (mr *MockServiceMockRecorder) GetUserByEmail(userEmail interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByEmail", reflect.TypeOf((*MockService)(nil).GetUserByEmail), userEmail) +} + +// GetUserByGitHubID mocks base method. +func (m *MockService) GetUserByGitHubID(gitHubID string) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserByGitHubID", gitHubID) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUserByGitHubID indicates an expected call of GetUserByGitHubID. +func (mr *MockServiceMockRecorder) GetUserByGitHubID(gitHubID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByGitHubID", reflect.TypeOf((*MockService)(nil).GetUserByGitHubID), gitHubID) +} + +// GetUserByGitHubUsername mocks base method. +func (m *MockService) GetUserByGitHubUsername(gitlabUsername string) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserByGitHubUsername", gitlabUsername) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUserByGitHubUsername indicates an expected call of GetUserByGitHubUsername. +func (mr *MockServiceMockRecorder) GetUserByGitHubUsername(gitlabUsername interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByGitHubUsername", reflect.TypeOf((*MockService)(nil).GetUserByGitHubUsername), gitlabUsername) +} + +// GetUserByGitLabUsername mocks base method. +func (m *MockService) GetUserByGitLabUsername(gitlabUsername string) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserByGitLabUsername", gitlabUsername) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUserByGitLabUsername indicates an expected call of GetUserByGitLabUsername. +func (mr *MockServiceMockRecorder) GetUserByGitLabUsername(gitlabUsername interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByGitLabUsername", reflect.TypeOf((*MockService)(nil).GetUserByGitLabUsername), gitlabUsername) +} + +// GetUserByGitlabID mocks base method. +func (m *MockService) GetUserByGitlabID(gitHubID int) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserByGitlabID", gitHubID) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUserByGitlabID indicates an expected call of GetUserByGitlabID. +func (mr *MockServiceMockRecorder) GetUserByGitlabID(gitHubID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByGitlabID", reflect.TypeOf((*MockService)(nil).GetUserByGitlabID), gitHubID) +} + +// GetUserByLFUserName mocks base method. +func (m *MockService) GetUserByLFUserName(lfUserName string) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserByLFUserName", lfUserName) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUserByLFUserName indicates an expected call of GetUserByLFUserName. +func (mr *MockServiceMockRecorder) GetUserByLFUserName(lfUserName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByLFUserName", reflect.TypeOf((*MockService)(nil).GetUserByLFUserName), lfUserName) +} + +// GetUserByUserName mocks base method. +func (m *MockService) GetUserByUserName(userName string, fullMatch bool) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserByUserName", userName, fullMatch) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUserByUserName indicates an expected call of GetUserByUserName. +func (mr *MockServiceMockRecorder) GetUserByUserName(userName, fullMatch interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserByUserName", reflect.TypeOf((*MockService)(nil).GetUserByUserName), userName, fullMatch) +} + +// Save mocks base method. +func (m *MockService) Save(user *models.UserUpdate, claUser *user.CLAUser) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Save", user, claUser) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Save indicates an expected call of Save. +func (mr *MockServiceMockRecorder) Save(user, claUser interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockService)(nil).Save), user, claUser) +} + +// SearchUsers mocks base method. +func (m *MockService) SearchUsers(field, searchTerm string, fullMatch bool) (*models.Users, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SearchUsers", field, searchTerm, fullMatch) + ret0, _ := ret[0].(*models.Users) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SearchUsers indicates an expected call of SearchUsers. +func (mr *MockServiceMockRecorder) SearchUsers(field, searchTerm, fullMatch interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchUsers", reflect.TypeOf((*MockService)(nil).SearchUsers), field, searchTerm, fullMatch) +} + +// UpdateUser mocks base method. +func (m *MockService) UpdateUser(userID string, updates map[string]interface{}) (*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateUser", userID, updates) + ret0, _ := ret[0].(*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateUser indicates an expected call of UpdateUser. +func (mr *MockServiceMockRecorder) UpdateUser(userID, updates interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUser", reflect.TypeOf((*MockService)(nil).UpdateUser), userID, updates) +} + +// UpdateUserCompanyID mocks base method. +func (m *MockService) UpdateUserCompanyID(userID, companyID, note string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateUserCompanyID", userID, companyID, note) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateUserCompanyID indicates an expected call of UpdateUserCompanyID. +func (mr *MockServiceMockRecorder) UpdateUserCompanyID(userID, companyID, note interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateUserCompanyID", reflect.TypeOf((*MockService)(nil).UpdateUserCompanyID), userID, companyID, note) +} diff --git a/cla-backend-go/v2/signatures/mock_v1_signatures/mock_service.go b/cla-backend-go/v2/signatures/mock_v1_signatures/mock_service.go new file mode 100644 index 000000000..714990cd3 --- /dev/null +++ b/cla-backend-go/v2/signatures/mock_v1_signatures/mock_service.go @@ -0,0 +1,534 @@ +// Copyright The Linux Foundation and each contributor to CommunityBridge. +// SPDX-License-Identifier: MIT + +// Code generated by MockGen. DO NOT EDIT. +// Source: signatures/service.go + +// Package mock_signatures is a generated GoMock package. +package mock_signatures + +import ( + context "context" + reflect "reflect" + + auth "github.com/LF-Engineering/lfx-kit/auth" + models "github.com/communitybridge/easycla/cla-backend-go/gen/v1/models" + signatures "github.com/communitybridge/easycla/cla-backend-go/gen/v1/restapi/operations/signatures" + signatures0 "github.com/communitybridge/easycla/cla-backend-go/signatures" + gomock "github.com/golang/mock/gomock" +) + +// MockSignatureService is a mock of SignatureService interface. +type MockSignatureService struct { + ctrl *gomock.Controller + recorder *MockSignatureServiceMockRecorder +} + +// MockSignatureServiceMockRecorder is the mock recorder for MockSignatureService. +type MockSignatureServiceMockRecorder struct { + mock *MockSignatureService +} + +// NewMockSignatureService creates a new mock instance. +func NewMockSignatureService(ctrl *gomock.Controller) *MockSignatureService { + mock := &MockSignatureService{ctrl: ctrl} + mock.recorder = &MockSignatureServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSignatureService) EXPECT() *MockSignatureServiceMockRecorder { + return m.recorder +} + +// AddCLAManager mocks base method. +func (m *MockSignatureService) AddCLAManager(ctx context.Context, signatureID, claManagerID string) (*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddCLAManager", ctx, signatureID, claManagerID) + ret0, _ := ret[0].(*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AddCLAManager indicates an expected call of AddCLAManager. +func (mr *MockSignatureServiceMockRecorder) AddCLAManager(ctx, signatureID, claManagerID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddCLAManager", reflect.TypeOf((*MockSignatureService)(nil).AddCLAManager), ctx, signatureID, claManagerID) +} + +// AddGithubOrganizationToApprovalList mocks base method. +func (m *MockSignatureService) AddGithubOrganizationToApprovalList(ctx context.Context, signatureID string, approvalListParams models.GhOrgWhitelist, githubAccessToken string) ([]models.GithubOrg, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddGithubOrganizationToApprovalList", ctx, signatureID, approvalListParams, githubAccessToken) + ret0, _ := ret[0].([]models.GithubOrg) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AddGithubOrganizationToApprovalList indicates an expected call of AddGithubOrganizationToApprovalList. +func (mr *MockSignatureServiceMockRecorder) AddGithubOrganizationToApprovalList(ctx, signatureID, approvalListParams, githubAccessToken interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddGithubOrganizationToApprovalList", reflect.TypeOf((*MockSignatureService)(nil).AddGithubOrganizationToApprovalList), ctx, signatureID, approvalListParams, githubAccessToken) +} + +// CreateOrUpdateEmployeeSignature mocks base method. +func (m *MockSignatureService) CreateOrUpdateEmployeeSignature(ctx context.Context, claGroupModel *models.ClaGroup, companyModel *models.Company, corporateSignatureModel *models.Signature) ([]*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateOrUpdateEmployeeSignature", ctx, claGroupModel, companyModel, corporateSignatureModel) + ret0, _ := ret[0].([]*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateOrUpdateEmployeeSignature indicates an expected call of CreateOrUpdateEmployeeSignature. +func (mr *MockSignatureServiceMockRecorder) CreateOrUpdateEmployeeSignature(ctx, claGroupModel, companyModel, corporateSignatureModel interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdateEmployeeSignature", reflect.TypeOf((*MockSignatureService)(nil).CreateOrUpdateEmployeeSignature), ctx, claGroupModel, companyModel, corporateSignatureModel) +} + +// CreateProjectSummaryReport mocks base method. +func (m *MockSignatureService) CreateProjectSummaryReport(ctx context.Context, params signatures.CreateProjectSummaryReportParams) (*models.SignatureReport, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateProjectSummaryReport", ctx, params) + ret0, _ := ret[0].(*models.SignatureReport) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateProjectSummaryReport indicates an expected call of CreateProjectSummaryReport. +func (mr *MockSignatureServiceMockRecorder) CreateProjectSummaryReport(ctx, params interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateProjectSummaryReport", reflect.TypeOf((*MockSignatureService)(nil).CreateProjectSummaryReport), ctx, params) +} + +// CreateSignature mocks base method. +func (m *MockSignatureService) CreateSignature(ctx context.Context, signature *signatures0.ItemSignature) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateSignature", ctx, signature) + ret0, _ := ret[0].(error) + return ret0 +} + +// CreateSignature indicates an expected call of CreateSignature. +func (mr *MockSignatureServiceMockRecorder) CreateSignature(ctx, signature interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateSignature", reflect.TypeOf((*MockSignatureService)(nil).CreateSignature), ctx, signature) +} + +// DeleteGithubOrganizationFromApprovalList mocks base method. +func (m *MockSignatureService) DeleteGithubOrganizationFromApprovalList(ctx context.Context, signatureID string, approvalListParams models.GhOrgWhitelist, githubAccessToken string) ([]models.GithubOrg, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteGithubOrganizationFromApprovalList", ctx, signatureID, approvalListParams, githubAccessToken) + ret0, _ := ret[0].([]models.GithubOrg) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteGithubOrganizationFromApprovalList indicates an expected call of DeleteGithubOrganizationFromApprovalList. +func (mr *MockSignatureServiceMockRecorder) DeleteGithubOrganizationFromApprovalList(ctx, signatureID, approvalListParams, githubAccessToken interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteGithubOrganizationFromApprovalList", reflect.TypeOf((*MockSignatureService)(nil).DeleteGithubOrganizationFromApprovalList), ctx, signatureID, approvalListParams, githubAccessToken) +} + +// GetCCLASignatures mocks base method. +func (m *MockSignatureService) GetCCLASignatures(ctx context.Context, signed, approved *bool) ([]*signatures0.ItemSignature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCCLASignatures", ctx, signed, approved) + ret0, _ := ret[0].([]*signatures0.ItemSignature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCCLASignatures indicates an expected call of GetCCLASignatures. +func (mr *MockSignatureServiceMockRecorder) GetCCLASignatures(ctx, signed, approved interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCCLASignatures", reflect.TypeOf((*MockSignatureService)(nil).GetCCLASignatures), ctx, signed, approved) +} + +// GetClaGroupCCLASignatures mocks base method. +func (m *MockSignatureService) GetClaGroupCCLASignatures(ctx context.Context, claGroupID string, approved, signed *bool) (*models.Signatures, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetClaGroupCCLASignatures", ctx, claGroupID, approved, signed) + ret0, _ := ret[0].(*models.Signatures) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetClaGroupCCLASignatures indicates an expected call of GetClaGroupCCLASignatures. +func (mr *MockSignatureServiceMockRecorder) GetClaGroupCCLASignatures(ctx, claGroupID, approved, signed interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetClaGroupCCLASignatures", reflect.TypeOf((*MockSignatureService)(nil).GetClaGroupCCLASignatures), ctx, claGroupID, approved, signed) +} + +// GetClaGroupCorporateContributors mocks base method. +func (m *MockSignatureService) GetClaGroupCorporateContributors(ctx context.Context, claGroupID string, companyID *string, pageSize *int64, nextKey, searchTerm *string) (*models.CorporateContributorList, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetClaGroupCorporateContributors", ctx, claGroupID, companyID, pageSize, nextKey, searchTerm) + ret0, _ := ret[0].(*models.CorporateContributorList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetClaGroupCorporateContributors indicates an expected call of GetClaGroupCorporateContributors. +func (mr *MockSignatureServiceMockRecorder) GetClaGroupCorporateContributors(ctx, claGroupID, companyID, pageSize, nextKey, searchTerm interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetClaGroupCorporateContributors", reflect.TypeOf((*MockSignatureService)(nil).GetClaGroupCorporateContributors), ctx, claGroupID, companyID, pageSize, nextKey, searchTerm) +} + +// GetClaGroupICLASignatures mocks base method. +func (m *MockSignatureService) GetClaGroupICLASignatures(ctx context.Context, claGroupID string, searchTerm *string, approved, signed *bool, pageSize int64, nextKey string, withExtraDetails bool) (*models.IclaSignatures, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetClaGroupICLASignatures", ctx, claGroupID, searchTerm, approved, signed, pageSize, nextKey, withExtraDetails) + ret0, _ := ret[0].(*models.IclaSignatures) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetClaGroupICLASignatures indicates an expected call of GetClaGroupICLASignatures. +func (mr *MockSignatureServiceMockRecorder) GetClaGroupICLASignatures(ctx, claGroupID, searchTerm, approved, signed, pageSize, nextKey, withExtraDetails interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetClaGroupICLASignatures", reflect.TypeOf((*MockSignatureService)(nil).GetClaGroupICLASignatures), ctx, claGroupID, searchTerm, approved, signed, pageSize, nextKey, withExtraDetails) +} + +// GetCompanyIDsWithSignedCorporateSignatures mocks base method. +func (m *MockSignatureService) GetCompanyIDsWithSignedCorporateSignatures(ctx context.Context, claGroupID string) ([]signatures0.SignatureCompanyID, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompanyIDsWithSignedCorporateSignatures", ctx, claGroupID) + ret0, _ := ret[0].([]signatures0.SignatureCompanyID) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompanyIDsWithSignedCorporateSignatures indicates an expected call of GetCompanyIDsWithSignedCorporateSignatures. +func (mr *MockSignatureServiceMockRecorder) GetCompanyIDsWithSignedCorporateSignatures(ctx, claGroupID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompanyIDsWithSignedCorporateSignatures", reflect.TypeOf((*MockSignatureService)(nil).GetCompanyIDsWithSignedCorporateSignatures), ctx, claGroupID) +} + +// GetCompanySignatures mocks base method. +func (m *MockSignatureService) GetCompanySignatures(ctx context.Context, params signatures.GetCompanySignaturesParams) (*models.Signatures, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCompanySignatures", ctx, params) + ret0, _ := ret[0].(*models.Signatures) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCompanySignatures indicates an expected call of GetCompanySignatures. +func (mr *MockSignatureServiceMockRecorder) GetCompanySignatures(ctx, params interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCompanySignatures", reflect.TypeOf((*MockSignatureService)(nil).GetCompanySignatures), ctx, params) +} + +// GetCorporateSignature mocks base method. +func (m *MockSignatureService) GetCorporateSignature(ctx context.Context, claGroupID, companyID string, approved, signed *bool) (*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCorporateSignature", ctx, claGroupID, companyID, approved, signed) + ret0, _ := ret[0].(*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCorporateSignature indicates an expected call of GetCorporateSignature. +func (mr *MockSignatureServiceMockRecorder) GetCorporateSignature(ctx, claGroupID, companyID, approved, signed interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCorporateSignature", reflect.TypeOf((*MockSignatureService)(nil).GetCorporateSignature), ctx, claGroupID, companyID, approved, signed) +} + +// GetCorporateSignatures mocks base method. +func (m *MockSignatureService) GetCorporateSignatures(ctx context.Context, claGroupID, companyID string, approved, signed *bool) ([]*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetCorporateSignatures", ctx, claGroupID, companyID, approved, signed) + ret0, _ := ret[0].([]*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetCorporateSignatures indicates an expected call of GetCorporateSignatures. +func (mr *MockSignatureServiceMockRecorder) GetCorporateSignatures(ctx, claGroupID, companyID, approved, signed interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCorporateSignatures", reflect.TypeOf((*MockSignatureService)(nil).GetCorporateSignatures), ctx, claGroupID, companyID, approved, signed) +} + +// GetGithubOrganizationsFromApprovalList mocks base method. +func (m *MockSignatureService) GetGithubOrganizationsFromApprovalList(ctx context.Context, signatureID, githubAccessToken string) ([]models.GithubOrg, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetGithubOrganizationsFromApprovalList", ctx, signatureID, githubAccessToken) + ret0, _ := ret[0].([]models.GithubOrg) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetGithubOrganizationsFromApprovalList indicates an expected call of GetGithubOrganizationsFromApprovalList. +func (mr *MockSignatureServiceMockRecorder) GetGithubOrganizationsFromApprovalList(ctx, signatureID, githubAccessToken interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGithubOrganizationsFromApprovalList", reflect.TypeOf((*MockSignatureService)(nil).GetGithubOrganizationsFromApprovalList), ctx, signatureID, githubAccessToken) +} + +// GetIndividualSignature mocks base method. +func (m *MockSignatureService) GetIndividualSignature(ctx context.Context, claGroupID, userID string, approved, signed *bool) (*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetIndividualSignature", ctx, claGroupID, userID, approved, signed) + ret0, _ := ret[0].(*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetIndividualSignature indicates an expected call of GetIndividualSignature. +func (mr *MockSignatureServiceMockRecorder) GetIndividualSignature(ctx, claGroupID, userID, approved, signed interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIndividualSignature", reflect.TypeOf((*MockSignatureService)(nil).GetIndividualSignature), ctx, claGroupID, userID, approved, signed) +} + +// GetIndividualSignatures mocks base method. +func (m *MockSignatureService) GetIndividualSignatures(ctx context.Context, claGroupID, userID string, approved, signed *bool) ([]*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetIndividualSignatures", ctx, claGroupID, userID, approved, signed) + ret0, _ := ret[0].([]*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetIndividualSignatures indicates an expected call of GetIndividualSignatures. +func (mr *MockSignatureServiceMockRecorder) GetIndividualSignatures(ctx, claGroupID, userID, approved, signed interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIndividualSignatures", reflect.TypeOf((*MockSignatureService)(nil).GetIndividualSignatures), ctx, claGroupID, userID, approved, signed) +} + +// GetProjectCompanyEmployeeSignatures mocks base method. +func (m *MockSignatureService) GetProjectCompanyEmployeeSignatures(ctx context.Context, params signatures.GetProjectCompanyEmployeeSignaturesParams, criteria *signatures0.ApprovalCriteria) (*models.Signatures, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetProjectCompanyEmployeeSignatures", ctx, params, criteria) + ret0, _ := ret[0].(*models.Signatures) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetProjectCompanyEmployeeSignatures indicates an expected call of GetProjectCompanyEmployeeSignatures. +func (mr *MockSignatureServiceMockRecorder) GetProjectCompanyEmployeeSignatures(ctx, params, criteria interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProjectCompanyEmployeeSignatures", reflect.TypeOf((*MockSignatureService)(nil).GetProjectCompanyEmployeeSignatures), ctx, params, criteria) +} + +// GetProjectCompanySignature mocks base method. +func (m *MockSignatureService) GetProjectCompanySignature(ctx context.Context, companyID, projectID string, approved, signed *bool, nextKey *string, pageSize *int64) (*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetProjectCompanySignature", ctx, companyID, projectID, approved, signed, nextKey, pageSize) + ret0, _ := ret[0].(*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetProjectCompanySignature indicates an expected call of GetProjectCompanySignature. +func (mr *MockSignatureServiceMockRecorder) GetProjectCompanySignature(ctx, companyID, projectID, approved, signed, nextKey, pageSize interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProjectCompanySignature", reflect.TypeOf((*MockSignatureService)(nil).GetProjectCompanySignature), ctx, companyID, projectID, approved, signed, nextKey, pageSize) +} + +// GetProjectCompanySignatures mocks base method. +func (m *MockSignatureService) GetProjectCompanySignatures(ctx context.Context, params signatures.GetProjectCompanySignaturesParams) (*models.Signatures, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetProjectCompanySignatures", ctx, params) + ret0, _ := ret[0].(*models.Signatures) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetProjectCompanySignatures indicates an expected call of GetProjectCompanySignatures. +func (mr *MockSignatureServiceMockRecorder) GetProjectCompanySignatures(ctx, params interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProjectCompanySignatures", reflect.TypeOf((*MockSignatureService)(nil).GetProjectCompanySignatures), ctx, params) +} + +// GetProjectSignatures mocks base method. +func (m *MockSignatureService) GetProjectSignatures(ctx context.Context, params signatures.GetProjectSignaturesParams) (*models.Signatures, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetProjectSignatures", ctx, params) + ret0, _ := ret[0].(*models.Signatures) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetProjectSignatures indicates an expected call of GetProjectSignatures. +func (mr *MockSignatureServiceMockRecorder) GetProjectSignatures(ctx, params interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetProjectSignatures", reflect.TypeOf((*MockSignatureService)(nil).GetProjectSignatures), ctx, params) +} + +// GetSignature mocks base method. +func (m *MockSignatureService) GetSignature(ctx context.Context, signatureID string) (*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSignature", ctx, signatureID) + ret0, _ := ret[0].(*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetSignature indicates an expected call of GetSignature. +func (mr *MockSignatureServiceMockRecorder) GetSignature(ctx, signatureID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSignature", reflect.TypeOf((*MockSignatureService)(nil).GetSignature), ctx, signatureID) +} + +// GetUserSignatures mocks base method. +func (m *MockSignatureService) GetUserSignatures(ctx context.Context, params signatures.GetUserSignaturesParams, projectID *string) (*models.Signatures, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUserSignatures", ctx, params, projectID) + ret0, _ := ret[0].(*models.Signatures) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUserSignatures indicates an expected call of GetUserSignatures. +func (mr *MockSignatureServiceMockRecorder) GetUserSignatures(ctx, params, projectID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserSignatures", reflect.TypeOf((*MockSignatureService)(nil).GetUserSignatures), ctx, params, projectID) +} + +// HasUserSigned mocks base method. +func (m *MockSignatureService) HasUserSigned(ctx context.Context, user *models.User, projectID string) (*bool, *bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasUserSigned", ctx, user, projectID) + ret0, _ := ret[0].(*bool) + ret1, _ := ret[1].(*bool) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// HasUserSigned indicates an expected call of HasUserSigned. +func (mr *MockSignatureServiceMockRecorder) HasUserSigned(ctx, user, projectID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasUserSigned", reflect.TypeOf((*MockSignatureService)(nil).HasUserSigned), ctx, user, projectID) +} + +// InvalidateProjectRecords mocks base method. +func (m *MockSignatureService) InvalidateProjectRecords(ctx context.Context, projectID, note string) (int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InvalidateProjectRecords", ctx, projectID, note) + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// InvalidateProjectRecords indicates an expected call of InvalidateProjectRecords. +func (mr *MockSignatureServiceMockRecorder) InvalidateProjectRecords(ctx, projectID, note interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InvalidateProjectRecords", reflect.TypeOf((*MockSignatureService)(nil).InvalidateProjectRecords), ctx, projectID, note) +} + +// ProcessEmployeeSignature mocks base method. +func (m *MockSignatureService) ProcessEmployeeSignature(ctx context.Context, companyModel *models.Company, claGroupModel *models.ClaGroup, user *models.User) (*bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ProcessEmployeeSignature", ctx, companyModel, claGroupModel, user) + ret0, _ := ret[0].(*bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ProcessEmployeeSignature indicates an expected call of ProcessEmployeeSignature. +func (mr *MockSignatureServiceMockRecorder) ProcessEmployeeSignature(ctx, companyModel, claGroupModel, user interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessEmployeeSignature", reflect.TypeOf((*MockSignatureService)(nil).ProcessEmployeeSignature), ctx, companyModel, claGroupModel, user) +} + +// RemoveCLAManager mocks base method. +func (m *MockSignatureService) RemoveCLAManager(ctx context.Context, ignatureID, claManagerID string) (*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoveCLAManager", ctx, ignatureID, claManagerID) + ret0, _ := ret[0].(*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// RemoveCLAManager indicates an expected call of RemoveCLAManager. +func (mr *MockSignatureServiceMockRecorder) RemoveCLAManager(ctx, ignatureID, claManagerID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveCLAManager", reflect.TypeOf((*MockSignatureService)(nil).RemoveCLAManager), ctx, ignatureID, claManagerID) +} + +// SaveOrUpdateSignature mocks base method. +func (m *MockSignatureService) SaveOrUpdateSignature(ctx context.Context, signature *signatures0.ItemSignature) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SaveOrUpdateSignature", ctx, signature) + ret0, _ := ret[0].(error) + return ret0 +} + +// SaveOrUpdateSignature indicates an expected call of SaveOrUpdateSignature. +func (mr *MockSignatureServiceMockRecorder) SaveOrUpdateSignature(ctx, signature interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveOrUpdateSignature", reflect.TypeOf((*MockSignatureService)(nil).SaveOrUpdateSignature), ctx, signature) +} + +// UpdateApprovalList mocks base method. +func (m *MockSignatureService) UpdateApprovalList(ctx context.Context, authUser *auth.User, claGroupModel *models.ClaGroup, companyModel *models.Company, claGroupID string, params *models.ApprovalList, projectSFID string) (*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateApprovalList", ctx, authUser, claGroupModel, companyModel, claGroupID, params, projectSFID) + ret0, _ := ret[0].(*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateApprovalList indicates an expected call of UpdateApprovalList. +func (mr *MockSignatureServiceMockRecorder) UpdateApprovalList(ctx, authUser, claGroupModel, companyModel, claGroupID, params, projectSFID interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateApprovalList", reflect.TypeOf((*MockSignatureService)(nil).UpdateApprovalList), ctx, authUser, claGroupModel, companyModel, claGroupID, params, projectSFID) +} + +// UpdateEnvelopeDetails mocks base method. +func (m *MockSignatureService) UpdateEnvelopeDetails(ctx context.Context, signatureID, envelopeID string, signURL *string) (*models.Signature, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateEnvelopeDetails", ctx, signatureID, envelopeID, signURL) + ret0, _ := ret[0].(*models.Signature) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateEnvelopeDetails indicates an expected call of UpdateEnvelopeDetails. +func (mr *MockSignatureServiceMockRecorder) UpdateEnvelopeDetails(ctx, signatureID, envelopeID, signURL interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateEnvelopeDetails", reflect.TypeOf((*MockSignatureService)(nil).UpdateEnvelopeDetails), ctx, signatureID, envelopeID, signURL) +} + +// UpdateSignature mocks base method. +func (m *MockSignatureService) UpdateSignature(ctx context.Context, signatureID string, updates map[string]interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateSignature", ctx, signatureID, updates) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateSignature indicates an expected call of UpdateSignature. +func (mr *MockSignatureServiceMockRecorder) UpdateSignature(ctx, signatureID, updates interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSignature", reflect.TypeOf((*MockSignatureService)(nil).UpdateSignature), ctx, signatureID, updates) +} + +// createOrGetEmployeeModels mocks base method. +func (m *MockSignatureService) createOrGetEmployeeModels(ctx context.Context, claGroupModel *models.ClaGroup, companyModel *models.Company, corporateSignatureModel *models.Signature) ([]*models.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "createOrGetEmployeeModels", ctx, claGroupModel, companyModel, corporateSignatureModel) + ret0, _ := ret[0].([]*models.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// createOrGetEmployeeModels indicates an expected call of createOrGetEmployeeModels. +func (mr *MockSignatureServiceMockRecorder) createOrGetEmployeeModels(ctx, claGroupModel, companyModel, corporateSignatureModel interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "createOrGetEmployeeModels", reflect.TypeOf((*MockSignatureService)(nil).createOrGetEmployeeModels), ctx, claGroupModel, companyModel, corporateSignatureModel) +} + +// handleGitHubStatusUpdate mocks base method. +func (m *MockSignatureService) handleGitHubStatusUpdate(ctx context.Context, employeeUserModel *models.User) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "handleGitHubStatusUpdate", ctx, employeeUserModel) + ret0, _ := ret[0].(error) + return ret0 +} + +// handleGitHubStatusUpdate indicates an expected call of handleGitHubStatusUpdate. +func (mr *MockSignatureServiceMockRecorder) handleGitHubStatusUpdate(ctx, employeeUserModel interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleGitHubStatusUpdate", reflect.TypeOf((*MockSignatureService)(nil).handleGitHubStatusUpdate), ctx, employeeUserModel) +} diff --git a/cla-backend-go/v2/signatures/service.go b/cla-backend-go/v2/signatures/service.go index 2e0bd47ae..461d1579a 100644 --- a/cla-backend-go/v2/signatures/service.go +++ b/cla-backend-go/v2/signatures/service.go @@ -444,31 +444,92 @@ func (s *Service) IsUserAuthorized(ctx context.Context, lfid, claGroupId string) utils.XREQUESTID: ctx.Value(utils.XREQUESTID), } + hasSigned := false + response := models.LfidAuthorizedResponse{ - ClaGroupID: claGroupId, - Lfid: lfid, + ClaGroupID: claGroupId, + Lfid: lfid, + Authorized: false, + ICLA: false, + CCLA: false, + CCLARequiresICLA: false, + } + + // fetch cla group + log.WithFields(f).Debug("fetching cla group") + claGroup, err := s.v1ProjectService.GetCLAGroupByID(ctx, claGroupId) + if err != nil { + log.WithFields(f).WithError(err).Debug("unable to fetch cla group") + return nil, err + } + + if claGroup == nil { + log.WithFields(f).Debug("cla group not found") + return &response, nil } + response.CCLARequiresICLA = claGroup.ProjectCCLARequiresICLA // fetch cla user log.WithFields(f).Debug("fetching user by lfid") user, err := s.usersService.GetUserByLFUserName(lfid) - if user.CompanyID != "" { - log.WithFields(f).Debugf("User is associated with company: %s", user.CompanyID) - response.CompanyID = user.CompanyID - } - if err != nil { log.WithFields(f).WithError(err).Debug("unable to fetch lfusername") return nil, err } - hasSigned, _, err := s.v1SignatureService.HasUserSigned(ctx, user, claGroupId) - if err != nil { - log.WithFields(f).WithError(err).Debug("Unable to check authorized status of the user") - return nil, err + if user == nil { + log.WithFields(f).Debug("user not found") + return &response, nil + } + + // check if user has signed ICLA + log.WithFields(f).Debug("checking if user has signed ICLA") + approved, signed := true, true + icla, iclaErr := s.v1SignatureService.GetIndividualSignature(ctx, claGroupId, user.UserID, &approved, &signed) + if iclaErr != nil { + log.WithFields(f).WithError(iclaErr).Debug("unable to get individual signature") + } + + if icla != nil { + log.WithFields(f).Debug("user has signed ICLA") + response.ICLA = true + hasSigned = true + } + + // fetch company + if user.CompanyID == "" { + log.WithFields(f).Debug("user company id not found") + response.CompanyAffiliation = false + } else { + log.WithFields(f).Debug("fetching company") + companyModel, err := s.v1CompanyService.GetCompany(ctx, user.CompanyID) + if err != nil { + log.WithFields(f).WithError(err).Debug("unable to fetch company") + return nil, err + } + if companyModel == nil { + log.WithFields(f).Debug("company not found") + response.CompanyAffiliation = false + } else { + log.WithFields(f).Debug("company found") + response.CompanyAffiliation = true + // process ecla + ecla, err := s.v1SignatureService.ProcessEmployeeSignature(ctx, companyModel, claGroup, user) + if err != nil { + log.WithFields(f).WithError(err).Debug("unable to process ecla") + return nil, err + } + if ecla != nil && *ecla { + log.WithFields(f).Debug("user has signed ECLA") + hasSigned = true + response.CCLA = true + } else { + log.WithFields(f).Debug("user has not acknowledged with the company ") + } + } } - response.Authorized = *hasSigned + response.Authorized = hasSigned return &response, nil } diff --git a/cla-backend-go/v2/signatures/service_test.go b/cla-backend-go/v2/signatures/service_test.go new file mode 100644 index 000000000..4e99c34e8 --- /dev/null +++ b/cla-backend-go/v2/signatures/service_test.go @@ -0,0 +1,201 @@ +// Copyright The Linux Foundation and each contributor to CommunityBridge. +// SPDX-License-Identifier: MIT + +package signatures + +import ( + "context" + "errors" + "fmt" + "testing" + + v1Models "github.com/communitybridge/easycla/cla-backend-go/gen/v1/models" + // mock_signatures "github.com/communitybridge/easycla/cla-backend-go/v2/signatures/mock_v1_signatures" + mock_company "github.com/communitybridge/easycla/cla-backend-go/company/mocks" + ini "github.com/communitybridge/easycla/cla-backend-go/init" + mock_project "github.com/communitybridge/easycla/cla-backend-go/project/mocks" + mock_users "github.com/communitybridge/easycla/cla-backend-go/v2/signatures/mock_users" + mock_v1_signatures "github.com/communitybridge/easycla/cla-backend-go/v2/signatures/mock_v1_signatures" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/assert" +) + +func TestService_IsUserAuthorized_User_Not_Found(t *testing.T) { + // TestIsUserAuthorized test case + lfid := "foolfid" + projectID := "project-1234" + + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + awsSession, err := ini.GetAWSSession() + if err != nil { + assert.Fail(t, "unable to create AWS session") + } + + mockUserService := mock_users.NewMockService(ctrl) + mockUserService.EXPECT().GetUserByLFUserName(lfid).Return(nil, nil) + + service := NewService(awsSession, "", nil, nil, nil, nil, nil, mockUserService, nil) + + result, err := service.IsUserAuthorized(context.Background(), lfid, projectID) + + assert.Nil(t, err) + assert.False(t, result.Authorized) +} + +func TestService_IsUserAuthorized_CCLA_Requires_ICLA(t *testing.T) { + type testCase struct { + lfid string + projectID string + userID string + companyID string + claGroupRequiresICLA bool + getIndividualSignatureResult *v1Models.Signature + getIndividualSignatureError error + processEmployeeSignatureResult *bool + processEmployeeSignatureError error + expectedAuthorized bool + expectedCCLARequiresICLA bool + expectedICLA bool + expectedCCLA bool + expectedCompanyAffiliation bool + } + + cases := []testCase{ + { + lfid: "foobar_1", + projectID: "project-123", + userID: "user-123", + companyID: "company-123", + claGroupRequiresICLA: true, + getIndividualSignatureResult: &v1Models.Signature{ + SignatureID: "signature-123", + }, + getIndividualSignatureError: nil, + processEmployeeSignatureResult: func() *bool { b := true; return &b }(), + processEmployeeSignatureError: nil, + expectedAuthorized: true, + expectedCCLARequiresICLA: true, + expectedICLA: true, + expectedCCLA: true, + expectedCompanyAffiliation: true, + }, + { + lfid: "foobar_2", + projectID: "project-123", + userID: "user-123", + companyID: "company-123", + claGroupRequiresICLA: false, + getIndividualSignatureResult: &v1Models.Signature{ + SignatureID: "signature-123", + }, + getIndividualSignatureError: nil, + processEmployeeSignatureResult: func() *bool { b := true; return &b }(), + processEmployeeSignatureError: nil, + expectedAuthorized: true, + expectedCCLARequiresICLA: false, + expectedICLA: true, + expectedCCLA: true, + expectedCompanyAffiliation: true, + }, + { + lfid: "foobar_3", + projectID: "project-123", + userID: "user-123", + companyID: "company-123", + claGroupRequiresICLA: true, + getIndividualSignatureResult: &v1Models.Signature{ + SignatureID: "signature-123", + }, + getIndividualSignatureError: nil, + processEmployeeSignatureResult: nil, + processEmployeeSignatureError: nil, + expectedAuthorized: true, + expectedCCLARequiresICLA: true, + expectedICLA: true, + expectedCCLA: false, + expectedCompanyAffiliation: true, + }, + { + lfid: "foobar_4", + projectID: "project-123", + userID: "user-123", + companyID: "company-123", + claGroupRequiresICLA: true, + getIndividualSignatureResult: nil, + getIndividualSignatureError: errors.New("some error"), + processEmployeeSignatureResult: func() *bool { b := true; return &b }(), + processEmployeeSignatureError: nil, + expectedAuthorized: true, + expectedCCLARequiresICLA: true, + expectedICLA: false, + expectedCCLA: true, + expectedCompanyAffiliation: true, + }, + { + lfid: "foobar_5", + projectID: "project-123", + userID: "user-123", + companyID: "company-123", + claGroupRequiresICLA: true, + getIndividualSignatureResult: nil, + getIndividualSignatureError: errors.New("some error"), + processEmployeeSignatureResult: func() *bool { b := false; return &b }(), + processEmployeeSignatureError: nil, + expectedAuthorized: false, + expectedCCLARequiresICLA: true, + expectedICLA: false, + expectedCCLA: false, + expectedCompanyAffiliation: true, + }, + } + + for _, tc := range cases { + t.Run(fmt.Sprintf("LFID=%s ProjectID=%s", tc.lfid, tc.projectID), func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + awsSession, err := ini.GetAWSSession() + if err != nil { + assert.Fail(t, "unable to create AWS session") + } + + mockUserService := mock_users.NewMockService(ctrl) + mockUserService.EXPECT().GetUserByLFUserName(tc.lfid).Return(&v1Models.User{ + UserID: tc.userID, + CompanyID: tc.companyID, + }, nil) + + mockProjectService := mock_project.NewMockService(ctrl) + mockProjectService.EXPECT().GetCLAGroupByID(context.Background(), tc.projectID).Return(&v1Models.ClaGroup{ + ProjectID: tc.projectID, + ProjectCCLARequiresICLA: tc.claGroupRequiresICLA, + }, nil) + + mockSignatureService := mock_v1_signatures.NewMockSignatureService(ctrl) + + approved := true + signed := true + mockSignatureService.EXPECT().GetIndividualSignature(context.Background(), tc.projectID, tc.userID, &approved, &signed).Return(tc.getIndividualSignatureResult, tc.getIndividualSignatureError) + + mockSignatureService.EXPECT().ProcessEmployeeSignature(context.Background(), gomock.Any(), gomock.Any(), gomock.Any()).Return(tc.processEmployeeSignatureResult, tc.processEmployeeSignatureError) + + mockCompanyService := mock_company.NewMockIService(ctrl) + mockCompanyService.EXPECT().GetCompany(context.Background(), tc.companyID).Return(&v1Models.Company{ + CompanyID: tc.companyID, + }, nil) + + service := NewService(awsSession, "", mockProjectService, mockCompanyService, mockSignatureService, nil, nil, mockUserService, nil) + + result, err := service.IsUserAuthorized(context.Background(), tc.lfid, tc.projectID) + + assert.Nil(t, err) + assert.Equal(t, tc.expectedAuthorized, result.Authorized) + assert.Equal(t, tc.expectedCCLARequiresICLA, result.CCLARequiresICLA) + assert.Equal(t, tc.expectedICLA, result.ICLA) + assert.Equal(t, tc.expectedCCLA, result.CCLA) + assert.Equal(t, tc.expectedCompanyAffiliation, result.CompanyAffiliation) + }) + } +}