From bdd4bcb90cb6e7c3b50b8435f95421990959c7a7 Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Tue, 31 Mar 2020 11:21:11 -0500 Subject: [PATCH 01/13] readme update --- extras/dgoss/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/dgoss/README.md b/extras/dgoss/README.md index c7d027eb1..ec8714a86 100644 --- a/extras/dgoss/README.md +++ b/extras/dgoss/README.md @@ -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 @@ -100,4 +100,5 @@ 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 `''`) From 1745381682ec5faae11375ffbdb0f2370265a509 Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Tue, 31 Mar 2020 12:05:32 -0500 Subject: [PATCH 02/13] set host properly header if present --- system/http.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/http.go b/system/http.go index eb40f9f01..81d042a47 100644 --- a/system/http.go +++ b/system/http.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http" + "os" "strings" "time" @@ -40,6 +41,7 @@ func NewDefHTTP(httpStr string, system *System, config util.Config) HTTP { str := strings.SplitN(r, ": ", 2) headers.Add(str[0], str[1]) } + fmt.Printf("\nheaders: %v\n\n", headers) return &DefHTTP{ http: httpStr, allowInsecure: config.AllowInsecure, @@ -86,6 +88,14 @@ func (u *DefHTTP) setup() error { return u.err } req.Header = u.RequestHeader.Clone() + + if host, ok := u.RequestHeader["Host"]; ok { + if len(host) > 1 { + fmt.Fprintf(os.Stderr, "multiple host headers detected, using first: (%v)", host[0]) + } + req.Host = host[0] + } + if u.Username != "" || u.Password != "" { req.SetBasicAuth(u.Username, u.Password) } From b9ed3a37146e6057524110a6ccbf57cae88040cb Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Tue, 31 Mar 2020 17:19:25 -0500 Subject: [PATCH 03/13] uncomment fix; add test --- integration-tests/goss/goss-shared.yaml | 8 ++++++++ system/http.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/integration-tests/goss/goss-shared.yaml b/integration-tests/goss/goss-shared.yaml index 68af361c0..1d816615c 100644 --- a/integration-tests/goss/goss-shared.yaml +++ b/integration-tests/goss/goss-shared.yaml @@ -180,6 +180,14 @@ interface: contain-element: have-prefix: '172.17' http: + https://httpbin.org/headers: + status: 200 + allow-insecure: false + timeout: 10000 + request-headers: + - "Host: example.com" + headers: ["Content-Type: application/json"] + body: ['"Host": "example.com"'] https://httpbin.org/headers: status: 200 allow-insecure: false diff --git a/system/http.go b/system/http.go index 81d042a47..b3503189c 100644 --- a/system/http.go +++ b/system/http.go @@ -5,7 +5,7 @@ import ( "fmt" "io" "net/http" - "os" + // "os" "strings" "time" From f95fac2bb3dab16dd932d000ebe09453beb767ff Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Wed, 1 Apr 2020 09:26:52 -0500 Subject: [PATCH 04/13] add back os lib --- system/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/http.go b/system/http.go index b3503189c..81d042a47 100644 --- a/system/http.go +++ b/system/http.go @@ -5,7 +5,7 @@ import ( "fmt" "io" "net/http" - // "os" + "os" "strings" "time" From 5077f3bc360e8887b752167620a8ccf5306817ba Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Wed, 1 Apr 2020 09:41:17 -0500 Subject: [PATCH 05/13] remove printing to stderr/stdout --- system/http.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/system/http.go b/system/http.go index 81d042a47..9f62acbdc 100644 --- a/system/http.go +++ b/system/http.go @@ -41,7 +41,6 @@ func NewDefHTTP(httpStr string, system *System, config util.Config) HTTP { str := strings.SplitN(r, ": ", 2) headers.Add(str[0], str[1]) } - fmt.Printf("\nheaders: %v\n\n", headers) return &DefHTTP{ http: httpStr, allowInsecure: config.AllowInsecure, @@ -90,9 +89,6 @@ func (u *DefHTTP) setup() error { req.Header = u.RequestHeader.Clone() if host, ok := u.RequestHeader["Host"]; ok { - if len(host) > 1 { - fmt.Fprintf(os.Stderr, "multiple host headers detected, using first: (%v)", host[0]) - } req.Host = host[0] } From 5f1c2d5d16a4b762b74c1525dfd06c0c8e073502 Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Wed, 1 Apr 2020 09:42:51 -0500 Subject: [PATCH 06/13] rename host header test --- integration-tests/goss/goss-shared.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/integration-tests/goss/goss-shared.yaml b/integration-tests/goss/goss-shared.yaml index 1d816615c..1bed22c1e 100644 --- a/integration-tests/goss/goss-shared.yaml +++ b/integration-tests/goss/goss-shared.yaml @@ -183,19 +183,19 @@ http: https://httpbin.org/headers: status: 200 allow-insecure: false - timeout: 10000 + timeout: 5000 request-headers: - - "Host: example.com" + - "Foo: bar" headers: ["Content-Type: application/json"] - body: ['"Host": "example.com"'] - https://httpbin.org/headers: + body: ['"Foo": "bar"'] + https://httpbin.org/headers?host: status: 200 allow-insecure: false - timeout: 5000 + timeout: 10000 request-headers: - - "Foo: bar" + - "Host: example.com" headers: ["Content-Type: application/json"] - body: ['"Foo": "bar"'] + body: ['"Host": "example.com"'] https://httpbin.org/basic-auth/username/secret: status: 200 username: username From b05b1683e28690cc6caec1d72bf5f400fe2a0c3e Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Wed, 1 Apr 2020 09:51:40 -0500 Subject: [PATCH 07/13] rename other duplicate test --- integration-tests/goss/goss-shared.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/goss/goss-shared.yaml b/integration-tests/goss/goss-shared.yaml index 1bed22c1e..a1a205129 100644 --- a/integration-tests/goss/goss-shared.yaml +++ b/integration-tests/goss/goss-shared.yaml @@ -191,7 +191,7 @@ http: https://httpbin.org/headers?host: status: 200 allow-insecure: false - timeout: 10000 + timeout: 5000 request-headers: - "Host: example.com" headers: ["Content-Type: application/json"] @@ -200,7 +200,7 @@ http: status: 200 username: username password: secret - https://httpbin.org/basic-auth/username/secret: + https://httpbin.org/basic-auth/username/secret?failure: status: 401 username: username password: wrong From fdb4ef10bbeca65736ec49191c08a78d7f34a15d Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Wed, 1 Apr 2020 10:06:40 -0500 Subject: [PATCH 08/13] remove unneeded lib --- system/http.go | 1 - 1 file changed, 1 deletion(-) diff --git a/system/http.go b/system/http.go index 9f62acbdc..1454bd62f 100644 --- a/system/http.go +++ b/system/http.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "net/http" - "os" "strings" "time" From 855d1234e6fe518ee54001cae11419ad93267ba0 Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Wed, 1 Apr 2020 10:45:44 -0500 Subject: [PATCH 09/13] update test counts --- integration-tests/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/test.sh b/integration-tests/test.sh index d8493eaf5..ac18920a2 100755 --- a/integration-tests/test.sh +++ b/integration-tests/test.sh @@ -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 From 2ce992f9632240c6a1e24a63ff1b479406dae70e Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Wed, 1 Apr 2020 10:47:12 -0500 Subject: [PATCH 10/13] ninja markdown edit --- extras/dgoss/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/dgoss/README.md b/extras/dgoss/README.md index ec8714a86..362be5f0b 100644 --- a/extras/dgoss/README.md +++ b/extras/dgoss/README.md @@ -100,5 +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'`. +**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 `''`) From 2ceff47b132fa7db171aa04fcc2e8b9eb01c5fba Mon Sep 17 00:00:00 2001 From: John Knutson Date: Mon, 6 Apr 2020 10:10:12 -0500 Subject: [PATCH 11/13] Update system/http.go Co-Authored-By: Ahmed Elsabbahy --- system/http.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/http.go b/system/http.go index 1454bd62f..faefb342e 100644 --- a/system/http.go +++ b/system/http.go @@ -87,8 +87,8 @@ func (u *DefHTTP) setup() error { } req.Header = u.RequestHeader.Clone() - if host, ok := u.RequestHeader["Host"]; ok { - req.Host = host[0] + if host := req.Header.Get("Host"); host != "" { + req.Host = host } if u.Username != "" || u.Password != "" { From cd4aeb3017c44c02b005c83cd14452f2af84b443 Mon Sep 17 00:00:00 2001 From: "John M. Knutson" Date: Mon, 6 Apr 2020 12:52:31 -0500 Subject: [PATCH 12/13] add note about host header --- docs/manual.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/manual.md b/docs/manual.md index 296fa5107..09d3e911b 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -617,6 +617,7 @@ http: skip: false ``` +**NOTE:** only the first `Host` header will be used to set the `Request.Host` value if multiple are provided. ### interface Validates network interface values From 19cb65d49aa39aebfc8583ae276a1bd33ef0aea9 Mon Sep 17 00:00:00 2001 From: Ahmed Elsabbahy Date: Sun, 3 May 2020 10:23:22 -0700 Subject: [PATCH 13/13] Revert documentation change since it was fixed with #582 --- extras/dgoss/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/extras/dgoss/README.md b/extras/dgoss/README.md index 362be5f0b..64d045d89 100644 --- a/extras/dgoss/README.md +++ b/extras/dgoss/README.md @@ -100,6 +100,4 @@ 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 `''`)