[rubygems/rubygems] Diagnose the RubyGems connection
https://github.com/rubygems/rubygems/commit/bf63859e1e
This commit is contained in:
parent
cba7408017
commit
7a10ce8c95
@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rubygems/remote_fetcher"
|
||||
require "uri"
|
||||
|
||||
module Bundler
|
||||
@ -15,6 +16,7 @@ module Bundler
|
||||
|
||||
output_ssl_environment
|
||||
bundler_success = bundler_connection_successful?
|
||||
rubygem_success = rubygem_connection_successful?
|
||||
end
|
||||
|
||||
private
|
||||
@ -79,6 +81,17 @@ module Bundler
|
||||
false
|
||||
end
|
||||
|
||||
def rubygem_connection_successful?
|
||||
Gem::RemoteFetcher.fetcher.fetch_path(uri)
|
||||
Bundler.ui.info("RubyGems: success")
|
||||
|
||||
true
|
||||
rescue StandardError => error
|
||||
Bundler.ui.warn("RubyGems: failed (#{Explanation.explain_bundler_or_rubygems_error(error)})")
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
module Explanation
|
||||
extend self
|
||||
|
||||
|
@ -43,15 +43,6 @@ def show_ssl_certs
|
||||
puts
|
||||
end
|
||||
|
||||
begin
|
||||
require 'rubygems/remote_fetcher'
|
||||
Gem::RemoteFetcher.fetcher.fetch_path(uri)
|
||||
rubygems_status = "✅ success"
|
||||
rescue => error
|
||||
rubygems_status = "❌ failed (#{error_reason(error)})"
|
||||
end
|
||||
puts "RubyGems: #{rubygems_status}"
|
||||
|
||||
begin
|
||||
# Try to connect using HTTPS
|
||||
Net::HTTP.new(uri.host, uri.port).tap do |http|
|
||||
|
@ -18,13 +18,16 @@ RSpec.describe "bundle doctor ssl" do
|
||||
|
||||
@previous_level = Bundler.ui.level
|
||||
Bundler.ui.instance_variable_get(:@warning_history).clear
|
||||
@previous_client = Gem::Request::ConnectionPools.client
|
||||
Bundler.ui.level = "info"
|
||||
Artifice.activate_with(@dummy_endpoint)
|
||||
Gem::Request::ConnectionPools.client = Gem::Net::HTTP
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
Bundler.ui.level = @previous_level
|
||||
Artifice.deactivate
|
||||
Gem::Request::ConnectionPools.client = @previous_client
|
||||
end
|
||||
|
||||
context "when a diagnostic fails" do
|
||||
@ -48,6 +51,8 @@ RSpec.describe "bundle doctor ssl" do
|
||||
end
|
||||
|
||||
Artifice.replace_net_http(net_http)
|
||||
Gem::Request::ConnectionPools.client = net_http
|
||||
Gem::RemoteFetcher.fetcher.close_all
|
||||
|
||||
expected_out = <<~MSG
|
||||
Here's your OpenSSL environment:
|
||||
@ -61,6 +66,7 @@ RSpec.describe "bundle doctor ssl" do
|
||||
|
||||
expected_err = <<~MSG
|
||||
Bundler: failed (certificate verification)
|
||||
RubyGems: failed (certificate verification)
|
||||
|
||||
MSG
|
||||
|
||||
@ -78,6 +84,8 @@ RSpec.describe "bundle doctor ssl" do
|
||||
end
|
||||
|
||||
Artifice.replace_net_http(net_http)
|
||||
Gem::Request::ConnectionPools.client = Gem::Net::HTTP
|
||||
Gem::RemoteFetcher.fetcher.close_all
|
||||
|
||||
expected_out = <<~MSG
|
||||
Here's your OpenSSL environment:
|
||||
@ -91,6 +99,7 @@ RSpec.describe "bundle doctor ssl" do
|
||||
|
||||
expected_err = <<~MSG
|
||||
Bundler: failed (SSL/TLS protocol version mismatch)
|
||||
RubyGems: failed (SSL/TLS protocol version mismatch)
|
||||
|
||||
MSG
|
||||
|
||||
@ -109,6 +118,7 @@ RSpec.describe "bundle doctor ssl" do
|
||||
|
||||
Trying connections to https://rubygems.org:
|
||||
Bundler: success
|
||||
RubyGems: success
|
||||
|
||||
MSG
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user