Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] ALF Serializer and responses tests #366

Merged
merged 1 commit into from
Jun 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kong/plugins/log_serializers/alf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function alf_mt:new_alf()
local ALF = {
version = "1.0.0",
serviceToken = "", -- will be filled by to_json_string()
environment = "",
environment = nil, -- stub
har = {
log = {
version = "1.2",
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/admin_api/apis_routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ describe("Admin API", function()

it("should not override a plugin's `value` if partial", function()
-- This is delicate since a plugin's `value` is a text field in a DB like Cassandra
local response, status = http_client.patch(BASE_URL..plugin.name, {
local _, status = http_client.patch(BASE_URL..plugin.name, {
["value.key_names"] = {"key_set_null_test"},
["value.hide_credentials"] = true
})
assert.equal(200, status)

response, status = http_client.patch(BASE_URL..plugin.name, {
local response, status = http_client.patch(BASE_URL..plugin.name, {
["value.key_names"] = {"key_set_null_test_updated"}
})
assert.equal(200, status)
Expand Down
9 changes: 8 additions & 1 deletion spec/plugins/analytics/alf_serializer_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe("ALF serializer", function()
har = {
log = {
version = "1.2",
creator = { name = "kong-mashape-analytics-plugin", version = "1.0.0"
creator = { name = "mashape-analytics-agent-kong", version = "1.0.0"
},
entries = {}
}
Expand Down Expand Up @@ -118,6 +118,13 @@ describe("ALF serializer", function()
assert.equal("string", type(json_str))
end)

it("should add an environment property", function()
local json = require "cjson"
local json_str = alf:to_json_string("stub_service_token", "test")
assert.equal("string", type(json_str))
local json_alf = json.decode(json_str)
assert.equal(json_alf.environment, "test")
end)
end)

describe("#flush_entries()", function()
Expand Down
5 changes: 4 additions & 1 deletion spec/unit/tools/responses_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ describe("Responses", function()
assert.falsy(ngx.ctx.stop_phases)

responses.send_HTTP_INTERNAL_SERVER_ERROR()
assert.stub(ngx.log).was.called()
assert.stub(ngx.log).was_not_called()
assert.True(ngx.ctx.stop_phases)

responses.send_HTTP_INTERNAL_SERVER_ERROR("error")
assert.stub(ngx.log).was_called()
end)

describe("default content rules for some status codes", function()
Expand Down