From f8d70b64a0d1bfefd78a902e7df15631efa164d5 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 1 Jun 2016 17:30:31 -0400 Subject: [PATCH] Show renewable status for tokens in output --- vault/token_store.go | 5 +++++ vault/token_store_test.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/vault/token_store.go b/vault/token_store.go index 9663fc95a..b77d23d8d 100644 --- a/vault/token_store.go +++ b/vault/token_store.go @@ -1280,6 +1280,11 @@ func (ts *TokenStore) handleLookup( if !leaseTimes.ExpireTime.IsZero() { resp.Data["ttl"] = int64(leaseTimes.ExpireTime.Sub(time.Now().Round(time.Second)).Seconds()) } + if err := leaseTimes.renewable(); err == nil { + resp.Data["renewable"] = true + } else { + resp.Data["renewable"] = false + } } return resp, nil diff --git a/vault/token_store_test.go b/vault/token_store_test.go index 54523891f..b37edefba 100644 --- a/vault/token_store_test.go +++ b/vault/token_store_test.go @@ -1016,6 +1016,7 @@ func TestTokenStore_HandleRequest_Lookup(t *testing.T) { "ttl": int64(3600), "role": "", "explicit_max_ttl": int64(0), + "renewable": true, } if resp.Data["creation_time"].(int64) == 0 { @@ -1058,6 +1059,7 @@ func TestTokenStore_HandleRequest_Lookup(t *testing.T) { "ttl": int64(3600), "role": "", "explicit_max_ttl": int64(0), + "renewable": true, } if resp.Data["creation_time"].(int64) == 0 {