This is an automated email from the ASF dual-hosted git repository.
baoyuan 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 0b19a18e0 fix: plugin disable invalid in API /plugin?all=true (#2737)
0b19a18e0 is described below
commit 0b19a18e02bf0ad64f1ffeadf60ea930f6e04209
Author: Joanthan Chen <[email protected]>
AuthorDate: Wed Feb 22 09:39:07 2023 +0800
fix: plugin disable invalid in API /plugin?all=true (#2737)
---
api/internal/handler/schema/plugin.go | 9 ++++++---
api/test/e2e/route/route_with_plugin_jwt_test.go | 7 +++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/api/internal/handler/schema/plugin.go
b/api/internal/handler/schema/plugin.go
index d282640c9..4585f56d0 100644
--- a/api/internal/handler/schema/plugin.go
+++ b/api/internal/handler/schema/plugin.go
@@ -51,8 +51,11 @@ func (h *Handler) Plugins(c droplet.Context) (interface{},
error) {
if input.All {
var res []map[string]interface{}
list := plugins.Value().(map[string]interface{})
- for name, conf := range list {
- plugin := conf.(map[string]interface{})
+ for name, schemaConfig := range list {
+ if enable, ok := conf.Plugins[name]; !ok || !enable {
+ continue
+ }
+ plugin := schemaConfig.(map[string]interface{})
plugin["name"] = name
if _, ok := plugin["type"]; !ok {
plugin["type"] = "other"
@@ -65,7 +68,7 @@ func (h *Handler) Plugins(c droplet.Context) (interface{},
error) {
var ret []string
list := plugins.Map()
for pluginName := range list {
- if res, ok := conf.Plugins[pluginName]; !ok || !res {
+ if enable, ok := conf.Plugins[pluginName]; !ok || !enable {
continue
}
diff --git a/api/test/e2e/route/route_with_plugin_jwt_test.go
b/api/test/e2e/route/route_with_plugin_jwt_test.go
index 72509d961..c1694a4fe 100644
--- a/api/test/e2e/route/route_with_plugin_jwt_test.go
+++ b/api/test/e2e/route/route_with_plugin_jwt_test.go
@@ -311,6 +311,13 @@ var _ = Describe("route with jwt plugin", func() {
Headers: map[string]string{"Authorization":
base.GetToken()},
ExpectStatus: http.StatusOK,
}),
+ Entry("delete the route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/jwt-sign",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
Entry("verify the deleted route", base.HttpTestCase{
Object: base.APISIXExpect(),
Method: http.MethodGet,