Skip to content

Commit 2affe4e

Browse files
authored
Merge pull request #646 from 3scale/validate-policy-configs
Validation for policy configurations
2 parents 02868a4 + 8c2df39 commit 2affe4e

21 files changed

Lines changed: 230 additions & 39 deletions

CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010

1111
- New property `summary` in the policy manifests [PR #633](https://github.com/3scale/apicast/pull/633)
1212
- OAuth2.0 Token Introspection policy [PR #619](https://github.com/3scale/apicast/pull/619)
13+
- New `metrics` phase that runs when prometheus is collecting metrics [PR #629](https://github.com/3scale/apicast/pull/629)
14+
- Validation of policy configs both in integration and unit tests [PR #646](https://github.com/3scale/apicast/pull/646)
1315

1416
## Fixed
1517

@@ -19,10 +21,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1921
- Bug in URL rewriting policy that ignored the `commands` attribute in the policy manifest [PR #641](https://github.com/3scale/apicast/pull/641)
2022
- Skip comentaries after `search` values in resolv.conf [PR #635](https://github.com/3scale/apicast/pull/635)
2123

22-
## Added
23-
24-
- New `metrics` phase that runs when prometheus is collecting metrics [PR #629](https://github.com/3scale/apicast/pull/629)
25-
2624
## [3.2.0-beta1] - 2018-02-20
2725

2826
## Added

gateway/Roverfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ luarocks {
44

55
group 'testing' {
66
module { 'busted' },
7+
module { 'ljsonschema' },
78
},
89

910
group 'development' {

gateway/Roverfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dkjson 2.5-2||testing
44
inspect 3.1.1-0||production
55
ldoc 1.4.6-2||development
66
liquid 0.1.0-1||production
7+
ljsonschema 0.1.0-1||testing
78
lua-resty-env 0.4.0-1||production
89
lua-resty-execvp 0.1.0-1||production
910
lua-resty-http 0.12-0||production
@@ -18,6 +19,7 @@ luassert 1.7.10-0||testing
1819
luasystem 0.2.1-0||testing
1920
markdown 0.33-1||development
2021
mediator_lua 1.1.2-0||testing
22+
net-url 0.9-1||testing
2123
nginx-lua-prometheus 0.20171117-4||production
2224
penlight 1.5.4-1||production,development,testing
2325
router 2.1-0||production

gateway/src/apicast/policy/caching/apicast-policy.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727
"type": "string",
2828
"oneOf": [
2929
{
30-
"const": "resilient",
30+
"enum": ["resilient"],
3131
"description": "Authorize according to last request when backend is down."
3232
},
3333
{
34-
"const": "strict",
34+
"enum": ["strict"],
3535
"description": "It only caches authorized calls."
3636
},
3737
{
38-
"const": "allow",
38+
"enum": ["allow"],
3939
"description": "When backend is down, allow everything unless seen before and denied."
4040
},
4141
{
42-
"const": "none",
42+
"enum": ["none"],
4343
"description": "Disables caching."
4444
}
4545
]

gateway/src/apicast/policy/caching/caching.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ end
9898
-- @tparam[opt] table config
9999
-- @field caching_type Caching type (strict, resilient, allow, none)
100100
function _M.new(config)
101-
local self = new()
101+
local self = new(config)
102102
self.cache_handler = handler(config or {})
103103
return self
104104
end

gateway/src/apicast/policy/cors/cors.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local new = _M.new
2525
-- @field[opt] allow_origin Allowed origins (e.g. 'http://example.com', '*')
2626
-- @field[opt] allow_credentials Boolean
2727
function _M.new(config)
28-
local self = new()
28+
local self = new(config)
2929
self.config = config or {}
3030
return self
3131
end

gateway/src/apicast/policy/echo/apicast-policy.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"type": "string",
1919
"oneOf": [
2020
{
21-
"const": "request",
21+
"enum": ["request"],
2222
"description": "Interrupts the processing of the request."
2323
},
2424
{
25-
"const": "set",
25+
"enum": ["set"],
2626
"description": "Only skips the rewrite phase."
2727
}
2828
]

gateway/src/apicast/policy/headers/apicast-policy.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
"type": "string",
2323
"oneOf": [
2424
{
25-
"const": "add",
25+
"enum": ["add"],
2626
"description": "Adds a value to an existing header."
2727
},
2828
{
29-
"const": "set",
29+
"enum": ["set"],
3030
"description": "Creates the header when not set, replaces its value when set."
3131
},
3232
{
33-
"const": "push",
33+
"enum": ["push"],
3434
"description": "Creates the header when not set, adds the value when set."
3535
}
3636
]

gateway/src/apicast/policy/headers/headers.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ end
106106
-- 2) When the header is set, it creates a new header with the same name and
107107
-- the given value.
108108
function _M.new(config)
109-
local self = new()
109+
local self = new(config)
110110
self.config = init_config(config)
111111
return self
112112
end

gateway/src/apicast/policy/token_introspection/token_introspection.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ local resty_env = require('resty.env')
1010
local new = _M.new
1111

1212
function _M.new(config)
13-
local self = new()
13+
local self = new(config)
1414
self.config = config or {}
1515
--- authorization for the token introspection endpoint.
1616
-- https://tools.ietf.org/html/rfc7662#section-2.2

0 commit comments

Comments
 (0)