Skip to content

Commit

Permalink
chore(specs) preperly name response-transformer specs
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Sep 24, 2015
1 parent b7935e3 commit c9dbb6c
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local http_client = require "kong.tools.http_client"
local cjson = require "cjson"

local STUB_GET_URL = spec_helper.PROXY_URL.."/get"
local STUB_POST_URL = spec_helper.PROXY_URL.."/post"
local STUB_HEADERS_URL = spec_helper.PROXY_URL.."/response-headers"

describe("Response Transformer Plugin #proxy", function()
Expand All @@ -11,20 +12,20 @@ describe("Response Transformer Plugin #proxy", function()
spec_helper.prepare_db()
spec_helper.insert_fixtures {
api = {
{ name = "tests-response-transformer", request_host = "response.com", upstream_url = "http://httpbin.org" },
{ name = "tests-response-transformer2", request_host = "response2.com", upstream_url = "http://httpbin.org" },
{name = "tests-response-transformer", request_host = "response.com", upstream_url = "http://httpbin.org"},
{name = "tests-response-transformer2", request_host = "response2.com", upstream_url = "http://httpbin.org"}
},
plugin = {
{
name = "response-transformer",
config = {
add = {
headers = {"x-added:true", "x-added2:true" },
headers = {"x-added:true", "x-added2:true"},
json = {"newjsonparam:newvalue"}
},
remove = {
headers = { "x-to-remove" },
json = { "origin" }
headers = {"x-to-remove"},
json = {"origin"}
}
},
__api = 1
Expand Down Expand Up @@ -58,14 +59,14 @@ describe("Response Transformer Plugin #proxy", function()
end)

it("should add new parameters on GET", function()
local response, status = http_client.get("http://127.0.0.1:8100/get", {}, {host = "response.com"})
local response, status = http_client.get(STUB_GET_URL, {}, {host = "response.com"})
assert.are.equal(200, status)
local body = cjson.decode(response)
assert.are.equal("newvalue", body["newjsonparam"])
end)

it("should add new parameters on POST", function()
local response, status = http_client.post("http://127.0.0.1:8100/post", {}, {host = "response.com"})
local response, status = http_client.post(STUB_POST_URL, {}, {host = "response.com"})
assert.are.equal(200, status)
local body = cjson.decode(response)
assert.are.equal("newvalue", body["newjsonparam"])
Expand All @@ -82,13 +83,13 @@ describe("Response Transformer Plugin #proxy", function()
describe("Test removing parameters", function()

it("should remove a header", function()
local _, status, headers = http_client.get(STUB_HEADERS_URL, { ["x-to-remove"] = "true"}, {host = "response.com"})
local _, status, headers = http_client.get(STUB_HEADERS_URL, {["x-to-remove"] = "true"}, {host = "response.com"})
assert.are.equal(200, status)
assert.falsy(headers["x-to-remove"])
end)

it("should remove a parameter on GET", function()
local response, status = http_client.get("http://127.0.0.1:8100/get", {}, {host = "response.com"})
local response, status = http_client.get(STUB_GET_URL, {}, {host = "response.com"})
assert.are.equal(200, status)
local body = cjson.decode(response)
assert.falsy(body.origin)
Expand Down

0 comments on commit c9dbb6c

Please sign in to comment.