mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-19 03:35:12 +00:00
# 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]>
52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package domainmock
|
|
|
|
import (
|
|
context "context"
|
|
|
|
gomock "go.uber.org/mock/gomock"
|
|
|
|
domain "github.com/zitadel/zitadel/backend/v3/domain"
|
|
database "github.com/zitadel/zitadel/backend/v3/storage/database"
|
|
"github.com/zitadel/zitadel/backend/v3/storage/database/repository"
|
|
)
|
|
|
|
func NewUserRepo(ctrl *gomock.Controller) *UserRepo {
|
|
return &UserRepo{
|
|
mock: NewMockUserRepository(ctrl),
|
|
UserRepository: repository.UserRepository(),
|
|
}
|
|
}
|
|
|
|
type UserRepo struct {
|
|
domain.UserRepository
|
|
mock *MockUserRepository
|
|
}
|
|
|
|
func (u *UserRepo) EXPECT() *MockUserRepositoryMockRecorder {
|
|
return u.mock.EXPECT()
|
|
}
|
|
|
|
func (u *UserRepo) Get(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.User, error) {
|
|
return u.mock.Get(ctx, client, opts...)
|
|
}
|
|
|
|
func (u *UserRepo) List(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) ([]*domain.User, error) {
|
|
return u.mock.List(ctx, client, opts...)
|
|
}
|
|
|
|
func (u *UserRepo) Create(ctx context.Context, client database.QueryExecutor, user *domain.User) error {
|
|
return u.mock.Create(ctx, client, user)
|
|
}
|
|
|
|
func (u *UserRepo) Delete(ctx context.Context, client database.QueryExecutor, condition database.Condition) (int64, error) {
|
|
return u.mock.Delete(ctx, client, condition)
|
|
}
|
|
|
|
func (u *UserRepo) Human() domain.HumanUserRepository {
|
|
return u.mock.Human()
|
|
}
|
|
|
|
func (u *UserRepo) Machine() domain.MachineUserRepository {
|
|
return u.mock.Machine()
|
|
}
|