From 4d936325e747db44a0dd50aea5b5f3f4cd90ee8e Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Nov 2014 17:16:11 +1100 Subject: [PATCH] test forwarding works as expected --- .../auth/default_current_user_provider_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/components/auth/default_current_user_provider_spec.rb b/spec/components/auth/default_current_user_provider_spec.rb index 99c5e2e96..153ac1395 100644 --- a/spec/components/auth/default_current_user_provider_spec.rb +++ b/spec/components/auth/default_current_user_provider_spec.rb @@ -43,13 +43,18 @@ describe Auth::DefaultCurrentUserProvider do it "allows a user with a matching ip" do user = Fabricate(:user) - ApiKey.create!(key: "hello", user_id: user.id, created_by_id: -1, allowed_ips: ['10.0.0.0/24']) + ApiKey.create!(key: "hello", user_id: user.id, created_by_id: -1, allowed_ips: ['100.0.0.0/24']) found_user = provider("/?api_key=hello&api_username=#{user.username.downcase}", - "REMOTE_ADDR" => "10.0.0.22").current_user + "REMOTE_ADDR" => "100.0.0.22").current_user found_user.id.should == user.id + + found_user = provider("/?api_key=hello&api_username=#{user.username.downcase}", + "HTTP_X_FORWARDED_FOR" => "10.1.1.1, 100.0.0.22").current_user + found_user.id.should == user.id + end it "finds a user for a correct system api key" do