-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat: use test host name for marker if localhost alias #370
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,6 +6,7 @@ package runner | |||||||||||
import ( | ||||||||||||
"errors" | ||||||||||||
"fmt" | ||||||||||||
"net" | ||||||||||||
"time" | ||||||||||||
|
||||||||||||
schema "github.com/coreruleset/ftw-tests-schema/v2/types" | ||||||||||||
|
@@ -221,6 +222,8 @@ func RunStage(runContext *TestRunContext, ftwCheck *check.FTWCheck, testCase sch | |||||||||||
} | ||||||||||||
|
||||||||||||
func markAndFlush(runContext *TestRunContext, dest *ftwhttp.Destination, stageID string) ([]byte, error) { | ||||||||||||
host := "localhost" | ||||||||||||
|
||||||||||||
rline := &ftwhttp.RequestLine{ | ||||||||||||
Method: "GET", | ||||||||||||
// Use the `/status` endpoint of `httpbin` (http://httpbingo.org), if possible, | ||||||||||||
|
@@ -230,10 +233,19 @@ func markAndFlush(runContext *TestRunContext, dest *ftwhttp.Destination, stageID | |||||||||||
Version: "HTTP/1.1", | ||||||||||||
} | ||||||||||||
|
||||||||||||
// check if destination host is an alias for localhost | ||||||||||||
addrs, err := net.LookupHost(dest.DestAddr) | ||||||||||||
if err != nil { | ||||||||||||
return nil, fmt.Errorf("ftw/run: can't resolve destination %+v: %w", dest, err) | ||||||||||||
} | ||||||||||||
// we only take the first IP address | ||||||||||||
if net.ParseIP(addrs[0]).IsLoopback() { | ||||||||||||
host = dest.DestAddr | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apart from the comment, I think this should be set to the host entry of the current stage. The
Suggested change
|
||||||||||||
} | ||||||||||||
headers := &ftwhttp.Header{ | ||||||||||||
"Accept": "*/*", | ||||||||||||
"User-Agent": "go-ftw test agent", | ||||||||||||
"Host": "localhost", | ||||||||||||
"Host": host, | ||||||||||||
runContext.Config.LogMarkerHeaderName: stageID, | ||||||||||||
} | ||||||||||||
|
||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know if this even make sense. Maybe just ignoring the error and moving on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it does. Running the test makes no sense because resolution will fail again.