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

2021-11-28 Thread GitBox


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",
+   

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

2021-11-11 Thread GitBox


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",
+   

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

2021-11-11 Thread GitBox


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",
+