-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runloop): query args not forwarded bug (#11328)
query args that are set in a plugin by kong are not forwarded to the upstream in case of empty query args in request but with a ? (e.g. /route?) also add test to validate the same Fixes #11325
- Loading branch information
1 parent
9b3393c
commit aa3abd2
Showing
2 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
local helpers = require "spec.helpers" | ||
local cjson = require "cjson" | ||
|
||
for _, strategy in helpers.each_strategy() do | ||
describe("query args specs [#" .. strategy .. "]", function() | ||
local proxy_client | ||
|
||
lazy_setup(function() | ||
local bp = helpers.get_db_utils(strategy, { | ||
"plugins", | ||
"routes", | ||
"services", | ||
}) | ||
|
||
local service = assert(bp.services:insert({ | ||
url = helpers.mock_upstream_url | ||
})) | ||
|
||
local route = assert(bp.routes:insert({ | ||
service = service, | ||
paths = { "/set-query-arg" } | ||
})) | ||
|
||
assert(bp.plugins:insert({ | ||
name = "request-transformer", | ||
route = { id = route.id }, | ||
config = { | ||
add = { | ||
querystring = {"dummy:1"}, | ||
}, | ||
}, | ||
})) | ||
|
||
helpers.start_kong({ | ||
database = strategy, | ||
plugins = "bundled", | ||
nginx_conf = "spec/fixtures/custom_nginx.template", | ||
}) | ||
end) | ||
|
||
lazy_teardown(function() | ||
helpers.stop_kong() | ||
end) | ||
|
||
before_each(function() | ||
proxy_client = helpers.proxy_client() | ||
end) | ||
|
||
after_each(function() | ||
if proxy_client then | ||
proxy_client:close() | ||
end | ||
end) | ||
|
||
it("does proxy set query args if URI does not contain arguments", function() | ||
local res = assert(proxy_client:send { | ||
method = "GET", | ||
path = "/set-query-arg?", | ||
headers = { | ||
["Host"] = "mock_upstream", | ||
}, | ||
}) | ||
|
||
local body = assert.res_status(200, res) | ||
local json = cjson.decode(body) | ||
assert.equal("1", json.uri_args.dummy) | ||
end) | ||
end) | ||
end |
aa3abd2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bazel Build
Docker image available
kong/kong:aa3abd2e5bb50ddde4eb4d83bb2584028e73a109
Artifacts available https://github.com/Kong/kong/actions/runs/5776769416