diff options
author | emboss <emboss@ruby-lang.org> | 2011-11-04 00:33:11 +0000 |
---|---|---|
committer | emboss <emboss@ruby-lang.org> | 2011-11-04 00:33:11 +0000 |
commit | 636669c452f386b83d23ebee039a99f867a31356 (patch) | |
tree | bd0c6426f78ee8742f4ed604a2fb35eaa7339c66 /test | |
parent | b7a9576d64e240643edad42f29be22e65cda1764 (diff) | |
download | ruby-openssl-history-636669c452f386b83d23ebee039a99f867a31356.tar.gz |
* test/openssl/test_engine.rb: add first tests for builtin "openssl"
engine.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/test_engine.rb | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/test/test_engine.rb b/test/test_engine.rb index 9258775..f9106c0 100644 --- a/test/test_engine.rb +++ b/test/test_engine.rb @@ -1,7 +1,5 @@ require_relative 'utils' -if defined?(OpenSSL) - class OpenSSL::TestEngine < Test::Unit::TestCase def test_engines_free # [ruby-dev:44173] @@ -11,6 +9,42 @@ class OpenSSL::TestEngine < Test::Unit::TestCase OpenSSL::Engine.cleanup # [ruby-core:40669] end -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") + 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") + 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") + digest = engine.digest("SHA1") + assert_not_nil(digest) + data = "test" + assert_equal(OpenSSL::Digest::SHA1.digest(data), digest.digest(data)) + end + + private + + def cleanup + OpenSSL::Engine.cleanup + assert_equal(0, OpenSSL::Engine::engines.size) + end + +end if defined?(OpenSSL) -end |