-
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.
feat(api) restrict data manipulation operations on 'off' db with errors
- Loading branch information
Showing
6 changed files
with
347 additions
and
4 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
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
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,98 @@ | ||
local Errors = require "kong.db.errors" | ||
local helpers = require "spec.helpers" | ||
|
||
|
||
describe("kong.db [#off]", function() | ||
local db | ||
lazy_setup(function() | ||
local _ | ||
_, db = helpers.get_db_utils("off", { }) | ||
end) | ||
|
||
describe("Routes", function() | ||
|
||
describe(":insert()", function() | ||
it("returns operation unsupported error", function() | ||
local _, err_t = db.strategies.routes:insert() | ||
assert.same({ | ||
code = Errors.codes.OPERATION_UNSUPPORTED, | ||
name = Errors.names[Errors.codes.OPERATION_UNSUPPORTED], | ||
message = "cannot create 'routes' entities when not using a database", | ||
strategy = "off", | ||
}, err_t) | ||
end) | ||
end) | ||
|
||
describe(":update()", function() | ||
it("returns operation unsupported error", function() | ||
local _, err_t = db.strategies.routes:update() | ||
assert.same({ | ||
code = Errors.codes.OPERATION_UNSUPPORTED, | ||
name = Errors.names[Errors.codes.OPERATION_UNSUPPORTED], | ||
message = "cannot update 'routes' entities when not using a database", | ||
strategy = "off", | ||
}, err_t) | ||
end) | ||
end) | ||
|
||
describe(":update_by_field()", function() | ||
it("returns operation unsupported error", function() | ||
local _, err_t = db.strategies.routes:update_by_field("name") | ||
assert.same({ | ||
code = Errors.codes.OPERATION_UNSUPPORTED, | ||
name = Errors.names[Errors.codes.OPERATION_UNSUPPORTED], | ||
message = "cannot update 'routes' entities by 'name' when not using a database", | ||
strategy = "off", | ||
}, err_t) | ||
end) | ||
end) | ||
|
||
describe(":upsert()", function() | ||
it("returns operation unsupported error", function() | ||
local _, err_t = db.strategies.routes:upsert() | ||
assert.same({ | ||
code = Errors.codes.OPERATION_UNSUPPORTED, | ||
name = Errors.names[Errors.codes.OPERATION_UNSUPPORTED], | ||
message = "cannot create or update 'routes' entities when not using a database", | ||
strategy = "off", | ||
}, err_t) | ||
end) | ||
end) | ||
|
||
describe(":upsert_by_field()", function() | ||
it("returns operation unsupported error", function() | ||
local _, err_t = db.strategies.routes:upsert_by_field("name") | ||
assert.same({ | ||
code = Errors.codes.OPERATION_UNSUPPORTED, | ||
name = Errors.names[Errors.codes.OPERATION_UNSUPPORTED], | ||
message = "cannot create or update 'routes' entities by 'name' when not using a database", | ||
strategy = "off", | ||
}, err_t) | ||
end) | ||
end) | ||
|
||
describe(":delete()", function() | ||
it("returns operation unsupported error", function() | ||
local _, err_t = db.strategies.routes:delete() | ||
assert.same({ | ||
code = Errors.codes.OPERATION_UNSUPPORTED, | ||
name = Errors.names[Errors.codes.OPERATION_UNSUPPORTED], | ||
message = "cannot remove 'routes' entities when not using a database", | ||
strategy = "off", | ||
}, err_t) | ||
end) | ||
end) | ||
|
||
describe(":delete_by_field()", function() | ||
it("returns operation unsupported error", function() | ||
local _, err_t = db.strategies.routes:delete_by_field("name") | ||
assert.same({ | ||
code = Errors.codes.OPERATION_UNSUPPORTED, | ||
name = Errors.names[Errors.codes.OPERATION_UNSUPPORTED], | ||
message = "cannot remove 'routes' entities by 'name' when not using a database", | ||
strategy = "off", | ||
}, err_t) | ||
end) | ||
end) | ||
end) | ||
end) |
Oops, something went wrong.