constellation/coordinator/kms/clusterkms_test.go
Leonard Cohnen 2d8fcd9bf4 monorepo
Co-authored-by: Malte Poll <mp@edgeless.systems>
Co-authored-by: katexochen <katexochen@users.noreply.github.com>
Co-authored-by: Daniel Weiße <dw@edgeless.systems>
Co-authored-by: Thomas Tendyck <tt@edgeless.systems>
Co-authored-by: Benedict Schlueter <bs@edgeless.systems>
Co-authored-by: leongross <leon.gross@rub.de>
Co-authored-by: Moritz Eckert <m1gh7ym0@gmail.com>
2022-03-22 16:09:39 +01:00

39 lines
871 B
Go

package kms
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCoordinatorKMS(t *testing.T) {
assert := assert.New(t)
kms := &ClusterKMS{}
masterKey := []byte("Constellation")
key, err := kms.GetDEK(context.Background(), "", "key-1", 32)
assert.Error(err)
assert.Nil(key)
err = kms.CreateKEK(context.Background(), "", masterKey)
assert.NoError(err)
assert.Equal(masterKey, kms.masterKey)
key1, err := kms.GetDEK(context.Background(), "", "key-1", 32)
assert.NoError(err)
assert.Len(key1, 32)
key2, err := kms.GetDEK(context.Background(), "", "key-1", 32)
assert.NoError(err)
assert.Equal(key1, key2)
key3, err := kms.GetDEK(context.Background(), "", "key-2", 32)
assert.NoError(err)
assert.NotEqual(key1, key3)
key, err = kms.GetDEK(context.Background(), "", "key", 64)
assert.NoError(err)
assert.Len(key, 64)
}