You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/11/09 10:13:08 UTC

[GitHub] [apisix-dashboard] bzp2010 opened a new pull request #2202: test: migrate global rule e2e

bzp2010 opened a new pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202


   Please answer these questions before submitting a pull request, **or your PR will get closed**.
   
   **Why submit this pull request?**
   
   - [ ] Bugfix
   - [ ] New feature provided
   - [x] Improve performance
   - [ ] Backport patches
   
   **What changes will this PR take into?**
   
   Migrate old backend global rule e2e tests to ginkgo implementation.
   
   **Related issues**
   
   part of #2197
   
   **Checklist:**
   
   - [x] Did you explain what problem does this PR solve? Or what new features have been added?
   - [x] Have you added corresponding test cases?
   - [x] Have you modified the corresponding document?
   - [x] Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] bzp2010 commented on a change in pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#discussion_r747973372



##########
File path: api/test/e2enew/global_rule/global_rule_test.go
##########
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package global_rule_test
+
+import (
+	"net/http"
+
+	. "github.com/onsi/ginkgo"
+	. "github.com/onsi/ginkgo/extensions/table"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = Describe("Global Rule", func() {
+	var _ = DescribeTable("test global rule curd",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("full update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-TEST":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-TEST\":\"1.0\"",
+		}),
+		Entry("partial update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPatch,
+			Path:   "/apisix/admin/global_rules/1/plugins",
+			Body: `{
+				"response-rewrite": {
+					"headers": {
+						"X-VERSION":"1.0"
+					}
+				},
+				"key-auth": {}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"key-auth\":{}",
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+	)
+
+	var _ = DescribeTable("test global rule integration",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create route", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					},
+					"uri-blocker": {
+						"block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("verify route with header", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("verify route that should be blocked", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			Query:         "name=%3Bselect%20from%20sys",
+			ExpectStatus:  http.StatusForbidden,
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("update route with same plugin response-rewrite", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"2.0"
+						}
+					}
+				},
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			 }`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"2.0\"",
+		}),
+		Entry("verify route that header should override", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "2.0"},
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),

Review comment:
       @nic-chen I did this test in the CURD section.
   [https://github.com/apache/apisix-dashboard/blob/665c3480a22e8bd1d4a232aa813ad214156af5b9/api/test/e2enew/global_rule/global_rule_test.go#L83-L89](https://github.com/apache/apisix-dashboard/blob/665c3480a22e8bd1d4a232aa813ad214156af5b9/api/test/e2enew/global_rule/global_rule_test.go#L83-L89)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-commenter edited a comment on pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#issuecomment-964005175


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2202](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (deb7de8) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/3f9fb2262554ce05a2cd3af3e11c5b7360809460?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3f9fb22) will **decrease** coverage by `0.84%`.
   > The diff coverage is `n/a`.
   
   > :exclamation: Current head deb7de8 differs from pull request most recent head 022a6b0. Consider uploading reports for the commit 022a6b0 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #2202      +/-   ##
   ==========================================
   - Coverage   62.86%   62.02%   -0.85%     
   ==========================================
     Files          57       57              
     Lines        3905     3905              
   ==========================================
   - Hits         2455     2422      -33     
   - Misses       1165     1203      +38     
   + Partials      285      280       -5     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | backend-e2e-test | `43.84% <ø> (-1.26%)` | :arrow_down: |
   | backend-unit-test | `49.16% <ø> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [api/internal/utils/closer.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL3V0aWxzL2Nsb3Nlci5nbw==) | `33.33% <0.00%> (-33.34%)` | :arrow_down: |
   | [api/internal/handler/global\_rule/global\_rule.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvZ2xvYmFsX3J1bGUvZ2xvYmFsX3J1bGUuZ28=) | `68.11% <0.00%> (-17.40%)` | :arrow_down: |
   | [api/cmd/root.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2NtZC9yb290Lmdv) | `62.50% <0.00%> (-15.63%)` | :arrow_down: |
   | [api/internal/core/server/server.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvc2VydmVyL3NlcnZlci5nbw==) | `44.68% <0.00%> (-8.52%)` | :arrow_down: |
   | [api/internal/core/store/storehub.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmVodWIuZ28=) | `55.55% <0.00%> (-2.97%)` | :arrow_down: |
   | [api/internal/core/storage/etcd.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmFnZS9ldGNkLmdv) | `44.88% <0.00%> (-2.37%)` | :arrow_down: |
   | [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `83.85% <0.00%> (-1.57%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3f9fb22...022a6b0](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-commenter commented on pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#issuecomment-964005175


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2202](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (deb7de8) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/3f9fb2262554ce05a2cd3af3e11c5b7360809460?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3f9fb22) will **decrease** coverage by `13.70%`.
   > The diff coverage is `n/a`.
   
   > :exclamation: Current head deb7de8 differs from pull request most recent head 022a6b0. Consider uploading reports for the commit 022a6b0 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff             @@
   ##           master    #2202       +/-   ##
   ===========================================
   - Coverage   62.86%   49.16%   -13.71%     
   ===========================================
     Files          57       41       -16     
     Lines        3905     3171      -734     
   ===========================================
   - Hits         2455     1559      -896     
   - Misses       1165     1412      +247     
   + Partials      285      200       -85     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | backend-e2e-test | `?` | |
   | backend-unit-test | `49.16% <ø> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [api/main.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL21haW4uZ28=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [api/internal/utils/version.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL3V0aWxzL3ZlcnNpb24uZ28=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [api/internal/filter/request\_id.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2ZpbHRlci9yZXF1ZXN0X2lkLmdv) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | [api/internal/filter/cors.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2ZpbHRlci9jb3JzLmdv) | `0.00% <0.00%> (-70.00%)` | :arrow_down: |
   | [api/internal/core/entity/entity.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvZW50aXR5L2VudGl0eS5nbw==) | `0.00% <0.00%> (-68.19%)` | :arrow_down: |
   | [api/internal/utils/closer.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL3V0aWxzL2Nsb3Nlci5nbw==) | `0.00% <0.00%> (-66.67%)` | :arrow_down: |
   | [api/internal/core/store/storehub.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmVodWIuZ28=) | `0.00% <0.00%> (-58.52%)` | :arrow_down: |
   | [api/internal/utils/consts/api\_error.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL3V0aWxzL2NvbnN0cy9hcGlfZXJyb3IuZ28=) | `0.00% <0.00%> (-50.00%)` | :arrow_down: |
   | [api/internal/handler/tool/tool.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvdG9vbC90b29sLmdv) | `60.00% <0.00%> (-40.00%)` | :arrow_down: |
   | [api/internal/handler/data\_loader/route\_import.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvZGF0YV9sb2FkZXIvcm91dGVfaW1wb3J0Lmdv) | `28.83% <0.00%> (-38.69%)` | :arrow_down: |
   | ... and [39 more](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3f9fb22...022a6b0](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] bzp2010 commented on pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#issuecomment-964142009


   ping @nic-6443 @starsz 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#discussion_r746242799



##########
File path: api/test/e2enew/global_rule/global_rule_test.go
##########
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package global_rule_test
+
+import (
+	"net/http"
+
+	. "github.com/onsi/ginkgo"
+	. "github.com/onsi/ginkgo/extensions/table"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = Describe("Global Rule", func() {
+	var _ = DescribeTable("test global rule curd",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("full update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-TEST":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-TEST\":\"1.0\"",
+		}),
+		Entry("partial update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPatch,
+			Path:   "/apisix/admin/global_rules/1/plugins",
+			Body: `{
+				"response-rewrite": {
+					"headers": {
+						"X-VERSION":"1.0"
+					}
+				},
+				"key-auth": {}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"key-auth\":{}",
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+	)
+
+	var _ = DescribeTable("test global rule integration",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create route", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					},
+					"uri-blocker": {
+						"block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("verify route with header", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("verify route that should be blocked", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			Query:         "name=%3Bselect%20from%20sys",
+			ExpectStatus:  http.StatusForbidden,
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("update route with same plugin response-rewrite", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"2.0"
+						}
+					}
+				},
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			 }`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"2.0\"",
+		}),
+		Entry("verify route that header should override", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "2.0"},
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),

Review comment:
       we could add a test case to check the delete




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] bzp2010 commented on a change in pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#discussion_r747973372



##########
File path: api/test/e2enew/global_rule/global_rule_test.go
##########
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package global_rule_test
+
+import (
+	"net/http"
+
+	. "github.com/onsi/ginkgo"
+	. "github.com/onsi/ginkgo/extensions/table"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = Describe("Global Rule", func() {
+	var _ = DescribeTable("test global rule curd",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("full update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-TEST":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-TEST\":\"1.0\"",
+		}),
+		Entry("partial update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPatch,
+			Path:   "/apisix/admin/global_rules/1/plugins",
+			Body: `{
+				"response-rewrite": {
+					"headers": {
+						"X-VERSION":"1.0"
+					}
+				},
+				"key-auth": {}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"key-auth\":{}",
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+	)
+
+	var _ = DescribeTable("test global rule integration",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create route", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					},
+					"uri-blocker": {
+						"block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("verify route with header", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("verify route that should be blocked", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			Query:         "name=%3Bselect%20from%20sys",
+			ExpectStatus:  http.StatusForbidden,
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("update route with same plugin response-rewrite", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"2.0"
+						}
+					}
+				},
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			 }`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"2.0\"",
+		}),
+		Entry("verify route that header should override", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "2.0"},
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),

Review comment:
       I did this test in the CURD section.
   [https://github.com/apache/apisix-dashboard/blob/665c3480a22e8bd1d4a232aa813ad214156af5b9/api/test/e2enew/global_rule/global_rule_test.go#L83-L89](https://github.com/apache/apisix-dashboard/blob/665c3480a22e8bd1d4a232aa813ad214156af5b9/api/test/e2enew/global_rule/global_rule_test.go#L83-L89)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#discussion_r747974671



##########
File path: api/test/e2enew/global_rule/global_rule_test.go
##########
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package global_rule_test
+
+import (
+	"net/http"
+
+	. "github.com/onsi/ginkgo"
+	. "github.com/onsi/ginkgo/extensions/table"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = Describe("Global Rule", func() {
+	var _ = DescribeTable("test global rule curd",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("full update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-TEST":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-TEST\":\"1.0\"",
+		}),
+		Entry("partial update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPatch,
+			Path:   "/apisix/admin/global_rules/1/plugins",
+			Body: `{
+				"response-rewrite": {
+					"headers": {
+						"X-VERSION":"1.0"
+					}
+				},
+				"key-auth": {}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"key-auth\":{}",
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+	)
+
+	var _ = DescribeTable("test global rule integration",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create route", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					},
+					"uri-blocker": {
+						"block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("verify route with header", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("verify route that should be blocked", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			Query:         "name=%3Bselect%20from%20sys",
+			ExpectStatus:  http.StatusForbidden,
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("update route with same plugin response-rewrite", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"2.0"
+						}
+					}
+				},
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			 }`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"2.0\"",
+		}),
+		Entry("verify route that header should override", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "2.0"},
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),

Review comment:
       Oh,it's not to test the deletion itself, but to make sure that it is really deleted in DP.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] bzp2010 commented on a change in pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
bzp2010 commented on a change in pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#discussion_r757928639



##########
File path: api/test/e2enew/global_rule/global_rule_test.go
##########
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package global_rule_test
+
+import (
+	"net/http"
+
+	. "github.com/onsi/ginkgo"
+	. "github.com/onsi/ginkgo/extensions/table"
+
+	"github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = Describe("Global Rule", func() {
+	var _ = DescribeTable("test global rule curd",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("full update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-TEST":"1.0"
+						}
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-TEST\":\"1.0\"",
+		}),
+		Entry("partial update global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPatch,
+			Path:   "/apisix/admin/global_rules/1/plugins",
+			Body: `{
+				"response-rewrite": {
+					"headers": {
+						"X-VERSION":"1.0"
+					}
+				},
+				"key-auth": {}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"key-auth\":{}",
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+	)
+
+	var _ = DescribeTable("test global rule integration",
+		func(tc base.HttpTestCase) {
+			base.RunTestCase(tc)
+		},
+		Entry("create route", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),
+		Entry("create global rule", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/global_rules/1",
+			Body: `{
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"1.0"
+						}
+					},
+					"uri-blocker": {
+						"block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))"]
+					}
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"1.0\"",
+		}),
+		Entry("verify route with header", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("verify route that should be blocked", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			Query:         "name=%3Bselect%20from%20sys",
+			ExpectStatus:  http.StatusForbidden,
+			ExpectHeaders: map[string]string{"X-VERSION": "1.0"},
+		}),
+		Entry("update route with same plugin response-rewrite", base.HttpTestCase{
+			Object: base.ManagerApiExpect(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/r1",
+			Body: `{
+				"name": "route1",
+				"uri": "/hello",
+				"plugins": {
+					"response-rewrite": {
+						"headers": {
+							"X-VERSION":"2.0"
+						}
+					}
+				},
+				"upstream": {
+					"type": "roundrobin",
+					"nodes": [{
+						"host": "` + base.UpstreamIp + `",
+						"port": 1981,
+						"weight": 1
+					}]
+				}
+			 }`,
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+			ExpectBody:   "\"X-VERSION\":\"2.0\"",
+		}),
+		Entry("verify route that header should override", base.HttpTestCase{
+			Object:        base.APISIXExpect(),
+			Method:        http.MethodGet,
+			Path:          "/hello",
+			ExpectStatus:  http.StatusOK,
+			ExpectBody:    "hello world",
+			ExpectHeaders: map[string]string{"X-VERSION": "2.0"},
+		}),
+		Entry("delete global rule", base.HttpTestCase{
+			Object:       base.ManagerApiExpect(),
+			Method:       http.MethodDelete,
+			Path:         "/apisix/admin/global_rules/1",
+			Headers:      map[string]string{"Authorization": base.GetToken()},
+			ExpectStatus: http.StatusOK,
+		}),

Review comment:
       Hi, @nic-chen, sorry for the delayed response.
   This will be executed in the `AfterSuite` phase, i.e. he will remove the content involved after the test is completed for each type of data.
   [https://github.com/apache/apisix-dashboard/blob/665c3480a22e8bd1d4a232aa813ad214156af5b9/api/test/e2enew/global_rule/global_rule_suite_test.go#L34-L38](https://github.com/apache/apisix-dashboard/blob/665c3480a22e8bd1d4a232aa813ad214156af5b9/api/test/e2enew/global_rule/global_rule_suite_test.go#L34-L38)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan merged pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
juzhiyuan merged pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] bzp2010 edited a comment on pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
bzp2010 edited a comment on pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#issuecomment-964142009


   ping @nic-6443 @starsz Please help review the code. Thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] codecov-commenter edited a comment on pull request #2202: test: migrate global rule e2e

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #2202:
URL: https://github.com/apache/apisix-dashboard/pull/2202#issuecomment-964005175


   # [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2202](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8db021b) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/3f9fb2262554ce05a2cd3af3e11c5b7360809460?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3f9fb22) will **decrease** coverage by `0.58%`.
   > The diff coverage is `n/a`.
   
   > :exclamation: Current head 8db021b differs from pull request most recent head 665c348. Consider uploading reports for the commit 665c348 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/graphs/tree.svg?width=650&height=150&src=pr&token=Q1HERXN96P&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #2202      +/-   ##
   ==========================================
   - Coverage   62.86%   62.27%   -0.59%     
   ==========================================
     Files          57       57              
     Lines        3905     3905              
   ==========================================
   - Hits         2455     2432      -23     
   - Misses       1165     1191      +26     
   + Partials      285      282       -3     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | backend-e2e-test | `44.12% <ø> (-0.98%)` | :arrow_down: |
   | backend-unit-test | `49.13% <ø> (-0.04%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [api/internal/handler/global\_rule/global\_rule.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2hhbmRsZXIvZ2xvYmFsX3J1bGUvZ2xvYmFsX3J1bGUuZ28=) | `68.11% <0.00%> (-17.40%)` | :arrow_down: |
   | [api/cmd/root.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2NtZC9yb290Lmdv) | `75.00% <0.00%> (-3.13%)` | :arrow_down: |
   | [api/internal/core/store/storehub.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmVodWIuZ28=) | `55.55% <0.00%> (-2.97%)` | :arrow_down: |
   | [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `83.33% <0.00%> (-2.09%)` | :arrow_down: |
   | [api/internal/core/storage/etcd.go](https://codecov.io/gh/apache/apisix-dashboard/pull/2202/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmFnZS9ldGNkLmdv) | `45.66% <0.00%> (-1.58%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3f9fb22...665c348](https://codecov.io/gh/apache/apisix-dashboard/pull/2202?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org