Skip to content

Commit

Permalink
Update plugin deps to include context changes (#3765)
Browse files Browse the repository at this point in the history
* Update plugin deps to include context changes

* Fix tests
  • Loading branch information
briankassouf authored Jan 8, 2018
1 parent 202a7ae commit 2a32435
Show file tree
Hide file tree
Showing 20 changed files with 306 additions and 159 deletions.
3 changes: 2 additions & 1 deletion builtin/logical/rabbitmq/backend_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rabbitmq

import (
"context"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -130,7 +131,7 @@ func testAccStepReadCreds(t *testing.T, b logical.Backend, name string) logicalt
t.Fatalf("unable to list vhosts with generated credentials: %s", err)
}

resp, err = b.HandleRequest(&logical.Request{
resp, err = b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.RevokeOperation,
Secret: &logical.Secret{
InternalData: map[string]interface{}{
Expand Down
5 changes: 3 additions & 2 deletions builtin/logical/rabbitmq/path_config_lease_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rabbitmq

import (
"context"
"testing"
"time"

Expand All @@ -27,7 +28,7 @@ func TestBackend_config_lease_RU(t *testing.T) {
Storage: config.StorageView,
Data: configData,
}
resp, err = b.HandleRequest(configReq)
resp, err = b.HandleRequest(context.Background(), configReq)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("bad: resp: %#v\nerr:%s", resp, err)
}
Expand All @@ -36,7 +37,7 @@ func TestBackend_config_lease_RU(t *testing.T) {
}

configReq.Operation = logical.ReadOperation
resp, err = b.HandleRequest(configReq)
resp, err = b.HandleRequest(context.Background(), configReq)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("bad: resp: %#v\nerr:%s", resp, err)
}
Expand Down
5 changes: 3 additions & 2 deletions command/generate-root_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package command

import (
"context"
"encoding/base64"
"encoding/hex"
"os"
Expand Down Expand Up @@ -160,7 +161,7 @@ func TestGenerateRoot_OTP(t *testing.T) {
req := logical.TestRequest(t, logical.ReadOperation, "lookup-self")
req.ClientToken = token

resp, err := ts.HandleRequest(req)
resp, err := ts.HandleRequest(context.Background(), req)
if err != nil {
t.Fatalf("error running token lookup-self: %v", err)
}
Expand Down Expand Up @@ -272,7 +273,7 @@ func TestGenerateRoot_PGP(t *testing.T) {
req := logical.TestRequest(t, logical.ReadOperation, "lookup-self")
req.ClientToken = token

resp, err := ts.HandleRequest(req)
resp, err := ts.HandleRequest(context.Background(), req)
if err != nil {
t.Fatalf("error running token lookup-self: %v", err)
}
Expand Down
7 changes: 4 additions & 3 deletions command/rekey_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package command

import (
"context"
"encoding/hex"
"os"
"sort"
Expand Down Expand Up @@ -267,7 +268,7 @@ func TestRekey_init_pgp(t *testing.T) {
backupVals := &backupStruct{}

req := logical.TestRequest(t, logical.ReadOperation, "rekey/backup")
resp, err := sysBackend.HandleRequest(req)
resp, err := sysBackend.HandleRequest(context.Background(), req)
if err != nil {
t.Fatalf("error running backed-up unseal key fetch: %v", err)
}
Expand All @@ -286,12 +287,12 @@ func TestRekey_init_pgp(t *testing.T) {

// Now delete and try again; the values should be inaccessible
req = logical.TestRequest(t, logical.DeleteOperation, "rekey/backup")
resp, err = sysBackend.HandleRequest(req)
resp, err = sysBackend.HandleRequest(context.Background(), req)
if err != nil {
t.Fatalf("error running backed-up unseal key delete: %v", err)
}
req = logical.TestRequest(t, logical.ReadOperation, "rekey/backup")
resp, err = sysBackend.HandleRequest(req)
resp, err = sysBackend.HandleRequest(context.Background(), req)
if err != nil {
t.Fatalf("error running backed-up unseal key fetch: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions helper/mfa/mfa_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mfa

import (
"context"
"testing"

"github.com/hashicorp/vault/logical"
Expand Down Expand Up @@ -43,8 +44,7 @@ func testPathLogin() *framework.Path {
}
}

func testPathLoginHandler(
req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
func testPathLoginHandler(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
username := d.Get("username").(string)

return &logical.Response{
Expand Down
45 changes: 23 additions & 22 deletions logical/framework/backend_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package framework

import (
"context"
"reflect"
"sync/atomic"
"testing"
Expand Down Expand Up @@ -42,7 +43,7 @@ func TestBackend_impl(t *testing.T) {
}

func TestBackendHandleRequest(t *testing.T) {
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
return &logical.Response{
Data: map[string]interface{}{
"value": data.Get("value"),
Expand All @@ -64,7 +65,7 @@ func TestBackendHandleRequest(t *testing.T) {
},
}

resp, err := b.HandleRequest(&logical.Request{
resp, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.ReadOperation,
Path: "foo/bar",
Data: map[string]interface{}{"value": "42"},
Expand All @@ -78,7 +79,7 @@ func TestBackendHandleRequest(t *testing.T) {
}

func TestBackendHandleRequest_badwrite(t *testing.T) {
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
return &logical.Response{
Data: map[string]interface{}{
"value": data.Get("value").(bool),
Expand All @@ -100,7 +101,7 @@ func TestBackendHandleRequest_badwrite(t *testing.T) {
},
}

_, err := b.HandleRequest(&logical.Request{
_, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.UpdateOperation,
Path: "foo/bar",
Data: map[string]interface{}{"value": "3false3"},
Expand All @@ -113,7 +114,7 @@ func TestBackendHandleRequest_badwrite(t *testing.T) {
}

func TestBackendHandleRequest_404(t *testing.T) {
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
return &logical.Response{
Data: map[string]interface{}{
"value": data.Get("value"),
Expand All @@ -135,7 +136,7 @@ func TestBackendHandleRequest_404(t *testing.T) {
},
}

_, err := b.HandleRequest(&logical.Request{
_, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.ReadOperation,
Path: "foo/baz",
Data: map[string]interface{}{"value": "84"},
Expand All @@ -159,7 +160,7 @@ func TestBackendHandleRequest_help(t *testing.T) {
},
}

resp, err := b.HandleRequest(&logical.Request{
resp, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.HelpOperation,
Path: "foo/bar",
Data: map[string]interface{}{"value": "42"},
Expand All @@ -177,7 +178,7 @@ func TestBackendHandleRequest_helpRoot(t *testing.T) {
Help: "42",
}

resp, err := b.HandleRequest(&logical.Request{
resp, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.HelpOperation,
Path: "",
})
Expand All @@ -192,7 +193,7 @@ func TestBackendHandleRequest_helpRoot(t *testing.T) {
func TestBackendHandleRequest_renewAuth(t *testing.T) {
b := &Backend{}

resp, err := b.HandleRequest(logical.RenewAuthRequest("/foo", &logical.Auth{}, nil))
resp, err := b.HandleRequest(context.Background(), logical.RenewAuthRequest("/foo", &logical.Auth{}, nil))
if err != nil {
t.Fatalf("err: %s", err)
}
Expand All @@ -203,7 +204,7 @@ func TestBackendHandleRequest_renewAuth(t *testing.T) {

func TestBackendHandleRequest_renewAuthCallback(t *testing.T) {
var called uint32
callback := func(*logical.Request, *FieldData) (*logical.Response, error) {
callback := func(context.Context, *logical.Request, *FieldData) (*logical.Response, error) {
atomic.AddUint32(&called, 1)
return nil, nil
}
Expand All @@ -212,7 +213,7 @@ func TestBackendHandleRequest_renewAuthCallback(t *testing.T) {
AuthRenew: callback,
}

_, err := b.HandleRequest(logical.RenewAuthRequest("/foo", &logical.Auth{}, nil))
_, err := b.HandleRequest(context.Background(), logical.RenewAuthRequest("/foo", &logical.Auth{}, nil))
if err != nil {
t.Fatalf("err: %s", err)
}
Expand All @@ -222,7 +223,7 @@ func TestBackendHandleRequest_renewAuthCallback(t *testing.T) {
}
func TestBackendHandleRequest_renew(t *testing.T) {
var called uint32
callback := func(*logical.Request, *FieldData) (*logical.Response, error) {
callback := func(context.Context, *logical.Request, *FieldData) (*logical.Response, error) {
atomic.AddUint32(&called, 1)
return nil, nil
}
Expand All @@ -235,7 +236,7 @@ func TestBackendHandleRequest_renew(t *testing.T) {
Secrets: []*Secret{secret},
}

_, err := b.HandleRequest(logical.RenewRequest("/foo", secret.Response(nil, nil).Secret, nil))
_, err := b.HandleRequest(context.Background(), logical.RenewRequest("/foo", secret.Response(nil, nil).Secret, nil))
if err != nil {
t.Fatalf("err: %s", err)
}
Expand All @@ -262,7 +263,7 @@ func TestBackendHandleRequest_renewExtend(t *testing.T) {
req := logical.RenewRequest("/foo", secret.Response(nil, nil).Secret, nil)
req.Secret.IssueTime = time.Now()
req.Secret.Increment = 1 * time.Hour
resp, err := b.HandleRequest(req)
resp, err := b.HandleRequest(context.Background(), req)
if err != nil {
t.Fatalf("err: %s", err)
}
Expand All @@ -277,7 +278,7 @@ func TestBackendHandleRequest_renewExtend(t *testing.T) {

func TestBackendHandleRequest_revoke(t *testing.T) {
var called uint32
callback := func(*logical.Request, *FieldData) (*logical.Response, error) {
callback := func(context.Context, *logical.Request, *FieldData) (*logical.Response, error) {
atomic.AddUint32(&called, 1)
return nil, nil
}
Expand All @@ -290,7 +291,7 @@ func TestBackendHandleRequest_revoke(t *testing.T) {
Secrets: []*Secret{secret},
}

_, err := b.HandleRequest(logical.RevokeRequest("/foo", secret.Response(nil, nil).Secret, nil))
_, err := b.HandleRequest(context.Background(), logical.RevokeRequest("/foo", secret.Response(nil, nil).Secret, nil))
if err != nil {
t.Fatalf("err: %s", err)
}
Expand Down Expand Up @@ -321,7 +322,7 @@ func TestBackendHandleRequest_rollback(t *testing.T) {

time.Sleep(10 * time.Millisecond)

_, err := b.HandleRequest(&logical.Request{
_, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.RollbackOperation,
Path: "",
Storage: storage,
Expand Down Expand Up @@ -354,7 +355,7 @@ func TestBackendHandleRequest_rollbackMinAge(t *testing.T) {
t.Fatalf("err: %s", err)
}

_, err := b.HandleRequest(&logical.Request{
_, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.RollbackOperation,
Path: "",
Storage: storage,
Expand All @@ -368,7 +369,7 @@ func TestBackendHandleRequest_rollbackMinAge(t *testing.T) {
}

func TestBackendHandleRequest_unsupportedOperation(t *testing.T) {
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
return &logical.Response{
Data: map[string]interface{}{
"value": data.Get("value"),
Expand All @@ -390,7 +391,7 @@ func TestBackendHandleRequest_unsupportedOperation(t *testing.T) {
},
}

_, err := b.HandleRequest(&logical.Request{
_, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.UpdateOperation,
Path: "foo/bar",
Data: map[string]interface{}{"value": "84"},
Expand All @@ -401,7 +402,7 @@ func TestBackendHandleRequest_unsupportedOperation(t *testing.T) {
}

func TestBackendHandleRequest_urlPriority(t *testing.T) {
callback := func(req *logical.Request, data *FieldData) (*logical.Response, error) {
callback := func(ctx context.Context, req *logical.Request, data *FieldData) (*logical.Response, error) {
return &logical.Response{
Data: map[string]interface{}{
"value": data.Get("value"),
Expand All @@ -423,7 +424,7 @@ func TestBackendHandleRequest_urlPriority(t *testing.T) {
},
}

resp, err := b.HandleRequest(&logical.Request{
resp, err := b.HandleRequest(context.Background(), &logical.Request{
Operation: logical.ReadOperation,
Path: "foo/42",
Data: map[string]interface{}{"value": "84"},
Expand Down
3 changes: 2 additions & 1 deletion logical/framework/lease_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package framework

import (
"context"
"testing"
"time"

Expand Down Expand Up @@ -97,7 +98,7 @@ func TestLeaseExtend(t *testing.T) {
}

callback := LeaseExtend(tc.BackendDefault, tc.BackendMax, testSysView)
resp, err := callback(req, nil)
resp, err := callback(context.Background(), req, nil)
if (err != nil) != tc.Error {
t.Fatalf("bad: %s\nerr: %s", name, err)
}
Expand Down
Loading

0 comments on commit 2a32435

Please sign in to comment.