[Rt-commit] r8832 - in rt/branches/3.7-EXPERIMENTAL: . t/mail
sartak at bestpractical.com
sartak at bestpractical.com
Thu Aug 30 11:17:32 EDT 2007
Author: sartak
Date: Thu Aug 30 11:17:31 2007
New Revision: 8832
Added:
rt/branches/3.7-EXPERIMENTAL/lib/t/data/mail/encrypted-badsig.txt
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-bad.t
Log:
r37622 at onn: sartak | 2007-08-30 11:17:10 -0400
Update gnupg-bad, add failing test of encrypted ok but signed badly
Added: rt/branches/3.7-EXPERIMENTAL/lib/t/data/mail/encrypted-badsig.txt
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL/lib/t/data/mail/encrypted-badsig.txt Thu Aug 30 11:17:31 2007
@@ -0,0 +1,64 @@
+From - Thu Aug 30 04:24:17 2007
+X-Mozilla-Status: 0001
+X-Mozilla-Status2: 00000000
+Message-ID: <46D60E13.9050806 at bestpractical.com>
+Date: Thu, 30 Aug 2007 04:23:47 +0400
+From: "Ruslan U. Zakirov" <ruz at bestpractical.com>
+User-Agent: Thunderbird 2.0.0.6 (X11/20070804)
+MIME-Version: 1.0
+To: The default queue via RT <rt at example.com>
+Subject: test
+X-Enigmail-Version: 0.95.3
+Content-Type: multipart/encrypted;
+ protocol="application/pgp-encrypted";
+ boundary="------------enig416AFA2C3A91008BB2F02ACE"
+
+This is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)
+--------------enig416AFA2C3A91008BB2F02ACE
+Content-Type: application/pgp-encrypted
+Content-Description: PGP/MIME version identification
+
+Version: 1
+
+--------------enig416AFA2C3A91008BB2F02ACE
+Content-Type: application/octet-stream; name="encrypted.asc"
+Content-Description: OpenPGP encrypted message
+Content-Disposition: inline; filename="encrypted.asc"
+
+-----BEGIN PGP MESSAGE-----
+Version: GnuPG v1.4.7 (GNU/Linux)
+Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
+
+hQ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71OqPqqf7KhMuFY8RIdmD6JVdVYIANmHuO+MGnQ4FsfJrb+X
+4zE4NU3FdZ16jttvfhRsg/i2hKr35IuZpYPGttu1PQhX+ZnkJjY77FZ5pciLROcJ
+nZ6IuEyDk5RrO6EaZopk5Y/jtlgNMNGZRCvKn+a+CN/LuBylB+dytGkTE3WHy4yK
+lTUajkgf50lG1ngV0kSH6CjMPy/r1rY7qQIRsWNSshAfweDpMMv9fXeTtskE3xDj
+t2DJfEvoYETOEOHaJqpatRcYlp/zxBorrZUPBTI8zNcu/IpQneP3ubJZ9KXAP7C/
+xYw0CGN+NkR1o/adqM10/59ZVjRVcBBA+w0OZJIhKAdzoTeAnv9+eNsd+bwWFnEI
+kl/SwB0BtMVU0mg2caO1rze1fpWakgWra1o4Dq5ftfW8Uj/XrYLtnXMrx6tWbMSR
+4otdHV482m2a+FFsFBSNfoZ/Ltwykg03puqwfmswivfWVJCfEJLYXjxNBtveuoLk
++0khV/HkmPowDei0K4DE5BiZmcWGKzjXwFy0+P65kYCHtF9oCkpCoJdtMYxla/mM
+srkCjLFWisA/W6Yd2NRs+GEhT2ZcqskTZunIGLLvSXxkpJ7sQALwt7EL2LIjLG3C
+y2mP2KKw6K2uhqxALWdnwweQKp+uwNRSJARqAaVKyiMawg==
+=DnVn
+-----END PGP MESSAGE-----
+
+--------------enig416AFA2C3A91008BB2F02ACE--
+
+
Modified: rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-bad.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-bad.t (original)
+++ rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-bad.t Thu Aug 30 11:17:31 2007
@@ -1,12 +1,13 @@
#!/usr/bin/perl
use strict;
use warnings;
-use Test::More skip_all => "Not fleshed out yet";
+use Test::More tests => 10;
use File::Temp;
use RT::Test;
use Cwd 'getcwd';
use String::ShellQuote 'shell_quote';
use IPC::Run3 'run3';
+use Digest::MD5 qw(md5_hex);
my $homedir = File::Spec->catdir( getcwd(), qw(lib t data crypt-gnupg) );
@@ -16,129 +17,57 @@
OutgoingMessagesFormat => 'RFC' );
RT->Config->Set( 'GnuPGOptions',
- homedir => $homedir );
+ homedir => $homedir,
+ passphrase => 'test',
+ 'no-permission-warning' => undef);
RT->Config->Set( 'MailPlugins' => 'Auth::MailFrom', 'Auth::GnuPG' );
my ($baseurl, $m) = RT::Test->started_ok;
-ok(my $user = RT::User->new($RT::SystemUser));
-ok($user->Load('root'), "Loaded user 'root'");
-$user->SetEmailAddress('recipient at example.com');
-
-diag "no signature" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('no-sig');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "no encryption on encrypted queue" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('unencrypted');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "mismatched signature" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('bad-sig');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
- my $tick = get_latest_ticket_ok();
-}
+$m->get( $baseurl."?user=root;pass=password" );
+$m->content_like(qr/Logout/, 'we did log in');
+$m->get( $baseurl.'/Admin/Queues/');
+$m->follow_link_ok( {text => 'General'} );
+$m->submit_form( form_number => 3,
+ fields => { CorrespondAddress => 'rt at example.com' } );
+$m->content_like(qr/rt\@example.com.* - never/, 'has key info.');
-diag "unknown public key" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('unk-pub-key');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "unknown private key" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('unk-priv-key');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "signer != sender" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('signer-not-sender');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "encryption to user whose pubkey is not signed" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('unsigned-pub-key');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "no encryption of attachment on encrypted queue" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('unencrypted-attachment');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "no signature of attachment" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('unsigged-attachment');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "revoked key" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('revoked-key');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
+ok(my $user = RT::User->new($RT::SystemUser));
+ok($user->Load('root'), "Loaded user 'root'");
+$user->SetEmailAddress('rt at example.com');
-diag "expired key" if $ENV{TEST_VERBOSE};
+diag "good encryption, unknown signer" if $ENV{TEST_VERBOSE};
{
- my $mail = get_contents('expired-key');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
-}
-
-diag "unknown algorithm" if $ENV{TEST_VERBOSE};
-{
- my $mail = get_contents('unknown-algorithm');
- my ($status, $id) = RT::Test->send_via_mailgate($mail);
- is ($status >> 8, 0, "The mail gateway exited normally");
-
- my $tick = get_latest_ticket_ok();
+ email_ok(glob => "encrypted-badsig.txt",
+ subject => "test",
+ encrypted => 1,
+ content => qr/test/,
+ );
+}
+
+if (0) {
+ # XXX: need to generate these mails
+ diag "no signature" if $ENV{TEST_VERBOSE};
+ diag "no encryption on encrypted queue" if $ENV{TEST_VERBOSE};
+ diag "mismatched signature" if $ENV{TEST_VERBOSE};
+ diag "unknown public key" if $ENV{TEST_VERBOSE};
+ diag "unknown private key" if $ENV{TEST_VERBOSE};
+ diag "signer != sender" if $ENV{TEST_VERBOSE};
+ diag "encryption to user whose pubkey is not signed" if $ENV{TEST_VERBOSE};
+ diag "no encryption of attachment on encrypted queue" if $ENV{TEST_VERBOSE};
+ diag "no signature of attachment" if $ENV{TEST_VERBOSE};
+ diag "revoked key" if $ENV{TEST_VERBOSE};
+ diag "expired key" if $ENV{TEST_VERBOSE};
+ diag "unknown algorithm" if $ENV{TEST_VERBOSE};
}
sub get_contents {
- my $pattern = shift;
+ my $glob = shift;
- my $file = glob("lib/t/data/mail/*$pattern*");
+ my ($file) = glob("lib/t/data/mail/$glob");
defined $file
- or do { diag "Unable to find lib/t/data/mail/*$pattern*"; return };
+ or do { diag "Unable to find lib/t/data/mail/$glob"; return };
open my $mailhandle, '<', $file
or do { diag "Unable to read $file: $!"; return };
@@ -149,12 +78,66 @@
return $mail;
}
-sub get_latest_ticket_ok {
- my $tickets = RT::Tickets->new($RT::SystemUser);
- $tickets->OrderBy( FIELD => 'id', ORDER => 'DESC' );
- $tickets->Limit( FIELD => 'id', OPERATOR => '>', VALUE => '0' );
- my $tick = $tickets->First();
- ok( $tick->Id, "found ticket " . $tick->Id );
- return $tick;
-}
+sub email_ok {
+ my %ARGS = @_;
+
+ my $mail = get_contents($ARGS{glob})
+ or return 0;
+ my ($status, $id) = RT::Test->send_via_mailgate($mail);
+ is ($status >> 8, 0, "The mail gateway exited normally");
+ ok ($id, "got id of a newly created ticket - $id");
+
+ my $tick = RT::Ticket->new( $RT::SystemUser );
+ $tick->Load( $id );
+ ok ($tick->id, "loaded ticket #$id");
+
+ is ($tick->Subject,
+ $ARGS{subject},
+ "Correct subject"
+ );
+
+ my $txn = $tick->Transactions->First;
+ my ($msg, @attachments) = @{$txn->Attachments->ItemsArrayRef};
+
+ if ($ARGS{encrypted}) {
+ is( $msg->GetHeader('X-RT-Incoming-Encryption'),
+ 'Success',
+ "recorded incoming mail that is encrypted"
+ );
+ is( $msg->GetHeader('X-RT-Privacy'),
+ 'PGP',
+ "recorded incoming mail that is encrypted"
+ );
+
+ like( $attachments[0]->Content,
+ $ARGS{content},
+ "incoming mail did NOT have original body"
+ );
+ }
+ else {
+ is( $msg->GetHeader('X-RT-Incoming-Encryption'),
+ 'Not encrypted',
+ "recorded incoming mail that is not encrypted"
+ );
+ like( $msg->Content || $attachments[0]->Content,
+ $ARGS{content},
+ "got original content"
+ );
+ }
+
+ if (defined $ARGS{signer}) {
+ is( $msg->GetHeader('X-RT-Incoming-Signature'),
+ $ARGS{signer},
+ "recorded incoming mail that is signed"
+ );
+ }
+ else {
+ is( $msg->GetHeader('X-RT-Incoming-Signature'),
+ undef,
+ "recorded incoming mail that is not signed"
+ );
+ }
+
+ return 0;
+}
More information about the Rt-commit
mailing list