You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by me...@apache.org on 2020/02/28 08:26:49 UTC
[incubator-apisix] branch master updated: bugfix: return 400 when
not pass plugin name to admin API. (#1174)
This is an automated email from the ASF dual-hosted git repository.
membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git
The following commit(s) were added to refs/heads/master by this push:
new a6f7c85 bugfix: return 400 when not pass plugin name to admin API. (#1174)
a6f7c85 is described below
commit a6f7c8571e3f006e6c27cf6cb062d6352f8451f6
Author: 温铭 WenMing <mo...@gmail.com>
AuthorDate: Fri Feb 28 16:26:39 2020 +0800
bugfix: return 400 when not pass plugin name to admin API. (#1174)
---
lua/apisix/admin/plugins.lua | 4 ++++
t/admin/plugins.t | 21 +++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/lua/apisix/admin/plugins.lua b/lua/apisix/admin/plugins.lua
index 1ae7dfe..7d6262c 100644
--- a/lua/apisix/admin/plugins.lua
+++ b/lua/apisix/admin/plugins.lua
@@ -87,6 +87,10 @@ end
function _M.get(name)
+ if not name then
+ return 400, {error_msg = "not found plugin name"}
+ end
+
local plugin_name = "apisix.plugins." .. name
local ok, plugin = pcall(require, plugin_name)
diff --git a/t/admin/plugins.t b/t/admin/plugins.t
index 031eaff..106b036 100644
--- a/t/admin/plugins.t
+++ b/t/admin/plugins.t
@@ -33,3 +33,24 @@ GET /apisix/admin/plugins/list
qr/\["limit-req","limit-count","limit-conn","key-auth","basic-auth","prometheus","node-status","jwt-auth","zipkin","ip-restriction","grpc-transcode","serverless-pre-function","serverless-post-function","openid-connect","proxy-rewrite","redirect","response-rewrite","fault-injection","udp-logger","wolf-rbac"\]/
--- no_error_log
[error]
+
+
+
+=== TEST 2: wrong path
+--- request
+GET /apisix/admin/plugins
+--- error_code: 400
+--- response_body
+{"error_msg":"not found plugin name"}
+--- no_error_log
+[error]
+
+
+
+=== TEST 3: get plugin schema
+--- request
+GET /apisix/admin/plugins/limit-req
+--- response_body
+{"properties":{"rate":{"minimum":0,"type":"number"},"burst":{"minimum":0,"type":"number"},"key":{"enum":["remote_addr","server_addr","http_x_real_ip","http_x_forwarded_for"],"type":"string"},"rejected_code":{"minimum":200,"type":"integer"}},"required":["rate","burst","key","rejected_code"],"type":"object"}
+--- no_error_log
+[error]