fix: deny locations with invalid auth-url annotation (#8256)

* fix: deny locations with invalid auth-url annotation

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

* Delete duplicate test

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
This commit is contained in:
Maksim Nabokikh 2022-03-01 14:13:51 +04:00 committed by GitHub
parent f3698d0445
commit 1e2ce80846
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 48 deletions

View file

@ -692,6 +692,39 @@ http {
Header("Location").Equal(fmt.Sprintf("http://%s/auth/start?rd=http://%s%s", thisHost, thisHost, url.QueryEscape("/?a=b&c=d")))
})
})
ginkgo.Context("with invalid auth-url should deny whole location", func() {
host := "auth"
var annotations map[string]string
var ing *networking.Ingress
ginkgo.BeforeEach(func() {
annotations = map[string]string{
"nginx.ingress.kubernetes.io/auth-url": "https://invalid..auth.url",
}
ing = framework.NewSingleIngress(host, "/denied-auth", host, f.Namespace, framework.EchoService, 80, annotations)
f.EnsureIngress(ing)
f.WaitForNginxServer(host, func(server string) bool {
return strings.Contains(server, "server_name auth")
})
})
ginkgo.It("should return 503 (location was denied)", func() {
f.HTTPTestClient().
GET("/denied-auth").
WithHeader("Host", host).
Expect().
Status(http.StatusServiceUnavailable)
})
ginkgo.It("should add error to the config", func() {
f.WaitForNginxServer(host, func(server string) bool {
return strings.Contains(server, "could not parse auth-url annotation: invalid url host")
})
})
})
})
// TODO: test Digest Auth