diff options
author | emboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-24 01:09:55 +0000 |
---|---|---|
committer | emboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-24 01:09:55 +0000 |
commit | 452b74c10682280912d14254795d2e76894fbdc9 (patch) | |
tree | 63dbbbdff972cb38eb6082d64f61df2fcb2b64a0 | |
parent | 5c7e691e5de1fc0d9a8d7bc15cf45cb4a06d4452 (diff) | |
download | ruby-452b74c10682280912d14254795d2e76894fbdc9.tar.gz |
* test/openssl/test_engine.rb: Suppress output from 'openssl'
engine's RC4 cipher.
[Bug #5633] [ruby-core:41026]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | test/openssl/test_engine.rb | 30 |
2 files changed, 23 insertions, 15 deletions
@@ -1,10 +1,16 @@ +Thu Nov 24 10:05:02 2011 Martin Bosslet <Martin.Bosslet@googlemail.com> + + * test/openssl/test_engine.rb: Suppress output from 'openssl' + engine's RC4 cipher. + [Bug #5633] [ruby-core:41026] + Thu Nov 24 08:05:02 2011 Martin Bosslet <Martin.Bosslet@googlemail.com> * ext/openssl/ossl_pkey_dsa.c: remove redundant colon from error message. * ext/openssl/ossl_ssl.c: ditto. * ext/openssl/ossl_pkey_rsa: ditto. - patched by Eric Hodel [Bug #5604] [ruby-core:40896] + patched by Eric Hodel [Bug #5604] [ruby-core:40896] Wed Nov 23 20:03:43 2011 NARUSE, Yui <naruse@ruby-lang.org> diff --git a/test/openssl/test_engine.rb b/test/openssl/test_engine.rb index fce5f76ee6..f56fbe757c 100644 --- a/test/openssl/test_engine.rb +++ b/test/openssl/test_engine.rb @@ -45,27 +45,29 @@ class OpenSSL::TestEngine < Test::Unit::TestCase algo = "RC4" #AES is not supported by openssl Engine (<=1.0.0e) data = "a" * 1000 key = OpenSSL::Random.random_bytes(16) - - encipher = engine.cipher(algo) - encipher.encrypt - encipher.key = key - - decipher = OpenSSL::Cipher.new(algo) - decipher.decrypt - decipher.key = key - - encrypted = encipher.update(data) + encipher.final - decrypted = decipher.update(encrypted) + decipher.final - + # suppress message from openssl Engine's RC4 cipher [ruby-core:41026] + err_back = $stderr.dup + $stderr.reopen(IO::NULL) + encrypted = crypt_data(data, key, :encrypt) { engine.cipher(algo) } + decrypted = crypt_data(encrypted, key, :decrypt) { OpenSSL::Cipher.new(algo) } assert_equal(data, decrypted) cleanup - end + ensure + $stderr = err_back if err_back + end private + def crypt_data(data, key, mode) + cipher = yield + cipher.send mode + cipher.key = key + cipher.update(data) + cipher.final + end + def cleanup OpenSSL::Engine.cleanup - assert_equal(0, OpenSSL::Engine::engines.size) + assert_equal(0, OpenSSL::Engine.engines.size) end end if defined?(OpenSSL) |