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(limit-conn): conn and default_conn_delay should > 0 #2478

Merged
merged 1 commit into from
Oct 20, 2020
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
4 changes: 2 additions & 2 deletions apisix/plugins/limit-conn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ local plugin_name = "limit-conn"
local schema = {
type = "object",
properties = {
conn = {type = "integer", minimum = 0},
conn = {type = "integer", exclusiveMinimum = 0},
burst = {type = "integer", minimum = 0},
default_conn_delay = {type = "number", minimum = 0},
default_conn_delay = {type = "number", exclusiveMinimum = 0},
key = {type = "string",
enum = {"remote_addr", "server_addr", "http_x_real_ip",
"http_x_forwarded_for"},
Expand Down
34 changes: 32 additions & 2 deletions t/plugin/limit-conn.t
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ GET /t
GET /t
--- error_code: 400
--- response_body
{"error_msg":"failed to check the configuration of plugin limit-conn err: property \"conn\" validation failed: expected -1 to be greater than 0"}
{"error_msg":"failed to check the configuration of plugin limit-conn err: property \"conn\" validation failed: expected -1 to be sctrictly greater than 0"}
--- no_error_log
[error]

Expand Down Expand Up @@ -511,7 +511,7 @@ GET /t
GET /t
--- error_code: 400
--- response_body
{"error_msg":"failed to check the configuration of plugin limit-conn err: property \"conn\" validation failed: expected -1 to be greater than 0"}
{"error_msg":"failed to check the configuration of plugin limit-conn err: property \"conn\" validation failed: expected -1 to be sctrictly greater than 0"}
--- no_error_log
[error]

Expand Down Expand Up @@ -956,3 +956,33 @@ GET /test_concurrency
200
--- no_error_log
[error]



=== TEST 25: invalid schema
--- config
location /t {
content_by_lua_block {
local plugin = require("apisix.plugins.limit-conn")
local cases = {
{conn = 0, burst = 0, default_conn_delay = 0.1, rejected_code = 503, key = 'remote_addr'},
{conn = 1, burst = 0, default_conn_delay = 0, rejected_code = 503, key = 'remote_addr'},
}
for _, c in ipairs(cases) do
local ok, err = plugin.check_schema(c)
if not ok then
ngx.say(err)
end
end

ngx.say("done")
}
}
--- request
GET /t
--- response_body
property "conn" validation failed: expected 0 to be sctrictly greater than 0
property "default_conn_delay" validation failed: expected 0 to be sctrictly greater than 0
done
--- no_error_log
[error]