Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more meaningful assertion for tls hsts test #4597

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions test/e2e/settings/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() {
By("setting max-age parameter")
f.UpdateNginxConfigMapData(hstsMaxAge, "86400")

f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "Strict-Transport-Security: max-age=86400; includeSubDomains\"")
})

resp, _, errs := gorequest.New().
Get(f.GetURL(framework.HTTPS)).
TLSClientConfig(tlsConfig).
Expand All @@ -132,16 +127,11 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() {

Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
Expect(resp.Header.Get("Strict-Transport-Security")).Should(ContainSubstring("max-age=86400"))
Expect(resp.Header.Get("Strict-Transport-Security")).Should(Equal("max-age=86400; includeSubDomains"))

By("setting includeSubDomains parameter")
f.UpdateNginxConfigMapData(hstsIncludeSubdomains, "false")

f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "Strict-Transport-Security: max-age=86400\"")
})

resp, _, errs = gorequest.New().
Get(f.GetURL(framework.HTTPS)).
TLSClientConfig(tlsConfig).
Expand All @@ -150,16 +140,11 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() {

Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
Expect(resp.Header.Get("Strict-Transport-Security")).ShouldNot(ContainSubstring("includeSubDomains"))
Expect(resp.Header.Get("Strict-Transport-Security")).Should(Equal("max-age=86400"))

By("setting preload parameter")
f.UpdateNginxConfigMapData(hstsPreload, "true")

f.WaitForNginxServer(host,
func(server string) bool {
return strings.Contains(server, "Strict-Transport-Security: max-age=86400; preload\"")
})

resp, _, errs = gorequest.New().
Get(f.GetURL(framework.HTTPS)).
TLSClientConfig(tlsConfig).
Expand All @@ -168,7 +153,7 @@ var _ = framework.IngressNginxDescribe("Settings - TLS)", func() {

Expect(errs).Should(BeEmpty())
Expect(resp.StatusCode).Should(Equal(http.StatusOK))
Expect(resp.Header.Get("Strict-Transport-Security")).Should(ContainSubstring("preload"))
Expect(resp.Header.Get("Strict-Transport-Security")).Should(Equal("max-age=86400; preload"))
})

It("should not use ports during the HTTP to HTTPS redirection", func() {
Expand Down