Files
zitadel/backend/v3/domain/mock/session_repo.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

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)
}