diff options
author | Greg Sterndale <gsterndale@gmail.com> | 2011-08-22 10:20:35 -0400 |
---|---|---|
committer | Greg Sterndale <gsterndale@gmail.com> | 2012-02-07 11:21:32 -0500 |
commit | dd09811fa6214a130fdc2de1d4c00b4337cb15f9 (patch) | |
tree | 6a888e513fa491b7076ea53c0f66662e8e617496 /actionpack/test | |
parent | ed9aeec92d60c2b62f3cef6b02112ad4401a0bcc (diff) | |
download | rails-dd09811fa6214a130fdc2de1d4c00b4337cb15f9.tar.gz rails-dd09811fa6214a130fdc2de1d4c00b4337cb15f9.tar.bz2 rails-dd09811fa6214a130fdc2de1d4c00b4337cb15f9.zip |
Trusted proxies is replaced with a Regexp or appended to with a String
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/request_test.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb index 5b3d38c48c..1b4b00ea9e 100644 --- a/actionpack/test/dispatch/request_test.rb +++ b/actionpack/test/dispatch/request_test.rb @@ -94,8 +94,8 @@ class RequestTest < ActiveSupport::TestCase assert_equal '127.0.0.1', request.remote_ip end - test "remote ip with user specified trusted proxies" do - @trusted_proxies = /^67\.205\.106\.73$/i + test "remote ip with user specified trusted proxies String" do + @trusted_proxies = "67.205.106.73" request = stub_request 'REMOTE_ADDR' => '67.205.106.73', 'HTTP_X_FORWARDED_FOR' => '3.4.5.6' @@ -120,6 +120,17 @@ class RequestTest < ActiveSupport::TestCase assert_equal '3.4.5.6', request.remote_ip end + test "remote ip with user specified trusted proxies Regexp" do + @trusted_proxies = /^67\.205\.106\.73$/i + + request = stub_request 'REMOTE_ADDR' => '67.205.106.73', + 'HTTP_X_FORWARDED_FOR' => '3.4.5.6' + assert_equal '3.4.5.6', request.remote_ip + + request = stub_request 'HTTP_X_FORWARDED_FOR' => '9.9.9.9, 3.4.5.6, 10.0.0.1, 67.205.106.73' + assert_equal '10.0.0.1', request.remote_ip + end + test "domains" do request = stub_request 'HTTP_HOST' => 'www.rubyonrails.org' assert_equal "rubyonrails.org", request.domain |