Files
zitadel/backend/v3/domain/mock/permission.mock.go
T
8b90ddb0b5 feat(session): User Check API with relation tables (#11777)
# Which Problems Are Solved

As part of #11035 , this PR implements the user check logic for session
validation

# How the Problems Are Solved

- Add user and session repositories as invoke options, as well as their
mocks to prepare the ground for testing
- Implement the logic for the UserCheck command, following what has been
done on eventstore side
- Add a session permission chek interface to be used during the
`Validate()` part of the Commander

# Additional Context

This is a cherry-picked PR + minor changes, coming from
https://github.com/zitadel/zitadel/pull/11164
- Relates to #11035

---------

Co-authored-by: Silvan <[email protected]>
2026-03-10 09:10:31 +00:00

232 lines
9.4 KiB
Go

// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/zitadel/zitadel/backend/v3/domain (interfaces: PermissionChecker)
//
// Generated by this command:
//
// mockgen -typed -package domainmock -destination ./mock/permission.mock.go . PermissionChecker
//
// Package domainmock is a generated GoMock package.
package domainmock
import (
context "context"
reflect "reflect"
gomock "go.uber.org/mock/gomock"
)
// MockPermissionChecker is a mock of PermissionChecker interface.
type MockPermissionChecker struct {
ctrl *gomock.Controller
recorder *MockPermissionCheckerMockRecorder
isgomock struct{}
}
// MockPermissionCheckerMockRecorder is the mock recorder for MockPermissionChecker.
type MockPermissionCheckerMockRecorder struct {
mock *MockPermissionChecker
}
// NewMockPermissionChecker creates a new mock instance.
func NewMockPermissionChecker(ctrl *gomock.Controller) *MockPermissionChecker {
mock := &MockPermissionChecker{ctrl: ctrl}
mock.recorder = &MockPermissionCheckerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockPermissionChecker) EXPECT() *MockPermissionCheckerMockRecorder {
return m.recorder
}
// CheckInstancePermission mocks base method.
func (m *MockPermissionChecker) CheckInstancePermission(ctx context.Context, permission string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CheckInstancePermission", ctx, permission)
ret0, _ := ret[0].(error)
return ret0
}
// CheckInstancePermission indicates an expected call of CheckInstancePermission.
func (mr *MockPermissionCheckerMockRecorder) CheckInstancePermission(ctx, permission any) *MockPermissionCheckerCheckInstancePermissionCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckInstancePermission", reflect.TypeOf((*MockPermissionChecker)(nil).CheckInstancePermission), ctx, permission)
return &MockPermissionCheckerCheckInstancePermissionCall{Call: call}
}
// MockPermissionCheckerCheckInstancePermissionCall wrap *gomock.Call
type MockPermissionCheckerCheckInstancePermissionCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockPermissionCheckerCheckInstancePermissionCall) Return(arg0 error) *MockPermissionCheckerCheckInstancePermissionCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockPermissionCheckerCheckInstancePermissionCall) Do(f func(context.Context, string) error) *MockPermissionCheckerCheckInstancePermissionCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockPermissionCheckerCheckInstancePermissionCall) DoAndReturn(f func(context.Context, string) error) *MockPermissionCheckerCheckInstancePermissionCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CheckOrganizationPermission mocks base method.
func (m *MockPermissionChecker) CheckOrganizationPermission(ctx context.Context, permission, orgID string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CheckOrganizationPermission", ctx, permission, orgID)
ret0, _ := ret[0].(error)
return ret0
}
// CheckOrganizationPermission indicates an expected call of CheckOrganizationPermission.
func (mr *MockPermissionCheckerMockRecorder) CheckOrganizationPermission(ctx, permission, orgID any) *MockPermissionCheckerCheckOrganizationPermissionCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckOrganizationPermission", reflect.TypeOf((*MockPermissionChecker)(nil).CheckOrganizationPermission), ctx, permission, orgID)
return &MockPermissionCheckerCheckOrganizationPermissionCall{Call: call}
}
// MockPermissionCheckerCheckOrganizationPermissionCall wrap *gomock.Call
type MockPermissionCheckerCheckOrganizationPermissionCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockPermissionCheckerCheckOrganizationPermissionCall) Return(arg0 error) *MockPermissionCheckerCheckOrganizationPermissionCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockPermissionCheckerCheckOrganizationPermissionCall) Do(f func(context.Context, string, string) error) *MockPermissionCheckerCheckOrganizationPermissionCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockPermissionCheckerCheckOrganizationPermissionCall) DoAndReturn(f func(context.Context, string, string) error) *MockPermissionCheckerCheckOrganizationPermissionCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CheckProjectGrantPermission mocks base method.
func (m *MockPermissionChecker) CheckProjectGrantPermission(ctx context.Context, permission, projectGrantID string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CheckProjectGrantPermission", ctx, permission, projectGrantID)
ret0, _ := ret[0].(error)
return ret0
}
// CheckProjectGrantPermission indicates an expected call of CheckProjectGrantPermission.
func (mr *MockPermissionCheckerMockRecorder) CheckProjectGrantPermission(ctx, permission, projectGrantID any) *MockPermissionCheckerCheckProjectGrantPermissionCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckProjectGrantPermission", reflect.TypeOf((*MockPermissionChecker)(nil).CheckProjectGrantPermission), ctx, permission, projectGrantID)
return &MockPermissionCheckerCheckProjectGrantPermissionCall{Call: call}
}
// MockPermissionCheckerCheckProjectGrantPermissionCall wrap *gomock.Call
type MockPermissionCheckerCheckProjectGrantPermissionCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockPermissionCheckerCheckProjectGrantPermissionCall) Return(arg0 error) *MockPermissionCheckerCheckProjectGrantPermissionCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockPermissionCheckerCheckProjectGrantPermissionCall) Do(f func(context.Context, string, string) error) *MockPermissionCheckerCheckProjectGrantPermissionCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockPermissionCheckerCheckProjectGrantPermissionCall) DoAndReturn(f func(context.Context, string, string) error) *MockPermissionCheckerCheckProjectGrantPermissionCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CheckProjectPermission mocks base method.
func (m *MockPermissionChecker) CheckProjectPermission(ctx context.Context, permission, projectID string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CheckProjectPermission", ctx, permission, projectID)
ret0, _ := ret[0].(error)
return ret0
}
// CheckProjectPermission indicates an expected call of CheckProjectPermission.
func (mr *MockPermissionCheckerMockRecorder) CheckProjectPermission(ctx, permission, projectID any) *MockPermissionCheckerCheckProjectPermissionCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckProjectPermission", reflect.TypeOf((*MockPermissionChecker)(nil).CheckProjectPermission), ctx, permission, projectID)
return &MockPermissionCheckerCheckProjectPermissionCall{Call: call}
}
// MockPermissionCheckerCheckProjectPermissionCall wrap *gomock.Call
type MockPermissionCheckerCheckProjectPermissionCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockPermissionCheckerCheckProjectPermissionCall) Return(arg0 error) *MockPermissionCheckerCheckProjectPermissionCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockPermissionCheckerCheckProjectPermissionCall) Do(f func(context.Context, string, string) error) *MockPermissionCheckerCheckProjectPermissionCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockPermissionCheckerCheckProjectPermissionCall) DoAndReturn(f func(context.Context, string, string) error) *MockPermissionCheckerCheckProjectPermissionCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// CheckSessionPermission mocks base method.
func (m *MockPermissionChecker) CheckSessionPermission(ctx context.Context, permission, sessionID string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CheckSessionPermission", ctx, permission, sessionID)
ret0, _ := ret[0].(error)
return ret0
}
// CheckSessionPermission indicates an expected call of CheckSessionPermission.
func (mr *MockPermissionCheckerMockRecorder) CheckSessionPermission(ctx, permission, sessionID any) *MockPermissionCheckerCheckSessionPermissionCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckSessionPermission", reflect.TypeOf((*MockPermissionChecker)(nil).CheckSessionPermission), ctx, permission, sessionID)
return &MockPermissionCheckerCheckSessionPermissionCall{Call: call}
}
// MockPermissionCheckerCheckSessionPermissionCall wrap *gomock.Call
type MockPermissionCheckerCheckSessionPermissionCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockPermissionCheckerCheckSessionPermissionCall) Return(arg0 error) *MockPermissionCheckerCheckSessionPermissionCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockPermissionCheckerCheckSessionPermissionCall) Do(f func(context.Context, string, string) error) *MockPermissionCheckerCheckSessionPermissionCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockPermissionCheckerCheckSessionPermissionCall) DoAndReturn(f func(context.Context, string, string) error) *MockPermissionCheckerCheckSessionPermissionCall {
c.Call = c.Call.DoAndReturn(f)
return c
}