Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions cmd/tenant-manager-cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ import (
eventprocessor "github.com/openkcm/cmk/internal/event-processor"
"github.com/openkcm/cmk/internal/manager"
"github.com/openkcm/cmk/internal/model"
cmkpluginregistry "github.com/openkcm/cmk/internal/pluginregistry"
"github.com/openkcm/cmk/internal/repo/sql"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
integrationutils "github.com/openkcm/cmk/test/integration/integration_utils"
"github.com/openkcm/cmk/utils/base62"
)
Expand Down Expand Up @@ -59,14 +57,11 @@ func (s *CLISuite) SetupSuite() {

ctx := s.T().Context()

ps, psCfg := testutils.NewTestPlugins(testplugins.NewIdentityManagement())
cfg := &config.Config{
Plugins: psCfg,
Database: dbCfg,
}
r := sql.NewRepository(s.db)
svcRegistry, err := cmkpluginregistry.New(ctx, cfg, cmkpluginregistry.WithBuiltInPlugins(ps))
s.NoError(err)
svcRegistry := testutils.NewTestPlugins()

cmkAuditor := auditor.New(ctx, cfg)

Expand Down
4 changes: 2 additions & 2 deletions cmd/tenant-manager-cli/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/openkcm/cmk/internal/db"
eventprocessor "github.com/openkcm/cmk/internal/event-processor"
"github.com/openkcm/cmk/internal/manager"
cmkpluginregistry "github.com/openkcm/cmk/internal/pluginregistry"
serviceapi "github.com/openkcm/cmk/internal/pluginregistry/service/api"
"github.com/openkcm/cmk/internal/repo"
"github.com/openkcm/cmk/internal/repo/sql"
)
Expand All @@ -27,7 +27,7 @@ func NewCommandFactory(
ctx context.Context,
cfg *config.Config,
dbCon *multitenancy.DB,
svcRegistry *cmkpluginregistry.Registry,
svcRegistry serviceapi.Registry,
) (*CommandFactory, error) {
r := sql.NewRepository(dbCon)

Expand Down
3 changes: 2 additions & 1 deletion cmd/tenant-manager-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/openkcm/cmk/internal/db"
"github.com/openkcm/cmk/internal/log"
cmkpluginregistry "github.com/openkcm/cmk/internal/pluginregistry"
serviceapi "github.com/openkcm/cmk/internal/pluginregistry/service/api"
)

func runFuncWithSignalHandling(f func(context.Context, *config.Config) error) int {
Expand Down Expand Up @@ -93,7 +94,7 @@ func setupCommands(
ctx context.Context,
cfg *config.Config,
dbCon *multitenancy.DB,
svcRegistry *cmkpluginregistry.Registry,
svcRegistry serviceapi.Registry,
) (*cobra.Command, error) {
factory, err := commands.NewCommandFactory(ctx, cfg, dbCon, svcRegistry)
if err != nil {
Expand Down
8 changes: 1 addition & 7 deletions cmd/tenant-manager-cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (

tmCLI "github.com/openkcm/cmk/cmd/tenant-manager-cli"
"github.com/openkcm/cmk/internal/config"
cmkpluginregistry "github.com/openkcm/cmk/internal/pluginregistry"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
)

var errTest = errors.New("test error")
Expand All @@ -37,16 +35,12 @@ func TestSetupCommands(t *testing.T) {
CreateDatabase: true,
})

ps, psCfg := testutils.NewTestPlugins(testplugins.NewIdentityManagement())
svcRegistry := testutils.NewTestPlugins()

cfg := &config.Config{
Plugins: psCfg,
Database: dbCfg,
}

svcRegistry, err := cmkpluginregistry.New(t.Context(), cfg, cmkpluginregistry.WithBuiltInPlugins(ps))
assert.NoError(t, err, "Failed to create catalog")

rootCmd, err := tmCLI.SetupCommands(ctx, cfg, nil, svcRegistry)
assert.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions internal/api/transform/key/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/openkcm/cmk/internal/api/cmkapi"
"github.com/openkcm/cmk/internal/api/transform/key/keyshared"
"github.com/openkcm/cmk/internal/errs"
cmkpluginregistry "github.com/openkcm/cmk/internal/pluginregistry"
serviceapi "github.com/openkcm/cmk/internal/pluginregistry/service/api"
"github.com/openkcm/cmk/internal/pluginregistry/service/api/keymanagement"
)

Expand Down Expand Up @@ -53,7 +53,7 @@ type PluginProviderTransformer struct {
}

func NewPluginProviderTransformer(
pluginCatalog *cmkpluginregistry.Registry,
pluginCatalog serviceapi.Registry,
provider string,
) (*PluginProviderTransformer, error) {
keyManagements, err := pluginCatalog.KeyManagements()
Expand Down
9 changes: 1 addition & 8 deletions internal/api/transform/key/transformer/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@ import (

"github.com/openkcm/cmk/internal/api/cmkapi"
"github.com/openkcm/cmk/internal/api/transform/key/transformer"
"github.com/openkcm/cmk/internal/config"
cmkpluginregistry "github.com/openkcm/cmk/internal/pluginregistry"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
"github.com/openkcm/cmk/utils/ptr"
)

func getPluginProviderTransformer(t *testing.T) *transformer.PluginProviderTransformer {
t.Helper()

ps, psCfg := testutils.NewTestPlugins(testplugins.NewKeystoreOperator())

cfg := &config.Config{Plugins: psCfg}
svcRegistry, err := cmkpluginregistry.New(t.Context(), cfg, cmkpluginregistry.WithBuiltInPlugins(ps))
assert.NoError(t, err)
svcRegistry := testutils.NewTestPlugins()

tf, err := transformer.NewPluginProviderTransformer(svcRegistry, "TEST")
assert.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/cmk/base_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
eventprocessor "github.com/openkcm/cmk/internal/event-processor"
"github.com/openkcm/cmk/internal/log"
"github.com/openkcm/cmk/internal/manager"
cmkpluginregistry "github.com/openkcm/cmk/internal/pluginregistry"
serviceapi "github.com/openkcm/cmk/internal/pluginregistry/service/api"
"github.com/openkcm/cmk/internal/repo"
)

// APIController handles API requests related to CMK (Customer Managed Keys).
type APIController struct {
pluginCatalog *cmkpluginregistry.Registry
pluginCatalog serviceapi.Registry
Repository repo.Repo
Manager *manager.Manager
config *config.Config
Expand All @@ -33,7 +33,7 @@ func NewAPIController(
config *config.Config,
clientsFactory clients.Factory,
migrator db.Migrator,
svcRegistry *cmkpluginregistry.Registry,
svcRegistry serviceapi.Registry,
authzLoader *authz_loader.AuthzLoader[authz.APIResourceTypeName, authz.APIAction],
) *APIController {
eventFactory, err := eventprocessor.NewEventFactory(ctx, config, r)
Expand Down
6 changes: 1 addition & 5 deletions internal/controllers/cmk/group_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"

"github.com/google/uuid"
"github.com/openkcm/plugin-sdk/pkg/catalog"
"github.com/stretchr/testify/assert"

multitenancy "github.com/bartventer/gorm-multitenancy/v8"
Expand All @@ -16,7 +15,6 @@ import (
"github.com/openkcm/cmk/internal/constants"
"github.com/openkcm/cmk/internal/repo/sql"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
"github.com/openkcm/cmk/utils/ptr"
)

Expand All @@ -26,9 +24,7 @@ func startAPIGroups(t *testing.T) (*multitenancy.DB, cmkapi.ServeMux, string) {
db, tenants, _ := testutils.NewTestDB(t, testutils.TestDBConfig{})

r := testutils.NewAPIServer(
t, db, testutils.TestAPIServerConfig{
Plugins: []catalog.BuiltInPlugin{testplugins.NewIdentityManagement()},
},
t, db, testutils.TestAPIServerConfig{},
)

return db, r, tenants[0]
Expand Down
18 changes: 8 additions & 10 deletions internal/controllers/cmk/key_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/google/uuid"
"github.com/openkcm/plugin-sdk/pkg/catalog"
"github.com/stretchr/testify/assert"
"gorm.io/gorm"

Expand All @@ -24,7 +23,6 @@ import (
"github.com/openkcm/cmk/internal/repo"
"github.com/openkcm/cmk/internal/repo/sql"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
cmkcontext "github.com/openkcm/cmk/utils/context"
"github.com/openkcm/cmk/utils/ptr"
)
Expand All @@ -37,16 +35,16 @@ var (
})
)

func startAPIKeys(t *testing.T, plugins ...catalog.BuiltInPlugin) (*multitenancy.DB, cmkapi.ServeMux, string) {
func startAPIKeys(t *testing.T) (*multitenancy.DB, cmkapi.ServeMux, string) {
t.Helper()

db, tenants, dbCfg := testutils.NewTestDB(t, testutils.TestDBConfig{
CreateDatabase: true,
})

return db, testutils.NewAPIServer(t, db, testutils.TestAPIServerConfig{
Plugins: plugins,
Config: config.Config{Database: dbCfg},
Registry: testutils.NewTestPlugins(),
Config: config.Config{Database: dbCfg},
}), tenants[0]
}

Expand Down Expand Up @@ -261,7 +259,7 @@ func TestKeyControllerGetKeysPagination(t *testing.T) {
}

func TestKeyControllerPostKeys(t *testing.T) {
db, sv, tenant := startAPIKeys(t, testplugins.NewKeystoreOperator())
db, sv, tenant := startAPIKeys(t)
r := sql.NewRepository(db)

ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
Expand Down Expand Up @@ -487,7 +485,7 @@ func TestKeyControllerPostKeys(t *testing.T) {
}

func TestKeyControllerPostKeysDrainedKeystorePool(t *testing.T) {
db, sv, tenant := startAPIKeys(t, testplugins.NewKeystoreOperator())
db, sv, tenant := startAPIKeys(t)
ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
r := sql.NewRepository(db)

Expand Down Expand Up @@ -623,7 +621,7 @@ func TestKeyControllerGetKeysKeyID(t *testing.T) {
}

func TestKeyControllerDeleteKeysKeyID(t *testing.T) {
db, sv, tenant := startAPIKeys(t, testplugins.NewKeystoreOperator())
db, sv, tenant := startAPIKeys(t)
ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
r := sql.NewRepository(db)

Expand Down Expand Up @@ -729,7 +727,7 @@ func TestKeyControllerDeleteKeysKeyID(t *testing.T) {
}

func TestKeyControllerUpdateKey(t *testing.T) {
db, sv, tenant := startAPIKeys(t, testplugins.NewKeystoreOperator())
db, sv, tenant := startAPIKeys(t)
ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
r := sql.NewRepository(db)

Expand Down Expand Up @@ -1086,7 +1084,7 @@ func TestKeyControllerGetImportParams(t *testing.T) {
}

func TestKeyControllerImportKeyMaterial(t *testing.T) {
db, sv, tenant := startAPIKeys(t, testplugins.NewKeystoreOperator())
db, sv, tenant := startAPIKeys(t)
ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
r := sql.NewRepository(db)

Expand Down
6 changes: 1 addition & 5 deletions internal/controllers/cmk/keyconfiguration_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/google/uuid"
"github.com/openkcm/common-sdk/pkg/auth"
"github.com/openkcm/common-sdk/pkg/commoncfg"
"github.com/openkcm/plugin-sdk/pkg/catalog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
Expand All @@ -29,7 +28,6 @@ import (
"github.com/openkcm/cmk/internal/repo"
"github.com/openkcm/cmk/internal/repo/sql"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
cmkcontext "github.com/openkcm/cmk/utils/context"
"github.com/openkcm/cmk/utils/crypto"
"github.com/openkcm/cmk/utils/ptr"
Expand All @@ -46,9 +44,7 @@ func startAPIKeyConfig(t *testing.T) (

tenant := tenants[0]

sv := testutils.NewAPIServer(t, db, testutils.TestAPIServerConfig{
Plugins: []catalog.BuiltInPlugin{testplugins.NewIdentityManagement()},
})
sv := testutils.NewAPIServer(t, db, testutils.TestAPIServerConfig{})

ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
r := sql.NewRepository(db)
Expand Down
3 changes: 1 addition & 2 deletions internal/controllers/cmk/keyversion_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/openkcm/cmk/internal/model"
"github.com/openkcm/cmk/internal/repo/sql"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
cmkcontext "github.com/openkcm/cmk/utils/context"
"github.com/openkcm/cmk/utils/ptr"
)
Expand Down Expand Up @@ -408,7 +407,7 @@ func TestKeyVersionController_GetKeyVersions_IsPrimaryWithPagination(t *testing.
}

func TestKeyVersionRefreshAndDisable(t *testing.T) {
db, sv, tenant := startAPIKeys(t, testplugins.NewKeystoreOperator())
db, sv, tenant := startAPIKeys(t)
ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
r := sql.NewRepository(db)

Expand Down
7 changes: 1 addition & 6 deletions internal/controllers/cmk/system_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"

"github.com/google/uuid"
"github.com/openkcm/plugin-sdk/pkg/catalog"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"

Expand All @@ -23,7 +22,6 @@ import (
"github.com/openkcm/cmk/internal/repo"
"github.com/openkcm/cmk/internal/repo/sql"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
cmkcontext "github.com/openkcm/cmk/utils/context"
"github.com/openkcm/cmk/utils/ptr"
)
Expand Down Expand Up @@ -719,7 +717,6 @@ func TestLinkSystemAction(t *testing.T) {
)

db, sv, tenant := startAPISystems(t, testutils.TestAPIServerConfig{
Plugins: []catalog.BuiltInPlugin{testplugins.NewSystemInformation()},
GRPCCon: grpcCon,
})
ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
Expand Down Expand Up @@ -881,9 +878,7 @@ func TestLinkSystemAction(t *testing.T) {
}

func TestUnlinkSystemAction(t *testing.T) {
db, sv, tenant := startAPISystems(t, testutils.TestAPIServerConfig{
Plugins: []catalog.BuiltInPlugin{testplugins.NewSystemInformation()},
})
db, sv, tenant := startAPISystems(t, testutils.TestAPIServerConfig{})
ctx := cmkcontext.CreateTenantContext(t.Context(), tenant)
r := sql.NewRepository(db)

Expand Down
5 changes: 1 addition & 4 deletions internal/controllers/cmk/workflow_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"testing"

"github.com/google/uuid"
"github.com/openkcm/plugin-sdk/pkg/catalog"
"github.com/stretchr/testify/assert"

multitenancy "github.com/bartventer/gorm-multitenancy/v8"
Expand All @@ -23,7 +22,6 @@ import (
"github.com/openkcm/cmk/internal/repo"
cmksql "github.com/openkcm/cmk/internal/repo/sql"
"github.com/openkcm/cmk/internal/testutils"
"github.com/openkcm/cmk/internal/testutils/testplugins"
wfMechanism "github.com/openkcm/cmk/internal/workflow"
cmkcontext "github.com/openkcm/cmk/utils/context"
"github.com/openkcm/cmk/utils/ptr"
Expand All @@ -37,8 +35,7 @@ func startAPIWorkflows(t *testing.T) (*multitenancy.DB, cmkapi.ServeMux, string)
db, tenants, dbCfg := testutils.NewTestDB(t, testutils.TestDBConfig{})

sv := testutils.NewAPIServer(t, db, testutils.TestAPIServerConfig{
Config: config.Config{Database: dbCfg},
Plugins: []catalog.BuiltInPlugin{testplugins.NewIdentityManagement()},
Config: config.Config{Database: dbCfg},
})

return db, sv, tenants[0]
Expand Down
6 changes: 3 additions & 3 deletions internal/event-processor/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/openkcm/cmk/internal/config"
"github.com/openkcm/cmk/internal/errs"
"github.com/openkcm/cmk/internal/log"
cmkpluginregistry "github.com/openkcm/cmk/internal/pluginregistry"
serviceapi "github.com/openkcm/cmk/internal/pluginregistry/service/api"
"github.com/openkcm/cmk/internal/repo"
)

Expand Down Expand Up @@ -80,7 +80,7 @@ type CryptoReconciler struct {
manager *orbital.Manager
targets map[string]struct{}
initiators []orbital.Initiator
svcRegistry *cmkpluginregistry.Registry
svcRegistry serviceapi.Registry
jobHandlerMap map[JobType]JobHandler
tracer trace.Tracer
}
Expand All @@ -92,7 +92,7 @@ func NewCryptoReconciler(
ctx context.Context,
cfg *config.Config,
repository repo.Repo,
svcRegistry *cmkpluginregistry.Registry,
svcRegistry serviceapi.Registry,
clientsFactory clients.Factory,
opts ...Option,
) (*CryptoReconciler, error) {
Expand Down
Loading
Loading