diff --git a/common/authorizer/mock_Authorizer.go b/common/authorizer/mock_Authorizer.go index 0461e71..4a32bd0 100644 --- a/common/authorizer/mock_Authorizer.go +++ b/common/authorizer/mock_Authorizer.go @@ -1,213 +1,80 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. +// Code generated by MockGen. DO NOT EDIT. +// Source: authorizer.go +// Package authorizer is a generated GoMock package. package authorizer import ( context "context" + reflect "reflect" - mock "github.com/stretchr/testify/mock" + gomock "github.com/golang/mock/gomock" ) -// MockAuthorizer is an autogenerated mock type for the Authorizer type +// MockAuthorizer is a mock of Authorizer interface. type MockAuthorizer struct { - mock.Mock + ctrl *gomock.Controller + recorder *MockAuthorizerMockRecorder } -type MockAuthorizer_Expecter struct { - mock *mock.Mock +// MockAuthorizerMockRecorder is the mock recorder for MockAuthorizer. +type MockAuthorizerMockRecorder struct { + mock *MockAuthorizer } -func (_m *MockAuthorizer) EXPECT() *MockAuthorizer_Expecter { - return &MockAuthorizer_Expecter{mock: &_m.Mock} -} - -// AffirmAuthorization provides a mock function with given fields: ctx, fullMethod, eq -func (_m *MockAuthorizer) AffirmAuthorization(ctx context.Context, fullMethod string, eq interface{}) (context.Context, error) { - ret := _m.Called(ctx, fullMethod, eq) - - if len(ret) == 0 { - panic("no return value specified for AffirmAuthorization") - } - - var r0 context.Context - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}) (context.Context, error)); ok { - return rf(ctx, fullMethod, eq) - } - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}) context.Context); ok { - r0 = rf(ctx, fullMethod, eq) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(context.Context) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, interface{}) error); ok { - r1 = rf(ctx, fullMethod, eq) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAuthorizer_AffirmAuthorization_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AffirmAuthorization' -type MockAuthorizer_AffirmAuthorization_Call struct { - *mock.Call -} - -// AffirmAuthorization is a helper method to define mock.On call -// - ctx context.Context -// - fullMethod string -// - eq interface{} -func (_e *MockAuthorizer_Expecter) AffirmAuthorization(ctx interface{}, fullMethod interface{}, eq interface{}) *MockAuthorizer_AffirmAuthorization_Call { - return &MockAuthorizer_AffirmAuthorization_Call{Call: _e.mock.On("AffirmAuthorization", ctx, fullMethod, eq)} -} - -func (_c *MockAuthorizer_AffirmAuthorization_Call) Run(run func(ctx context.Context, fullMethod string, eq interface{})) *MockAuthorizer_AffirmAuthorization_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(interface{})) - }) - return _c -} - -func (_c *MockAuthorizer_AffirmAuthorization_Call) Return(_a0 context.Context, _a1 error) *MockAuthorizer_AffirmAuthorization_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAuthorizer_AffirmAuthorization_Call) RunAndReturn(run func(context.Context, string, interface{}) (context.Context, error)) *MockAuthorizer_AffirmAuthorization_Call { - _c.Call.Return(run) - return _c -} - -// Evaluate provides a mock function with given fields: ctx, fullMethod, req, opaEvaluator -func (_m *MockAuthorizer) Evaluate(ctx context.Context, fullMethod string, req interface{}, opaEvaluator OpaEvaluator) (bool, context.Context, error) { - ret := _m.Called(ctx, fullMethod, req, opaEvaluator) - - if len(ret) == 0 { - panic("no return value specified for Evaluate") - } - - var r0 bool - var r1 context.Context - var r2 error - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, OpaEvaluator) (bool, context.Context, error)); ok { - return rf(ctx, fullMethod, req, opaEvaluator) - } - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, OpaEvaluator) bool); ok { - r0 = rf(ctx, fullMethod, req, opaEvaluator) - } else { - r0 = ret.Get(0).(bool) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, interface{}, OpaEvaluator) context.Context); ok { - r1 = rf(ctx, fullMethod, req, opaEvaluator) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(context.Context) - } - } - - if rf, ok := ret.Get(2).(func(context.Context, string, interface{}, OpaEvaluator) error); ok { - r2 = rf(ctx, fullMethod, req, opaEvaluator) - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// MockAuthorizer_Evaluate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Evaluate' -type MockAuthorizer_Evaluate_Call struct { - *mock.Call -} - -// Evaluate is a helper method to define mock.On call -// - ctx context.Context -// - fullMethod string -// - req interface{} -// - opaEvaluator OpaEvaluator -func (_e *MockAuthorizer_Expecter) Evaluate(ctx interface{}, fullMethod interface{}, req interface{}, opaEvaluator interface{}) *MockAuthorizer_Evaluate_Call { - return &MockAuthorizer_Evaluate_Call{Call: _e.mock.On("Evaluate", ctx, fullMethod, req, opaEvaluator)} -} - -func (_c *MockAuthorizer_Evaluate_Call) Run(run func(ctx context.Context, fullMethod string, req interface{}, opaEvaluator OpaEvaluator)) *MockAuthorizer_Evaluate_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(interface{}), args[3].(OpaEvaluator)) - }) - return _c -} - -func (_c *MockAuthorizer_Evaluate_Call) Return(_a0 bool, _a1 context.Context, _a2 error) *MockAuthorizer_Evaluate_Call { - _c.Call.Return(_a0, _a1, _a2) - return _c -} - -func (_c *MockAuthorizer_Evaluate_Call) RunAndReturn(run func(context.Context, string, interface{}, OpaEvaluator) (bool, context.Context, error)) *MockAuthorizer_Evaluate_Call { - _c.Call.Return(run) - return _c +// NewMockAuthorizer creates a new mock instance. +func NewMockAuthorizer(ctrl *gomock.Controller) *MockAuthorizer { + mock := &MockAuthorizer{ctrl: ctrl} + mock.recorder = &MockAuthorizerMockRecorder{mock} + return mock } -// OpaQuery provides a mock function with given fields: ctx, decisionDocument, opaReq, opaResp -func (_m *MockAuthorizer) OpaQuery(ctx context.Context, decisionDocument string, opaReq interface{}, opaResp interface{}) error { - ret := _m.Called(ctx, decisionDocument, opaReq, opaResp) - - if len(ret) == 0 { - panic("no return value specified for OpaQuery") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, interface{}) error); ok { - r0 = rf(ctx, decisionDocument, opaReq, opaResp) - } else { - r0 = ret.Error(0) - } - - return r0 +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAuthorizer) EXPECT() *MockAuthorizerMockRecorder { + return m.recorder } -// MockAuthorizer_OpaQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OpaQuery' -type MockAuthorizer_OpaQuery_Call struct { - *mock.Call +// AffirmAuthorization mocks base method. +func (m *MockAuthorizer) AffirmAuthorization(ctx context.Context, fullMethod string, eq interface{}) (context.Context, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AffirmAuthorization", ctx, fullMethod, eq) + ret0, _ := ret[0].(context.Context) + ret1, _ := ret[1].(error) + return ret0, ret1 } -// OpaQuery is a helper method to define mock.On call -// - ctx context.Context -// - decisionDocument string -// - opaReq interface{} -// - opaResp interface{} -func (_e *MockAuthorizer_Expecter) OpaQuery(ctx interface{}, decisionDocument interface{}, opaReq interface{}, opaResp interface{}) *MockAuthorizer_OpaQuery_Call { - return &MockAuthorizer_OpaQuery_Call{Call: _e.mock.On("OpaQuery", ctx, decisionDocument, opaReq, opaResp)} +// AffirmAuthorization indicates an expected call of AffirmAuthorization. +func (mr *MockAuthorizerMockRecorder) AffirmAuthorization(ctx, fullMethod, eq interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AffirmAuthorization", reflect.TypeOf((*MockAuthorizer)(nil).AffirmAuthorization), ctx, fullMethod, eq) } -func (_c *MockAuthorizer_OpaQuery_Call) Run(run func(ctx context.Context, decisionDocument string, opaReq interface{}, opaResp interface{})) *MockAuthorizer_OpaQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(interface{}), args[3].(interface{})) - }) - return _c +// Evaluate mocks base method. +func (m *MockAuthorizer) Evaluate(ctx context.Context, fullMethod string, req interface{}, opaEvaluator OpaEvaluator) (bool, context.Context, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Evaluate", ctx, fullMethod, req, opaEvaluator) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(context.Context) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 } -func (_c *MockAuthorizer_OpaQuery_Call) Return(_a0 error) *MockAuthorizer_OpaQuery_Call { - _c.Call.Return(_a0) - return _c +// Evaluate indicates an expected call of Evaluate. +func (mr *MockAuthorizerMockRecorder) Evaluate(ctx, fullMethod, req, opaEvaluator interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Evaluate", reflect.TypeOf((*MockAuthorizer)(nil).Evaluate), ctx, fullMethod, req, opaEvaluator) } -func (_c *MockAuthorizer_OpaQuery_Call) RunAndReturn(run func(context.Context, string, interface{}, interface{}) error) *MockAuthorizer_OpaQuery_Call { - _c.Call.Return(run) - return _c +// OpaQuery mocks base method. +func (m *MockAuthorizer) OpaQuery(ctx context.Context, decisionDocument string, opaReq, opaResp interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "OpaQuery", ctx, decisionDocument, opaReq, opaResp) + ret0, _ := ret[0].(error) + return ret0 } -// NewMockAuthorizer creates a new instance of MockAuthorizer. 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 NewMockAuthorizer(t interface { - mock.TestingT - Cleanup(func()) -}) *MockAuthorizer { - mock := &MockAuthorizer{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock +// OpaQuery indicates an expected call of OpaQuery. +func (mr *MockAuthorizerMockRecorder) OpaQuery(ctx, decisionDocument, opaReq, opaResp interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OpaQuery", reflect.TypeOf((*MockAuthorizer)(nil).OpaQuery), ctx, decisionDocument, opaReq, opaResp) } diff --git a/common/authorizer/mock_ClaimsVerifier.go b/common/authorizer/mock_ClaimsVerifier.go deleted file mode 100644 index 21141b6..0000000 --- a/common/authorizer/mock_ClaimsVerifier.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package authorizer - -import mock "github.com/stretchr/testify/mock" - -// MockClaimsVerifier is an autogenerated mock type for the ClaimsVerifier type -type MockClaimsVerifier struct { - mock.Mock -} - -type MockClaimsVerifier_Expecter struct { - mock *mock.Mock -} - -func (_m *MockClaimsVerifier) EXPECT() *MockClaimsVerifier_Expecter { - return &MockClaimsVerifier_Expecter{mock: &_m.Mock} -} - -// Execute provides a mock function with given fields: _a0, _a1 -func (_m *MockClaimsVerifier) Execute(_a0 []string, _a1 []string) (string, []error) { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for Execute") - } - - var r0 string - var r1 []error - if rf, ok := ret.Get(0).(func([]string, []string) (string, []error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func([]string, []string) string); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func([]string, []string) []error); ok { - r1 = rf(_a0, _a1) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).([]error) - } - } - - return r0, r1 -} - -// MockClaimsVerifier_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' -type MockClaimsVerifier_Execute_Call struct { - *mock.Call -} - -// Execute is a helper method to define mock.On call -// - _a0 []string -// - _a1 []string -func (_e *MockClaimsVerifier_Expecter) Execute(_a0 interface{}, _a1 interface{}) *MockClaimsVerifier_Execute_Call { - return &MockClaimsVerifier_Execute_Call{Call: _e.mock.On("Execute", _a0, _a1)} -} - -func (_c *MockClaimsVerifier_Execute_Call) Run(run func(_a0 []string, _a1 []string)) *MockClaimsVerifier_Execute_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].([]string), args[1].([]string)) - }) - return _c -} - -func (_c *MockClaimsVerifier_Execute_Call) Return(_a0 string, _a1 []error) *MockClaimsVerifier_Execute_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockClaimsVerifier_Execute_Call) RunAndReturn(run func([]string, []string) (string, []error)) *MockClaimsVerifier_Execute_Call { - _c.Call.Return(run) - return _c -} - -// NewMockClaimsVerifier creates a new instance of MockClaimsVerifier. 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 NewMockClaimsVerifier(t interface { - mock.TestingT - Cleanup(func()) -}) *MockClaimsVerifier { - mock := &MockClaimsVerifier{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/common/authorizer/mock_DecisionInputHandler.go b/common/authorizer/mock_DecisionInputHandler.go deleted file mode 100644 index 380af7a..0000000 --- a/common/authorizer/mock_DecisionInputHandler.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package authorizer - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// MockDecisionInputHandler is an autogenerated mock type for the DecisionInputHandler type -type MockDecisionInputHandler struct { - mock.Mock -} - -type MockDecisionInputHandler_Expecter struct { - mock *mock.Mock -} - -func (_m *MockDecisionInputHandler) EXPECT() *MockDecisionInputHandler_Expecter { - return &MockDecisionInputHandler_Expecter{mock: &_m.Mock} -} - -// GetDecisionInput provides a mock function with given fields: ctx, fullMethod, req -func (_m *MockDecisionInputHandler) GetDecisionInput(ctx context.Context, fullMethod string, req interface{}) (*DecisionInput, error) { - ret := _m.Called(ctx, fullMethod, req) - - if len(ret) == 0 { - panic("no return value specified for GetDecisionInput") - } - - var r0 *DecisionInput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}) (*DecisionInput, error)); ok { - return rf(ctx, fullMethod, req) - } - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}) *DecisionInput); ok { - r0 = rf(ctx, fullMethod, req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*DecisionInput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, interface{}) error); ok { - r1 = rf(ctx, fullMethod, req) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockDecisionInputHandler_GetDecisionInput_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDecisionInput' -type MockDecisionInputHandler_GetDecisionInput_Call struct { - *mock.Call -} - -// GetDecisionInput is a helper method to define mock.On call -// - ctx context.Context -// - fullMethod string -// - req interface{} -func (_e *MockDecisionInputHandler_Expecter) GetDecisionInput(ctx interface{}, fullMethod interface{}, req interface{}) *MockDecisionInputHandler_GetDecisionInput_Call { - return &MockDecisionInputHandler_GetDecisionInput_Call{Call: _e.mock.On("GetDecisionInput", ctx, fullMethod, req)} -} - -func (_c *MockDecisionInputHandler_GetDecisionInput_Call) Run(run func(ctx context.Context, fullMethod string, req interface{})) *MockDecisionInputHandler_GetDecisionInput_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(interface{})) - }) - return _c -} - -func (_c *MockDecisionInputHandler_GetDecisionInput_Call) Return(_a0 *DecisionInput, _a1 error) *MockDecisionInputHandler_GetDecisionInput_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockDecisionInputHandler_GetDecisionInput_Call) RunAndReturn(run func(context.Context, string, interface{}) (*DecisionInput, error)) *MockDecisionInputHandler_GetDecisionInput_Call { - _c.Call.Return(run) - return _c -} - -// NewMockDecisionInputHandler creates a new instance of MockDecisionInputHandler. 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 NewMockDecisionInputHandler(t interface { - mock.TestingT - Cleanup(func()) -}) *MockDecisionInputHandler { - mock := &MockDecisionInputHandler{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/common/authorizer/mock_OpaEvaluator.go b/common/authorizer/mock_OpaEvaluator.go deleted file mode 100644 index f385096..0000000 --- a/common/authorizer/mock_OpaEvaluator.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package authorizer - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// MockOpaEvaluator is an autogenerated mock type for the OpaEvaluator type -type MockOpaEvaluator struct { - mock.Mock -} - -type MockOpaEvaluator_Expecter struct { - mock *mock.Mock -} - -func (_m *MockOpaEvaluator) EXPECT() *MockOpaEvaluator_Expecter { - return &MockOpaEvaluator_Expecter{mock: &_m.Mock} -} - -// Execute provides a mock function with given fields: ctx, decisionDocument, opaReq, opaResp -func (_m *MockOpaEvaluator) Execute(ctx context.Context, decisionDocument string, opaReq interface{}, opaResp interface{}) error { - ret := _m.Called(ctx, decisionDocument, opaReq, opaResp) - - if len(ret) == 0 { - panic("no return value specified for Execute") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, interface{}) error); ok { - r0 = rf(ctx, decisionDocument, opaReq, opaResp) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockOpaEvaluator_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' -type MockOpaEvaluator_Execute_Call struct { - *mock.Call -} - -// Execute is a helper method to define mock.On call -// - ctx context.Context -// - decisionDocument string -// - opaReq interface{} -// - opaResp interface{} -func (_e *MockOpaEvaluator_Expecter) Execute(ctx interface{}, decisionDocument interface{}, opaReq interface{}, opaResp interface{}) *MockOpaEvaluator_Execute_Call { - return &MockOpaEvaluator_Execute_Call{Call: _e.mock.On("Execute", ctx, decisionDocument, opaReq, opaResp)} -} - -func (_c *MockOpaEvaluator_Execute_Call) Run(run func(ctx context.Context, decisionDocument string, opaReq interface{}, opaResp interface{})) *MockOpaEvaluator_Execute_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(interface{}), args[3].(interface{})) - }) - return _c -} - -func (_c *MockOpaEvaluator_Execute_Call) Return(_a0 error) *MockOpaEvaluator_Execute_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockOpaEvaluator_Execute_Call) RunAndReturn(run func(context.Context, string, interface{}, interface{}) error) *MockOpaEvaluator_Execute_Call { - _c.Call.Return(run) - return _c -} - -// NewMockOpaEvaluator creates a new instance of MockOpaEvaluator. 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 NewMockOpaEvaluator(t interface { - mock.TestingT - Cleanup(func()) -}) *MockOpaEvaluator { - mock := &MockOpaEvaluator{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/go.mod b/go.mod index 6b0a8c8..59155a5 100644 --- a/go.mod +++ b/go.mod @@ -1,24 +1,24 @@ module github.com/infobloxopen/atlas-authz-middleware/v2 -go 1.19 +go 1.18 require ( + github.com/golang/mock v1.6.0 github.com/google/uuid v1.3.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/infobloxopen/atlas-claims v1.0.0 github.com/infobloxopen/seal v0.2.3 github.com/open-policy-agent/opa v0.37.2 github.com/sirupsen/logrus v1.8.1 - github.com/stretchr/testify v1.7.0 - go.uber.org/multierr v1.6.0 golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd google.golang.org/grpc v1.44.0 ) +require github.com/google/go-cmp v0.5.9 // indirect + require ( github.com/OneOfOne/xxhash v1.2.8 // indirect github.com/bytecodealliance/wasmtime-go v0.34.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/getkin/kin-openapi v0.89.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/go-ini/ini v1.66.4 // indirect @@ -32,19 +32,16 @@ require ( github.com/mailru/easyjson v0.7.7 // indirect github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/stretchr/objx v0.1.1 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b // indirect go.opentelemetry.io/otel v1.4.1 // indirect go.opentelemetry.io/otel/trace v1.4.1 // indirect - go.uber.org/atomic v1.7.0 // indirect - golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect + golang.org/x/sys v0.1.0 // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gotest.tools/v3 v3.5.1 ) diff --git a/go.sum b/go.sum index 6729d25..3a96c44 100644 --- a/go.sum +++ b/go.sum @@ -192,6 +192,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -230,8 +231,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -446,7 +448,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -505,12 +506,10 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.opentelemetry.io/proto/otlp v0.11.0 h1:cLDgIBTf4lLOlztkhzAEdQsJ4Lj+i5Wc9k6Nn0K1VyU= go.opentelemetry.io/proto/otlp v0.11.0/go.mod h1:QpEjXPrNQzrFDZgoTo49dgHR9RYRSrg3NAKnUGl9YpQ= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= @@ -711,8 +710,8 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -786,7 +785,6 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -961,6 +959,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= +gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/http_opa/authorizer.go b/http_opa/authorizer.go index d6f2f7d..0e16541 100644 --- a/http_opa/authorizer.go +++ b/http_opa/authorizer.go @@ -3,6 +3,7 @@ package httpopa import ( "context" + "errors" "fmt" "net/http" "time" @@ -16,7 +17,6 @@ import ( "github.com/infobloxopen/atlas-authz-middleware/v2/http_opa/util" "github.com/infobloxopen/atlas-authz-middleware/v2/pkg/opa_client" log "github.com/sirupsen/logrus" - "go.uber.org/multierr" ) // SERVICENAME is the name of the OPA service. @@ -89,7 +89,7 @@ func (a *httpAuthorizer) Evaluate(ctx context.Context, endpoint string, req inte rawJWT, errs := claimsVerifier([]string{bearer}, nil) if len(errs) > 0 { return false, ctx, exception.NewHttpError( - exception.WithError(multierr.Combine(errs...)), + exception.WithError(errors.Join(errs...)), exception.WithHttpStatus(http.StatusUnauthorized)) } diff --git a/http_opa/exception/mock_ErrOpt.go b/http_opa/exception/mock_ErrOpt.go deleted file mode 100644 index 42c8bd5..0000000 --- a/http_opa/exception/mock_ErrOpt.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package exception - -import mock "github.com/stretchr/testify/mock" - -// MockErrOpt is an autogenerated mock type for the ErrOpt type -type MockErrOpt struct { - mock.Mock -} - -type MockErrOpt_Expecter struct { - mock *mock.Mock -} - -func (_m *MockErrOpt) EXPECT() *MockErrOpt_Expecter { - return &MockErrOpt_Expecter{mock: &_m.Mock} -} - -// Execute provides a mock function with given fields: he -func (_m *MockErrOpt) Execute(he *HttpError) { - _m.Called(he) -} - -// MockErrOpt_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' -type MockErrOpt_Execute_Call struct { - *mock.Call -} - -// Execute is a helper method to define mock.On call -// - he *HttpError -func (_e *MockErrOpt_Expecter) Execute(he interface{}) *MockErrOpt_Execute_Call { - return &MockErrOpt_Execute_Call{Call: _e.mock.On("Execute", he)} -} - -func (_c *MockErrOpt_Execute_Call) Run(run func(he *HttpError)) *MockErrOpt_Execute_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*HttpError)) - }) - return _c -} - -func (_c *MockErrOpt_Execute_Call) Return() *MockErrOpt_Execute_Call { - _c.Call.Return() - return _c -} - -func (_c *MockErrOpt_Execute_Call) RunAndReturn(run func(*HttpError)) *MockErrOpt_Execute_Call { - _c.Call.Return(run) - return _c -} - -// NewMockErrOpt creates a new instance of MockErrOpt. 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 NewMockErrOpt(t interface { - mock.TestingT - Cleanup(func()) -}) *MockErrOpt { - mock := &MockErrOpt{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/http_opa/middleware_test.go b/http_opa/middleware_test.go index e5c197f..61d3768 100644 --- a/http_opa/middleware_test.go +++ b/http_opa/middleware_test.go @@ -6,12 +6,18 @@ import ( "net/http/httptest" "testing" + "github.com/golang/mock/gomock" "github.com/infobloxopen/atlas-authz-middleware/v2/common/authorizer" "github.com/infobloxopen/atlas-authz-middleware/v2/http_opa/exception" - "github.com/stretchr/testify/assert" - mock "github.com/stretchr/testify/mock" + "gotest.tools/v3/assert" ) +// TestAuthzMiddleware is a unit test function that tests the behavior of the AuthzMiddleware function. +// It uses a table-driven approach to test different scenarios of authorized and unauthorized requests. +// The function takes a testing.T parameter for test assertions. +// The test cases include authorized and unauthorized requests with different application names and authorizer modifications. +// For each test case, it creates a new mock authorizer, modifies it based on the test case, and then runs the AuthzMiddleware function with the modified authorizer. +// Finally, it asserts the expected authorization result based on the test case. func TestAuthzMiddleware(t *testing.T) { testCases := []struct { name string @@ -24,7 +30,7 @@ func TestAuthzMiddleware(t *testing.T) { name: "Authorized request", application: "testApp", modifyAuthorizer: func(ma *authorizer.MockAuthorizer) { - ma.On("Evaluate", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(true, context.Background(), nil) + ma.EXPECT().Evaluate(context.Background(), gomock.Any(), gomock.Any(), gomock.Any()).Return(true, context.Background(), nil) }, expectAuth: true, }, @@ -32,7 +38,7 @@ func TestAuthzMiddleware(t *testing.T) { name: "Unauthorized request", application: "testApp", modifyAuthorizer: func(ma *authorizer.MockAuthorizer) { - ma.On("Evaluate", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(false, context.Background(), exception.ErrForbidden) + ma.EXPECT().Evaluate(context.Background(), gomock.Any(), gomock.Any(), gomock.Any()).Return(false, context.Background(), exception.ErrForbidden) }, expectAuth: false, }, @@ -41,10 +47,13 @@ func TestAuthzMiddleware(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + ma := authorizer.NewMockAuthorizer(ctrl) handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { }) - ma := &authorizer.MockAuthorizer{} tc.modifyAuthorizer(ma) tc.opts = append(tc.opts, WithAuthorizer(ma)) @@ -55,7 +64,9 @@ func TestAuthzMiddleware(t *testing.T) { rr := httptest.NewRecorder() middleware(handler).ServeHTTP(rr, request) + assert.Equal(t, tc.expectAuth, rr.Code == http.StatusOK, "Expected authorized request") + }) } } diff --git a/http_opa/mock_Option.go b/http_opa/mock_Option.go deleted file mode 100644 index faeb338..0000000 --- a/http_opa/mock_Option.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package httpopa - -import mock "github.com/stretchr/testify/mock" - -// MockOption is an autogenerated mock type for the Option type -type MockOption struct { - mock.Mock -} - -type MockOption_Expecter struct { - mock *mock.Mock -} - -func (_m *MockOption) EXPECT() *MockOption_Expecter { - return &MockOption_Expecter{mock: &_m.Mock} -} - -// Execute provides a mock function with given fields: c -func (_m *MockOption) Execute(c *Config) { - _m.Called(c) -} - -// MockOption_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' -type MockOption_Execute_Call struct { - *mock.Call -} - -// Execute is a helper method to define mock.On call -// - c *Config -func (_e *MockOption_Expecter) Execute(c interface{}) *MockOption_Execute_Call { - return &MockOption_Execute_Call{Call: _e.mock.On("Execute", c)} -} - -func (_c *MockOption_Execute_Call) Run(run func(c *Config)) *MockOption_Execute_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*Config)) - }) - return _c -} - -func (_c *MockOption_Execute_Call) Return() *MockOption_Execute_Call { - _c.Call.Return() - return _c -} - -func (_c *MockOption_Execute_Call) RunAndReturn(run func(*Config)) *MockOption_Execute_Call { - _c.Call.Return(run) - return _c -} - -// NewMockOption creates a new instance of MockOption. 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 NewMockOption(t interface { - mock.TestingT - Cleanup(func()) -}) *MockOption { - mock := &MockOption{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/opa_client/mock_Clienter.go b/pkg/opa_client/mock_Clienter.go deleted file mode 100644 index 5d7af9e..0000000 --- a/pkg/opa_client/mock_Clienter.go +++ /dev/null @@ -1,332 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package opa_client - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// MockClienter is an autogenerated mock type for the Clienter type -type MockClienter struct { - mock.Mock -} - -type MockClienter_Expecter struct { - mock *mock.Mock -} - -func (_m *MockClienter) EXPECT() *MockClienter_Expecter { - return &MockClienter_Expecter{mock: &_m.Mock} -} - -// Address provides a mock function with given fields: -func (_m *MockClienter) Address() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Address") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockClienter_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' -type MockClienter_Address_Call struct { - *mock.Call -} - -// Address is a helper method to define mock.On call -func (_e *MockClienter_Expecter) Address() *MockClienter_Address_Call { - return &MockClienter_Address_Call{Call: _e.mock.On("Address")} -} - -func (_c *MockClienter_Address_Call) Run(run func()) *MockClienter_Address_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockClienter_Address_Call) Return(_a0 string) *MockClienter_Address_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClienter_Address_Call) RunAndReturn(run func() string) *MockClienter_Address_Call { - _c.Call.Return(run) - return _c -} - -// CustomQuery provides a mock function with given fields: ctx, document, reqData, resp -func (_m *MockClienter) CustomQuery(ctx context.Context, document string, reqData interface{}, resp interface{}) error { - ret := _m.Called(ctx, document, reqData, resp) - - if len(ret) == 0 { - panic("no return value specified for CustomQuery") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}, interface{}) error); ok { - r0 = rf(ctx, document, reqData, resp) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClienter_CustomQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CustomQuery' -type MockClienter_CustomQuery_Call struct { - *mock.Call -} - -// CustomQuery is a helper method to define mock.On call -// - ctx context.Context -// - document string -// - reqData interface{} -// - resp interface{} -func (_e *MockClienter_Expecter) CustomQuery(ctx interface{}, document interface{}, reqData interface{}, resp interface{}) *MockClienter_CustomQuery_Call { - return &MockClienter_CustomQuery_Call{Call: _e.mock.On("CustomQuery", ctx, document, reqData, resp)} -} - -func (_c *MockClienter_CustomQuery_Call) Run(run func(ctx context.Context, document string, reqData interface{}, resp interface{})) *MockClienter_CustomQuery_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(interface{}), args[3].(interface{})) - }) - return _c -} - -func (_c *MockClienter_CustomQuery_Call) Return(_a0 error) *MockClienter_CustomQuery_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClienter_CustomQuery_Call) RunAndReturn(run func(context.Context, string, interface{}, interface{}) error) *MockClienter_CustomQuery_Call { - _c.Call.Return(run) - return _c -} - -// CustomQueryBytes provides a mock function with given fields: ctx, document, reqData -func (_m *MockClienter) CustomQueryBytes(ctx context.Context, document string, reqData interface{}) ([]byte, error) { - ret := _m.Called(ctx, document, reqData) - - if len(ret) == 0 { - panic("no return value specified for CustomQueryBytes") - } - - var r0 []byte - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}) ([]byte, error)); ok { - return rf(ctx, document, reqData) - } - if rf, ok := ret.Get(0).(func(context.Context, string, interface{}) []byte); ok { - r0 = rf(ctx, document, reqData) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, interface{}) error); ok { - r1 = rf(ctx, document, reqData) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockClienter_CustomQueryBytes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CustomQueryBytes' -type MockClienter_CustomQueryBytes_Call struct { - *mock.Call -} - -// CustomQueryBytes is a helper method to define mock.On call -// - ctx context.Context -// - document string -// - reqData interface{} -func (_e *MockClienter_Expecter) CustomQueryBytes(ctx interface{}, document interface{}, reqData interface{}) *MockClienter_CustomQueryBytes_Call { - return &MockClienter_CustomQueryBytes_Call{Call: _e.mock.On("CustomQueryBytes", ctx, document, reqData)} -} - -func (_c *MockClienter_CustomQueryBytes_Call) Run(run func(ctx context.Context, document string, reqData interface{})) *MockClienter_CustomQueryBytes_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(interface{})) - }) - return _c -} - -func (_c *MockClienter_CustomQueryBytes_Call) Return(_a0 []byte, _a1 error) *MockClienter_CustomQueryBytes_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockClienter_CustomQueryBytes_Call) RunAndReturn(run func(context.Context, string, interface{}) ([]byte, error)) *MockClienter_CustomQueryBytes_Call { - _c.Call.Return(run) - return _c -} - -// CustomQueryStream provides a mock function with given fields: ctx, document, postReqBody, respRdrFn -func (_m *MockClienter) CustomQueryStream(ctx context.Context, document string, postReqBody []byte, respRdrFn StreamReaderFn) error { - ret := _m.Called(ctx, document, postReqBody, respRdrFn) - - if len(ret) == 0 { - panic("no return value specified for CustomQueryStream") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, []byte, StreamReaderFn) error); ok { - r0 = rf(ctx, document, postReqBody, respRdrFn) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClienter_CustomQueryStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CustomQueryStream' -type MockClienter_CustomQueryStream_Call struct { - *mock.Call -} - -// CustomQueryStream is a helper method to define mock.On call -// - ctx context.Context -// - document string -// - postReqBody []byte -// - respRdrFn StreamReaderFn -func (_e *MockClienter_Expecter) CustomQueryStream(ctx interface{}, document interface{}, postReqBody interface{}, respRdrFn interface{}) *MockClienter_CustomQueryStream_Call { - return &MockClienter_CustomQueryStream_Call{Call: _e.mock.On("CustomQueryStream", ctx, document, postReqBody, respRdrFn)} -} - -func (_c *MockClienter_CustomQueryStream_Call) Run(run func(ctx context.Context, document string, postReqBody []byte, respRdrFn StreamReaderFn)) *MockClienter_CustomQueryStream_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].([]byte), args[3].(StreamReaderFn)) - }) - return _c -} - -func (_c *MockClienter_CustomQueryStream_Call) Return(_a0 error) *MockClienter_CustomQueryStream_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClienter_CustomQueryStream_Call) RunAndReturn(run func(context.Context, string, []byte, StreamReaderFn) error) *MockClienter_CustomQueryStream_Call { - _c.Call.Return(run) - return _c -} - -// Health provides a mock function with given fields: -func (_m *MockClienter) Health() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Health") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClienter_Health_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Health' -type MockClienter_Health_Call struct { - *mock.Call -} - -// Health is a helper method to define mock.On call -func (_e *MockClienter_Expecter) Health() *MockClienter_Health_Call { - return &MockClienter_Health_Call{Call: _e.mock.On("Health")} -} - -func (_c *MockClienter_Health_Call) Run(run func()) *MockClienter_Health_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockClienter_Health_Call) Return(_a0 error) *MockClienter_Health_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClienter_Health_Call) RunAndReturn(run func() error) *MockClienter_Health_Call { - _c.Call.Return(run) - return _c -} - -// Query provides a mock function with given fields: ctx, reqData, resp -func (_m *MockClienter) Query(ctx context.Context, reqData interface{}, resp interface{}) error { - ret := _m.Called(ctx, reqData, resp) - - if len(ret) == 0 { - panic("no return value specified for Query") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, interface{}, interface{}) error); ok { - r0 = rf(ctx, reqData, resp) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClienter_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query' -type MockClienter_Query_Call struct { - *mock.Call -} - -// Query is a helper method to define mock.On call -// - ctx context.Context -// - reqData interface{} -// - resp interface{} -func (_e *MockClienter_Expecter) Query(ctx interface{}, reqData interface{}, resp interface{}) *MockClienter_Query_Call { - return &MockClienter_Query_Call{Call: _e.mock.On("Query", ctx, reqData, resp)} -} - -func (_c *MockClienter_Query_Call) Run(run func(ctx context.Context, reqData interface{}, resp interface{})) *MockClienter_Query_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(interface{}), args[2].(interface{})) - }) - return _c -} - -func (_c *MockClienter_Query_Call) Return(_a0 error) *MockClienter_Query_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClienter_Query_Call) RunAndReturn(run func(context.Context, interface{}, interface{}) error) *MockClienter_Query_Call { - _c.Call.Return(run) - return _c -} - -// NewMockClienter creates a new instance of MockClienter. 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 NewMockClienter(t interface { - mock.TestingT - Cleanup(func()) -}) *MockClienter { - mock := &MockClienter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/opa_client/mock_Option.go b/pkg/opa_client/mock_Option.go deleted file mode 100644 index 30bff43..0000000 --- a/pkg/opa_client/mock_Option.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package opa_client - -import mock "github.com/stretchr/testify/mock" - -// MockOption is an autogenerated mock type for the Option type -type MockOption struct { - mock.Mock -} - -type MockOption_Expecter struct { - mock *mock.Mock -} - -func (_m *MockOption) EXPECT() *MockOption_Expecter { - return &MockOption_Expecter{mock: &_m.Mock} -} - -// Execute provides a mock function with given fields: c -func (_m *MockOption) Execute(c *Client) { - _m.Called(c) -} - -// MockOption_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' -type MockOption_Execute_Call struct { - *mock.Call -} - -// Execute is a helper method to define mock.On call -// - c *Client -func (_e *MockOption_Expecter) Execute(c interface{}) *MockOption_Execute_Call { - return &MockOption_Execute_Call{Call: _e.mock.On("Execute", c)} -} - -func (_c *MockOption_Execute_Call) Run(run func(c *Client)) *MockOption_Execute_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*Client)) - }) - return _c -} - -func (_c *MockOption_Execute_Call) Return() *MockOption_Execute_Call { - _c.Call.Return() - return _c -} - -func (_c *MockOption_Execute_Call) RunAndReturn(run func(*Client)) *MockOption_Execute_Call { - _c.Call.Return(run) - return _c -} - -// NewMockOption creates a new instance of MockOption. 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 NewMockOption(t interface { - mock.TestingT - Cleanup(func()) -}) *MockOption { - mock := &MockOption{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/opa_client/mock_StreamReaderFn.go b/pkg/opa_client/mock_StreamReaderFn.go deleted file mode 100644 index 0e18419..0000000 --- a/pkg/opa_client/mock_StreamReaderFn.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. - -package opa_client - -import ( - io "io" - - mock "github.com/stretchr/testify/mock" -) - -// MockStreamReaderFn is an autogenerated mock type for the StreamReaderFn type -type MockStreamReaderFn struct { - mock.Mock -} - -type MockStreamReaderFn_Expecter struct { - mock *mock.Mock -} - -func (_m *MockStreamReaderFn) EXPECT() *MockStreamReaderFn_Expecter { - return &MockStreamReaderFn_Expecter{mock: &_m.Mock} -} - -// Execute provides a mock function with given fields: _a0 -func (_m *MockStreamReaderFn) Execute(_a0 io.Reader) error { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for Execute") - } - - var r0 error - if rf, ok := ret.Get(0).(func(io.Reader) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockStreamReaderFn_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' -type MockStreamReaderFn_Execute_Call struct { - *mock.Call -} - -// Execute is a helper method to define mock.On call -// - _a0 io.Reader -func (_e *MockStreamReaderFn_Expecter) Execute(_a0 interface{}) *MockStreamReaderFn_Execute_Call { - return &MockStreamReaderFn_Execute_Call{Call: _e.mock.On("Execute", _a0)} -} - -func (_c *MockStreamReaderFn_Execute_Call) Run(run func(_a0 io.Reader)) *MockStreamReaderFn_Execute_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(io.Reader)) - }) - return _c -} - -func (_c *MockStreamReaderFn_Execute_Call) Return(_a0 error) *MockStreamReaderFn_Execute_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockStreamReaderFn_Execute_Call) RunAndReturn(run func(io.Reader) error) *MockStreamReaderFn_Execute_Call { - _c.Call.Return(run) - return _c -} - -// NewMockStreamReaderFn creates a new instance of MockStreamReaderFn. 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 NewMockStreamReaderFn(t interface { - mock.TestingT - Cleanup(func()) -}) *MockStreamReaderFn { - mock := &MockStreamReaderFn{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}