-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): disallow delete or create workspaces (#12374)
Fix FTI-5620 Co-authored-by: Guilherme Salazar <[email protected]>
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |