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
|
||||
}
|
||||
|
||||
if h.Username != "" || h.Password != "" {
|
||||
req.SetBasicAuth(h.Username, h.Password)
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", defaultContentType)
|
||||
for k, v := range h.Headers {
|
||||
req.Header.Set(k, v)
|
||||
|
|
|
@ -237,8 +237,6 @@ func TestBasicAuth(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
plugin *HTTP
|
||||
username string
|
||||
password string
|
||||
}{
|
||||
{
|
||||
name: "default",
|
||||
|
@ -274,8 +272,8 @@ func TestBasicAuth(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
username, password, _ := r.BasicAuth()
|
||||
require.Equal(t, tt.username, username)
|
||||
require.Equal(t, tt.password, password)
|
||||
require.Equal(t, tt.plugin.Username, username)
|
||||
require.Equal(t, tt.plugin.Password, password)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue