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

Fix Renew operation for KV v1 #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 7 additions & 8 deletions passthrough.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func LeaseSwitchedPassthroughBackend(ctx context.Context, conf *logical.BackendC
},

Paths: []*framework.Path{
&framework.Path{
{
Pattern: framework.MatchAllRegex("path"),

Fields: map[string]*framework.FieldSchema{
Expand All @@ -76,10 +76,13 @@ func LeaseSwitchedPassthroughBackend(ctx context.Context, conf *logical.BackendC
},
},
Secrets: []*framework.Secret{
&framework.Secret{
{
Type: "kv",

Renew: b.handleRead(),
Renew: func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
// This is a no-op
return nil, nil
},
Revoke: func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
// This is a no-op
return nil, nil
Expand All @@ -89,7 +92,7 @@ func LeaseSwitchedPassthroughBackend(ctx context.Context, conf *logical.BackendC
}

if conf == nil {
return nil, fmt.Errorf("Configuation passed into backend is nil")
return nil, fmt.Errorf("Configuration passed into backend is nil")
}
backend.Setup(ctx, conf)
b.Backend = backend
Expand Down Expand Up @@ -185,10 +188,6 @@ func (b *PassthroughBackend) handleRead() framework.OperationFunc {
}
}

func (b *PassthroughBackend) GeneratesLeases() bool {
return b.generateLeases
}

func (b *PassthroughBackend) handleWrite() framework.OperationFunc {
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
key := data.Get("path").(string)
Expand Down
19 changes: 19 additions & 0 deletions passthrough_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,25 @@ func TestPassthroughBackend_List(t *testing.T) {
test(b)
}

func TestPassthroughBackend_Renew(t *testing.T) {
test := func(b logical.Backend) {
req := logical.TestRequest(t, logical.RenewOperation, "kv")
req.Secret = &logical.Secret{
InternalData: map[string]interface{}{
"secret_type": "kv",
},
}

if _, err := b.HandleRequest(context.Background(), req); err != nil {
t.Fatalf("err: %v", err)
}
}
b := testPassthroughBackend()
test(b)
b = testPassthroughLeasedBackend()
test(b)
}

func TestPassthroughBackend_Revoke(t *testing.T) {
test := func(b logical.Backend) {
req := logical.TestRequest(t, logical.RevokeOperation, "kv")
Expand Down