Skip to content

Commit

Permalink
backport of commit 044efbc (#20077)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Scheel <alex.scheel@hashicorp.com>
  • Loading branch information
1 parent 5eae4ca commit f980e0b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions helper/testhelpers/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func GenerateRootWithError(t testing.T, cluster *vault.TestCluster, kind Generat
keys = cluster.BarrierKeys
}
client := cluster.Cores[0].Client
oldNS := client.Namespace()
defer client.SetNamespace(oldNS)
client.ClearNamespace()

var err error
var status *api.GenerateRootStatusResponse
Expand Down Expand Up @@ -174,6 +177,10 @@ func AttemptUnsealCore(c *vault.TestCluster, core *vault.TestClusterCore) error
}

client := core.Client
oldNS := client.Namespace()
defer client.SetNamespace(oldNS)
client.ClearNamespace()

client.Sys().ResetUnsealProcess()
for j := 0; j < len(c.BarrierKeys); j++ {
statusResp, err := client.Sys().Unseal(base64.StdEncoding.EncodeToString(c.BarrierKeys[j]))
Expand Down Expand Up @@ -242,7 +249,10 @@ func DeriveActiveCore(t testing.T, cluster *vault.TestCluster) *vault.TestCluste
t.Helper()
for i := 0; i < 60; i++ {
for _, core := range cluster.Cores {
oldNS := core.Client.Namespace()
core.Client.ClearNamespace()
leaderResp, err := core.Client.Sys().Leader()
core.Client.SetNamespace(oldNS)
if err != nil {
t.Fatal(err)
}
Expand All @@ -260,7 +270,10 @@ func DeriveStandbyCores(t testing.T, cluster *vault.TestCluster) []*vault.TestCl
t.Helper()
cores := make([]*vault.TestClusterCore, 0, 2)
for _, core := range cluster.Cores {
oldNS := core.Client.Namespace()
core.Client.ClearNamespace()
leaderResp, err := core.Client.Sys().Leader()
core.Client.SetNamespace(oldNS)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit f980e0b

Please sign in to comment.