mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-16 15:01:13 +01:00
Set TokenParent in the Index to be cached (#10833)
Co-authored-by: Calvin Leung Huang <cleung2010@gmail.com>
This commit is contained in:
parent
298b9cde2f
commit
38a6f4cf9e
3
changelog/10833.txt
Normal file
3
changelog/10833.txt
Normal file
@ -0,0 +1,3 @@
|
||||
```release-note:bug
|
||||
agent: Set TokenParent correctly in the Index to be cached.
|
||||
```
|
||||
2
command/agent/cache/lease_cache.go
vendored
2
command/agent/cache/lease_cache.go
vendored
@ -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)
|
||||
|
||||
12
command/agent/cache/lease_cache_test.go
vendored
12
command/agent/cache/lease_cache_test.go
vendored
@ -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…
x
Reference in New Issue
Block a user