From 9f87c132558ba66cecacd8fa54ceae044b7714a6 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 15 Aug 2019 09:59:06 -0700 Subject: Add test for OpenSSL::PKCS7.{read,write}_smime The 2nd and 3rd arguments to write_smime are not really testable without exposing additional OpenSSL constants to Ruby. Still, test that write_smime works when passed 3 arguments. Fixes Ruby Bug 8274. --- test/test_pkcs7.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/test_pkcs7.rb b/test/test_pkcs7.rb index 6437112b..5b356fbc 100644 --- a/test/test_pkcs7.rb +++ b/test/test_pkcs7.rb @@ -172,6 +172,28 @@ class OpenSSL::TestPKCS7 < OpenSSL::TestCase assert_equal(:encrypted, p7.type) end + def test_smime + store = OpenSSL::X509::Store.new + store.add_cert(@ca_cert) + ca_certs = [@ca_cert] + + data = "aaaaa\r\nbbbbb\r\nccccc\r\n" + tmp = OpenSSL::PKCS7.sign(@ee1_cert, @rsa1024, data, ca_certs) + p7 = OpenSSL::PKCS7.new(tmp.to_der) + smime = OpenSSL::PKCS7.write_smime(p7) + assert_equal(true, smime.start_with?(<