vault: Test renew of bad ID
This commit is contained in:
parent
e52f1ee960
commit
57b4f970d2
|
@ -203,7 +203,11 @@ func (b *SystemBackend) handleRenew(
|
|||
increment := time.Duration(incrementRaw) * time.Second
|
||||
|
||||
// Invoke the expiration manager directly
|
||||
return b.Core.expiration.Renew(vaultID, increment)
|
||||
resp, err := b.Core.expiration.Renew(vaultID, increment)
|
||||
if err != nil {
|
||||
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// sysHelp is all the help text for the sys backend.
|
||||
|
|
|
@ -184,6 +184,20 @@ func TestSystemBackend_renew(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSystemBackend_renew_invalidID(t *testing.T) {
|
||||
b := testSystemBackend(t)
|
||||
|
||||
// Attempt renew
|
||||
req := logical.TestRequest(t, logical.WriteOperation, "renew/foobarbaz")
|
||||
resp, err := b.HandleRequest(req)
|
||||
if err != logical.ErrInvalidRequest {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if resp.Data["error"] != "lease not found" {
|
||||
t.Fatalf("bad: %v", resp)
|
||||
}
|
||||
}
|
||||
|
||||
func testSystemBackend(t *testing.T) logical.Backend {
|
||||
c, _ := TestCoreUnsealed(t)
|
||||
return NewSystemBackend(c)
|
||||
|
|
Loading…
Reference in New Issue