Skip to content

Commit

Permalink
test: add core ctx case
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Nov 4, 2021
1 parent d06cc08 commit 0a7b2fb
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions t/core/ctx2.t
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,73 @@ GET /hello
--- error_code: 404
--- response_body
{"error_msg":"404 Route Not Found"}
=== TEST 11: parsed post args is cached under ctx
--- 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,
[=[{
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"plugins": {
"serverless-pre-function": {
"phase": "rewrite",
"functions" : ["return function(conf, ctx) ngx.log(ngx.WARN, 'find ctx.req_post_args: ', ctx.req_post_args ~= nil) end"]
}
},
"uri": "/hello",
"vars": [["post_arg_test", "==", "test"]]
}]=]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]
=== TEST 12: hit
--- request
POST /hello
test=test
--- response_body
hello world
--- error_log
find ctx.req_post_args: true
=== TEST 13: missed (post_arg_test is missing)
--- request
POST /hello
--- error_code: 404
--- response_body
{"error_msg":"404 Route Not Found"}
=== TEST 14: missed (post_arg_test is mismatch)
--- request
POST /hello
test=tesy
--- error_code: 404
--- response_body
{"error_msg":"404 Route Not Found"}

0 comments on commit 0a7b2fb

Please sign in to comment.