-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' of https://github.com/Mashape/kong into fix/reque…
…st-size
- Loading branch information
Showing
8 changed files
with
300 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### Summary | ||
|
||
SUMMARY_GOES_HERE | ||
|
||
### Steps To Reproduce | ||
|
||
1. | ||
2. | ||
3. | ||
4. | ||
|
||
### Additional Details & Logs | ||
|
||
- Kong version (`$ kong version`) | ||
- Kong configuration (registered APIs/Plugins & configuration file) | ||
- Kong error logs (`<KONG_PREFIX>/logs/error.log`) | ||
- Operating System |
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,15 @@ | ||
**Note: new features are to be opened against next, hotfixes against master.** | ||
|
||
### Summary | ||
|
||
SUMMARY_GOES_HERE | ||
|
||
### Full changelog | ||
|
||
* [Implement ...] | ||
* [Add related tests] | ||
* ... | ||
|
||
### Issues resolved | ||
|
||
Fix #XXX |
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
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,113 @@ | ||
local helpers = require "spec.helpers" | ||
local cjson = require "cjson" | ||
|
||
describe("Plugin: request-transformer (API)", function() | ||
local admin_client | ||
setup(function() | ||
helpers.kill_all() | ||
helpers.prepare_prefix() | ||
|
||
assert(helpers.start_kong()) | ||
admin_client = helpers.admin_client() | ||
end) | ||
teardown(function() | ||
if admin_client then | ||
admin_client:close() | ||
end | ||
helpers.stop_kong() | ||
end) | ||
|
||
describe("POST", function() | ||
setup(function() | ||
assert(helpers.dao.apis:insert { | ||
name = "test", | ||
request_host = "test1.com", | ||
upstream_url = "http://mockbin.com" | ||
}) | ||
end) | ||
|
||
describe("validate config parameters", function() | ||
it("remove succeeds without colons", function() | ||
local res = assert(admin_client:send { | ||
method = "POST", | ||
path = "/apis/test/plugins/", | ||
body = { | ||
name = "request-transformer", | ||
config = { | ||
remove = { | ||
headers = "just_a_key", | ||
body = "just_a_key", | ||
querystring = "just_a_key", | ||
}, | ||
}, | ||
}, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
}, | ||
}) | ||
assert.response(res).has.status(201) | ||
local body = assert.response(res).has.jsonbody() | ||
assert.equals("just_a_key", body.config.remove.headers[1]) | ||
assert.equals("just_a_key", body.config.remove.body[1]) | ||
assert.equals("just_a_key", body.config.remove.querystring[1]) | ||
end) | ||
it("add fails with missing colons for key/value separation", function() | ||
local res = assert(admin_client:send { | ||
method = "POST", | ||
path = "/apis/test/plugins/", | ||
body = { | ||
name = "request-transformer", | ||
config = { | ||
add = { | ||
headers = "just_a_key", | ||
}, | ||
}, | ||
}, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
}, | ||
}) | ||
local body = assert.response(res).has.status(400) | ||
assert.equals([[{"config.add.headers":"key 'just_a_key' has no value"}]], body) | ||
end) | ||
it("replace fails with missing colons for key/value separation", function() | ||
local res = assert(admin_client:send { | ||
method = "POST", | ||
path = "/apis/test/plugins/", | ||
body = { | ||
name = "request-transformer", | ||
config = { | ||
replace = { | ||
headers = "just_a_key", | ||
}, | ||
}, | ||
}, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
}, | ||
}) | ||
local body = assert.response(res).has.status(400) | ||
assert.equals([[{"config.replace.headers":"key 'just_a_key' has no value"}]], body) | ||
end) | ||
it("append fails with missing colons for key/value separation", function() | ||
local res = assert(admin_client:send { | ||
method = "POST", | ||
path = "/apis/test/plugins/", | ||
body = { | ||
name = "request-transformer", | ||
config = { | ||
append = { | ||
headers = "just_a_key", | ||
}, | ||
}, | ||
}, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
}, | ||
}) | ||
local body = assert.response(res).has.status(400) | ||
assert.equals([[{"config.append.headers":"key 'just_a_key' has no value"}]], body) | ||
end) | ||
end) | ||
end) | ||
end) |
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,111 @@ | ||
local helpers = require "spec.helpers" | ||
local cjson = require "cjson" | ||
|
||
describe("Plugin: response-transformer (API)", function() | ||
local admin_client | ||
setup(function() | ||
helpers.kill_all() | ||
helpers.prepare_prefix() | ||
|
||
assert(helpers.start_kong()) | ||
admin_client = helpers.admin_client() | ||
end) | ||
teardown(function() | ||
if admin_client then | ||
admin_client:close() | ||
end | ||
helpers.stop_kong() | ||
end) | ||
|
||
describe("POST", function() | ||
setup(function() | ||
assert(helpers.dao.apis:insert { | ||
name = "test", | ||
request_host = "test1.com", | ||
upstream_url = "http://mockbin.com" | ||
}) | ||
end) | ||
|
||
describe("validate config parameters", function() | ||
it("remove succeeds without colons", function() | ||
local res = assert(admin_client:send { | ||
method = "POST", | ||
path = "/apis/test/plugins/", | ||
body = { | ||
name = "response-transformer", | ||
config = { | ||
remove = { | ||
headers = "just_a_key", | ||
json = "just_a_key", | ||
}, | ||
}, | ||
}, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
}, | ||
}) | ||
assert.response(res).has.status(201) | ||
local body = assert.response(res).has.jsonbody() | ||
assert.equals("just_a_key", body.config.remove.headers[1]) | ||
assert.equals("just_a_key", body.config.remove.json[1]) | ||
end) | ||
it("add fails with missing colons for key/value separation", function() | ||
local res = assert(admin_client:send { | ||
method = "POST", | ||
path = "/apis/test/plugins/", | ||
body = { | ||
name = "response-transformer", | ||
config = { | ||
add = { | ||
headers = "just_a_key", | ||
}, | ||
}, | ||
}, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
}, | ||
}) | ||
local body = assert.response(res).has.status(400) | ||
assert.equals([[{"config.add.headers":"key 'just_a_key' has no value"}]], body) | ||
end) | ||
it("replace fails with missing colons for key/value separation", function() | ||
local res = assert(admin_client:send { | ||
method = "POST", | ||
path = "/apis/test/plugins/", | ||
body = { | ||
name = "response-transformer", | ||
config = { | ||
replace = { | ||
headers = "just_a_key", | ||
}, | ||
}, | ||
}, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
}, | ||
}) | ||
local body = assert.response(res).has.status(400) | ||
assert.equals([[{"config.replace.headers":"key 'just_a_key' has no value"}]], body) | ||
end) | ||
it("append fails with missing colons for key/value separation", function() | ||
local res = assert(admin_client:send { | ||
method = "POST", | ||
path = "/apis/test/plugins/", | ||
body = { | ||
name = "response-transformer", | ||
config = { | ||
append = { | ||
headers = "just_a_key", | ||
}, | ||
}, | ||
}, | ||
headers = { | ||
["Content-Type"] = "application/json", | ||
}, | ||
}) | ||
local body = assert.response(res).has.status(400) | ||
assert.equals([[{"config.append.headers":"key 'just_a_key' has no value"}]], body) | ||
end) | ||
end) | ||
end) | ||
end) |
File renamed without changes.
File renamed without changes.