diff options
| author | Gibheer <gibheer@gmail.com> | 2014-03-05 09:42:49 +0100 | 
|---|---|---|
| committer | Gibheer <gibheer@gmail.com> | 2014-03-05 09:44:06 +0100 | 
| commit | 4aab135bc6fffb0b13979e240479c24a3f553b06 (patch) | |
| tree | 9a1d0810b8e534def30c6a2d84da2d6d3536078c /spec | |
| parent | 3876754ab4b139bf8387d9f37e0502008743783e (diff) | |
add x-forwarded-for header to the client
This adds the way to find out the actual ip of the client machine, even
if it is hidden behind a local reverse proxy.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/unit/zero/request/client/address_spec.rb | 24 | 
1 files changed, 21 insertions, 3 deletions
| diff --git a/spec/unit/zero/request/client/address_spec.rb b/spec/unit/zero/request/client/address_spec.rb index 5e0b65d..09c6da9 100644 --- a/spec/unit/zero/request/client/address_spec.rb +++ b/spec/unit/zero/request/client/address_spec.rb @@ -2,8 +2,26 @@ require 'spec_helper'  describe Zero::Request::Client, '#address' do    subject { Zero::Request::Client.new(env) } -  let(:address) { '127.0.0.1' } -  let(:env) { {'REMOTE_ADDR' => address} } -  its(:address) { should == address } +  context 'without a proxy' do +    let(:address) { '127.0.0.1' } +    let(:env) { {'REMOTE_ADDR' => address} } + +    its(:address) { should == address } +  end + +  context 'with a proxy' do +    let(:proxy)   { '127.0.0.1' } +    let(:address) { '192.168.42.3' } +    let(:env) do +      { +        'REMOTE_ADDR' => proxy, +        'X_FORWARDED_FOR' => address +      } +    end + +    its(:address) { should == address } +    its(:remote_address) { should == proxy } +    its(:forwarded_for)  { should == address } +  end  end | 
