1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

skip OpenSSL dependent tests if not available

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-04-23 13:48:41 +00:00
parent 535a28c737
commit 77b1d88513
4 changed files with 34 additions and 32 deletions

View file

@ -45,8 +45,8 @@ class IMAPTest < Test::Unit::TestCase
assert_match(/\A24-Jul-2009 01:23 [+\-]\d{4}\z/, s)
end
def test_imaps_unknown_ca
if defined?(OpenSSL)
if defined?(OpenSSL::SSL::SSLError)
def test_imaps_unknown_ca
assert_raise(OpenSSL::SSL::SSLError) do
imaps_test do |port|
begin
@ -59,10 +59,8 @@ class IMAPTest < Test::Unit::TestCase
end
end
end
end
def test_imaps_with_ca_file
if defined?(OpenSSL)
def test_imaps_with_ca_file
assert_nothing_raised do
imaps_test do |port|
begin
@ -75,10 +73,8 @@ class IMAPTest < Test::Unit::TestCase
end
end
end
end
def test_imaps_verify_none
if defined?(OpenSSL)
def test_imaps_verify_none
assert_nothing_raised do
imaps_test do |port|
Net::IMAP.new(SERVER_ADDR,
@ -87,10 +83,8 @@ class IMAPTest < Test::Unit::TestCase
end
end
end
end
def test_imaps_post_connection_check
if defined?(OpenSSL)
def test_imaps_post_connection_check
assert_raise(OpenSSL::SSL::SSLError) do
imaps_test do |port|
# SERVER_ADDR is different from the hostname in the certificate,
@ -103,20 +97,20 @@ class IMAPTest < Test::Unit::TestCase
end
end
def test_starttls
imap = nil
if defined?(OpenSSL)
if defined?(OpenSSL::SSL)
def test_starttls
imap = nil
starttls_test do |port|
imap = Net::IMAP.new("localhost", :port => port)
imap.starttls(:ca_file => CA_FILE)
imap
end
end
rescue SystemCallError
skip $!
ensure
if imap && !imap.disconnected?
imap.disconnect
rescue SystemCallError
skip $!
ensure
if imap && !imap.disconnected?
imap.disconnect
end
end
end

View file

@ -1,13 +1,18 @@
require 'test/unit'
require 'open-uri'
require 'openssl'
require 'stringio'
require 'webrick'
require 'webrick/https'
begin
require 'openssl'
require 'webrick/https'
rescue LoadError
end
require 'webrick/httpproxy'
class TestOpenURISSL < Test::Unit::TestCase
end
class TestOpenURISSL
NullLog = Object.new
def NullLog.<<(arg)
end
@ -100,7 +105,7 @@ class TestOpenURISSL < Test::Unit::TestCase
}
end
end
end if defined?(OpenSSL)
# mkdir demoCA demoCA/private demoCA/newcerts
# touch demoCA/index.txt

View file

@ -1,7 +1,10 @@
require 'rubygems/test_case'
require 'ostruct'
require 'webrick'
require 'webrick/https'
begin
require 'webrick/https'
rescue LoadError
end
require 'rubygems/remote_fetcher'
require 'rubygems/format'
@ -749,7 +752,7 @@ gems:
with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher|
fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
end
end
end if defined?(OpenSSL::PKey)
def test_do_not_allow_insecure_ssl_connection_by_default
ssl_server = self.class.start_ssl_server
@ -758,14 +761,14 @@ gems:
fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
end
end
end
end if defined?(OpenSSL::PKey)
def test_ssl_connection_allow_verify_none
ssl_server = self.class.start_ssl_server
with_configured_fetcher(":ssl_verify_mode: 0") do |fetcher|
fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml")
end
end
end if defined?(OpenSSL::PKey)
def test_do_not_follow_insecure_redirect
ssl_server = self.class.start_ssl_server
@ -775,7 +778,7 @@ gems:
fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri}")
end
end
end
end if defined?(OpenSSL::PKey)
def with_configured_fetcher(config_str = nil, &block)
if config_str
@ -853,7 +856,7 @@ gems:
end
DIR = File.expand_path(File.dirname(__FILE__))
DH_PARAM = OpenSSL::PKey::DH.new(128)
DH_PARAM = defined?(OpenSSL::PKey) ? OpenSSL::PKey::DH.new(128) : nil
def start_ssl_server(config = {})
null_logger = NilLog.new
@ -891,7 +894,7 @@ gems:
end
end
server
end
end if DH_PARAM

View file

@ -102,7 +102,7 @@ module XMLRPC
refute user
refute password
refute timeout
end
end if defined?(OpenSSL)
def test_new2_ssl_custom_port
client = Fake::Client.new2 'https://example.org:1234/foo'
@ -117,7 +117,7 @@ module XMLRPC
refute user
refute password
refute timeout
end
end if defined?(OpenSSL)
def test_new2_user_password
client = Fake::Client.new2 'http://aaron:tenderlove@example.org/foo'