Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
Signed-off-by: revolyssup <ashishjaitiwari15112000@gmail.com>
  • Loading branch information
Revolyssup committed Jul 11, 2023
1 parent ca0637e commit 4e98bbe
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
1 change: 0 additions & 1 deletion apisix/plugins/proxy-rewrite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ function _M.rewrite(conf, ctx)
upstream_uri = sub_str(upstream_uri, 1, index - 1)
..sub_str(upstream_uri,index)
end
req_set_uri(upstream_uri)
ctx.var.upstream_uri = upstream_uri
end
if conf.headers then
Expand Down
58 changes: 58 additions & 0 deletions t/plugin/proxy-rewrite3.t
Original file line number Diff line number Diff line change
Expand Up @@ -942,3 +942,61 @@ GET /test/plugin/proxy/rewrite/world HTTP/1.1
}
--- response_body
/world/plugin_proxy_rewrite
=== TEST 40: use regex uri with unsafe allowed
--- 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,
[[{
"plugins": {
"proxy-rewrite": {
"regex_uri": [
"/hello/(.+)",
"/hello?unsafe_variable=$1"
],
"use_real_request_uri_unsafe": true
}
},
"upstream": {
"nodes": {
"127.0.0.1:8125": 1
},
"type": "roundrobin"
},
"uri": "/hello/*"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
=== TEST 41: hit
--- request
GET /hello/%ED%85%8C%EC%8A%A4%ED%8A%B8 HTTP/1.1
--- http_config
server {
listen 8125;
location / {
content_by_lua_block {
ngx.say(ngx.var.request_uri)
}
}
}
--- response_body
/hello?unsafe_variable=%ED%85%8C%EC%8A%A4%ED%8A%B8

0 comments on commit 4e98bbe

Please sign in to comment.