added test cases for keymanager and plugin

This commit is contained in:
MohitKatare-protean
2025-05-20 12:01:14 +05:30
parent 0101fe80c5
commit 63e1bc44d9
4 changed files with 1373 additions and 7 deletions

View File

@@ -9,7 +9,12 @@ import (
)
// keyManagerProvider implements the plugin provider for the KeyManager plugin.
type keyManagerProvider struct{}
type keyManagerProvider struct {
newFunc func(ctx context.Context, cache definition.Cache, registry definition.RegistryLookup, cfg *keymanager.Config) (definition.KeyManager, func() error, error)
}
// newKeyManagerFunc is a function type that creates a new KeyManager instance.
var newKeyManagerFunc = keymanager.New
// New creates and initializes a new KeyManager instance using the provided cache, registry lookup, and configuration.
func (k *keyManagerProvider) New(ctx context.Context, cache definition.Cache, registry definition.RegistryLookup, cfg map[string]string) (definition.KeyManager, func() error, error) {
@@ -18,7 +23,7 @@ func (k *keyManagerProvider) New(ctx context.Context, cache definition.Cache, re
KVVersion: cfg["kv_version"],
}
log.Debugf(ctx, "Keymanager config mapped: %+v", cfg)
km, cleanup, err := keymanager.New(ctx, cache, registry, config)
km, cleanup, err := newKeyManagerFunc(ctx, cache, registry, config)
if err != nil {
log.Error(ctx, err, "Failed to initialize KeyManager")
return nil, nil, err