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
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
package vault
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/vault/vault/seal"
|
|
vaultseal "github.com/hashicorp/vault/vault/seal"
|
|
testing "github.com/mitchellh/go-testing-interface"
|
|
)
|
|
|
|
func TestCoreUnsealedWithConfigs(t testing.TB, barrierConf, recoveryConf *SealConfig) (*Core, [][]byte, [][]byte, string) {
|
|
t.Helper()
|
|
opts := &seal.TestSealOpts{}
|
|
if recoveryConf == nil {
|
|
opts.StoredKeys = seal.StoredKeysSupportedShamirMaster
|
|
}
|
|
return TestCoreUnsealedWithConfigSealOpts(t, barrierConf, recoveryConf, opts)
|
|
}
|
|
|
|
func TestCoreUnsealedWithConfigSealOpts(t testing.TB, barrierConf, recoveryConf *SealConfig, sealOpts *seal.TestSealOpts) (*Core, [][]byte, [][]byte, string) {
|
|
t.Helper()
|
|
seal := NewTestSeal(t, sealOpts)
|
|
core := TestCoreWithSeal(t, seal, false)
|
|
result, err := core.Initialize(context.Background(), &InitParams{
|
|
BarrierConfig: barrierConf,
|
|
RecoveryConfig: recoveryConf,
|
|
LegacyShamirSeal: sealOpts.StoredKeys == vaultseal.StoredKeysNotSupported,
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
err = core.UnsealWithStoredKeys(context.Background())
|
|
if err != nil && IsFatalError(err) {
|
|
t.Fatalf("err: %s", err)
|
|
}
|
|
if core.Sealed() {
|
|
for _, key := range result.SecretShares {
|
|
if _, err := core.Unseal(TestKeyCopy(key)); err != nil {
|
|
t.Fatalf("unseal err: %s", err)
|
|
}
|
|
}
|
|
|
|
if core.Sealed() {
|
|
t.Fatal("should not be sealed")
|
|
}
|
|
}
|
|
|
|
return core, result.SecretShares, result.RecoveryShares, result.RootToken
|
|
}
|