logical/framework: support renew

This commit is contained in:
Mitchell Hashimoto
2015-03-19 20:20:25 +01:00
parent b54dc20aff
commit 163bfa62a6
7 changed files with 107 additions and 39 deletions

View File

@@ -137,6 +137,39 @@ func TestBackendHandleRequest_help(t *testing.T) {
}
}
func TestBackendHandleRequest_renew(t *testing.T) {
var called uint32
callback := func(*Request) (*logical.Response, error) {
atomic.AddUint32(&called, 1)
return nil, nil
}
b := &Backend{
Secrets: []*Secret{
&Secret{
Type: "foo",
Renew: callback,
},
},
}
_, err := b.HandleRequest(&logical.Request{
Operation: logical.RenewOperation,
Path: "/foo",
Data: map[string]interface{}{
"previous_lease": &logical.Lease{
VaultID: "foo-bar",
},
},
})
if err != nil {
t.Fatalf("err: %s", err)
}
if v := atomic.LoadUint32(&called); v != 1 {
t.Fatalf("bad: %#v", v)
}
}
func TestBackendHandleRequest_revoke(t *testing.T) {
var called uint32
callback := func(*Request) (*logical.Response, error) {