From f31f1f1adf4b6c573d2620ee2bf72f3bc1fb854c Mon Sep 17 00:00:00 2001 From: rhe Date: Sun, 19 Jun 2016 09:42:29 +0000 Subject: 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 --- test/openssl/test_ocsp.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') diff --git a/test/openssl/test_ocsp.rb b/test/openssl/test_ocsp.rb index ad8e10a0ea..0f9a5acd90 100644 --- a/test/openssl/test_ocsp.rb +++ b/test/openssl/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 -- cgit v1.2.3