fix: Remove curl dependencies in e2e tests #9716

Signed-off-by: Son Bui <sonbv00@gmail.com>
This commit is contained in:
Son Bui 2023-08-11 19:44:14 +08:00
parent 061d4d8b13
commit 57aacebd90

View file

@ -170,15 +170,17 @@ var _ = framework.DescribeSetting("[SSL] TLS protocols, ciphers and headers)", f
hstsIncludeSubdomains: "false", hstsIncludeSubdomains: "false",
}) })
// we can not use gorequest here because it flattens the duplicate headers expectResponse := f.HTTPTestClientWithTLSConfig(tlsConfig).
// and specifically in case of Strict-Transport-Security it ignore extra headers GET("/").
// intead of concatenating, rightfully. And I don't know of any API it provides for getting raw headers. WithURL(f.GetURL(framework.HTTPS)).
curlCmd := fmt.Sprintf("curl -I -k --fail --silent --resolve settings-tls:443:127.0.0.1 https://settings-tls%v", "?hsts=true") WithHeader("Host", host).
output, err := f.ExecIngressPod(curlCmd) WithQuery("hsts", "true").
assert.Nil(ginkgo.GinkgoT(), err) Expect()
assert.Contains(ginkgo.GinkgoT(), output, "strict-transport-security: max-age=86400; preload")
// this is what the upstream sets expectResponse.Header("Strict-Transport-Security").Equal("max-age=86400; preload")
assert.NotContains(ginkgo.GinkgoT(), output, "strict-transport-security: max-age=3600; preload") header := expectResponse.Raw().Header
got := header["Strict-Transport-Security"]
assert.Equal(ginkgo.GinkgoT(), 1, len(got))
}) })
}) })