summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-04 00:33:11 +0000
committeremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-04 00:33:11 +0000
commit3463615a69288dd066df0579eea087737a6c6bf8 (patch)
treee57ab82d8690ea6de47a4b2b5c6a0d914c140a3b /test
parent00bfe1940e10abdf646096aeb4e489f978c91411 (diff)
* 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/openssl/test_engine.rb42
1 files changed, 38 insertions, 4 deletions
diff --git a/test/openssl/test_engine.rb b/test/openssl/test_engine.rb
index 9258775bd36..f9106c01028 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