Skip to content

Commit

Permalink
Remove check for Server header in curl request tests
Browse files Browse the repository at this point in the history
Starting on version 1.181.0, capi will no longer report the version of
the nginx server to ensure that no information is leaked.
For more information check cloudfoundry/capi-release#406

Signed-off-by: João Pereira <joaod@vmware.com>
  • Loading branch information
joaopapereira committed Jun 24, 2024
1 parent 74d334e commit 867d09c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions integration/v7/isolated/curl_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"

. "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers"

"code.cloudfoundry.org/cli/integration/helpers"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -57,11 +56,9 @@ var _ = Describe("curl command", func() {

var ExpectResponseHeaders = func(session *Session) {
Eventually(session).Should(Say("HTTP/1.1 200 OK"))
Eventually(session).Should(Say(`Connection: .+`))
Eventually(session).Should(Say(`Content-Length: .+`))
Eventually(session).Should(Say(`Content-Type: .+`))
Eventually(session).Should(Say(`Date: .+`))
Eventually(session).Should(Say(`Server: .+`))
Eventually(session).Should(Say(`X-Content-Type-Options: .+`))
Eventually(session).Should(Say(`X-Vcap-Request-Id: .+`))
}
Expand Down Expand Up @@ -386,15 +383,27 @@ var _ = Describe("curl command", func() {
})

When("--output is passed with a file name", func() {
It("writes the response body to the file but the other output to stdout", func() {
It("writes the response headers and body to the file", func() {
outFile, err := os.CreateTemp("", "output*.json")
Expect(err).ToNot(HaveOccurred())
session := helpers.CF("curl", "/v2/apps", "-i", "--output", outFile.Name())
Eventually(session).Should(Exit(0))
ExpectResponseHeaders(session)
body, err := os.ReadFile(outFile.Name())
Expect(err).ToNot(HaveOccurred())
Expect(string(body)).To(MatchJSON(expectedJSON))

contents := string(body)
jsonStartsAt := strings.Index(contents, "{")

Expect(contents).To(ContainSubstring("HTTP/1.1 200 OK"))
Expect(contents).To(MatchRegexp(`Content-Length: .+`))
Expect(contents).To(MatchRegexp(`Content-Type: .+`))
Expect(contents).To(MatchRegexp(`Date: .+`))
Expect(contents).To(MatchRegexp(`X-Content-Type-Options: .+`))
Expect(contents).To(MatchRegexp(`X-Vcap-Request-Id: .+`))

actualJSON := contents[jsonStartsAt:]
Expect(actualJSON).To(MatchJSON(expectedJSON))
})

When("--output is passed and CF_TRACE is set to a file", func() {
Expand Down

0 comments on commit 867d09c

Please sign in to comment.