Skip to content

Commit

Permalink
fix(core): disallow delete or create workspaces (#12374)
Browse files Browse the repository at this point in the history
Fix FTI-5620

Co-authored-by: Guilherme Salazar <[email protected]>
  • Loading branch information
outsinre and gszr authored Feb 26, 2024
1 parent 7473c81 commit 6470d9b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions kong/db/schema/entities/workspaces.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ return {
cache_key = { "name" },
endpoint_key = "name",
dao = "kong.db.dao.workspaces",
generate_admin_api = false,

fields = {
{ id = typedefs.uuid },
Expand Down
50 changes: 50 additions & 0 deletions spec/02-integration/04-admin_api/25-workspaces_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
local helpers = require "spec.helpers"
local cjson = require "cjson"

for _, strategy in helpers.each_strategy() do
describe("Admin API - workspaces #" .. strategy, function()
local db, admin_client

lazy_setup(function()
_, db = helpers.get_db_utils(strategy,{ "workspaces" })

assert(helpers.start_kong({
database = strategy,
}))
end)

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

before_each(function()
admin_client = helpers.admin_client()
end)

after_each(function()
if admin_client then admin_client:close() end
end)

it("has no admin api", function()
finally(function() db:truncate("workspaces") end)

local res = assert(admin_client:post("/workspaces", {
body = { name = "jim" },
headers = {["Content-Type"] = "application/json"},
}))

local body = assert.res_status(404, res)
body = cjson.decode(body)
assert.match("Not found", body.message)
end)

it("disallow deletion", function()
finally(function() db:truncate("workspaces") end)

local res = assert(admin_client:delete("/workspaces/default"))
local body = assert.res_status(404, res)
body = cjson.decode(body)
assert.match("Not found", body.message)
end)
end)
end

0 comments on commit 6470d9b

Please sign in to comment.