aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_bundled_ca.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-01 12:43:26 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-01 12:43:26 +0000
commita21d403f21473b21b5766c2483b4325240e9edda (patch)
treebd10197f9589251f35f0f9dc6fa387f0e298a6ef /test/rubygems/test_bundled_ca.rb
parent94cfa2893ccab71341d4671201253339d56d6c97 (diff)
downloadruby-a21d403f21473b21b5766c2483b4325240e9edda.tar.gz
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.5.2.
It supports to enable frozen string literal and add `--norc` option for disable to `.gemrc` configuration. See 2.5.2 release notes for other fixes and enhancements. https://github.com/rubygems/rubygems/blob/a8aa3bac723f045c52471c7b9328310a048561e0/History.txt#L3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_bundled_ca.rb')
-rw-r--r--test/rubygems/test_bundled_ca.rb80
1 files changed, 39 insertions, 41 deletions
diff --git a/test/rubygems/test_bundled_ca.rb b/test/rubygems/test_bundled_ca.rb
index 0f8b6bd6a9..f3da13b1b5 100644
--- a/test/rubygems/test_bundled_ca.rb
+++ b/test/rubygems/test_bundled_ca.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
require 'rubygems/test_case'
require 'net/https'
require 'rubygems/request'
@@ -7,55 +7,53 @@ require 'rubygems/request'
#
# 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__
+if ENV["TRAVIS"] || ENV["TEST_SSL"]
+ class TestBundledCA < Gem::TestCase
- def bundled_certificate_store
- store = OpenSSL::X509::Store.new
+ THIS_FILE = File.expand_path __FILE__
- ssl_cert_glob =
- File.expand_path '../../../lib/rubygems/ssl_certs/*.pem', THIS_FILE
+ def bundled_certificate_store
+ store = OpenSSL::X509::Store.new
- Dir[ssl_cert_glob].each do |ssl_cert|
- store.add_file ssl_cert
- end
+ ssl_cert_glob =
+ File.expand_path '../../../lib/rubygems/ssl_certs/*.pem', THIS_FILE
- store
- end
+ Dir[ssl_cert_glob].each do |ssl_cert|
+ store.add_file ssl_cert
+ end
- def assert_https(host)
- if self.respond_to? :_assertions # minitest <= 4
- self._assertions += 1
- else # minitest >= 5
- self.assertions += 1
+ store
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, Errno::ETIMEDOUT
- 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}"
+
+ 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, Errno::ETIMEDOUT
+ 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
- raise
- end
- def test_accessing_rubygems
- assert_https('rubygems.org')
- end
+ def test_accessing_rubygems
+ assert_https('rubygems.org')
+ end
- def test_accessing_cloudfront
- assert_https('d2chzxaqi4y7f8.cloudfront.net')
- end
+ def test_accessing_fastly
+ assert_https('rubygems.global.ssl.fastly.net')
+ end
- def test_accessing_fastly
- assert_https('rubygems.global.ssl.fastly.net')
end
-
-end if ENV['TRAVIS']
-
+end