mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Revert the WithContext changes to vault tests (#14947)
This commit is contained in:
committed by
GitHub
parent
48b43e9213
commit
e7b5b2a48d
@@ -170,7 +170,7 @@ func TestKVPutCommand(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -195,7 +195,7 @@ func TestKVPutCommand(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -302,7 +302,7 @@ func TestKVPutCommand(t *testing.T) {
|
||||
t.Fatalf("expected 0 to be %d", code)
|
||||
}
|
||||
|
||||
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/stdin_full")
|
||||
secret, err := client.Logical().Read("secret/write/stdin_full")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -337,7 +337,7 @@ func TestKVPutCommand(t *testing.T) {
|
||||
t.Fatalf("expected 0 to be %d", code)
|
||||
}
|
||||
|
||||
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/stdin_value")
|
||||
secret, err := client.Logical().Read("secret/write/stdin_value")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -365,7 +365,7 @@ func TestKVPutCommand(t *testing.T) {
|
||||
t.Fatalf("expected 0 to be %d", code)
|
||||
}
|
||||
|
||||
secret, err := client.Logical().ReadWithContext(context.Background(), "secret/write/integration")
|
||||
secret, err := client.Logical().Read("secret/write/integration")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -489,7 +489,7 @@ func TestKVGetCommand(t *testing.T) {
|
||||
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -498,13 +498,13 @@ func TestKVGetCommand(t *testing.T) {
|
||||
// Give time for the upgrade code to run/finish
|
||||
time.Sleep(time.Second)
|
||||
|
||||
if _, err := client.Logical().WriteWithContext(context.Background(), "secret/read/foo", map[string]interface{}{
|
||||
if _, err := client.Logical().Write("secret/read/foo", map[string]interface{}{
|
||||
"foo": "bar",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/read/foo", map[string]interface{}{
|
||||
if _, err := client.Logical().Write("kv/data/read/foo", map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -614,7 +614,7 @@ func TestKVMetadataGetCommand(t *testing.T) {
|
||||
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -623,7 +623,7 @@ func TestKVMetadataGetCommand(t *testing.T) {
|
||||
// Give time for the upgrade code to run/finish
|
||||
time.Sleep(time.Second)
|
||||
|
||||
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/foo", map[string]interface{}{
|
||||
if _, err := client.Logical().Write("kv/data/foo", map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
@@ -710,7 +710,7 @@ func TestKVPatchCommand_ArgValidation(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
@@ -746,13 +746,13 @@ func TestKVPatchCommand_StdinFull(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
}
|
||||
|
||||
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/patch/foo", map[string]interface{}{
|
||||
if _, err := client.Logical().Write("kv/data/patch/foo", map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"foo": "a",
|
||||
},
|
||||
@@ -813,13 +813,13 @@ func TestKVPatchCommand_StdinValue(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
}
|
||||
|
||||
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/patch/foo", map[string]interface{}{
|
||||
if _, err := client.Logical().Write("kv/data/patch/foo", map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"foo": "a",
|
||||
},
|
||||
@@ -877,7 +877,7 @@ func TestKVPatchCommand_RWMethodNotExists(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
@@ -906,13 +906,13 @@ func TestKVPatchCommand_RWMethodSucceeds(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
}
|
||||
|
||||
if _, err := client.Logical().WriteWithContext(context.Background(), "kv/data/patch/foo", map[string]interface{}{
|
||||
if _, err := client.Logical().Write("kv/data/patch/foo", map[string]interface{}{
|
||||
"data": map[string]interface{}{
|
||||
"foo": "a",
|
||||
"bar": "b",
|
||||
@@ -997,7 +997,7 @@ func TestKVPatchCommand_CAS(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
@@ -1017,7 +1017,7 @@ func TestKVPatchCommand_CAS(t *testing.T) {
|
||||
|
||||
kvClient.SetToken(secretAuth.ClientToken)
|
||||
|
||||
_, err = kvClient.Logical().WriteWithContext(context.Background(), "kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
|
||||
_, err = kvClient.Logical().Write("kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1076,7 +1076,7 @@ func TestKVPatchCommand_Methods(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
@@ -1096,7 +1096,7 @@ func TestKVPatchCommand_Methods(t *testing.T) {
|
||||
|
||||
kvClient.SetToken(secretAuth.ClientToken)
|
||||
|
||||
_, err = kvClient.Logical().WriteWithContext(context.Background(), "kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
|
||||
_, err = kvClient.Logical().Write("kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1150,7 +1150,7 @@ func TestKVPatchCommand_403Fallback(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
@@ -1171,7 +1171,7 @@ func TestKVPatchCommand_403Fallback(t *testing.T) {
|
||||
kvClient.SetToken(secretAuth.ClientToken)
|
||||
|
||||
// Write a value then attempt to patch it
|
||||
_, err = kvClient.Logical().WriteWithContext(context.Background(), "kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
|
||||
_, err = kvClient.Logical().Write("kv/data/foo", map[string]interface{}{"data": map[string]interface{}{"bar": "baz"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1231,7 +1231,7 @@ func TestKVPatchCommand_RWMethodPolicyVariations(t *testing.T) {
|
||||
client, closer := testVaultServer(t)
|
||||
defer closer()
|
||||
|
||||
if err := client.Sys().MountWithContext(context.Background(), "kv/", &api.MountInput{
|
||||
if err := client.Sys().Mount("kv/", &api.MountInput{
|
||||
Type: "kv-v2",
|
||||
}); err != nil {
|
||||
t.Fatalf("kv-v2 mount attempt failed - err: %#v\n", err)
|
||||
@@ -1315,11 +1315,11 @@ func TestPadEqualSigns(t *testing.T) {
|
||||
func createTokenForPolicy(t *testing.T, client *api.Client, policy string) (*api.SecretAuth, error) {
|
||||
t.Helper()
|
||||
|
||||
if err := client.Sys().PutPolicyWithContext(context.Background(), "policy", policy); err != nil {
|
||||
if err := client.Sys().PutPolicy("policy", policy); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
secret, err := client.Auth().Token().CreateWithContext(context.Background(), &api.TokenCreateRequest{
|
||||
secret, err := client.Auth().Token().Create(&api.TokenCreateRequest{
|
||||
Policies: []string{"policy"},
|
||||
TTL: "30m",
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user