Skip to content

Commit

Permalink
fix(limit-count): conf with group and disable can't be configured (ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
soulbird authored and Liu-Junlin committed Nov 4, 2022
1 parent e738a2c commit 74cb2b8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apisix/plugins/limit-count.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ local schema = {
}
}

local schema_copy = core.table.deepcopy(schema)

local _M = {
version = 0.4,
Expand All @@ -151,7 +152,10 @@ function _M.check_schema(conf)

if conf.group then
local fields = {}
for k in pairs(schema.properties) do
-- When the goup field is configured,
-- we will use schema_copy to get the whitelist of properties,
-- so that we can avoid getting injected properties.
for k in pairs(schema_copy.properties) do
tab_insert(fields, k)
end
local extra = policy_to_additional_properties[conf.policy]
Expand Down
37 changes: 37 additions & 0 deletions t/plugin/limit-count2.t
Original file line number Diff line number Diff line change
Expand Up @@ -764,3 +764,40 @@ limit key: afafafhao2:remote_addr
limit key: afafafhao2:remote_addr
--- response_body
[200,200,503,503]
=== TEST 22: group with disable
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/services/1',
ngx.HTTP_PUT,
[[{
"plugins": {
"limit-count": {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"group": "abcd",
"disable": false
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
}
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- response_body
passed

0 comments on commit 74cb2b8

Please sign in to comment.