Merge pull request #766 from hashicorp/issue-766
Display whether a token is an orphan on lookup.
This commit is contained in:
commit
3717b31b63
|
@ -33,6 +33,8 @@ IMPROVEMENTS:
|
|||
* core: Tokens can now renew themselves [GH-455]
|
||||
* core: Base64-encoded PGP keys can be used with the CLI for `init` and
|
||||
`rekey` operations [GH-653]
|
||||
* credential/token: Display whether or not a token is an orphan in the output
|
||||
of a lookup call [GH-766]
|
||||
* logical: Allow `.` in path-based variables in many more locations [GH-244]
|
||||
* logical: Responses now contain a "warnings" key containing a list of
|
||||
warnings returned from the server. These are conditions that did not require
|
||||
|
|
|
@ -121,6 +121,7 @@ func TestLogical_StandbyRedirect(t *testing.T) {
|
|||
"path": "auth/token/root",
|
||||
"policies": []interface{}{"root"},
|
||||
"display_name": "root",
|
||||
"orphan": true,
|
||||
"id": root,
|
||||
"ttl": float64(0),
|
||||
},
|
||||
|
|
|
@ -800,10 +800,16 @@ func (ts *TokenStore) handleLookup(
|
|||
"meta": out.Meta,
|
||||
"display_name": out.DisplayName,
|
||||
"num_uses": out.NumUses,
|
||||
"orphan": false,
|
||||
"creation_time": int(out.CreationTime),
|
||||
"ttl": int(out.TTL.Seconds()),
|
||||
},
|
||||
}
|
||||
|
||||
if out.Parent == "" {
|
||||
resp.Data["orphan"] = true
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -866,12 +866,39 @@ func TestTokenStore_HandleRequest_Lookup(t *testing.T) {
|
|||
"path": "auth/token/root",
|
||||
"meta": map[string]string(nil),
|
||||
"display_name": "root",
|
||||
"orphan": true,
|
||||
"num_uses": 0,
|
||||
"ttl": 0,
|
||||
}
|
||||
delete(resp.Data, "creation_time")
|
||||
if !reflect.DeepEqual(resp.Data, exp) {
|
||||
t.Fatalf("bad: %#v exp: %#v", resp.Data, exp)
|
||||
t.Fatalf("bad:\n%#v\nexp:\n%#v\n", resp.Data, exp)
|
||||
}
|
||||
|
||||
testMakeToken(t, ts, root, "client", []string{"foo"})
|
||||
|
||||
req = logical.TestRequest(t, logical.ReadOperation, "lookup/client")
|
||||
resp, err = ts.HandleRequest(req)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v %v", err, resp)
|
||||
}
|
||||
if resp == nil {
|
||||
t.Fatalf("bad: %#v", resp)
|
||||
}
|
||||
|
||||
exp = map[string]interface{}{
|
||||
"id": "client",
|
||||
"policies": []string{"foo"},
|
||||
"path": "auth/token/create",
|
||||
"meta": map[string]string(nil),
|
||||
"display_name": "token",
|
||||
"orphan": false,
|
||||
"num_uses": 0,
|
||||
"ttl": 2592000,
|
||||
}
|
||||
delete(resp.Data, "creation_time")
|
||||
if !reflect.DeepEqual(resp.Data, exp) {
|
||||
t.Fatalf("bad:\n%#v\nexp:\n%#v\n", resp.Data, exp)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -933,6 +960,7 @@ func TestTokenStore_HandleRequest_LookupSelf(t *testing.T) {
|
|||
"path": "auth/token/root",
|
||||
"meta": map[string]string(nil),
|
||||
"display_name": "root",
|
||||
"orphan": true,
|
||||
"num_uses": 0,
|
||||
"ttl": 0,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue