This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 60ed87be97fffe874498a217c71d80f543f2a055
Author: soulbird <[email protected]>
AuthorDate: Thu Jul 7 11:37:31 2022 +0800

    fix(limit-count): conf with group and disable can't be configured (#7384)
---
 apisix/plugins/limit-count.lua |  6 +++++-
 t/plugin/limit-count2.t        | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/apisix/plugins/limit-count.lua b/apisix/plugins/limit-count.lua
index 746e474b9..e191b6223 100644
--- a/apisix/plugins/limit-count.lua
+++ b/apisix/plugins/limit-count.lua
@@ -129,6 +129,7 @@ local schema = {
     }
 }
 
+local schema_copy = core.table.deepcopy(schema)
 
 local _M = {
     version = 0.4,
@@ -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]
diff --git a/t/plugin/limit-count2.t b/t/plugin/limit-count2.t
index 621edad8a..e3025be5d 100644
--- a/t/plugin/limit-count2.t
+++ b/t/plugin/limit-count2.t
@@ -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

Reply via email to