Project

General

Profile

Bug #11248 » rubygems-ruby_2_0_0.patch

hsbt (Hiroshi SHIBATA), 06/11/2015 06:04 AM

View differences:

lib/rubygems/remote_fetcher.rb
rescue Resolv::ResolvError
uri
else
URI.parse "#{res.target}#{uri.path}"
target = res.target.to_s.strip
if /\.#{Regexp.quote(host)}\z/ =~ target
return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
end
uri
end
end
test/rubygems/test_gem_remote_fetcher.rb
end
def test_api_endpoint
uri = URI.parse "http://example.com/foo"
target = MiniTest::Mock.new
target.expect :target, "gems.example.com"
dns = MiniTest::Mock.new
dns.expect :getresource, target, [String, Object]
fetch = Gem::RemoteFetcher.new nil, dns
assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
target.verify
dns.verify
end
def test_api_endpoint_ignores_trans_domain_values
uri = URI.parse "http://gems.example.com/foo"
target = MiniTest::Mock.new
target.expect :target, "http://blah.com"
target.expect :target, "blah.com"
dns = MiniTest::Mock.new
dns.expect :getresource, target, [String, Object]
fetch = Gem::RemoteFetcher.new nil, dns
assert_equal URI.parse("http://blah.com/foo"), fetch.api_endpoint(uri)
assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
target.verify
dns.verify
end
def test_api_endpoint_ignores_trans_domain_values_that_starts_with_original
uri = URI.parse "http://example.com/foo"
target = MiniTest::Mock.new
target.expect :target, "example.combadguy.com"
dns = MiniTest::Mock.new
dns.expect :getresource, target, [String, Object]
fetch = Gem::RemoteFetcher.new nil, dns
assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
target.verify
dns.verify
end
def test_api_endpoint_ignores_trans_domain_values_that_end_with_original
uri = URI.parse "http://example.com/foo"
target = MiniTest::Mock.new
target.expect :target, "badexample.com"
dns = MiniTest::Mock.new
dns.expect :getresource, target, [String, Object]
fetch = Gem::RemoteFetcher.new nil, dns
assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
target.verify
dns.verify
(1-1/3)