diff --git a/internal/ingress/annotations/rewrite/main.go b/internal/ingress/annotations/rewrite/main.go index 270bdb1a71..b1e63bc37a 100644 --- a/internal/ingress/annotations/rewrite/main.go +++ b/internal/ingress/annotations/rewrite/main.go @@ -39,7 +39,7 @@ type Config struct { // AppRoot defines the Application Root that the Controller must redirect if it's in '/' context AppRoot string `json:"appRoot"` // UseRegex indicates whether or not the locations use regex paths - UseRegex bool `json:useRegex` + UseRegex bool `json:"useRegex"` } // Equal tests for equality between two Redirect types diff --git a/test/e2e/annotations/affinity.go b/test/e2e/annotations/affinity.go index 2cd389bfe2..5903f7e154 100644 --- a/test/e2e/annotations/affinity.go +++ b/test/e2e/annotations/affinity.go @@ -36,8 +36,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", f := framework.NewDefaultFramework("affinity") BeforeEach(func() { - err := f.NewEchoDeploymentWithReplicas(2) - Expect(err).NotTo(HaveOccurred()) + f.NewEchoDeploymentWithReplicas(2) }) AfterEach(func() { @@ -51,16 +50,12 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", } ing := framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations) - _, err := f.EnsureIngress(ing) + f.EnsureIngress(ing) - Expect(err).NotTo(HaveOccurred()) - Expect(ing).NotTo(BeNil()) - - err = f.WaitForNginxServer(host, + f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, fmt.Sprintf("server_name %s ;", host)) }) - Expect(err).NotTo(HaveOccurred()) resp, _, errs := gorequest.New(). Get(f.IngressController.HTTPURL). @@ -80,16 +75,12 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", } ing := framework.NewSingleIngress(host, "/something", host, f.IngressController.Namespace, "http-svc", 80, &annotations) - _, err := f.EnsureIngress(ing) - - Expect(err).NotTo(HaveOccurred()) - Expect(ing).NotTo(BeNil()) + f.EnsureIngress(ing) - err = f.WaitForNginxServer(host, + f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, fmt.Sprintf("server_name %s ;", host)) }) - Expect(err).NotTo(HaveOccurred()) resp, _, errs := gorequest.New(). Get(f.IngressController.HTTPURL+"/something"). @@ -108,7 +99,7 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", "nginx.ingress.kubernetes.io/session-cookie-name": "SERVERID", } - ing, err := f.EnsureIngress(&v1beta1.Ingress{ + f.EnsureIngress(&v1beta1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Name: host, Namespace: f.IngressController.Namespace, @@ -143,14 +134,10 @@ var _ = framework.IngressNginxDescribe("Annotations - Affinity/Sticky Sessions", }, }) - Expect(err).NotTo(HaveOccurred()) - Expect(ing).NotTo(BeNil()) - - err = f.WaitForNginxServer(host, + f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, fmt.Sprintf("server_name %s ;", host)) }) - Expect(err).NotTo(HaveOccurred()) resp, _, errs := gorequest.New(). Get(f.IngressController.HTTPURL+"/something"). diff --git a/test/e2e/lua/dynamic_certificates.go b/test/e2e/lua/dynamic_certificates.go index 46cf79585c..3541997df7 100644 --- a/test/e2e/lua/dynamic_certificates.go +++ b/test/e2e/lua/dynamic_certificates.go @@ -150,6 +150,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Certificate", func() { It("picks up the updated certificate without reloading", func() { ing, err := f.KubeClientSet.ExtensionsV1beta1().Ingresses(f.IngressController.Namespace).Get(host, metav1.GetOptions{}) + Expect(err).ToNot(HaveOccurred()) ensureHTTPSRequest(fmt.Sprintf("%s?id=dummy_log_splitter_foo_bar", f.IngressController.HTTPSURL), host, host) diff --git a/test/e2e/settings/geoip2.go b/test/e2e/settings/geoip2.go index f802fd575d..325691b514 100644 --- a/test/e2e/settings/geoip2.go +++ b/test/e2e/settings/geoip2.go @@ -19,11 +19,12 @@ package settings import ( "strings" + "net/http" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/parnurzeal/gorequest" "k8s.io/ingress-nginx/test/e2e/framework" - "net/http" ) var _ = framework.IngressNginxDescribe("Geoip2", func() { @@ -32,27 +33,23 @@ var _ = framework.IngressNginxDescribe("Geoip2", func() { host := "geoip2" BeforeEach(func() { - err := f.NewEchoDeployment() - Expect(err).NotTo(HaveOccurred()) + f.NewEchoDeployment() }) It("should only allow requests from specific countries", func() { - err := f.UpdateNginxConfigMapData("use-geoip2", "true") - Expect(err).NotTo(HaveOccurred()) + f.UpdateNginxConfigMapData("use-geoip2", "true") httpSnippetAllowingOnlyAustralia := `map $geoip2_city_country_code $blocked_country { default 1; AU 0; }` - err = f.UpdateNginxConfigMapData("http-snippet", httpSnippetAllowingOnlyAustralia) - Expect(err).NotTo(HaveOccurred()) + f.UpdateNginxConfigMapData("http-snippet", httpSnippetAllowingOnlyAustralia) - err = f.WaitForNginxConfiguration( + f.WaitForNginxConfiguration( func(cfg string) bool { return strings.Contains(cfg, "map $geoip2_city_country_code $blocked_country") }) - Expect(err).NotTo(HaveOccurred()) configSnippet := `if ($blocked_country) { @@ -63,32 +60,29 @@ var _ = framework.IngressNginxDescribe("Geoip2", func() { "nginx.ingress.kubernetes.io/configuration-snippet": configSnippet, } - ing, err := f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)) - Expect(err).NotTo(HaveOccurred()) - Expect(ing).NotTo(BeNil()) + f.EnsureIngress(framework.NewSingleIngress(host, "/", host, f.IngressController.Namespace, "http-svc", 80, &annotations)) - err = f.WaitForNginxConfiguration( + f.WaitForNginxConfiguration( func(cfg string) bool { return strings.Contains(cfg, "if ($blocked_country)") }) - Expect(err).NotTo(HaveOccurred()) // Should be blocked - usIp := "8.8.8.8" + usIP := "8.8.8.8" resp, _, errs := gorequest.New(). Get(f.IngressController.HTTPURL). Set("Host", host). - Set("X-Forwarded-For", usIp). + Set("X-Forwarded-For", usIP). End() Expect(errs).To(BeNil()) Expect(resp.StatusCode).Should(Equal(http.StatusForbidden)) // Shouldn't be blocked - australianIp := "1.1.1.1" + australianIP := "1.1.1.1" resp, _, errs = gorequest.New(). Get(f.IngressController.HTTPURL). Set("Host", host). - Set("X-Forwarded-For", australianIp). + Set("X-Forwarded-For", australianIP). End() Expect(errs).To(BeNil()) Expect(resp.StatusCode).Should(Equal(http.StatusOK))