Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect param value in the Echo policy #684

Merged
merged 3 commits into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)