From 867d09c0b69bf0ed1ec5748b00420951bb12dfe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Tue, 18 Jun 2024 12:08:59 -0500 Subject: [PATCH] Remove check for Server header in curl request tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 https://github.com/cloudfoundry/capi-release/pull/406 Signed-off-by: João Pereira --- integration/v7/isolated/curl_command_test.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/integration/v7/isolated/curl_command_test.go b/integration/v7/isolated/curl_command_test.go index 5cc7f01d5b..b6d3889aae 100644 --- a/integration/v7/isolated/curl_command_test.go +++ b/integration/v7/isolated/curl_command_test.go @@ -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" @@ -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: .+`)) } @@ -386,7 +383,7 @@ 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()) @@ -394,7 +391,19 @@ var _ = Describe("curl command", func() { 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() {