fix: plugin disable invalid in API /plugin?all=true (#2737)
diff --git a/api/internal/handler/schema/plugin.go b/api/internal/handler/schema/plugin.go
index d282640..4585f56 100644
--- a/api/internal/handler/schema/plugin.go
+++ b/api/internal/handler/schema/plugin.go
@@ -51,8 +51,11 @@
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 @@
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 72509d9..c1694a4 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 @@
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,