Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support namespaces in test helpers #20048

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions helper/testhelpers/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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 @@ -177,6 +180,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 @@ -245,7 +252,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 @@ -263,7 +273,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