[Rt-commit] rt branch, 4.4/smime-send-other-certs, updated. rt-4.4.2-70-g2e6ebd60f
? sunnavy
sunnavy at bestpractical.com
Fri Feb 2 12:25:26 EST 2018
The branch, 4.4/smime-send-other-certs has been updated
via 2e6ebd60f27c84cdd5517701c52c2d5457947618 (commit)
from d16f96695a217546618250e87440abad7976ab97 (commit)
Summary of changes:
t/crypt/smime/other-certs.t | 62 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 t/crypt/smime/other-certs.t
- Log -----------------------------------------------------------------
commit 2e6ebd60f27c84cdd5517701c52c2d5457947618
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Feb 3 01:21:54 2018 +0800
tests OtherCertificatesToSend option
diff --git a/t/crypt/smime/other-certs.t b/t/crypt/smime/other-certs.t
new file mode 100644
index 000000000..1b4407586
--- /dev/null
+++ b/t/crypt/smime/other-certs.t
@@ -0,0 +1,62 @@
+use strict;
+use warnings;
+
+use RT::Test::SMIME tests => undef;
+use IPC::Run3 'run3';
+
+RT::Test::SMIME->import_key( 'sender at example.com' );
+
+diag "No OtherCertificatesToSend";
+
+my $mime = MIME::Entity->build(
+ From => 'sender at example.com',
+ Type => 'text/plain',
+ Data => ["this is body\n"],
+);
+
+RT::Crypt::SMIME->SignEncrypt( Entity => $mime, Signer => 'sender at example.com', Sign => 1, Encrypt => 0 );
+
+my ( $pk7, $err, $cert );
+run3( [ RT::Crypt::SMIME->OpenSSLPath, qw(smime -pk7out) ], \$mime->as_string, \$pk7, \$err );
+ok( $pk7, 'got pk7 signature' );
+ok( !$err, 'no errors' );
+
+run3( [ RT::Crypt::SMIME->OpenSSLPath, qw(pkcs7 -print_certs -text) ], \$pk7, \$cert, \$err );
+ok( $cert, 'got cert' );
+ok( !$err, 'no errors' );
+
+chomp $cert;
+open my $fh, '<', RT::Test::SMIME->key_path( 'sender at example.com.crt' ) or die $!;
+my $sender_cert = do { local $/; <$fh> };
+is( $cert, $sender_cert, 'cert is the same one' );
+
+diag "Has OtherCertificatesToSend";
+
+RT->Config->Get( 'SMIME' )->{OtherCertificatesToSend} = RT::Test::SMIME->key_path( 'demoCA', 'cacert.pem' );
+
+$mime = MIME::Entity->build(
+ From => 'sender at example.com',
+ Type => 'text/plain',
+ Data => ["this is body\n"],
+);
+
+RT::Crypt::SMIME->SignEncrypt( Entity => $mime, Signer => 'sender at example.com', Sign => 1, Encrypt => 0 );
+
+run3( [ RT::Crypt::SMIME->OpenSSLPath, qw(smime -pk7out) ], \$mime->as_string, \$pk7, \$err );
+ok( $pk7, 'got pk7 signature' );
+ok( !$err, 'no errors' );
+
+run3( [ RT::Crypt::SMIME->OpenSSLPath, qw(pkcs7 -print_certs -text) ], \$pk7, \$cert, \$err );
+ok( $cert, 'got cert' );
+ok( !$err, 'no errors' );
+
+chomp $cert;
+my @certs = split /\n(?=Certificate:)/, $cert;
+is( scalar @certs, 2, 'found 2 certs' );
+
+open $fh, '<', RT::Test::SMIME->key_path( 'demoCA', 'cacert.pem' ) or die $!;
+my $ca_cert = do { local $/; <$fh> };
+is( $certs[0], $ca_cert, 'got ca cert' );
+is( $certs[1], $sender_cert, 'got sender cert' );
+
+done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list