Skip to content

Commit

Permalink
fix(api) consumers endpoint filtering by custom id
Browse files Browse the repository at this point in the history
This issue was reported by @JoarSvensson on issue #4402.
  • Loading branch information
bungle committed Mar 26, 2019
1 parent efff81f commit 1c6ae83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kong/api/endpoints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ local function query_entity(context, self, db, schema, method)
end

if is_update then
return dao[method or context](dao, key, args, opts)
return dao[method or context](dao, method and key.id or key, args, opts)
end

return dao[method or context](dao, key, opts)
return dao[method or context](dao, method and key.id or key, opts)
end


Expand Down
11 changes: 11 additions & 0 deletions spec/02-integration/04-admin_api/03-consumers_routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ describe("Admin API (#" .. strategy .. "): ", function()
local body = assert.res_status(200, res)
local json = cjson.decode(body)

assert.equal(1, #json.data)
assert.same(c, json.data[1])
end)
it("allows filtering by uuid-like custom_id", function()
local custom_id = utils.uuid()
local c = bp.consumers:insert({ custom_id = custom_id }, { nulls = true })

local res = client:get("/consumers?custom_id=" .. custom_id)
local body = assert.res_status(200, res)
local json = cjson.decode(body)

assert.equal(1, #json.data)
assert.same(c, json.data[1])
end)
Expand Down

0 comments on commit 1c6ae83

Please sign in to comment.