mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Fix SRV Lookups (#8520)
* Pin HTTP Host header for all client requests * Drop port map scheme * Add SRV Lookup environment var * Lookup SRV records only when env var is specified * Add docs Co-Authored-By: Michel Vocks <michelvocks@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c53e0c8ebf
commit
8dd6180e31
@@ -97,6 +97,37 @@ func TestClientToken(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientHostHeader(t *testing.T) {
|
||||
handler := func(w http.ResponseWriter, req *http.Request) {
|
||||
w.Write([]byte(req.Host))
|
||||
}
|
||||
config, ln := testHTTPServer(t, http.HandlerFunc(handler))
|
||||
defer ln.Close()
|
||||
|
||||
config.Address = strings.ReplaceAll(config.Address, "127.0.0.1", "localhost")
|
||||
client, err := NewClient(config)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// Set the token manually
|
||||
client.SetToken("foo")
|
||||
|
||||
resp, err := client.RawRequest(client.NewRequest("PUT", "/"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Copy the response
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, resp.Body)
|
||||
|
||||
// Verify we got the response from the primary
|
||||
if buf.String() != strings.ReplaceAll(config.Address, "http://", "") {
|
||||
t.Fatalf("Bad address: %s", buf.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientBadToken(t *testing.T) {
|
||||
handler := func(w http.ResponseWriter, req *http.Request) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user