Skip to content

Commit

Permalink
fix: fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
oowl committed May 6, 2024
1 parent 7e77147 commit 2398af2
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions spec/03-plugins/04-file-log/01-log_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,36 @@ for _, strategy in helpers.each_strategy() do
},
}

local route10 = bp.routes:insert {
hosts = { "file_logging10.test" },
response_buffering = true,
}

bp.plugins:insert({
name = "pre-function",
route = { id = route10.id },
config = {
access = {
[[
kong.service.request.enable_buffering()
]],
},
}
})

bp.plugins:insert {
route = { id = route10.id },
name = "file-log",
config = {
path = FILE_LOG_PATH,
reopen = true,
custom_fields_by_lua = {
new_field = "return 123",
route = "return nil", -- unset route field
},
},
}

assert(helpers.start_kong({
database = strategy,
nginx_conf = "spec/fixtures/custom_nginx.template",
Expand Down Expand Up @@ -337,6 +367,28 @@ for _, strategy in helpers.each_strategy() do
assert.is_number(log_message.response.size)
assert.same(nil, log_message.route)
end)
it("correct upstream status when we use response phase", function()
local uuid = random_string()

-- Making the request
local res = assert(proxy_client:send({
method = "GET",
path = "/status/200",
headers = {
["file-log-uuid"] = uuid,
["Host"] = "file_logging10.test"
}
}))
assert.res_status(200, res)

local log_message = wait_for_json_log_entry()
assert.same("127.0.0.1", log_message.client_ip)
assert.same(uuid, log_message.request.headers["file-log-uuid"])
assert.is_number(log_message.request.size)
assert.is_number(log_message.response.size)
assert.same(nil, log_message.route)
assert.same(200, log_message.upstream_status)
end)
end)

it("logs to file #grpc", function()
Expand Down

0 comments on commit 2398af2

Please sign in to comment.