summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-06-29 18:37:55 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-07-31 21:07:19 +0900
commitd3efba0950b3d73e9cea1b8cecf3d0b44323f77e (patch)
treefe261f31f30c313ab5ffb1885002f39d5a561de3
parented3794495d524d64cf0d25d7485c7fde628bd787 (diff)
[rubygems/rubygems] Run `test/rubygems/test_bundled_ca.rb` locally
It's not that slow. https://github.com/rubygems/rubygems/commit/9b928a4503
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3379
-rw-r--r--test/rubygems/test_bundled_ca.rb70
1 files changed, 34 insertions, 36 deletions
diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb
index d1c74cb..aabfd46 100644
--- a/test/rubygems/test_bundled_ca.rb
+++ b/test/rubygems/test_bundled_ca.rb
@@ -8,50 +8,48 @@ require 'rubygems/request'
# The tested hosts are explained in detail here: https://github.com/rubygems/rubygems/commit/5e16a5428f973667cabfa07e94ff939e7a83ebd9
#
-if ENV["CI"]
- class TestBundledCA < Gem::TestCase
- THIS_FILE = File.expand_path __FILE__
+class TestBundledCA < Gem::TestCase
+ THIS_FILE = File.expand_path __FILE__
- def bundled_certificate_store
- store = OpenSSL::X509::Store.new
+ def bundled_certificate_store
+ store = OpenSSL::X509::Store.new
- ssl_cert_glob =
- File.expand_path '../../../lib/rubygems/ssl_certs/*/*.pem', THIS_FILE
+ 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
+ Dir[ssl_cert_glob].each do |ssl_cert|
+ store.add_file ssl_cert
end
- def assert_https(host)
- self.assertions += 1
- 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, Errno::ETIMEDOUT, SocketError
- 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
+ store
+ end
- def test_accessing_rubygems
- assert_https('rubygems.org')
+ def assert_https(host)
+ self.assertions += 1
+ 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, Errno::ETIMEDOUT, SocketError
+ 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_fastly
- assert_https('rubygems.global.ssl.fastly.net')
- end
+ def test_accessing_rubygems
+ assert_https('rubygems.org')
+ end
- def test_accessing_new_index
- assert_https('fastly.rubygems.org')
- end
+ def test_accessing_fastly
+ assert_https('rubygems.global.ssl.fastly.net')
+ end
+
+ def test_accessing_new_index
+ assert_https('fastly.rubygems.org')
end
end