Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Plugin disable invalid in API /plugin?all=true #2737

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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