Set TokenParent in the Index to be cached (#10833)
Co-authored-by: Calvin Leung Huang <cleung2010@gmail.com>
This commit is contained in:
parent
b1c4b86d7f
commit
c62ce48b5b
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
agent: Set TokenParent correctly in the Index to be cached.
|
||||
```
|
|
@ -353,7 +353,7 @@ func (c *LeaseCache) Send(ctx context.Context, req *SendRequest) (*SendResponse,
|
|||
c.logger.Debug("setting parent context", "method", req.Request.Method, "path", req.Request.URL.Path)
|
||||
parentCtx = entry.RenewCtxInfo.Ctx
|
||||
|
||||
entry.TokenParent = req.Token
|
||||
index.TokenParent = req.Token
|
||||
}
|
||||
|
||||
renewCtxInfo = c.createCtxInfo(parentCtx)
|
||||
|
|
|
@ -162,6 +162,18 @@ func TestLeaseCache_SendCacheable(t *testing.T) {
|
|||
t.Fatalf("expected getting proxied response: got %v", diff)
|
||||
}
|
||||
|
||||
// Check TokenParent
|
||||
cachedItem, err := lc.db.Get(cachememdb.IndexNameToken, "testtoken")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cachedItem == nil {
|
||||
t.Fatalf("expected token entry from cache")
|
||||
}
|
||||
if cachedItem.TokenParent != "autoauthtoken" {
|
||||
t.Fatalf("unexpected value for tokenparent: %s", cachedItem.TokenParent)
|
||||
}
|
||||
|
||||
// Modify the request a little bit to ensure the second response is
|
||||
// returned to the lease cache.
|
||||
sendReq = &SendRequest{
|
||||
|
|
Loading…
Reference in New Issue