-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Policy: Fixes on Status Codes overwrite policies:
- Fix jsonschema format. - Fix some test typos. - Add unittest - Rename policy - Add Readme file - Add changelog entry FIX THREESCALE-6255 Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
- Loading branch information
Showing
8 changed files
with
96 additions
and
10 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,22 @@ | ||
# StatusCode overwrite | ||
|
||
This policy changes the upstream status code with the desired ones. | ||
|
||
## Examples | ||
|
||
Change status 200 to 201 | ||
|
||
``` | ||
{ | ||
"name": "statuscode_overwrite", | ||
"version": "builtin", | ||
"configuration": { | ||
"http_codes": [ | ||
{ | ||
"upstream": 200, | ||
"apicast": 201 | ||
} | ||
] | ||
} | ||
} | ||
``` |
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
File renamed without changes.
Empty file.
53 changes: 53 additions & 0 deletions
53
spec/policy/statuscode_overwrite/statuscode_overwrite_spec.lua
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,53 @@ | ||
local StatusCodeOverwrite = require('apicast.policy.statuscode_overwrite') | ||
|
||
describe('IP Check policy', function() | ||
before_each(function() | ||
end) | ||
|
||
it('mapped correctly valid status code', function() | ||
local policy = StatusCodeOverwrite.new({ | ||
http_codes = { | ||
{ upstream=200, apicast=201 } | ||
} | ||
}) | ||
|
||
ngx.status = 200 | ||
policy:header_filter() | ||
assert.same(ngx.status, 201) | ||
|
||
ngx.status = 403 | ||
policy:header_filter() | ||
assert.same(ngx.status, 403) | ||
|
||
end) | ||
|
||
it('invalid code fails correctly', function() | ||
assert.has_error(function() | ||
return StatusCodeOverwrite.new({ | ||
http_codes = { | ||
{ upstream=1, apicast=201 } | ||
}}) | ||
end) | ||
|
||
end) | ||
|
||
|
||
it('Upstream code is not defined', function() | ||
assert.has_error(function() | ||
return StatusCodeOverwrite.new({ | ||
http_codes = { | ||
{ apicast=201 } | ||
}}) | ||
end) | ||
end) | ||
|
||
it('Apicast code is not defined', function() | ||
assert.has_error(function() | ||
return StatusCodeOverwrite.new({ | ||
http_codes = { | ||
{ upstream=201 } | ||
}}) | ||
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