diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/openssl/test_engine.rb | 42 |
2 files changed, 43 insertions, 4 deletions
@@ -1,3 +1,8 @@ +Fri Nov 04 01:31:25 2011 Martin Bosslet <Martin.Bosslet@googlemail.com> + + * test/openssl/test_engine.rb: add first tests for builtin "openssl" + engine. + Fri Nov 04 08:41:26 2011 Martin Bosslet <Martin.Bosslet@googlemail.com> * ext/openssl/extconf.rb: diff --git a/test/openssl/test_engine.rb b/test/openssl/test_engine.rb index 9258775bd3..f9106c0102 100644 --- a/test/openssl/test_engine.rb +++ b/test/openssl/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 |