summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-23 13:48:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-23 13:48:41 +0000
commit77b1d88513cb4aea0183fef256dc2d7f168a2b4b (patch)
treebb03c437b79b8cfff376bb3e33ff05423eb6172f
parent535a28c73748874eed9016e48515f01a71c507eb (diff)
skip OpenSSL dependent tests if not available
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/net/imap/test_imap.rb34
-rw-r--r--test/open-uri/test_ssl.rb11
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb17
-rw-r--r--test/xmlrpc/test_client.rb4
4 files changed, 34 insertions, 32 deletions
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index df9cd8b8a2..0feabb9108 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -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
diff --git a/test/open-uri/test_ssl.rb b/test/open-uri/test_ssl.rb
index 059465d73d..4ba59d567a 100644
--- a/test/open-uri/test_ssl.rb
+++ b/test/open-uri/test_ssl.rb
@@ -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
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index 6d370cfe3d..2c8769c1c1 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -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
diff --git a/test/xmlrpc/test_client.rb b/test/xmlrpc/test_client.rb
index bf57d7e54c..96f3af8599 100644
--- a/test/xmlrpc/test_client.rb
+++ b/test/xmlrpc/test_client.rb
@@ -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'