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