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

[configuration] fix error when loading empty policy chain #626

Merged
merged 2 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## Fixed

- Error loading policy chain configuration JSON with null value [PR #626](https://github.com/3scale/apicast/pull/626)

## [3.2.0-beta1] - 2018-02-20

## Added
Expand Down
3 changes: 2 additions & 1 deletion gateway/src/apicast/configuration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local next = next
local lower = string.lower
local insert = table.insert
local setmetatable = setmetatable
local null = ngx.null

local re = require 'ngx.re'
local env = require 'resty.env'
Expand Down Expand Up @@ -55,7 +56,7 @@ local function backend_endpoint(proxy)
end

local function build_policy_chain(policies)
if not policies then return nil, 'no policy chain' end
if not policies or policies == null then return nil, 'no policy chain' end

local chain = {}

Expand Down
10 changes: 10 additions & 0 deletions spec/configuration_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ describe('Configuration object', function()
assert.equals(429, config.limits_exceeded_status)
end)


describe('policy_chain', function()

it('works with null', function()
local config = configuration.parse_service({ proxy = { policy_chain = ngx.null }})

assert(config)
end)
end)

describe('backend', function()
it('defaults to fake backend', function()
local config = configuration.parse_service({ proxy = {
Expand Down