Skip to content

Commit

Permalink
fix: plugin disable invalid in API /plugin?all=true (#2737)
Browse files Browse the repository at this point in the history
  • Loading branch information
mscb402 authored Feb 22, 2023
1 parent 9b1f8f0 commit 0b19a18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/internal/handler/schema/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

Expand Down
7 changes: 7 additions & 0 deletions api/test/e2e/route/route_with_plugin_jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0b19a18

Please sign in to comment.