-
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 #1328 from samugi/THREESCALE-8000
THREESCALE-8000 + THREESCALE-8007 + THREESCALE-8252 (clear context policy)
- Loading branch information
Showing
10 changed files
with
382 additions
and
11 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
20 changes: 20 additions & 0 deletions
20
gateway/src/apicast/policy/clear_context/clear_context.lua
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,20 @@ | ||
local _M = require('apicast.policy').new('Clear Context') | ||
local new = _M.new | ||
|
||
function _M.new(...) | ||
return new(...) | ||
end | ||
|
||
function _M:ssl_certificate(context) | ||
--resetting the context after every other policy in the chain | ||
--has executed their ssl_certificate phase. | ||
clear_table(ngx.ctx) | ||
end | ||
|
||
function clear_table(t) | ||
for k, _ in pairs(t) do | ||
t[k] = nil | ||
end | ||
end | ||
|
||
return _M |
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 @@ | ||
return require('clear_context') |
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,26 @@ | ||
local ClearContextPolicy = require('apicast.policy.clear_context') | ||
local ngx_variable = require('apicast.policy.ngx_variable') | ||
|
||
|
||
describe('Clear Context policy', function() | ||
local current_ctx = {some_key = 'some_value'} | ||
|
||
describe('log phase context reset', function() | ||
before_each(function() | ||
ctx = ngx.ctx | ||
stub(ngx_variable, 'available_context', function(context) return context end) | ||
end) | ||
|
||
context('.ssl_certificate', function() | ||
local clear_context_policy = ClearContextPolicy.new() | ||
|
||
it('clears the context', function() | ||
ctx.current = current_ctx | ||
clear_context_policy:ssl_certificate(ctx) | ||
assert.is_nil(ctx.current) | ||
end) | ||
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
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
Oops, something went wrong.