bugfix: return 400 when not pass plugin name to admin API. (#1174)

This commit is contained in:
温铭 WenMing 2020-02-28 16:26:39 +08:00 committed by GitHub
parent 7f7b4a5376
commit a6f7c8571e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -87,6 +87,10 @@ end
function _M.get(name) function _M.get(name)
if not name then
return 400, {error_msg = "not found plugin name"}
end
local plugin_name = "apisix.plugins." .. name local plugin_name = "apisix.plugins." .. name
local ok, plugin = pcall(require, plugin_name) local ok, plugin = pcall(require, plugin_name)

View File

@ -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"\]/ 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 --- no_error_log
[error] [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]