forked from Kong/kong
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65130bb
commit 53830c6
Showing
15 changed files
with
50 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
CMD="busted -v -o gtest --exclude-tags=ci" | ||
|
||
if [ "$TEST_SUITE" == "unit" ]; then | ||
CMD="$CMD --coverage spec/unit && luacov-coveralls -i kong" | ||
elif [ "$TEST_SUITE" == "plugins" ]; then | ||
CMD="$CMD spec/plugins" | ||
elif [ "$TEST_SUITE" == "integration" ]; then | ||
CMD="$CMD spec/integration" | ||
fi | ||
|
||
eval $CMD |
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 was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,48 +1,38 @@ | ||
local validate_entity = require("kong.dao.schemas_validation").validate_entity | ||
local oauth2_schema = require "kong.plugins.oauth2.schema" | ||
|
||
require "kong.tools.ngx_stub" | ||
|
||
describe("OAuth2 Entities Schemas", function() | ||
|
||
describe("OAuth2 Configuration", function() | ||
|
||
it("should not require a `scopes` when `mandatory_scope` is false", function() | ||
local valid, errors = validate_entity({ mandatory_scope = false }, oauth2_schema) | ||
local valid, errors = validate_entity({mandatory_scope = false}, oauth2_schema) | ||
assert.truthy(valid) | ||
assert.falsy(errors) | ||
end) | ||
|
||
it("should require a `scopes` when `mandatory_scope` is true", function() | ||
local valid, errors = validate_entity({ mandatory_scope = true }, oauth2_schema) | ||
local valid, errors = validate_entity({mandatory_scope = true}, oauth2_schema) | ||
assert.falsy(valid) | ||
assert.equal("To set a mandatory scope you also need to create available scopes", errors.mandatory_scope) | ||
end) | ||
|
||
it("should pass when both `scopes` when `mandatory_scope` are passed", function() | ||
local valid, errors = validate_entity({ mandatory_scope = true, scopes = { "email", "info" } }, oauth2_schema) | ||
local valid, errors = validate_entity({mandatory_scope = true, scopes = {"email", "info"}}, oauth2_schema) | ||
assert.truthy(valid) | ||
assert.falsy(errors) | ||
end) | ||
|
||
it("should autogenerate a `provision_key` when it is not being passed", function() | ||
local t = { mandatory_scope = true, scopes = { "email", "info" } } | ||
local t = {mandatory_scope = true, scopes = {"email", "info"}} | ||
local valid, errors = validate_entity(t, oauth2_schema) | ||
assert.truthy(valid) | ||
assert.falsy(errors) | ||
assert.truthy(t.provision_key) | ||
assert.are.equal(32, t.provision_key:len()) | ||
end) | ||
|
||
it("should not autogenerate a `provision_key` when it is being passed", function() | ||
local t = { mandatory_scope = true, scopes = { "email", "info" }, provision_key = "hello" } | ||
local t = {mandatory_scope = true, scopes = {"email", "info"}, provision_key = "hello"} | ||
local valid, errors = validate_entity(t, oauth2_schema) | ||
assert.truthy(valid) | ||
assert.falsy(errors) | ||
assert.truthy(t.provision_key) | ||
assert.are.equal("hello", t.provision_key) | ||
end) | ||
|
||
end) | ||
|
||
end) |
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