summaryrefslogtreecommitdiff
path: root/test/openssl/test_engine.rb
diff options
context:
space:
mode:
authoremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-24 01:09:55 +0000
committeremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-24 01:09:55 +0000
commit452b74c10682280912d14254795d2e76894fbdc9 (patch)
tree63dbbbdff972cb38eb6082d64f61df2fcb2b64a0 /test/openssl/test_engine.rb
parent5c7e691e5de1fc0d9a8d7bc15cf45cb4a06d4452 (diff)
* 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
Diffstat (limited to 'test/openssl/test_engine.rb')
-rw-r--r--test/openssl/test_engine.rb30
1 files changed, 16 insertions, 14 deletions
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)