Skip to content

Commit

Permalink
Merge pull request #1026 from 3scale/fix-ip-check-policy
Browse files Browse the repository at this point in the history
[THREESCALE-1692] Change schema of IP check policy so it renders correctly in the UI
  • Loading branch information
davidor authored May 7, 2019
2 parents c890c39 + bdef0b1 commit c93ea1b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `export()` now works correctly in policies of the local chain. It was only working in the `rewrite` phase [PR #1023](https://github.com/3scale/APIcast/pull/1023)
- The caching policy now works correctly when combined with the 3scale batcher one [PR #1023](https://github.com/3scale/APIcast/pull/1023)
- Fixed the name of the 3scale batching policy in the logs. Some logs showed "Caching policy" where it should have said "3scale Batcher" [PR #1029](https://github.com/3scale/APIcast/pull/1029)
- Changed the schema of the IP check policy so it renders correctly in the UI [PR #1026](https://github.com/3scale/APIcast/pull/1026), [THREESCALE-1692](https://issues.jboss.org/browse/THREESCALE-1692)

### Removed

Expand Down
2 changes: 1 addition & 1 deletion gateway/src/apicast/policy/ip_check/apicast-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"type": "array",
"default": ["last_caller"],
"minItems": 1,
"uniqueItems": true,
"maxItems": 3,
"items": {
"type": "string",
"anyOf": [
Expand Down
17 changes: 17 additions & 0 deletions spec/policy/ip_check/client_ip_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,22 @@ describe('ClientIP', function()
assert.equals('1.2.3.4', ip)
end)
end)

-- Because of a limitation in how the schema needs to be written to be
-- rendered correctly, there might be duplicated sources.
describe('when there are duplicated sources', function()
it('returns the value of the first one set', function()
stub(ngx.req, 'get_headers', function()
return { ["X-Forwarded-For"] = '1.2.3.4' }
end)

-- Notice that "X-Forwarded-For" is duplicated
local ip = client_ip.get_from(
{ 'X-Real-IP', 'X-Forwarded-For', 'X-Forwarded-For' }
)

assert.equals('1.2.3.4', ip)
end)
end)
end)
end)

0 comments on commit c93ea1b

Please sign in to comment.