From 92e726628e3baf4acb1a349089aa4d3278c2ad40 Mon Sep 17 00:00:00 2001 From: hsbt Date: Wed, 19 Dec 2018 07:20:17 +0000 Subject: [PATCH] Merge RubyGems 3.0.0 from upstream. https://blog.rubygems.org/2018/12/19/3.0.0-released.html git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems.rb | 2 +- lib/rubygems/request.rb | 1 + test/rubygems/test_bundled_ca.rb | 2 +- test/rubygems/test_gem.rb | 4 +++- .../test_gem_commands_setup_command.rb | 6 ++++-- test/rubygems/test_gem_remote_fetcher.rb | 20 +++++++++++++++++-- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 048eb9bdda..abf2e9b5da 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -9,7 +9,7 @@ require 'rbconfig' module Gem - VERSION = "3.0.0.beta3".freeze + VERSION = "3.0.0".freeze end # Must be first since it unloads the prelude from 1.9.2 diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb index 9aadc38cb3..fb164d79cf 100644 --- a/lib/rubygems/request.rb +++ b/lib/rubygems/request.rb @@ -45,6 +45,7 @@ class Gem::Request end def self.configure_connection_for_https(connection, cert_files) + require 'net/https' connection.use_ssl = true connection.verify_mode = Gem.configuration.ssl_verify_mode || OpenSSL::SSL::VERIFY_PEER diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb index d56a374e1d..97a64af323 100644 --- a/test/rubygems/test_bundled_ca.rb +++ b/test/rubygems/test_bundled_ca.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true require 'rubygems/test_case' -require 'net/http' +require 'net/https' require 'rubygems/request' # = Testing Bundled CA diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 682fa84612..e062eebbaa 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -5,6 +5,7 @@ require 'rubygems/command' require 'rubygems/installer' require 'pathname' require 'tmpdir' +require 'rbconfig' # TODO: push this up to test_case.rb once battle tested @@ -13,6 +14,7 @@ $LOAD_PATH.map! do |path| end class TestGem < Gem::TestCase + RUBY_INSTALL_NAME = RbConfig::CONFIG['RUBY_INSTALL_NAME'] PLUGINS_LOADED = [] # rubocop:disable Style/MutableConstant @@ -181,7 +183,7 @@ class TestGem < Gem::TestCase dir_mode = (options[:dir_mode] & mask).to_s(8) data_mode = (options[:data_mode] & mask).to_s(8) expected = { - 'bin/foo.cmd' => prog_mode, + "bin/#{RUBY_INSTALL_NAME.sub('ruby', 'foo.cmd')}" => prog_mode, 'gems/foo-1' => dir_mode, 'gems/foo-1/bin' => dir_mode, 'gems/foo-1/data' => dir_mode, diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb index d788c19ad5..f1598f3fc2 100644 --- a/test/rubygems/test_gem_commands_setup_command.rb +++ b/test/rubygems/test_gem_commands_setup_command.rb @@ -113,9 +113,11 @@ class TestGemCommandsSetupCommand < Gem::TestCase @cmd.options[:env_shebang] = true @cmd.execute - default_gem_bin_path = File.join @install_dir, 'bin', 'gem' + gem_exec = sprintf Gem.default_exec_format, 'gem' + default_gem_bin_path = File.join @install_dir, 'bin', gem_exec if Gem::USE_BUNDLER_FOR_GEMDEPS - default_bundle_bin_path = File.join @install_dir, 'bin', 'bundle' + bundle_exec = sprintf Gem.default_exec_format, 'bundle' + default_bundle_bin_path = File.join @install_dir, 'bin', bundle_exec end ruby_exec = sprintf Gem.default_exec_format, 'ruby' diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index 5029a6a6fd..a725fe205c 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -835,10 +835,26 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== def test_do_not_follow_insecure_redirect ssl_server = self.class.start_ssl_server - temp_ca_cert = File.join(DIR, 'ca_cert.pem'), + temp_ca_cert = File.join(DIR, 'ca_cert.pem') + expected_error_message = + "redirecting to non-https resource: #{@server_uri} (https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri})" + + with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher| + err = assert_raises Gem::RemoteFetcher::FetchError do + fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri}") + end + + assert_equal(err.message, expected_error_message) + end + end + + def test_nil_ca_cert + ssl_server = self.class.start_ssl_server + temp_ca_cert = nil + with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher| assert_raises Gem::RemoteFetcher::FetchError do - fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri}") + fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}") end end end