From 799f0ae76d948849d5c8aa4e1897b2bbb307c688 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Tue, 24 Sep 2019 15:39:20 -0400 Subject: [PATCH] more meaningful assertion for tls hsts test --- test/e2e/settings/tls.go | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/test/e2e/settings/tls.go b/test/e2e/settings/tls.go index c74449553f..ac9930786c 100644 --- a/test/e2e/settings/tls.go +++ b/test/e2e/settings/tls.go @@ -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). @@ -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). @@ -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). @@ -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() {