use t::APISix 'no_plan'; repeat_each(1); no_long_string(); no_shuffle(); no_root_location(); run_tests; __DATA__ === TEST 1: sanity --- config location /t { content_by_lua_block { local plugin = require("apisix.plugins.limit-count") local ok, err = plugin.check_schema({count = 2, time_window = 60, rejected_code = 503, key = 'remote_addr'}) if not ok then ngx.say(err) end ngx.say("done") } } --- request GET /t --- response_body done --- no_error_log [error] === TEST 2: wrong value of key --- config location /t { content_by_lua_block { local plugin = require("apisix.plugins.limit-count") local ok, err = plugin.check_schema({count = 2, time_window = 60, rejected_code = 503, key = 'host'}) if not ok then ngx.say(err) end ngx.say("done") } } --- request GET /t --- response_body invalid "enum" in docuement at pointer "#/key" done --- no_error_log [error] === TEST 3: set route(id: 1) --- config location /t { content_by_lua_block { local t = require("lib.test_admin").test local code, body = t('/apisix/admin/routes/1', ngx.HTTP_PUT, [[{ "methods": ["GET"], "plugins": { "limit-count": { "count": 2, "time_window": 60, "rejected_code": 503, "key": "remote_addr" } }, "id":1, "upstream": { "nodes": { "127.0.0.1:1980": 1 }, "type": "roundrobin" }, "uri": "/hello" }]] ) if code >= 300 then ngx.status = code end ngx.say(body) } } --- request GET /t --- response_body passed --- no_error_log [error] === TEST 4: up the limit --- pipelined_requests eval ["GET /hello", "GET /hello", "GET /hello", "GET /hello"] --- error_code eval [200, 200, 503, 503] --- no_error_log [error] === TEST 5: up the limit --- pipelined_requests eval ["GET /hello1", "GET /hello", "GET /hello2", "GET /hello", "GET /hello"] --- error_code eval [404, 200, 404, 200, 503] --- no_error_log [error]