Skip to content

Commit

Permalink
fix: add Host to request in trigger (#4008)
Browse files Browse the repository at this point in the history
add Host to request in trigger
  • Loading branch information
mathnogueira authored Sep 3, 2024
1 parent 62def36 commit 1a3b7b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions agent/workers/trigger/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func (te *httpTriggerer) Trigger(ctx context.Context, triggerConfig Trigger, opt
tReq.Authenticate(req)
propagators().Inject(ctx, propagation.HeaderCarrier(req.Header))

if host := req.Header.Get("Host"); host != "" {
req.Host = host
}

resp, err := client.Do(req.WithContext(ctx))
if err != nil {
return response, err
Expand Down
11 changes: 5 additions & 6 deletions agent/workers/trigger/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"

"github.com/kubeshop/tracetest/agent/workers/trigger"
triggerer "github.com/kubeshop/tracetest/agent/workers/trigger"
"github.com/kubeshop/tracetest/server/pkg/id"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -56,7 +55,7 @@ func TestTriggerGet(t *testing.T) {
},
}

ex := triggerer.HTTP()
ex := trigger.HTTP()

resp, err := ex.Trigger(createContext(), triggerConfig, nil)
assert.NoError(t, err)
Expand Down Expand Up @@ -100,7 +99,7 @@ func TestTriggerPost(t *testing.T) {
},
}

ex := triggerer.HTTP()
ex := trigger.HTTP()

resp, err := ex.Trigger(createContext(), triggerConfig, nil)
assert.NoError(t, err)
Expand Down Expand Up @@ -158,7 +157,7 @@ func TestTriggerPostWithApiKeyAuth(t *testing.T) {
},
}

ex := triggerer.HTTP()
ex := trigger.HTTP()

resp, err := ex.Trigger(createContext(), triggerConfig, nil)
assert.NoError(t, err)
Expand Down Expand Up @@ -215,7 +214,7 @@ func TestTriggerPostWithBasicAuth(t *testing.T) {
},
}

ex := triggerer.HTTP()
ex := trigger.HTTP()

resp, err := ex.Trigger(createContext(), triggerConfig, nil)
assert.NoError(t, err)
Expand Down Expand Up @@ -271,7 +270,7 @@ func TestTriggerPostWithBearerAuth(t *testing.T) {
},
}

ex := triggerer.HTTP()
ex := trigger.HTTP()

resp, err := ex.Trigger(createContext(), triggerConfig, nil)
assert.NoError(t, err)
Expand Down
4 changes: 4 additions & 0 deletions server/executor/trigger/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ func (te *httpTriggerer) Trigger(ctx context.Context, test test.Test, opts *Trig
tReq.Authenticate(req)
propagators().Inject(ctx, propagation.HeaderCarrier(req.Header))

if host := req.Header.Get("Host"); host != "" {
req.Host = host
}

resp, err := client.Do(req.WithContext(ctx))
if err != nil {
return response, err
Expand Down

0 comments on commit 1a3b7b0

Please sign in to comment.