Skip to content

Commit

Permalink
Merge pull request #684 from 3scale/fix-echo-policy-incorrect-exit-va…
Browse files Browse the repository at this point in the history
…lues

Fix incorrect param value in the Echo policy
  • Loading branch information
davidor authored and mikz committed May 11, 2018
1 parent 46ba9e3 commit 8553bdb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed

- Fixed set of valid values for the exit param of the Echo policy [PR #684](https://github.com/3scale/apicast/pull/684/)

## [3.2.0-rc1] - 2018-04-24

### Added
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/apicast/policy/echo/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"title": "Interrupt the processing of the request."
},
{
"enum": ["set"],
"enum": ["phase"],
"title": "Skip only the rewrite phase."
}
]
Expand Down
28 changes: 28 additions & 0 deletions spec/policy/echo/echo_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local EchoPolicy = require('apicast.policy.echo')

describe('Echo policy', function()
describe('.rewrite', function()
describe('when configured with exit=request', function()
it('stops processing the request and returns with the configured status', function()
local ngx_exit_spy = spy.on(ngx, 'exit')
local status = 200
local echo = EchoPolicy.new({ status = status, exit = 'request' })

echo:rewrite()

assert.spy(ngx_exit_spy).was_called_with(status)
end)
end)

describe('when configured with exit=phase', function()
it('skips the current phase', function()
local ngx_exit_spy = spy.on(ngx, 'exit')
local echo = EchoPolicy.new({ status = 200, exit = 'phase' })

echo:rewrite()

assert.spy(ngx_exit_spy).was_called_with(0)
end)
end)
end)
end)

0 comments on commit 8553bdb

Please sign in to comment.