feat: authsession service
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package testkit
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"galaxy/authsession/internal/ports"
|
||||
)
|
||||
|
||||
// StaticConfigProvider is a deterministic ConfigProvider double that returns a
|
||||
// preconfigured session-limit value or error.
|
||||
type StaticConfigProvider struct {
|
||||
// Config stores the configuration returned when Err is nil.
|
||||
Config ports.SessionLimitConfig
|
||||
|
||||
// Err is returned directly from LoadSessionLimit when set.
|
||||
Err error
|
||||
}
|
||||
|
||||
// LoadSessionLimit returns the preconfigured session-limit result.
|
||||
func (p StaticConfigProvider) LoadSessionLimit(ctx context.Context) (ports.SessionLimitConfig, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return ports.SessionLimitConfig{}, err
|
||||
}
|
||||
if p.Err != nil {
|
||||
return ports.SessionLimitConfig{}, p.Err
|
||||
}
|
||||
if err := p.Config.Validate(); err != nil {
|
||||
return ports.SessionLimitConfig{}, err
|
||||
}
|
||||
|
||||
return p.Config, nil
|
||||
}
|
||||
|
||||
var _ ports.ConfigProvider = StaticConfigProvider{}
|
||||
Reference in New Issue
Block a user