-
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.
Adding "preserve_host" flag to APIs, closes #444
- Loading branch information
1 parent
6af2a17
commit 25053ce
Showing
5 changed files
with
50 additions
and
5 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 @@ | ||
local Migration = { | ||
name = "2015-08-21-813213_0.5.0", | ||
|
||
up = function(options) | ||
return [[ | ||
ALTER TABLE apis ADD preserve_host boolean; | ||
]] | ||
end, | ||
|
||
down = function(options) | ||
return [[ | ||
ALTER TABLE apis DROP preserve_host; | ||
]] | ||
end | ||
} | ||
|
||
return Migration |
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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ local http_client = require "kong.tools.http_client" | |
|
||
local STUB_GET_URL = spec_helper.STUB_GET_URL | ||
local STUB_GET_SSL_URL = spec_helper.STUB_GET_SSL_URL | ||
local PROXY_URL = spec_helper.PROXY_URL | ||
|
||
-- Parses an SSL certificate returned by LuaSec | ||
local function parse_cert(cert) | ||
|
@@ -32,7 +33,9 @@ describe("Resolver", function() | |
{name = "tests stripped path resolver with pattern characters", target_url = "http://mockbin.com", path = "/mockbin-with-pattern/", strip_path = true}, | ||
{name = "tests deep path resolver", target_url = "http://mockbin.com", path = "/deep/path/", strip_path = true}, | ||
{name = "tests wildcard subdomain", target_url = "http://mockbin.com/status/200", public_dns = "*.wildcard.com"}, | ||
{name = "tests wildcard subdomain 2", target_url = "http://mockbin.com/status/201", public_dns = "wildcard.*"} | ||
{name = "tests wildcard subdomain 2", target_url = "http://mockbin.com/status/201", public_dns = "wildcard.*"}, | ||
{name = "tests preserve host", public_dns = "httpbin-nopreserve.com", target_url = "http://httpbin.org"}, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
subnetmarco
Author
Member
|
||
{name = "tests preserve host 2", public_dns = "httpbin-preserve.com", target_url = "http://httpbin.org", preserve_host = true} | ||
}, | ||
plugin_configuration = { | ||
{ name = "keyauth", value = {key_names = {"apikey"} }, __api = 2 } | ||
|
@@ -192,4 +195,22 @@ describe("Resolver", function() | |
end) | ||
|
||
end) | ||
|
||
describe("Preseve Host", function() | ||
|
||
it("should not preserve the host (default behavior)", function() | ||
local response, status = http_client.get(PROXY_URL.."/get", nil, { host = "httpbin-nopreserve.com"}) | ||
assert.equal(200, status) | ||
local parsed_response = cjson.decode(response) | ||
assert.equal("httpbin.org", parsed_response.headers["Host"]) | ||
end) | ||
|
||
it("should preserve the host (default behavior)", function() | ||
local response, status = http_client.get(PROXY_URL.."/get", nil, { host = "httpbin-preserve.com"}) | ||
assert.equal(200, status) | ||
local parsed_response = cjson.decode(response) | ||
assert.equal("httpbin-preserve.com", parsed_response.headers["Host"]) | ||
end) | ||
|
||
end) | ||
end) |
you can use
mockbin.com
&mockbin.org
here