Fix golangci-lint errors (#10196)
* Fix golangci-lint errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix dupl errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix comments Signed-off-by: z1cheng <imchench@gmail.com> * Fix errcheck lint errors Signed-off-by: z1cheng <imchench@gmail.com> * Fix assert in e2e test Signed-off-by: z1cheng <imchench@gmail.com> * Not interrupt the waitForPodsReady Signed-off-by: z1cheng <imchench@gmail.com> * Replace string with constant Signed-off-by: z1cheng <imchench@gmail.com> * Fix comments Signed-off-by: z1cheng <imchench@gmail.com> * Revert write file permision Signed-off-by: z1cheng <imchench@gmail.com> --------- Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
46d87d3462
commit
b3060bfbd0
253 changed files with 2434 additions and 2113 deletions
|
|
@ -25,6 +25,11 @@ import (
|
|||
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||
)
|
||||
|
||||
const (
|
||||
originHost = "http://origin.com:8080"
|
||||
corsHost = "cors.foo.com"
|
||||
)
|
||||
|
||||
var _ = framework.DescribeAnnotation("cors-*", func() {
|
||||
f := framework.NewDefaultFramework("cors")
|
||||
|
||||
|
|
@ -33,7 +38,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should enable cors", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
}
|
||||
|
|
@ -60,7 +65,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should set cors methods to only allow POST, GET", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-allow-methods": "POST, GET",
|
||||
|
|
@ -76,7 +81,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should set cors max-age", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-max-age": "200",
|
||||
|
|
@ -92,7 +97,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should disable cors allow credentials", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-allow-credentials": "false",
|
||||
|
|
@ -108,7 +113,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow origin for cors", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "https://origin.cors.com:8080"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -135,7 +140,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow headers for cors", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-allow-headers": "DNT, User-Agent",
|
||||
|
|
@ -151,7 +156,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should expose headers for cors", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-expose-headers": "X-CustomResponseHeader, X-CustomSecondHeader",
|
||||
|
|
@ -167,7 +172,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow - single origin for multiple cors values", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "https://origin.cors.com:8080"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -194,7 +199,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not allow - single origin for multiple cors values", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "http://no.origin.com"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -214,7 +219,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow correct origins - single origin for multiple cors values", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
badOrigin := "origin.cors.com:8080"
|
||||
origin1 := "https://origin2.cors.com"
|
||||
origin2 := "https://origin.com"
|
||||
|
|
@ -265,7 +270,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not break functionality", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-allow-origin": "*",
|
||||
|
|
@ -289,7 +294,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not break functionality - without `*`", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
}
|
||||
|
|
@ -312,7 +317,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not break functionality with extra domain", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-allow-origin": "*, foo.bar.com",
|
||||
|
|
@ -336,7 +341,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not match", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "https://fooxbar.com"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -356,8 +361,8 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow - single origin with required port", func() {
|
||||
host := "cors.foo.com"
|
||||
origin := "http://origin.com:8080"
|
||||
host := corsHost
|
||||
origin := originHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-allow-origin": "http://origin.cors.com:8080, http://origin.com:8080",
|
||||
|
|
@ -384,8 +389,8 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not allow - single origin with port and origin without port", func() {
|
||||
host := "cors.foo.com"
|
||||
origin := "http://origin.com:8080"
|
||||
host := corsHost
|
||||
origin := originHost
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
"nginx.ingress.kubernetes.io/cors-allow-origin": "https://origin2.cors.com, http://origin.com",
|
||||
|
|
@ -403,7 +408,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not allow - single origin without port and origin with required port", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "http://origin.com"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -423,7 +428,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow - matching origin with wildcard origin (2 subdomains)", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "http://foo.origin.cors.com"
|
||||
origin2 := "http://bar-foo.origin.cors.com"
|
||||
annotations := map[string]string{
|
||||
|
|
@ -466,7 +471,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not allow - unmatching origin with wildcard origin (2 subdomains)", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "http://bar.foo.origin.cors.com"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -486,7 +491,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow - matching origin+port with wildcard origin", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "http://abc.origin.com:8080"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -513,7 +518,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should not allow - portless origin with wildcard origin", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "http://abc.origin.com"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -533,8 +538,8 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow correct origins - missing subdomain + origin with wildcard origin and correct origin", func() {
|
||||
host := "cors.foo.com"
|
||||
badOrigin := "http://origin.com:8080"
|
||||
host := corsHost
|
||||
badOrigin := originHost
|
||||
origin := "http://bar.origin.com:8080"
|
||||
annotations := map[string]string{
|
||||
"nginx.ingress.kubernetes.io/enable-cors": "true",
|
||||
|
|
@ -569,7 +574,7 @@ var _ = framework.DescribeAnnotation("cors-*", func() {
|
|||
})
|
||||
|
||||
ginkgo.It("should allow - missing origins (should allow all origins)", func() {
|
||||
host := "cors.foo.com"
|
||||
host := corsHost
|
||||
origin := "http://origin.com"
|
||||
origin2 := "http://book.origin.com"
|
||||
origin3 := "test.origin.com"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue