forked from TrueCloudLab/frostfs-node
WIP: Morph: Add unit tests #2
3 changed files with 23 additions and 72 deletions
|
@ -421,20 +421,16 @@ func createACLServiceV2(c *cfg, splitSvc *objectService.TransportSplitter) v2.Se
|
|||
irFetcher := createInnerRingFetcher(c)
|
||||
|
||||
return v2.New(
|
||||
v2.WithLogger(c.log),
|
||||
v2.WithIRFetcher(newCachedIRFetcher(irFetcher)),
|
||||
v2.WithNetmapSource(c.netMapSource),
|
||||
v2.WithContainerSource(
|
||||
c.cfgObject.cnrSource,
|
||||
),
|
||||
v2.WithNextService(splitSvc),
|
||||
v2.WithEACLChecker(
|
||||
splitSvc,
|
||||
c.netMapSource,
|
||||
newCachedIRFetcher(irFetcher),
|
||||
acl.NewChecker(
|
||||
c.cfgNetmap.state,
|
||||
c.cfgObject.eaclSource,
|
||||
eaclSDK.NewValidator(),
|
||||
ls),
|
||||
),
|
||||
c.cfgObject.cnrSource,
|
||||
v2.WithLogger(c.log),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package v2
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
|
||||
objectSvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
)
|
||||
|
||||
|
@ -13,39 +10,3 @@ func WithLogger(v *logger.Logger) Option {
|
|||
c.log = v
|
||||
}
|
||||
}
|
||||
|
||||
// WithNetmapSource return option to set
|
||||
// netmap source.
|
||||
func WithNetmapSource(v netmap.Source) Option {
|
||||
return func(c *cfg) {
|
||||
c.nm = v
|
||||
}
|
||||
}
|
||||
|
||||
// WithContainerSource returns option to set container source.
|
||||
func WithContainerSource(v container.Source) Option {
|
||||
return func(c *cfg) {
|
||||
c.containers = v
|
||||
}
|
||||
}
|
||||
|
||||
// WithNextService returns option to set next object service.
|
||||
func WithNextService(v objectSvc.ServiceServer) Option {
|
||||
return func(c *cfg) {
|
||||
c.next = v
|
||||
}
|
||||
}
|
||||
|
||||
// WithEACLChecker returns option to set eACL checker.
|
||||
func WithEACLChecker(v ACLChecker) Option {
|
||||
return func(c *cfg) {
|
||||
c.checker = v
|
||||
}
|
||||
}
|
||||
|
||||
// WithIRFetcher returns option to set inner ring fetcher.
|
||||
func WithIRFetcher(v InnerRingFetcher) Option {
|
||||
return func(c *cfg) {
|
||||
c.irFetcher = v
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,32 +73,26 @@ type cfg struct {
|
|||
next object.ServiceServer
|
||||
}
|
||||
|
||||
func defaultCfg() *cfg {
|
||||
return &cfg{
|
||||
log: &logger.Logger{Logger: zap.L()},
|
||||
}
|
||||
}
|
||||
|
||||
// New is a constructor for object ACL checking service.
|
||||
func New(opts ...Option) Service {
|
||||
cfg := defaultCfg()
|
||||
func New(next object.ServiceServer,
|
||||
nm netmap.Source,
|
||||
irf InnerRingFetcher,
|
||||
acl ACLChecker,
|
||||
cs container.Source,
|
||||
opts ...Option) Service {
|
||||
cfg := &cfg{
|
||||
log: &logger.Logger{Logger: zap.L()},
|
||||
next: next,
|
||||
nm: nm,
|
||||
irFetcher: irf,
|
||||
checker: acl,
|
||||
containers: cs,
|
||||
}
|
||||
|
||||
for i := range opts {
|
||||
opts[i](cfg)
|
||||
}
|
||||
|
||||
panicOnNil := func(v any, name string) {
|
||||
if v == nil {
|
||||
panic(fmt.Sprintf("ACL service: %s is nil", name))
|
||||
}
|
||||
}
|
||||
|
||||
panicOnNil(cfg.next, "next Service")
|
||||
panicOnNil(cfg.nm, "netmap client")
|
||||
panicOnNil(cfg.irFetcher, "inner Ring fetcher")
|
||||
panicOnNil(cfg.checker, "acl checker")
|
||||
panicOnNil(cfg.containers, "container source")
|
||||
|
||||
return Service{
|
||||
cfg: cfg,
|
||||
c: senderClassifier{
|
||||
|
|
Loading…
Reference in a new issue