diff --git a/apisix/plugins/limit-conn.lua b/apisix/plugins/limit-conn.lua index 7979b5fd128e..ca8ca3c853ab 100644 --- a/apisix/plugins/limit-conn.lua +++ b/apisix/plugins/limit-conn.lua @@ -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"}, diff --git a/t/plugin/limit-conn.t b/t/plugin/limit-conn.t index 4bc99d4bf4ec..44018574ebf9 100644 --- a/t/plugin/limit-conn.t +++ b/t/plugin/limit-conn.t @@ -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] @@ -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] @@ -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]