From 5da0e32d2da138a94720cb576785f80b663e2d31 Mon Sep 17 00:00:00 2001 From: Mart Aarma Date: Thu, 6 Apr 2023 11:13:54 +0300 Subject: [PATCH] fix: consent manager mock --- consent/handler_test.go | 2 +- consent/manager_mock_test.go | 124 ++++++++++++++--------------------- 2 files changed, 52 insertions(+), 74 deletions(-) diff --git a/consent/handler_test.go b/consent/handler_test.go index f74009e2ea9..c9eda49da5d 100644 --- a/consent/handler_test.go +++ b/consent/handler_test.go @@ -18,7 +18,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/tidwall/gjson" - "github.com/ory/hydra/driver" + "github.com/ory/hydra/v2/driver" "github.com/ory/x/pointerx" diff --git a/consent/manager_mock_test.go b/consent/manager_mock_test.go index 7088bbce2d5..c12e474e4f2 100644 --- a/consent/manager_mock_test.go +++ b/consent/manager_mock_test.go @@ -1,8 +1,9 @@ -// Copyright © 2022 Ory Corp +// Copyright © 2023 Ory Corp // SPDX-License-Identifier: Apache-2.0 // Code generated by MockGen. DO NOT EDIT. // Source: consent/manager.go + // Package mock_consent is a generated GoMock package. package consent_test @@ -15,13 +16,13 @@ import ( "gopkg.in/square/go-jose.v2" "github.com/ory/fosite" - "github.com/ory/hydra/consent" - "github.com/ory/hydra/oauth2/trust" + "github.com/ory/hydra/v2/oauth2/trust" "github.com/ory/x/popx" gomock "github.com/golang/mock/gomock" - client "github.com/ory/hydra/client" + client "github.com/ory/hydra/v2/client" + consent "github.com/ory/hydra/v2/consent" ) // MockManager is a mock of Manager interface. @@ -205,6 +206,21 @@ func (mr *MockManagerMockRecorder) FindSubjectsGrantedConsentRequests(ctx, user, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindSubjectsGrantedConsentRequests", reflect.TypeOf((*MockManager)(nil).FindSubjectsGrantedConsentRequests), ctx, user, limit, offset) } +// FindSubjectsSessionGrantedConsentRequests mocks base method. +func (m *MockManager) FindSubjectsSessionGrantedConsentRequests(ctx context.Context, user, sid string, limit, offset int) ([]consent.AcceptOAuth2ConsentRequest, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindSubjectsSessionGrantedConsentRequests", ctx, user, sid, limit, offset) + ret0, _ := ret[0].([]consent.AcceptOAuth2ConsentRequest) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindSubjectsSessionGrantedConsentRequests indicates an expected call of FindSubjectsSessionGrantedConsentRequests. +func (mr *MockManagerMockRecorder) FindSubjectsSessionGrantedConsentRequests(ctx, user, sid, limit, offset interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindSubjectsSessionGrantedConsentRequests", reflect.TypeOf((*MockManager)(nil).FindSubjectsSessionGrantedConsentRequests), ctx, user, sid, limit, offset) +} + // GetConsentRequest mocks base method. func (m *MockManager) GetConsentRequest(ctx context.Context, challenge string) (*consent.OAuth2ConsentRequest, error) { m.ctrl.T.Helper() @@ -281,18 +297,18 @@ func (mr *MockManagerMockRecorder) GetRememberedLoginSession(ctx, id interface{} } // HandleConsentRequest mocks base method. -func (m *MockManager) HandleConsentRequest(ctx context.Context, challenge string, r *consent.AcceptOAuth2ConsentRequest) (*consent.OAuth2ConsentRequest, error) { +func (m *MockManager) HandleConsentRequest(ctx context.Context, r *consent.AcceptOAuth2ConsentRequest) (*consent.OAuth2ConsentRequest, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "HandleConsentRequest", ctx, challenge, r) + ret := m.ctrl.Call(m, "HandleConsentRequest", ctx, r) ret0, _ := ret[0].(*consent.OAuth2ConsentRequest) ret1, _ := ret[1].(error) return ret0, ret1 } // HandleConsentRequest indicates an expected call of HandleConsentRequest. -func (mr *MockManagerMockRecorder) HandleConsentRequest(ctx, challenge, r interface{}) *gomock.Call { +func (mr *MockManagerMockRecorder) HandleConsentRequest(ctx, r interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleConsentRequest", reflect.TypeOf((*MockManager)(nil).HandleConsentRequest), ctx, challenge, r) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HandleConsentRequest", reflect.TypeOf((*MockManager)(nil).HandleConsentRequest), ctx, r) } // HandleLoginRequest mocks base method. @@ -311,48 +327,33 @@ func (mr *MockManagerMockRecorder) HandleLoginRequest(ctx, challenge, r interfac } // ListUserAuthenticatedClientsWithBackChannelLogout mocks base method. -func (m *MockManager) ListUserAuthenticatedClientsWithBackChannelLogout(ctx context.Context, subject string) ([]client.LoginSessionClient, error) { +func (m *MockManager) ListUserAuthenticatedClientsWithBackChannelLogout(ctx context.Context, subject, sid string) ([]client.Client, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListUserAuthenticatedClientsWithBackChannelLogout", ctx, subject) - ret0, _ := ret[0].([]client.LoginSessionClient) + ret := m.ctrl.Call(m, "ListUserAuthenticatedClientsWithBackChannelLogout", ctx, subject, sid) + ret0, _ := ret[0].([]client.Client) ret1, _ := ret[1].(error) return ret0, ret1 } // ListUserAuthenticatedClientsWithBackChannelLogout indicates an expected call of ListUserAuthenticatedClientsWithBackChannelLogout. -func (mr *MockManagerMockRecorder) ListUserAuthenticatedClientsWithBackChannelLogout(ctx, subject interface{}) *gomock.Call { +func (mr *MockManagerMockRecorder) ListUserAuthenticatedClientsWithBackChannelLogout(ctx, subject, sid interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUserAuthenticatedClientsWithBackChannelLogout", reflect.TypeOf((*MockManager)(nil).ListUserAuthenticatedClientsWithBackChannelLogout), ctx, subject) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUserAuthenticatedClientsWithBackChannelLogout", reflect.TypeOf((*MockManager)(nil).ListUserAuthenticatedClientsWithBackChannelLogout), ctx, subject, sid) } -// ListUserSessionAuthenticatedClientsWithBackChannelLogout mocks base method. -func (m *MockManager) ListUserSessionAuthenticatedClientsWithBackChannelLogout(ctx context.Context, subject, sid string) ([]client.LoginSessionClient, error) { +// ListUserAuthenticatedClientsWithFrontChannelLogout mocks base method. +func (m *MockManager) ListUserAuthenticatedClientsWithFrontChannelLogout(ctx context.Context, subject, sid string) ([]client.Client, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListUserSessionAuthenticatedClientsWithBackChannelLogout", ctx, subject, sid) - ret0, _ := ret[0].([]client.LoginSessionClient) + ret := m.ctrl.Call(m, "ListUserAuthenticatedClientsWithFrontChannelLogout", ctx, subject, sid) + ret0, _ := ret[0].([]client.Client) ret1, _ := ret[1].(error) return ret0, ret1 } -// ListUserSessionAuthenticatedClientsWithBackChannelLogout indicates an expected call of ListUserSessionAuthenticatedClientsWithBackChannelLogout. -func (mr *MockManagerMockRecorder) ListUserSessionAuthenticatedClientsWithBackChannelLogout(ctx, subject, sid interface{}) *gomock.Call { +// ListUserAuthenticatedClientsWithFrontChannelLogout indicates an expected call of ListUserAuthenticatedClientsWithFrontChannelLogout. +func (mr *MockManagerMockRecorder) ListUserAuthenticatedClientsWithFrontChannelLogout(ctx, subject, sid interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUserSessionAuthenticatedClientsWithBackChannelLogout", reflect.TypeOf((*MockManager)(nil).ListUserSessionAuthenticatedClientsWithBackChannelLogout), ctx, subject, sid) -} - -// ListUserSessionAuthenticatedClientsWithFrontChannelLogout mocks base method. -func (m *MockManager) ListUserSessionAuthenticatedClientsWithFrontChannelLogout(ctx context.Context, subject, sid string) ([]client.LoginSessionClient, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListUserSessionAuthenticatedClientsWithFrontChannelLogout", ctx, subject, sid) - ret0, _ := ret[0].([]client.LoginSessionClient) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ListUserSessionAuthenticatedClientsWithFrontChannelLogout indicates an expected call of ListUserSessionAuthenticatedClientsWithFrontChannelLogout. -func (mr *MockManagerMockRecorder) ListUserSessionAuthenticatedClientsWithFrontChannelLogout(ctx, subject, sid interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUserSessionAuthenticatedClientsWithFrontChannelLogout", reflect.TypeOf((*MockManager)(nil).ListUserSessionAuthenticatedClientsWithFrontChannelLogout), ctx, subject, sid) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListUserAuthenticatedClientsWithFrontChannelLogout", reflect.TypeOf((*MockManager)(nil).ListUserAuthenticatedClientsWithFrontChannelLogout), ctx, subject, sid) } // RejectLogoutRequest mocks base method. @@ -369,20 +370,6 @@ func (mr *MockManagerMockRecorder) RejectLogoutRequest(ctx, challenge interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RejectLogoutRequest", reflect.TypeOf((*MockManager)(nil).RejectLogoutRequest), ctx, challenge) } -// RevokeLoginSessionConsentSession mocks base method. -func (m *MockManager) RevokeLoginSessionConsentSession(ctx context.Context, loginSessionId string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RevokeLoginSessionConsentSession", ctx, loginSessionId) - ret0, _ := ret[0].(error) - return ret0 -} - -// RevokeLoginSessionConsentSession indicates an expected call of RevokeLoginSessionConsentSession. -func (mr *MockManagerMockRecorder) RevokeLoginSessionConsentSession(ctx, loginSessionId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeLoginSessionConsentSession", reflect.TypeOf((*MockManager)(nil).RevokeLoginSessionConsentSession), ctx, loginSessionId) -} - // RevokeSubjectClientConsentSession mocks base method. func (m *MockManager) RevokeSubjectClientConsentSession(ctx context.Context, user, client string) error { m.ctrl.T.Helper() @@ -397,20 +384,6 @@ func (mr *MockManagerMockRecorder) RevokeSubjectClientConsentSession(ctx, user, return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeSubjectClientConsentSession", reflect.TypeOf((*MockManager)(nil).RevokeSubjectClientConsentSession), ctx, user, client) } -// RevokeSubjectClientLoginSessionConsentSession mocks base method. -func (m *MockManager) RevokeSubjectClientLoginSessionConsentSession(ctx context.Context, user, client, loginSessionId string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RevokeSubjectClientLoginSessionConsentSession", ctx, user, client, loginSessionId) - ret0, _ := ret[0].(error) - return ret0 -} - -// RevokeSubjectClientLoginSessionConsentSession indicates an expected call of RevokeSubjectClientLoginSessionConsentSession. -func (mr *MockManagerMockRecorder) RevokeSubjectClientLoginSessionConsentSession(ctx, user, client, loginSessionId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevokeSubjectClientLoginSessionConsentSession", reflect.TypeOf((*MockManager)(nil).RevokeSubjectClientLoginSessionConsentSession), ctx, user, client, loginSessionId) -} - // RevokeSubjectConsentSession mocks base method. func (m *MockManager) RevokeSubjectConsentSession(ctx context.Context, user string) error { m.ctrl.T.Helper() @@ -484,6 +457,11 @@ func (mr *MockManagerMockRecorder) VerifyAndInvalidateLogoutRequest(ctx, verifie return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyAndInvalidateLogoutRequest", reflect.TypeOf((*MockManager)(nil).VerifyAndInvalidateLogoutRequest), ctx, verifier) } +func (m *MockManager) GetClient(ctx context.Context, id string) (fosite.Client, error) { + //TODO implement me + panic("implement me") +} + func (m *MockManager) CreateClient(ctx context.Context, c *client.Client) error { //TODO implement me panic("implement me") @@ -519,11 +497,6 @@ func (m *MockManager) Authenticate(ctx context.Context, id string, secret []byte panic("implement me") } -func (m *MockManager) GetClient(ctx context.Context, id string) (fosite.Client, error) { - //TODO implement me - panic("implement me") -} - func (m *MockManager) ClientAssertionJWTValid(ctx context.Context, jti string) error { //TODO implement me panic("implement me") @@ -589,6 +562,11 @@ func (m *MockManager) GetOpenIDConnectSession(ctx context.Context, authorizeCode panic("implement me") } +func (m *MockManager) DeleteOpenIDConnectSession(ctx context.Context, authorizeCode string) error { + //TODO implement me + panic("implement me") +} + func (m *MockManager) GetPKCERequestSession(ctx context.Context, signature string, session fosite.Session) (fosite.Requester, error) { //TODO implement me panic("implement me") @@ -659,11 +637,6 @@ func (m *MockManager) FlushInactiveRefreshTokens(ctx context.Context, notAfter t panic("implement me") } -func (m *MockManager) DeleteOpenIDConnectSession(ctx context.Context, authorizeCode string) error { - //TODO implement me - panic("implement me") -} - func (m *MockManager) GenerateAndPersistKeySet(ctx context.Context, set, kid, alg, use string) (*jose.JSONWebKeySet, error) { //TODO implement me panic("implement me") @@ -763,3 +736,8 @@ func (m *MockManager) Connection(ctx context.Context) *pop.Connection { //TODO implement me panic("implement me") } + +func (m *MockManager) Ping() error { + //TODO implement me + panic("implement me") +}