mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-03 04:26:20 -04:00
keyservice: move kms code to internal/kms
Recovery (disk-mapper) and init (bootstrapper) will have to work with multiple external KMSes in the future.
This commit is contained in:
parent
59664f7020
commit
0e71322e2e
33 changed files with 49 additions and 47 deletions
51
internal/kms/storage/memfsstroage_test.go
Normal file
51
internal/kms/storage/memfsstroage_test.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
Copyright (c) Edgeless Systems GmbH
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/goleak"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
goleak.VerifyTestMain(m,
|
||||
// https://github.com/census-instrumentation/opencensus-go/issues/1262
|
||||
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
|
||||
)
|
||||
}
|
||||
|
||||
func TestMemMapStorage(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
storage := NewMemMapStorage()
|
||||
|
||||
testDEK1 := []byte("test DEK")
|
||||
testDEK2 := []byte("more test DEK")
|
||||
ctx := context.Background()
|
||||
|
||||
// request unset value
|
||||
_, err := storage.Get(ctx, "test:input")
|
||||
assert.ErrorIs(err, ErrDEKUnset)
|
||||
|
||||
// test Put method
|
||||
assert.NoError(storage.Put(ctx, "volume01", testDEK1))
|
||||
assert.NoError(storage.Put(ctx, "volume02", testDEK2))
|
||||
|
||||
// make sure values have been set
|
||||
val, err := storage.Get(ctx, "volume01")
|
||||
assert.NoError(err)
|
||||
assert.Equal(testDEK1, val)
|
||||
val, err = storage.Get(ctx, "volume02")
|
||||
assert.NoError(err)
|
||||
assert.Equal(testDEK2, val)
|
||||
|
||||
_, err = storage.Get(ctx, "invalid:key")
|
||||
assert.ErrorIs(err, ErrDEKUnset)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue