diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-13 07:52:25 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-13 07:52:25 +0000 |
commit | 1b6684f87868c74e9f14d1102c56a4a805a9f7ae (patch) | |
tree | b6747c63e535b9ad491e1b6971b2acb2bd2ab287 /test | |
parent | 7e06731b99355b1d9308e83a4c0b9ee05d363ea8 (diff) |
test/uri/test_generic.rb: split test_find_proxy
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/uri/test_generic.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb index b759657f23..fcfe1f9696 100644 --- a/test/uri/test_generic.rb +++ b/test/uri/test_generic.rb @@ -795,12 +795,18 @@ class URI::TestGeneric < Test::Unit::TestCase # 192.0.2.0/24 is TEST-NET. [RFC3330] - def test_find_proxy + def test_find_proxy_bad_uri assert_raise(URI::BadURIError){ URI("foo").find_proxy } + end + + def test_find_proxy_no_env with_env({}) { assert_nil(URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) } + end + + def test_find_proxy with_env('http_proxy'=>'http://127.0.0.1:8080') { assert_equal(URI('http://127.0.0.1:8080'), URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) @@ -809,16 +815,29 @@ class URI::TestGeneric < Test::Unit::TestCase assert_nil(URI("http://192.0.2.1/").find_proxy) assert_equal(URI('http://127.0.0.1:8080'), URI("ftp://192.0.2.1/").find_proxy) } + end + + def test_find_proxy_get with_env('REQUEST_METHOD'=>'GET') { assert_nil(URI("http://192.0.2.1/").find_proxy) } with_env('CGI_HTTP_PROXY'=>'http://127.0.0.1:8080', 'REQUEST_METHOD'=>'GET') { assert_equal(URI('http://127.0.0.1:8080'), URI("http://192.0.2.1/").find_proxy) } + end + + def test_find_proxy_no_proxy with_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'192.0.2.2') { assert_equal(URI('http://127.0.0.1:8080'), URI("http://192.0.2.1/").find_proxy) assert_nil(URI("http://192.0.2.2/").find_proxy) } + with_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'example.org') { + assert_nil(URI("http://example.org/").find_proxy) + assert_nil(URI("http://www.example.org/").find_proxy) + } + end + + def test_find_proxy_bad_value with_env('http_proxy'=>'') { assert_nil(URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) @@ -827,10 +846,6 @@ class URI::TestGeneric < Test::Unit::TestCase assert_nil(URI("http://192.0.2.1/").find_proxy) assert_nil(URI("ftp://192.0.2.1/").find_proxy) } - with_env('http_proxy'=>'http://127.0.0.1:8080', 'no_proxy'=>'example.net') { - assert_nil(URI("http://example.net/").find_proxy) - assert_nil(URI("http://www.example.net/").find_proxy) - } end def test_find_proxy_case_sensitive_env |