a26d1300e8
* upgrade vault dependency set * etcd and grpc issues: * better for tests * testing * all upgrades for hashicorp deps * kubernetes plugin upgrade seems to work * kubernetes plugin upgrade seems to work * etcd and a bunch of other stuff * all vulnerable packages upgraded * k8s is broken in linux env but not locally * test fixes * fix testing * fix etcd and grpc * fix etcd and grpc * use master branch of go-testing-interface * roll back etcd upgrade * have to fix grpc since other vendors pull in grpc 1.35.0 but we cant due to etcd * rolling back in the replace directives * a few more testing dependencies to clean up * fix go mod vendor
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package vault
|
|
|
|
import (
|
|
"github.com/hashicorp/go-hclog"
|
|
wrapping "github.com/hashicorp/go-kms-wrapping"
|
|
aeadwrapper "github.com/hashicorp/go-kms-wrapping/wrappers/aead"
|
|
"github.com/hashicorp/vault/sdk/helper/logging"
|
|
"github.com/hashicorp/vault/vault/seal"
|
|
testing "github.com/mitchellh/go-testing-interface"
|
|
)
|
|
|
|
func NewTestSeal(t testing.TB, opts *seal.TestSealOpts) Seal {
|
|
t.Helper()
|
|
if opts == nil {
|
|
opts = &seal.TestSealOpts{}
|
|
}
|
|
if opts.Logger == nil {
|
|
opts.Logger = logging.NewVaultLogger(hclog.Debug)
|
|
}
|
|
|
|
switch opts.StoredKeys {
|
|
case seal.StoredKeysSupportedShamirMaster:
|
|
newSeal := NewDefaultSeal(&seal.Access{
|
|
Wrapper: aeadwrapper.NewShamirWrapper(&wrapping.WrapperOptions{
|
|
Logger: opts.Logger,
|
|
}),
|
|
})
|
|
// Need StoredShares set or this will look like a legacy shamir seal.
|
|
newSeal.SetCachedBarrierConfig(&SealConfig{
|
|
StoredShares: 1,
|
|
SecretThreshold: 1,
|
|
SecretShares: 1,
|
|
})
|
|
return newSeal
|
|
case seal.StoredKeysNotSupported:
|
|
newSeal := NewDefaultSeal(&seal.Access{
|
|
Wrapper: aeadwrapper.NewShamirWrapper(&wrapping.WrapperOptions{
|
|
Logger: opts.Logger,
|
|
}),
|
|
})
|
|
newSeal.SetCachedBarrierConfig(&SealConfig{
|
|
StoredShares: 0,
|
|
SecretThreshold: 1,
|
|
SecretShares: 1,
|
|
})
|
|
return newSeal
|
|
default:
|
|
return NewAutoSeal(seal.NewTestSeal(opts))
|
|
}
|
|
}
|