mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-18 03:15:11 +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]>
48 lines
1.5 KiB
Go
48 lines
1.5 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 NewSessionRepo(ctrl *gomock.Controller) *SessionRepo {
|
|
return &SessionRepo{
|
|
mock: NewMockSessionRepository(ctrl),
|
|
SessionRepository: repository.SessionRepository(),
|
|
}
|
|
}
|
|
|
|
type SessionRepo struct {
|
|
domain.SessionRepository
|
|
mock *MockSessionRepository
|
|
}
|
|
|
|
func (s *SessionRepo) EXPECT() *MockSessionRepositoryMockRecorder {
|
|
return s.mock.EXPECT()
|
|
}
|
|
|
|
func (s *SessionRepo) Get(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.Session, error) {
|
|
return s.mock.Get(ctx, client, opts...)
|
|
}
|
|
|
|
func (s *SessionRepo) List(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) ([]*domain.Session, error) {
|
|
return s.mock.List(ctx, client, opts...)
|
|
}
|
|
|
|
func (s *SessionRepo) Create(ctx context.Context, client database.QueryExecutor, user *domain.Session) error {
|
|
return s.mock.Create(ctx, client, user)
|
|
}
|
|
|
|
func (s *SessionRepo) Update(ctx context.Context, client database.QueryExecutor, condition database.Condition, changes ...database.Change) (int64, error) {
|
|
return s.mock.Update(ctx, client, condition, changes...)
|
|
}
|
|
|
|
func (s *SessionRepo) Delete(ctx context.Context, client database.QueryExecutor, condition database.Condition) (int64, error) {
|
|
return s.mock.Delete(ctx, client, condition)
|
|
}
|