mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-28 08:59:34 -05:00
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)
|
||
|
}
|