core: handleLoginRequest should set resp.Auth.Orphan = true (#6335)

* core: handleLoginRequest should set resp.Auth.Orphan = true

* set auth.Orphan in RegisterAuth dynamically

* update related tests
This commit is contained in:
Calvin Leung Huang
2019-03-04 14:32:09 -08:00
committed by GitHub
parent 213da13264
commit 4858864a70
3 changed files with 4 additions and 2 deletions

View File

@@ -217,6 +217,7 @@ func TestLogical_CreateToken(t *testing.T) {
"renewable": false,
"entity_id": "",
"token_type": "service",
"orphan": false,
},
"warnings": nilWarnings,
}

View File

@@ -35,8 +35,8 @@ func TestTokenStore_CreateOrphanResponse(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if secret.Auth.Orphan {
t.Fatalf("failed to set orphan as true")
if !secret.Auth.Orphan {
t.Fatalf("failed to set orphan as true, got: %#v", secret.Auth)
}
}

View File

@@ -1162,6 +1162,7 @@ func (c *Core) RegisterAuth(ctx context.Context, tokenTTL time.Duration, path st
auth.ClientToken = te.ID
auth.Accessor = te.Accessor
auth.TTL = te.TTL
auth.Orphan = te.Parent == ""
switch auth.TokenType {
case logical.TokenTypeBatch: