mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-28 00:49:26 -05:00
2d8fcd9bf4
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>
39 lines
871 B
Go
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)
|
|
}
|