Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add Host to request in trigger #4008

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Comment on lines 10 to -11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those were the same import, but one was named.

"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
Loading