Files
zitadel/backend/v3/domain/mock/permission.mock.go
T
f5ce288ea5 feat(domain): define user repositories (#11059)
This pull request introduces a new set of domain models and repositories
for managing users within the new v3 structure. The goal is to establish
a clean, robust, and extensible foundation for user management.

### Summary

This PR accomplishes the following:

- **Polymorphic User Model**: Introduces a `User` model in user.go that
can represent either a `Human` or a `Machine` user. This provides a
unified way to handle different user types while allowing for specific
attributes and logic for each.
- **Repository Pattern**: Implements the repository pattern for
accessing and manipulating user data. This decouples the business logic
from the data storage implementation. The main repository interfaces
(`UserRepository`, `HumanUserRepository`, `MachineUserRepository`) are
now defined in `backend/v3/domain/user_repository.go`.
- **Comprehensive User Models**: The user.go file now also defines the
domain models for associated user data, including `UserMetadata`,
`IdentityProviderLink`, `Passkey`, `PersonalAccessToken`, and
`MachineKey`.
- **Generic Verification and Check System**: Introduces verification.go
and check.go to provide a standardized way of handling various
verification flows (e.g., email verification, OTP checks).
- **Generated Code**: Adds new generated files for enums
(`humangender_enumer.go`, `machinekeytype_enumer.go`,
`passkeytype_enumer.go`, `personalaccesstokentype_enumer.go`,
`userstate_enumer.go`, `usertype_enumer.go`) and mocks for the new
repositories.
- **Session Domain Refactoring**: Updates the session domain
(`backend/v3/domain/session*.go`) to align with the new user model
structure.

This foundational work paves the way for migrating user management logic
to the new `v3` backend, with a more maintainable and testable
architecture.

part of #10224

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Marco A. <[email protected]>
2025-11-25 11:54:32 +01:00

194 lines
7.8 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
}