This is an automated email from the ASF dual-hosted git repository.
starsz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 611ab09 chore: add plugin test (#1574)
611ab09 is described below
commit 611ab09411790484ab6ed0465ac19508ce3aa040
Author: Peter Zhu <[email protected]>
AuthorDate: Thu Mar 11 18:30:06 2021 +0800
chore: add plugin test (#1574)
---
api/test/e2enew/plugin/plugin_suite_test.go | 27 ++++++++++
api/test/e2enew/plugin/plugin_test.go | 84 +++++++++++++++++++++++++++++
2 files changed, 111 insertions(+)
diff --git a/api/test/e2enew/plugin/plugin_suite_test.go
b/api/test/e2enew/plugin/plugin_suite_test.go
new file mode 100644
index 0000000..2775ba3
--- /dev/null
+++ b/api/test/e2enew/plugin/plugin_suite_test.go
@@ -0,0 +1,27 @@
+/*
+ * 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 plugin
+
+import (
+ "testing"
+
+ "github.com/onsi/ginkgo"
+)
+
+func TestPlugin(t *testing.T) {
+ ginkgo.RunSpecs(t, "plugin suite")
+}
diff --git a/api/test/e2enew/plugin/plugin_test.go
b/api/test/e2enew/plugin/plugin_test.go
new file mode 100644
index 0000000..c3d88c6
--- /dev/null
+++ b/api/test/e2enew/plugin/plugin_test.go
@@ -0,0 +1,84 @@
+/*
+ * 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 plugin
+
+import (
+ "net/http"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+
+ "e2enew/base"
+)
+
+var _ = ginkgo.Describe("Plugin Basic", func() {
+ table.DescribeTable("test plugin basic", func(testCase
base.HttpTestCase) {
+ base.RunTestCase(testCase)
+ },
+ table.Entry("get all plugins", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Path: "/apisix/admin/plugins",
+ Query: "all=true",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ ExpectBody: []string{"request-id", "syslog", "echo",
"proxy-mirror"},
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("get all plugins", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Path: "/apisix/admin/plugins",
+ Query: "all=false",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ ExpectBody: []string{"request-id", "syslog", "echo",
"proxy-mirror"},
+ Sleep: base.SleepTime,
+ }),
+ )
+
+ table.DescribeTable("test schema basic", func(testCase
base.HttpTestCase) {
+ base.RunTestCase(testCase)
+ },
+ table.Entry("get consumer schema", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Path: "/apisix/admin/schema/plugins/jwt-auth",
+ Query: "schema_type=consumer",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ ExpectBody:
"{\"dependencies\":{\"algorithm\":{\"oneOf\":[{\"properties\":{\"algorithm\":" +
+
"{\"default\":\"HS256\",\"enum\":[\"HS256\",\"HS512\"]}}},{\"properties\":{\"algorithm\":"
+
+
"{\"enum\":[\"RS256\"]},\"private_key\":{\"type\":\"string\"},\"public_key\":{\"type\":\"string\"}},"
+
+
"\"required\":[\"private_key\",\"public_key\"]}]}},\"properties\":{\"algorithm\":{\"default\":"
+
+
"\"HS256\",\"enum\":[\"HS256\",\"HS512\",\"RS256\"],\"type\":\"string\"},\"base64_secret\""
+
+
":{\"default\":false,\"type\":\"boolean\"},\"exp\":{\"default\":86400,\"minimum\":1,\"type\":"
+
+
"\"integer\"},\"key\":{\"type\":\"string\"},\"secret\":{\"type\":\"string\"}},"
+
+ "\"required\":[\"key\"],\"type\":\"object\"}",
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("get require-id plugin", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodGet,
+ Path: "/apisix/admin/schema/plugins/jwt-auth",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "{\"$comment\":\"this is a mark for our
injected plugin
schema\",\"additionalProperties\":false,\"properties\":{\"disable\":{\"type\":\"boolean\"}},\"type\":\"object\"}",
+ Sleep: base.SleepTime,
+ }),
+ )
+})