Skip to content
Merged
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
2 changes: 1 addition & 1 deletion kms/platform/kms_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func newKMS(ctx context.Context, opts apiv1.Options) (*KMS, error) {
return newTPMKMS(ctx, opts)
case apiv1.SoftKMS:
return newSoftKMS(ctx, opts)
case apiv1.DefaultKMS, apiv1.MacKMS:
case apiv1.PlatformKMS, apiv1.DefaultKMS, apiv1.MacKMS:
return newMacKMS(ctx, opts)
default:
return nil, fmt.Errorf("failed parsing options: unsupported backend %q", backend)
Expand Down
2 changes: 1 addition & 1 deletion kms/platform/kms_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func newKMS(ctx context.Context, opts apiv1.Options) (*KMS, error) {
switch backend {
case apiv1.SoftKMS:
return newSoftKMS(ctx, opts)
case apiv1.DefaultKMS, apiv1.TPMKMS:
case apiv1.PlatformKMS, apiv1.DefaultKMS, apiv1.TPMKMS:
return newTPMKMS(ctx, opts)
default:
return nil, fmt.Errorf("failed parsing options: unsupported backend %q", backend)
Expand Down
16 changes: 16 additions & 0 deletions kms/platform/kms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ func TestNew(t *testing.T) {
shouldSkipNow(t, platformKMS)
assert.Equal(t, platformKMS.Type(), k.Type())
}, assert.NoError},
{"ok platformKMS type", args{t.Context(), apiv1.Options{Type: apiv1.PlatformKMS}}, func(t *testing.T, k *KMS) {
shouldSkipNow(t, platformKMS)
assert.Equal(t, platformKMS.Type(), k.Type())
}, assert.NoError},
{"ok backend type", args{t.Context(), apiv1.Options{Type: platformKMS.Type()}}, func(t *testing.T, k *KMS) {
shouldSkipNow(t, platformKMS)
assert.Equal(t, platformKMS.Type(), k.Type())
}, assert.NoError},
{"ok softkms uri", args{t.Context(), apiv1.Options{URI: "kms:backend=softkms"}}, func(t *testing.T, k *KMS) {
assert.Equal(t, apiv1.SoftKMS, k.Type())
}, assert.NoError},
Expand All @@ -354,6 +362,14 @@ func TestNew(t *testing.T) {
}
}

func TestLoadKeyManagerNewFunc(t *testing.T) {
fn, ok := apiv1.LoadKeyManagerNewFunc(apiv1.PlatformKMS)
require.True(t, ok)
km, err := fn(t.Context(), apiv1.Options{})
require.NoError(t, err)
assert.IsType(t, &KMS{}, km)
}

func TestKMS_Type(t *testing.T) {
softKMS := mustKMS(t, "kms:backend=softkms")
assert.Equal(t, apiv1.SoftKMS, softKMS.Type())
Expand Down
2 changes: 1 addition & 1 deletion kms/platform/kms_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func newKMS(ctx context.Context, opts apiv1.Options) (*KMS, error) {
return newCAPIKMS(ctx, opts)
case apiv1.SoftKMS:
return newSoftKMS(ctx, opts)
case apiv1.DefaultKMS, apiv1.TPMKMS:
case apiv1.PlatformKMS, apiv1.DefaultKMS, apiv1.TPMKMS:
// Add enable-cng=true if necessary
if opts.URI, err = withEnableCNG(opts.URI); err != nil {
return nil, err
Expand Down
Loading