-
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 #343 from 3scale/proxy-post_action-oauth
don't call post action for oauth routes
- Loading branch information
Showing
6 changed files
with
127 additions
and
23 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
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 |
---|---|---|
@@ -1,12 +1,57 @@ | ||
local apicast = require 'apicast' | ||
local _M = require 'apicast' | ||
|
||
describe('APIcast module', function() | ||
|
||
it('has a name', function() | ||
assert.truthy(apicast._NAME) | ||
assert.truthy(_M._NAME) | ||
end) | ||
|
||
it('has a version', function() | ||
assert.truthy(apicast._VERSION) | ||
assert.truthy(_M._VERSION) | ||
end) | ||
|
||
describe(':access', function() | ||
|
||
local apicast | ||
|
||
before_each(function() | ||
apicast = _M.new() | ||
ngx.ctx.proxy = {} | ||
end) | ||
|
||
it('triggers post action when access phase succeeds', function() | ||
ngx.var = { original_request_id = 'foobar' } | ||
|
||
stub(ngx.ctx.proxy, 'call', function() | ||
return function() return 'ok' end | ||
end) | ||
|
||
stub(ngx.ctx.proxy, 'post_action', function() | ||
return 'post_ok' | ||
end) | ||
|
||
local ok, err = apicast:access() | ||
|
||
assert.same('ok', ok) | ||
assert.falsy(err) | ||
|
||
assert.same('post_ok', apicast:post_action()) | ||
end) | ||
|
||
it('skips post action when access phase not executed', function() | ||
stub(ngx.ctx.proxy, 'call', function() | ||
-- return nothing for example | ||
end) | ||
|
||
local ok, err = apicast:access() | ||
|
||
assert.falsy(ok) | ||
assert.falsy(err) | ||
|
||
ngx.ctx.proxy = nil -- in post_action the ctx is not shared | ||
ngx.var = { original_request_id = 'foobar' } | ||
|
||
assert.equal(nil, apicast:post_action()) | ||
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