Skip to content

Commit

Permalink
use post-func
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Nov 27, 2024
1 parent a3a40ba commit 149ff55
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
1 change: 0 additions & 1 deletion kong/db/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function DB.new(kong_config, strategy)

local connector, strategies, err = Strategies.new(kong_config, strategy,
schemas, errors)

if err then
return nil, err
end
Expand Down
36 changes: 29 additions & 7 deletions spec/02-integration/11-dbless/04-pagination_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,48 @@ local helpers = require "spec.helpers"
local SERVICE_YML = [[
- name: my-service-%d
url: https://example%d.dev
plugins:
- name: dbless-pagination-test
routes:
- name: my-route-%d
paths:
- /%d
]]


local POST_FUNC = [[
plugins:
- name: key-auth
- name: post-function
config:
log:
- |
return function(conf)
local db = kong.db
assert(db.routes.pagination.max_page_size == 2048)
end
]]


local COUNT = 1001


describe("dbless pagination #off", function()
lazy_setup(function()
assert(helpers.start_kong({
nginx_conf = "spec/fixtures/custom_nginx.template",
database = "off",
plugins = "bundled,dbless-pagination-test",
}))
print("helpers.start_kong")
end)

lazy_teardown(function()
helpers.stop_kong()
end)

it("Routes", function()
local buffer = {"_format_version: '3.0'", "services:"}
for i = 1, 1001 do
local buffer = {"_format_version: '3.0'", POST_FUNC, "services:"}
for i = 1, COUNT do
buffer[#buffer + 1] = fmt(SERVICE_YML, i, i, i, i)
end

local config = table.concat(buffer, "\n")

local admin_client = assert(helpers.admin_client())
Expand All @@ -45,5 +59,13 @@ describe("dbless pagination #off", function()
assert.res_status(201, res)
admin_client:close()

assert(helpers.restart_kong({
database = "off",
}))

local proxy_client = assert(helpers.proxy_client())

res = assert(proxy_client:get("/1", { headers = { host = "example1.dev" } }))
assert.res_status(401, res)
end)
end)

This file was deleted.

This file was deleted.

0 comments on commit 149ff55

Please sign in to comment.