diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e32c870f..9ffb0f538 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/gateway/src/apicast/policy/echo/apicast-policy.json b/gateway/src/apicast/policy/echo/apicast-policy.json index 30e693d56..ccb0385e4 100644 --- a/gateway/src/apicast/policy/echo/apicast-policy.json +++ b/gateway/src/apicast/policy/echo/apicast-policy.json @@ -22,7 +22,7 @@ "title": "Interrupt the processing of the request." }, { - "enum": ["set"], + "enum": ["phase"], "title": "Skip only the rewrite phase." } ] diff --git a/spec/policy/echo/echo_spec.lua b/spec/policy/echo/echo_spec.lua new file mode 100644 index 000000000..e1b31f5b9 --- /dev/null +++ b/spec/policy/echo/echo_spec.lua @@ -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)