diff --git a/test/openssl/test_bn.rb b/test/openssl/test_bn.rb index 98348d6078..769b7ed831 100644 --- a/test/openssl/test_bn.rb +++ b/test/openssl/test_bn.rb @@ -1,5 +1,4 @@ require_relative 'utils' -require "digest/md5" if defined?(OpenSSL) diff --git a/test/openssl/test_config.rb b/test/openssl/test_config.rb index 3c21fb1f86..1239e50b48 100644 --- a/test/openssl/test_config.rb +++ b/test/openssl/test_config.rb @@ -1,7 +1,4 @@ -require 'openssl' -require "test/unit" -require 'tempfile' -require File.join(File.dirname(__FILE__), "utils.rb") +require_relative 'utils' class OpenSSL::TestConfig < Test::Unit::TestCase def setup diff --git a/test/openssl/test_digest.rb b/test/openssl/test_digest.rb index 8941588b97..e9b4ad136d 100644 --- a/test/openssl/test_digest.rb +++ b/test/openssl/test_digest.rb @@ -1,9 +1,4 @@ -begin - require "openssl" -rescue LoadError -end -require "digest/md5" -require "test/unit" +require_relative 'utils' if defined?(OpenSSL) diff --git a/test/openssl/test_ec.rb b/test/openssl/test_ec.rb index 39f5577dc2..f80c3d40ae 100644 --- a/test/openssl/test_ec.rb +++ b/test/openssl/test_ec.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require File.join(File.dirname(__FILE__), "utils.rb") -rescue LoadError -end -require "test/unit" +require_relative 'utils' if defined?(OpenSSL::PKey::EC) diff --git a/test/openssl/test_hmac.rb b/test/openssl/test_hmac.rb index 23a3ce4264..ba158d2b51 100644 --- a/test/openssl/test_hmac.rb +++ b/test/openssl/test_hmac.rb @@ -1,8 +1,4 @@ -begin - require "openssl" -rescue LoadError -end -require "test/unit" +require_relative 'utils' class OpenSSL::TestHMAC < Test::Unit::TestCase def setup diff --git a/test/openssl/test_ns_spki.rb b/test/openssl/test_ns_spki.rb index 14895edb7d..3bcf3e6fbe 100644 --- a/test/openssl/test_ns_spki.rb +++ b/test/openssl/test_ns_spki.rb @@ -1,13 +1,7 @@ -begin - require "openssl" - require_relative 'utils' -rescue LoadError -end -require "test/unit" +require_relative 'utils' if defined?(OpenSSL) - class OpenSSL::TestNSSPI < Test::Unit::TestCase def setup # This request data is adopt from the specification of @@ -20,9 +14,6 @@ class OpenSSL::TestNSSPI < Test::Unit::TestCase @b64 << "i0//rgBvmco=" end - def teardown - end - def test_build_data key1 = OpenSSL::TestUtils::TEST_KEY_RSA1024 key2 = OpenSSL::TestUtils::TEST_KEY_RSA2048 diff --git a/test/openssl/test_ocsp.rb b/test/openssl/test_ocsp.rb index 98e1ebbf1b..19c37e4d32 100644 --- a/test/openssl/test_ocsp.rb +++ b/test/openssl/test_ocsp.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require_relative "utils" -rescue LoadError -end -require "test/unit" +require_relative "utils" if defined?(OpenSSL) diff --git a/test/openssl/test_pkcs7.rb b/test/openssl/test_pkcs7.rb index fa71b9e938..34c523aacc 100644 --- a/test/openssl/test_pkcs7.rb +++ b/test/openssl/test_pkcs7.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require_relative 'utils' -rescue LoadError -end -require "test/unit" +require_relative 'utils' if defined?(OpenSSL) diff --git a/test/openssl/test_pkey_rsa.rb b/test/openssl/test_pkey_rsa.rb index 401cb6c3e0..c9c5f3d98c 100644 --- a/test/openssl/test_pkey_rsa.rb +++ b/test/openssl/test_pkey_rsa.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require File.join(File.dirname(__FILE__), "utils.rb") -rescue LoadError -end -require 'test/unit' +require_relative 'utils' if defined?(OpenSSL) diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index c8e42f43af..d83dd4283d 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -1,12 +1,4 @@ -begin - require "openssl" - require_relative "utils.rb" -rescue LoadError -end -require "rbconfig" -require "socket" -require "test/unit" -require_relative '../ruby/envutil' +require_relative "utils" if defined?(OpenSSL) diff --git a/test/openssl/test_x509cert.rb b/test/openssl/test_x509cert.rb index 48bab1715a..8b88ad4ddd 100644 --- a/test/openssl/test_x509cert.rb +++ b/test/openssl/test_x509cert.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require_relative "utils" -rescue LoadError -end -require "test/unit" +require_relative "utils" if defined?(OpenSSL) diff --git a/test/openssl/test_x509crl.rb b/test/openssl/test_x509crl.rb index 61a8de5723..c0c996e966 100644 --- a/test/openssl/test_x509crl.rb +++ b/test/openssl/test_x509crl.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require_relative "utils" -rescue LoadError -end -require "test/unit" +require_relative "utils" if defined?(OpenSSL) diff --git a/test/openssl/test_x509ext.rb b/test/openssl/test_x509ext.rb index d43bbd6bd3..89b45c728f 100644 --- a/test/openssl/test_x509ext.rb +++ b/test/openssl/test_x509ext.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require File.join(File.dirname(__FILE__), "utils.rb") -rescue LoadError -end -require "test/unit" +require_relative 'utils' if defined?(OpenSSL) diff --git a/test/openssl/test_x509name.rb b/test/openssl/test_x509name.rb index 951c36c425..ef9925202a 100644 --- a/test/openssl/test_x509name.rb +++ b/test/openssl/test_x509name.rb @@ -1,8 +1,4 @@ -begin - require "openssl" -rescue LoadError -end -require "test/unit" +require_relative 'utils' if defined?(OpenSSL) diff --git a/test/openssl/test_x509req.rb b/test/openssl/test_x509req.rb index f53408f696..0ea7cabcee 100644 --- a/test/openssl/test_x509req.rb +++ b/test/openssl/test_x509req.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require_relative "utils" -rescue LoadError -end -require "test/unit" +require_relative "utils" if defined?(OpenSSL) diff --git a/test/openssl/test_x509store.rb b/test/openssl/test_x509store.rb index 81fa0b0dcb..0a93207eee 100644 --- a/test/openssl/test_x509store.rb +++ b/test/openssl/test_x509store.rb @@ -1,9 +1,4 @@ -begin - require "openssl" - require_relative "utils" -rescue LoadError -end -require "test/unit" +require_relative "utils" if defined?(OpenSSL) diff --git a/test/openssl/utils.rb b/test/openssl/utils.rb index 92c6c5596e..0b2115bbf3 100644 --- a/test/openssl/utils.rb +++ b/test/openssl/utils.rb @@ -3,6 +3,11 @@ begin rescue LoadError end require "test/unit" +require "digest/md5" +require 'tempfile' +require "rbconfig" +require "socket" +require_relative '../ruby/envutil' module OpenSSL::TestUtils TEST_KEY_RSA1024 = OpenSSL::PKey::RSA.new <<-_end_of_pem_