2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-05-10 06:35:17 -04:00
|
|
|
package setup
|
2022-03-22 11:03:15 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2023-03-02 09:08:31 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
2022-03-22 11:03:15 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
2022-06-30 09:24:36 -04:00
|
|
|
"go.uber.org/goleak"
|
2022-03-22 11:03:15 -04:00
|
|
|
)
|
|
|
|
|
2022-06-30 09:24:36 -04:00
|
|
|
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"),
|
2024-01-16 11:45:35 -05:00
|
|
|
goleak.IgnoreAnyFunction("github.com/bazelbuild/rules_go/go/tools/bzltestutil.RegisterTimeoutHandler.func1"),
|
2022-06-30 09:24:36 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-03-22 11:03:15 -04:00
|
|
|
func TestSetUpKMS(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2022-10-05 09:02:46 -04:00
|
|
|
kms, err := KMS(context.Background(), "storage://unknown", "kms://unknown")
|
2022-03-22 11:03:15 -04:00
|
|
|
assert.Error(err)
|
|
|
|
assert.Nil(kms)
|
|
|
|
|
2023-03-02 09:08:31 -05:00
|
|
|
masterSecret := uri.MasterSecret{Key: []byte("key"), Salt: []byte("salt")}
|
2023-01-16 05:19:03 -05:00
|
|
|
kms, err = KMS(context.Background(), "storage://no-store", masterSecret.EncodeToURI())
|
2022-03-22 11:03:15 -04:00
|
|
|
assert.NoError(err)
|
|
|
|
assert.NotNil(kms)
|
|
|
|
}
|