-
Notifications
You must be signed in to change notification settings - Fork 31
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 panic on renewing a renewable KV v1 secret #118
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,6 +270,40 @@ func TestPassthroughBackend_Revoke(t *testing.T) { | |
test(b) | ||
} | ||
|
||
func TestPassthroughBackend_Renew(t *testing.T) { | ||
b := testPassthroughLeasedBackend() | ||
|
||
req := logical.TestRequest(t, logical.CreateOperation, "foo") | ||
req.Data = map[string]interface{}{ | ||
"ttl": "4h", | ||
"payload": "alpha", | ||
} | ||
storage := req.Storage | ||
if _, err := b.HandleRequest(context.Background(), req); err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
|
||
req = logical.TestRequest(t, logical.RenewOperation, "foo") | ||
req.Storage = storage | ||
req.Secret = &logical.Secret{ | ||
InternalData: map[string]interface{}{ | ||
"secret_type": "kv", | ||
}, | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to reviewer: This is a bit fake, hacking together just enough of what a real RenewOperation request would look like. Ideally I'd like to run a real Core and generate a real lease renewal, but the relevant test helpers are not exposed for out-of-tree plugins to use. This is probably good enough, I guess. |
||
resp, err := b.HandleRequest(context.Background(), req) | ||
if err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
|
||
expected := map[string]interface{}{ | ||
"ttl": "4h", | ||
"payload": "alpha", | ||
} | ||
if !reflect.DeepEqual(resp.Data, expected) { | ||
t.Fatalf("bad response.\n\nexpected: %#v\n\nGot: %#v", expected, resp) | ||
} | ||
} | ||
|
||
func testPassthroughBackend() logical.Backend { | ||
return testPassthroughBackendWithEvents(nil) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewer: The changes above are just an opportunistic cleanup whilst I was here ... one of the three factory functions was inconsistently missing the
Factory
suffix.Compatibility: Should not really be an issue, no-one other than Vault should be importing this as a library and Vault doesn't (yet) call these.