Replace request_uri

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-09-27 20:26:39 -03:00
parent 108637bb1c
commit 493dd6726d
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
6 changed files with 31 additions and 16 deletions

View file

@ -46,6 +46,6 @@ var _ = framework.DescribeAnnotation("force-ssl-redirect", func() {
WithHeader("Host", host).
Expect().
Status(http.StatusPermanentRedirect).
Header("Location").Equal("https://forcesslredirect.bar.com/")
Header("Location").Equal("https://forcesslredirect.bar.com")
})
})

View file

@ -49,7 +49,7 @@ var _ = framework.DescribeAnnotation("from-to-www-redirect", func() {
f.WaitForNginxConfiguration(
func(cfg string) bool {
return strings.Contains(cfg, `server_name www.fromtowwwredirect.bar.com;`) &&
strings.Contains(cfg, `return 308 $scheme://fromtowwwredirect.bar.com$request_uri;`)
strings.Contains(cfg, `return 308 $redirect_to;`)
})
ginkgo.By("sending request to www.fromtowwwredirect.bar.com")
@ -85,7 +85,7 @@ var _ = framework.DescribeAnnotation("from-to-www-redirect", func() {
f.WaitForNginxServer(toHost,
func(server string) bool {
return strings.Contains(server, fmt.Sprintf(`server_name %v;`, toHost)) &&
strings.Contains(server, fmt.Sprintf(`return 308 $scheme://%v$request_uri;`, fromHost))
strings.Contains(server, `return 308 $redirect_to;`)
})
ginkgo.By("sending request to www should redirect to domain")
@ -98,7 +98,7 @@ var _ = framework.DescribeAnnotation("from-to-www-redirect", func() {
WithHeader("Host", toHost).
Expect().
Status(http.StatusPermanentRedirect).
Header("Location").Equal(fmt.Sprintf("https://%v/", fromHost))
Header("Location").Equal(fmt.Sprintf("https://%v", fromHost))
ginkgo.By("sending request to domain should not redirect to www")
f.HTTPTestClientWithTLSConfig(&tls.Config{

View file

@ -196,7 +196,7 @@ var _ = framework.DescribeSetting("[SSL] TLS protocols, ciphers and headers)", f
// 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")
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")
@ -222,7 +222,7 @@ var _ = framework.DescribeSetting("[SSL] TLS protocols, ciphers and headers)", f
WithHeader("Host", host).
Expect().
Status(http.StatusPermanentRedirect).
Header("Location").Equal(fmt.Sprintf("https://%v/", host))
Header("Location").Equal(fmt.Sprintf("https://%v", host))
})
ginkgo.It("should not use ports or X-Forwarded-Host during the HTTP to HTTPS redirection", func() {
@ -243,7 +243,7 @@ var _ = framework.DescribeSetting("[SSL] TLS protocols, ciphers and headers)", f
WithHeader("X-Forwarded-Host", "example.com:80").
Expect().
Status(http.StatusPermanentRedirect).
Header("Location").Equal("https://example.com/")
Header("Location").Equal("https://example.com")
})
})

View file

@ -54,6 +54,6 @@ var _ = framework.IngressNginxDescribe("[SSL] redirect to HTTPS", func() {
WithHeader("Host", host).
Expect().
Status(http.StatusPermanentRedirect).
Header("Location").Equal("https://redirect.com/")
Header("Location").Equal("https://redirect.com")
})
})