Skip to content

Commit

Permalink
use legacy_dns_client switch to check if we need to reply 501 in /s…
Browse files Browse the repository at this point in the history
…tatus/dns
  • Loading branch information
chobits committed Apr 8, 2024
1 parent c7fabcd commit 36ae59a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kong/api/routes/kong.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ return {
},
["/status/dns"] = {
GET = function (self, db, helpers)
if not kong.dns.stats then
if kong.configuration.legacy_dns_client then
return kong.response.exit(501, { message = "not implemented with the legacy DNS client" })
end

Expand Down
37 changes: 36 additions & 1 deletion spec/02-integration/04-admin_api/26-dns_client_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for _, strategy in helpers.each_strategy() do
helpers.stop_kong()
end)

it("/status/dns", function ()
it("/status/dns - status code 200", function ()
local res = assert(client:send {
method = "GET",
path = "/status/dns",
Expand All @@ -41,4 +41,39 @@ for _, strategy in helpers.each_strategy() do
assert(type(json.stats["127.0.0.1"].runs) == "number")
end)
end)

describe("Admin API - DNS client route with [#" .. strategy .. "]" , function()
local client

lazy_setup(function()
helpers.get_db_utils(strategy)

assert(helpers.start_kong({
database = strategy,
nginx_conf = "spec/fixtures/custom_nginx.template",
legacy_dns_client = true,
}))

client = helpers.admin_client()
end)

teardown(function()
if client then
client:close()
end
helpers.stop_kong()
end)

it("/status/dns - status code 501", function ()
local res = assert(client:send {
method = "GET",
path = "/status/dns",
headers = { ["Content-Type"] = "application/json" }
})

local body = assert.res_status(501, res)
local json = cjson.decode(body)
assert.same("not implemented with the legacy DNS client", json.message)
end)
end)
end

0 comments on commit 36ae59a

Please sign in to comment.