summaryrefslogtreecommitdiff
path: root/spec/initializers
diff options
context:
space:
mode:
authorlookatmike <cisephys@gmail.com>2016-07-31 15:36:11 -0400
committerlookatmike <cisephys@gmail.com>2016-07-31 15:36:11 -0400
commitae108ff703a8b9e73f2a260806c89eccac5a6cf6 (patch)
treec955b4dbdee3537495e9a80caaaddbad667aeaec /spec/initializers
parente299504b798c053817f1c866649542ac0c779924 (diff)
downloadgitlab-ce-ae108ff703a8b9e73f2a260806c89eccac5a6cf6.tar.gz
Ignore invalid IPs in X-Forwarded-For when trusted proxies are configured.
Diffstat (limited to 'spec/initializers')
-rw-r--r--spec/initializers/trusted_proxies_spec.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/initializers/trusted_proxies_spec.rb b/spec/initializers/trusted_proxies_spec.rb
index 52d5a7dffc9..290e47763eb 100644
--- a/spec/initializers/trusted_proxies_spec.rb
+++ b/spec/initializers/trusted_proxies_spec.rb
@@ -47,6 +47,12 @@ describe 'trusted_proxies', lib: true do
expect(request.remote_ip).to eq('1.1.1.1')
expect(request.ip).to eq('1.1.1.1')
end
+
+ it 'handles invalid ip addresses' do
+ request = stub_request('HTTP_X_FORWARDED_FOR' => '(null), 1.1.1.1:12345, 1.1.1.1')
+ expect(request.remote_ip).to eq('1.1.1.1')
+ expect(request.ip).to eq('1.1.1.1')
+ end
end
def stub_request(headers = {})