diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-24 14:31:17 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-24 14:31:17 +0000 |
commit | 9493eb7260af756626a83359e22921a786e0ba3b (patch) | |
tree | a786b60ea9a35a21a6c37c0e9f74e4145863da38 /test/rubygems | |
parent | 11239c0e8cec548407cdc6da502e94fd50e94753 (diff) |
* lib/rubygems: Update to RubyGems 2.0.12. [ruby-core:57818]
[Backport #9014]
the patch is provided by drbrain (Eric Hodel).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems')
-rw-r--r-- | test/rubygems/test_bundled_ca.rb | 59 | ||||
-rw-r--r-- | test/rubygems/test_gem_remote_fetcher.rb | 27 | ||||
-rw-r--r-- | test/rubygems/test_require.rb | 12 |
3 files changed, 94 insertions, 4 deletions
diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb new file mode 100644 index 0000000000..dc4762e826 --- /dev/null +++ b/test/rubygems/test_bundled_ca.rb @@ -0,0 +1,59 @@ +require 'rubygems/test_case' +require 'net/https' + +# = Testing Bundled CA +# +# The tested hosts are explained in detail here: https://github.com/rubygems/rubygems/commit/5e16a5428f973667cabfa07e94ff939e7a83ebd9 +# +class TestBundledCA < Gem::TestCase + + THIS_FILE = File.expand_path __FILE__ + + def bundled_certificate_store + store = OpenSSL::X509::Store.new + + ssl_cert_glob = + File.expand_path '../../../lib/rubygems/ssl_certs/*.pem', THIS_FILE + + Dir[ssl_cert_glob].each do |ssl_cert| + store.add_file ssl_cert + end + + store + end + + def assert_https(host) + if self.respond_to? :_assertions # minitest <= 4 + self._assertions += 1 + else # minitest >= 5 + self.assertions += 1 + end + http = Net::HTTP.new(host, 443) + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_PEER + http.cert_store = bundled_certificate_store + http.get('/') + rescue Errno::ENOENT + skip "#{host} seems offline, I can't tell whether ssl would work." + rescue OpenSSL::SSL::SSLError => e + # Only fail for certificate verification errors + if e.message =~ /certificate verify failed/ + flunk "#{host} is not verifiable using the included certificates. Error was: #{e.message}" + end + raise + end + + def test_accessing_rubygems + assert_https('rubygems.org') + end + + def test_accessing_cloudfront + assert_https('d2chzxaqi4y7f8.cloudfront.net') + end + + def test_accessing_s3 + assert_https('s3.amazonaws.com') + end + +end if ENV['TRAVIS'] + diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index d3cc388db4..e960354e6b 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -143,6 +143,14 @@ gems: assert_equal proxy_uri, fetcher.instance_variable_get(:@proxy_uri) end + def test_escape_auth_info + assert_equal 'a%40b%5Cc', @fetcher.escape_auth_info('a@b\c') + end + + def test_unescape_auth_info + assert_equal 'a@b\c', @fetcher.unescape_auth_info('a%40b%5Cc') + end + def test_fetch_size_bad_uri fetcher = Gem::RemoteFetcher.new nil @@ -438,7 +446,7 @@ gems: uri.user, uri.password = 'domain%5Cuser', 'bar' fetcher = Gem::RemoteFetcher.new uri.to_s proxy = fetcher.instance_variable_get("@proxy_uri") - assert_equal 'domain\user', fetcher.unescape(proxy.user) + assert_equal 'domain\user', fetcher.unescape_auth_info(proxy.user) assert_equal 'bar', proxy.password assert_data_from_proxy fetcher.fetch_path(@server_uri) end @@ -449,7 +457,7 @@ gems: fetcher = Gem::RemoteFetcher.new uri.to_s proxy = fetcher.instance_variable_get("@proxy_uri") assert_equal 'user', proxy.user - assert_equal 'my pass', fetcher.unescape(proxy.password) + assert_equal 'my pass', fetcher.unescape_auth_info(proxy.password) assert_data_from_proxy fetcher.fetch_path(@server_uri) end end @@ -472,8 +480,19 @@ gems: ENV['http_proxy_pass'] = 'my bar' fetcher = Gem::RemoteFetcher.new nil proxy = fetcher.instance_variable_get("@proxy_uri") - assert_equal 'foo\user', fetcher.unescape(proxy.user) - assert_equal 'my bar', fetcher.unescape(proxy.password) + assert_equal 'foo\user', fetcher.unescape_auth_info(proxy.user) + assert_equal 'my bar', fetcher.unescape_auth_info(proxy.password) + assert_data_from_proxy fetcher.fetch_path(@server_uri) + end + + use_ui @ui do + ENV['http_proxy'] = @proxy_uri + ENV['http_proxy_user'] = 'foo@user' + ENV['http_proxy_pass'] = 'my@bar' + fetcher = Gem::RemoteFetcher.new nil + proxy = fetcher.instance_variable_get("@proxy_uri") + assert_equal 'foo@user', fetcher.unescape_auth_info(proxy.user) + assert_equal 'my@bar', fetcher.unescape_auth_info(proxy.password) assert_data_from_proxy fetcher.fetch_path(@server_uri) end end diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index b846103f1b..c52c9937fe 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -67,6 +67,18 @@ class TestGemRequire < Gem::TestCase end end + def test_require_can_use_a_pathname_object + a1 = new_spec "a", "1", nil, "lib/test_gem_require_a.rb" + + install_specs a1 + + save_loaded_features do + assert_require Pathname.new 'test_gem_require_a' + assert_equal %w(a-1), loaded_spec_names + assert_equal unresolved_names, [] + end + end + def test_activate_via_require_respects_loaded_files require 'benchmark' # stdlib save_loaded_features do |