-
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.
Merge pull request #684 from 3scale/fix-echo-policy-incorrect-exit-va…
…lues Fix incorrect param value in the Echo policy
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
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
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,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) |