5037185d5d
* Revamp agent cache client * Update command/agent.go Co-Authored-By: vishalnayak <vishalnayak@users.noreply.github.com> * Agent cache auto auth token lookup case (#6258) * agent cache auto auth token lookup case * Use Blake2b256Hash instead of SHA256 * agent/cache: update cache-clear endpoint; use bytes.NewReader instead (#6259) * agent/cache: update cache-clear endpoint; use bytes.NewReader instead * agent/cache: Fix TestCache_ComputeIndexID after switching to blake2b * agent/cache: Only parse response body if it's non-nil (#6260) * Differently disable agent address in the API client * Remove DisableAgent
48 lines
1,013 B
Go
48 lines
1,013 B
Go
package cache
|
|
|
|
import (
|
|
"testing"
|
|
|
|
hclog "github.com/hashicorp/go-hclog"
|
|
"github.com/hashicorp/vault/api"
|
|
"github.com/hashicorp/vault/helper/jsonutil"
|
|
"github.com/hashicorp/vault/helper/logging"
|
|
"github.com/hashicorp/vault/helper/namespace"
|
|
)
|
|
|
|
func TestCache_APIProxy(t *testing.T) {
|
|
cleanup, client, _, _ := setupClusterAndAgent(namespace.RootContext(nil), t, nil)
|
|
defer cleanup()
|
|
|
|
proxier, err := NewAPIProxy(&APIProxyConfig{
|
|
Client: client,
|
|
Logger: logging.NewVaultLogger(hclog.Trace),
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
r := client.NewRequest("GET", "/v1/sys/health")
|
|
req, err := r.ToHTTP()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
resp, err := proxier.Send(namespace.RootContext(nil), &SendRequest{
|
|
Request: req,
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
var result api.HealthResponse
|
|
err = jsonutil.DecodeJSONFromReader(resp.Response.Body, &result)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !result.Initialized || result.Sealed || result.Standby {
|
|
t.Fatalf("bad sys/health response")
|
|
}
|
|
}
|