mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-17 20:04:36 -05:00
csi: let constructor take care of setting up cryptsetup (#2312)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
d3c940a6a0
commit
327315d5de
@ -40,9 +40,9 @@ type CryptMapper struct {
|
||||
|
||||
// New initializes a new CryptMapper with the given kms client and key-encryption-key ID.
|
||||
// kms is used to fetch data encryption keys for the dm-crypt volumes.
|
||||
func New(kms keyCreator, mapper deviceMapper) *CryptMapper {
|
||||
func New(kms keyCreator) *CryptMapper {
|
||||
return &CryptMapper{
|
||||
mapper: mapper,
|
||||
mapper: cryptsetup.New(),
|
||||
kms: kms,
|
||||
getDiskFormat: getDiskFormat,
|
||||
}
|
||||
|
@ -57,7 +57,11 @@ func TestCloseCryptDevice(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
mapper := New(&fakeKMS{}, &stubCryptDevice{})
|
||||
mapper := &CryptMapper{
|
||||
mapper: &stubCryptDevice{},
|
||||
kms: &fakeKMS{},
|
||||
getDiskFormat: getDiskFormat,
|
||||
}
|
||||
err := mapper.CloseCryptDevice("volume01-unit-test")
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
@ -214,7 +218,11 @@ func TestOpenCryptDevice(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
mapper := New(&fakeKMS{}, &stubCryptDevice{})
|
||||
mapper := &CryptMapper{
|
||||
mapper: &stubCryptDevice{},
|
||||
kms: &fakeKMS{},
|
||||
getDiskFormat: getDiskFormat,
|
||||
}
|
||||
_, err := mapper.OpenCryptDevice(context.Background(), "/dev/some-device", "volume01", false)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
@ -8,14 +8,12 @@ go_test(
|
||||
deps = select({
|
||||
"@io_bazel_rules_go//go/platform:android": [
|
||||
"//csi/cryptmapper",
|
||||
"//internal/cryptsetup",
|
||||
"@com_github_stretchr_testify//assert",
|
||||
"@com_github_stretchr_testify//require",
|
||||
"@org_uber_go_goleak//:goleak",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"//csi/cryptmapper",
|
||||
"//internal/cryptsetup",
|
||||
"@com_github_stretchr_testify//assert",
|
||||
"@com_github_stretchr_testify//require",
|
||||
"@org_uber_go_goleak//:goleak",
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/csi/cryptmapper"
|
||||
"github.com/edgelesssys/constellation/v2/internal/cryptsetup"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/goleak"
|
||||
@ -67,7 +66,7 @@ func TestOpenAndClose(t *testing.T) {
|
||||
setup()
|
||||
defer teardown(devicePath)
|
||||
|
||||
mapper := cryptmapper.New(&fakeKMS{}, cryptsetup.New())
|
||||
mapper := cryptmapper.New(&fakeKMS{})
|
||||
|
||||
newPath, err := mapper.OpenCryptDevice(context.Background(), devicePath, deviceName, false)
|
||||
require.NoError(err)
|
||||
@ -107,7 +106,7 @@ func TestOpenAndCloseIntegrity(t *testing.T) {
|
||||
setup()
|
||||
defer teardown(devicePath)
|
||||
|
||||
mapper := cryptmapper.New(&fakeKMS{}, cryptsetup.New())
|
||||
mapper := cryptmapper.New(&fakeKMS{})
|
||||
|
||||
newPath, err := mapper.OpenCryptDevice(context.Background(), devicePath, deviceName, true)
|
||||
require.NoError(err)
|
||||
@ -146,7 +145,7 @@ func TestDeviceCloning(t *testing.T) {
|
||||
setup()
|
||||
defer teardown(devicePath)
|
||||
|
||||
mapper := cryptmapper.New(&dynamicKMS{}, cryptsetup.New())
|
||||
mapper := cryptmapper.New(&dynamicKMS{})
|
||||
|
||||
_, err := mapper.OpenCryptDevice(context.Background(), devicePath, deviceName, false)
|
||||
assert.NoError(err)
|
||||
|
Loading…
Reference in New Issue
Block a user