aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorrhe <rhe@ruby-lang.org>2016-06-19 09:42:29 +0000
committerKazuki Yamaguchi <k@rhe.jp>2016-06-19 23:25:32 +0900
commitcfa26091f9576be7381a67f6ee5b1a8901eeb77e (patch)
tree034066a51668a1a08bb9f840f24ad4055c65d440 /test
parentba9ca639dcabb9d64079e9219640099251af9ac0 (diff)
downloadruby-openssl-cfa26091f9576be7381a67f6ee5b1a8901eeb77e.tar.gz
openssl: implement initialize_copy for OpenSSL::OCSP::*
* ext/openssl/ossl_ocsp.c: Implement OCSP::{CertificateId,Request, BasicResponse,Response}#initialize_copy. [ruby-core:75504] [Bug #12381] * test/openssl/test_ocsp.rb: Test them. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_ocsp.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_ocsp.rb b/test/test_ocsp.rb
index ad8e10a0..0f9a5acd 100644
--- a/test/test_ocsp.rb
+++ b/test/test_ocsp.rb
@@ -73,6 +73,11 @@ class OpenSSL::TestOCSP < OpenSSL::TestCase
assert_equal der, OpenSSL::OCSP::CertificateId.new(der).to_der
end
+ def test_certificate_id_dup
+ cid = OpenSSL::OCSP::CertificateId.new(@cert, @ca_cert)
+ assert_equal cid.to_der, cid.dup.to_der
+ end
+
def test_request_der
request = OpenSSL::OCSP::Request.new
cid = OpenSSL::OCSP::CertificateId.new(@cert, @ca_cert, OpenSSL::Digest::SHA1.new)
@@ -116,6 +121,14 @@ class OpenSSL::TestOCSP < OpenSSL::TestCase
assert_equal 3, req0.check_nonce(bres)
end
+ def test_request_dup
+ request = OpenSSL::OCSP::Request.new
+ cid = OpenSSL::OCSP::CertificateId.new(@cert, @ca_cert, OpenSSL::Digest::SHA1.new)
+ request.add_certid(cid)
+ request.sign(@cert, @key, nil, 0, "SHA1")
+ assert_equal request.to_der, request.dup.to_der
+ end
+
def test_basic_response_der
bres = OpenSSL::OCSP::BasicResponse.new
cid = OpenSSL::OCSP::CertificateId.new(@cert, @ca_cert, OpenSSL::Digest::SHA1.new)
@@ -141,6 +154,14 @@ class OpenSSL::TestOCSP < OpenSSL::TestCase
assert_equal true, bres.verify([], store2, OpenSSL::OCSP::NOVERIFY)
end
+ def test_basic_response_dup
+ bres = OpenSSL::OCSP::BasicResponse.new
+ cid = OpenSSL::OCSP::CertificateId.new(@cert, @ca_cert, OpenSSL::Digest::SHA1.new)
+ bres.add_status(cid, OpenSSL::OCSP::V_CERTSTATUS_GOOD, 0, nil, -300, 500, [])
+ bres.sign(@cert2, @key2, [@ca_cert], 0)
+ assert_equal bres.to_der, bres.dup.to_der
+ end
+
def test_response_der
bres = OpenSSL::OCSP::BasicResponse.new
cid = OpenSSL::OCSP::CertificateId.new(@cert, @ca_cert, OpenSSL::Digest::SHA1.new)
@@ -154,6 +175,13 @@ class OpenSSL::TestOCSP < OpenSSL::TestCase
assert_equal bres.to_der, asn1.value[1].value[0].value[1].value
assert_equal der, OpenSSL::OCSP::Response.new(der).to_der
end
+
+ def test_response_dup
+ bres = OpenSSL::OCSP::BasicResponse.new
+ bres.sign(@cert2, @key2, [@ca_cert], 0)
+ res = OpenSSL::OCSP::Response.create(OpenSSL::OCSP::RESPONSE_STATUS_SUCCESSFUL, bres)
+ assert_equal res.to_der, res.dup.to_der
+ end
end
end