From 0f59228a0b08bf59e4f9747b9272adca0899b157 Mon Sep 17 00:00:00 2001 From: emboss Date: Sat, 26 Nov 2011 14:04:52 +0000 Subject: [PATCH] * test/openssl/test_engine.rb: remove side effect of generic engine load by explicitly loading software-based "openssl" engine for all tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/openssl/test_engine.rb | 34 ++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19a09d0c25..b7aa9e1ce4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Nov 26 23:01:38 2011 Martin Bosslet + + * test/openssl/test_engine.rb: remove side effect of generic engine + load by explicitly loading software-based "openssl" engine for + all tests. + Sat Nov 26 20:41:48 2011 NARUSE, Yui * lib/net/http.rb (Net::HTTP.get_response): enable use_ssl diff --git a/test/openssl/test_engine.rb b/test/openssl/test_engine.rb index a6b2cf0a17..5b90054c8f 100644 --- a/test/openssl/test_engine.rb +++ b/test/openssl/test_engine.rb @@ -2,46 +2,46 @@ require_relative 'utils' class OpenSSL::TestEngine < Test::Unit::TestCase - def test_engines_free # [ruby-dev:44173] - OpenSSL::Engine.load - OpenSSL::Engine.engines - OpenSSL::Engine.engines + def teardown OpenSSL::Engine.cleanup # [ruby-core:40669] + assert_equal(0, OpenSSL::Engine.engines.size) + end + + def test_engines_free # [ruby-dev:44173] + OpenSSL::Engine.load("openssl") + OpenSSL::Engine.engines + OpenSSL::Engine.engines end def test_openssl_engine_builtin engine = OpenSSL::Engine.load("openssl") assert_equal(true, engine) assert_equal(1, OpenSSL::Engine.engines.size) - cleanup end def test_openssl_engine_by_id_string - engine = OpenSSL::Engine.by_id("openssl") + engine = get_engine assert_not_nil(engine) assert_equal(1, OpenSSL::Engine.engines.size) - cleanup end def test_openssl_engine_id_name_inspect - engine = OpenSSL::Engine.by_id("openssl") + engine = get_engine assert_equal("openssl", engine.id) assert_not_nil(engine.name) assert_not_nil(engine.inspect) - cleanup end def test_openssl_engine_digest_sha1 - engine = OpenSSL::Engine.by_id("openssl") + engine = get_engine digest = engine.digest("SHA1") assert_not_nil(digest) data = "test" assert_equal(OpenSSL::Digest::SHA1.digest(data), digest.digest(data)) - cleanup end def test_openssl_engine_cipher_rc4 - engine = OpenSSL::Engine.by_id("openssl") + engine = get_engine algo = "RC4" #AES is not supported by openssl Engine (<=1.0.0e) data = "a" * 1000 key = OpenSSL::Random.random_bytes(16) @@ -51,7 +51,6 @@ class OpenSSL::TestEngine < Test::Unit::TestCase encrypted = crypt_data(data, key, :encrypt) { engine.cipher(algo) } decrypted = crypt_data(encrypted, key, :decrypt) { OpenSSL::Cipher.new(algo) } assert_equal(data, decrypted) - cleanup ensure if err_back $stderr.reopen(err_back) @@ -61,6 +60,10 @@ class OpenSSL::TestEngine < Test::Unit::TestCase private + def get_engine + OpenSSL::Engine.by_id("openssl") + end + def crypt_data(data, key, mode) cipher = yield cipher.send mode @@ -68,10 +71,5 @@ class OpenSSL::TestEngine < Test::Unit::TestCase cipher.update(data) + cipher.final end - def cleanup - OpenSSL::Engine.cleanup - assert_equal(0, OpenSSL::Engine.engines.size) - end - end if defined?(OpenSSL)