Skip to content

Commit

Permalink
fix: Remove curl dependencies in e2e tests kubernetes#9716
Browse files Browse the repository at this point in the history
Signed-off-by: Son Bui <[email protected]>
  • Loading branch information
sonbui00 committed Aug 11, 2023
1 parent 061d4d8 commit 57aaceb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/e2e/settings/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})

})
Expand Down

0 comments on commit 57aaceb

Please sign in to comment.