mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-03 04:42:15 +00:00
# Which Problems Are Solved This PR introduces the possibility of using the relational DB when calling the ListSession gRPC endpoint. # How the Problems Are Solved - Implement the Querier interface for ListSession: - Create a `domain` model for the Session object to be able to map the gRPC session into it. - Match the permission filters on ES side to be sure the same sessions are returned - Implement converter methods to go from `gRPC` to `domain` models (both ways) - Fix the session sql relational migration: rework the trigger to update the `expiration` field to perform the update only when the input `lifetime` has a non-zero value. - Link the Querier implementation with the gRPC endpoint - Run the same integration tests against the relational DB, making sure the outcome is the same. ⚠️ Due to missing permission checks, some divergence is expected. Hence, specific code to circumvent the differences has been put in place # Additional Context - Closes #11039
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
package domainmock
|
|
|
|
import (
|
|
context "context"
|
|
"time"
|
|
|
|
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, permissionCondition database.Condition) (int64, time.Time, error) {
|
|
return s.mock.Delete(ctx, client, condition, permissionCondition)
|
|
}
|
|
|
|
func (s *SessionRepo) LoadUserData() domain.SessionRepository {
|
|
return s.mock.LoadUserData()
|
|
}
|