[Rt-commit] rt branch, 4.4/add-crypt-status-functions, updated. rt-4.4.4-175-ga11c3094c5
Dianne Skoll
dianne at bestpractical.com
Tue Nov 24 16:46:23 EST 2020
The branch, 4.4/add-crypt-status-functions has been updated
via a11c3094c5aef7072c8f6248ac9ed4bf5db6c8fc (commit)
from 46d3b0d9754022a50a1bfa699cc317cf3837ee3a (commit)
Summary of changes:
lib/RT/Attachment.pm | 10 +++++-----
t/mail/gnupg-incoming.t | 2 +-
t/mail/smime/incoming.t | 16 ++++++++++++++--
3 files changed, 20 insertions(+), 8 deletions(-)
- Log -----------------------------------------------------------------
commit a11c3094c5aef7072c8f6248ac9ed4bf5db6c8fc
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Tue Nov 24 16:45:30 2020 -0500
Don't short-circuit GetCryptStatus when we hit the first crypto status header; process them all.
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 355ca5fd7c..f587309d1c 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -874,20 +874,20 @@ in L<RT::Crypt::ParseStatus>; however, each hashref has one additional
entry 'Protocol' which is the name of the crypto protocol used
and is one of 'SMIME' or 'GnuPG'.
-If no crypto header exists, returns the array: ( { Protocol => 'None' } )
+If no crypto header exists, returns an empty array
=cut
sub GetCryptStatus
{
my $self = shift;
- my @result = ( {Protocol => 'None' } );
+ my @ret = ( );
foreach my $h ($self->SplitHeaders) {
next unless $h =~ /^X-RT-(GnuPG|SMIME)-Status:/i;
my $protocol = $1;
my ($h_key, $h_val) = split(/:\s*/, $h, 2);
- @result = RT::Crypt->ParseStatus(Protocol => $protocol,
+ my @result = RT::Crypt->ParseStatus(Protocol => $protocol,
Status => $h_val);
# Canonicalize protocol case so it's always SMIME or GnuPG
@@ -898,10 +898,10 @@ sub GetCryptStatus
}
foreach my $hash (@result) {
$hash->{'Protocol'} = $protocol;
+ push(@ret, $hash);
}
- last;
}
- return @result;
+ return @ret;
}
=head2 SplitHeaders
diff --git a/t/mail/gnupg-incoming.t b/t/mail/gnupg-incoming.t
index c8a4fcc678..a7b1bc4349 100644
--- a/t/mail/gnupg-incoming.t
+++ b/t/mail/gnupg-incoming.t
@@ -65,7 +65,7 @@ RT::Test->close_mailgate_ok($mail);
like( $txn->Attachments->First->Content, qr/Blah/);
my ($msg) = @{$txn->Attachments->ItemsArrayRef};
my @status = $msg->GetCryptStatus;
- cmp_deeply(\@status, [{Protocol => 'None'}], 'Got expected crypt status (Protocol => None)');
+ cmp_deeply(\@status, [], 'Got empty array for unsigned/unencrypted attachment');
}
# test for signed mail
diff --git a/t/mail/smime/incoming.t b/t/mail/smime/incoming.t
index 6b798916f9..27b9edd16a 100644
--- a/t/mail/smime/incoming.t
+++ b/t/mail/smime/incoming.t
@@ -55,7 +55,7 @@ RT::Test->close_mailgate_ok($mail);
like( $txn->Attachments->First->Content, qr'Blah');
my ($msg) = @{$txn->Attachments->ItemsArrayRef};
my @status = $msg->GetCryptStatus;
- cmp_deeply(\@status, [{Protocol => 'None'}], 'Got expected crypt status (Protocol => None)');
+ cmp_deeply(\@status, [], 'Got expected crypt status (Empty array)');
}
{
@@ -145,7 +145,19 @@ RT::Test->close_mailgate_ok($mail);
Protocol => 'SMIME',
Message => 'Decryption process succeeded',
EncryptedTo => [{EmailAddress => 'sender at example.com'}],
- Status => 'DONE'}], 'Got expected encryption status');
+ Status => 'DONE'},
+ {
+ Status => 'DONE',
+ UserString => '"Enoch Root" <root at example.com>',
+ Trust => 'FULL',
+ Issuer => '"CA Owner" <ca.owner at example.com>',
+ CreatedTimestamp => re('^\d+$'),
+ Message => 'The signature is good, signed by "Enoch Root" <root at example.com>, assured by "CA Owner" <ca.owner at example.com>, trust is full',
+ ExpireTimestamp => re('^\d+$'),
+ Operation => 'Verify',
+ Protocol => 'SMIME'
+ }
+ ], 'Got expected signing/encryption status');
}
{
-----------------------------------------------------------------------
More information about the rt-commit
mailing list