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

Host header update #565

Merged
merged 15 commits into from
May 3, 2020
4 changes: 3 additions & 1 deletion extras/dgoss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The following environment variables can be set to change the behavior of dgoss.
##### GOSS_PATH
Location of the goss binary to use. (Default: `$(which goss)`)

#### GOSS_FILE
##### GOSS_FILE
Name of the goss file to use. (Default: `goss.yaml`)

##### GOSS_OPTS
Expand Down Expand Up @@ -100,4 +100,6 @@ Strategy used for copying goss files into the docker container. If set to `'moun
(Default `'mount'`)

##### CONTAINER_LOG_OUTPUT
**Note:** this only works when `GOSS_FILES_STRATEGY` is set to `'mount'`.

Location of the file that contains tested container logs. Logs are retained only if the variable is set to a non-empty string. (Default `''`)
10 changes: 9 additions & 1 deletion integration-tests/goss/goss-shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,19 @@ http:
- "Foo: bar"
headers: ["Content-Type: application/json"]
body: ['"Foo": "bar"']
https://httpbin.org/headers?host:
johnk-novu marked this conversation as resolved.
Show resolved Hide resolved
status: 200
allow-insecure: false
timeout: 5000
request-headers:
- "Host: example.com"
headers: ["Content-Type: application/json"]
body: ['"Host": "example.com"']
https://httpbin.org/basic-auth/username/secret:
status: 200
username: username
password: secret
https://httpbin.org/basic-auth/username/secret:
https://httpbin.org/basic-auth/username/secret?failure:
johnk-novu marked this conversation as resolved.
Show resolved Hide resolved
status: 401
username: username
password: wrong
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ out=$(docker_exec "/goss/$os/goss-linux-$arch" --vars "/goss/vars.yaml" --vars-i
echo "$out"

if [[ $os == "arch" ]]; then
egrep -q 'Count: 86, Failed: 0, Skipped: 3' <<<"$out"
egrep -q 'Count: 90, Failed: 0, Skipped: 3' <<<"$out"
else
egrep -q 'Count: 103, Failed: 0, Skipped: 5' <<<"$out"
egrep -q 'Count: 107, Failed: 0, Skipped: 5' <<<"$out"
fi

if [[ ! $os == "arch" ]]; then
Expand Down
5 changes: 5 additions & 0 deletions system/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func (u *DefHTTP) setup() error {
return u.err
}
req.Header = u.RequestHeader.Clone()

if host, ok := u.RequestHeader["Host"]; ok {
req.Host = host[0]
}
johnk-novu marked this conversation as resolved.
Show resolved Hide resolved

if u.Username != "" || u.Password != "" {
req.SetBasicAuth(u.Username, u.Password)
}
Expand Down