Fix sending of basic auth credentials in http output (#4609)
This commit is contained in:
parent
8b2d64585d
commit
7b05993a6e
|
@ -131,6 +131,10 @@ func (h *HTTP) write(reqBody []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if h.Username != "" || h.Password != "" {
|
||||||
|
req.SetBasicAuth(h.Username, h.Password)
|
||||||
|
}
|
||||||
|
|
||||||
req.Header.Set("Content-Type", defaultContentType)
|
req.Header.Set("Content-Type", defaultContentType)
|
||||||
for k, v := range h.Headers {
|
for k, v := range h.Headers {
|
||||||
req.Header.Set(k, v)
|
req.Header.Set(k, v)
|
||||||
|
|
|
@ -237,8 +237,6 @@ func TestBasicAuth(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
plugin *HTTP
|
plugin *HTTP
|
||||||
username string
|
|
||||||
password string
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "default",
|
name: "default",
|
||||||
|
@ -274,8 +272,8 @@ func TestBasicAuth(t *testing.T) {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
username, password, _ := r.BasicAuth()
|
username, password, _ := r.BasicAuth()
|
||||||
require.Equal(t, tt.username, username)
|
require.Equal(t, tt.plugin.Username, username)
|
||||||
require.Equal(t, tt.password, password)
|
require.Equal(t, tt.plugin.Password, password)
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue