[Rt-commit] r6180 - in rt/branches/3.7-EXPERIMENTAL: . bin
ruz at bestpractical.com
ruz at bestpractical.com
Tue Oct 10 05:00:13 EDT 2006
Author: ruz
Date: Tue Oct 10 05:00:11 2006
New Revision: 6180
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/bin/rt-mailgate.in
rt/branches/3.7-EXPERIMENTAL/lib/t/regression/06mailgateway.t
Log:
r3912 at cubic-pc: cubic | 2006-10-10 13:10:25 +0400
* pass through non standard --extension values
Modified: rt/branches/3.7-EXPERIMENTAL/bin/rt-mailgate.in
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/bin/rt-mailgate.in (original)
+++ rt/branches/3.7-EXPERIMENTAL/bin/rt-mailgate.in Tue Oct 10 05:00:11 2006
@@ -89,16 +89,15 @@
exit 0;
}
-if ( $opts{'extension'} ) {
- unless ( $opts{'extension'} =~ /^(action|queue|ticket)$/i ) {
- print STDERR "Wrong value of --extension argument\n";
- exit 1;
- }
+if ( ($opts{'extension'} || '') =~ /^(?:action|queue|ticket)$/i ) {
$args{ lc $opts{'extension'} } = $ENV{'EXTENSION'};
+} elsif ( $opts{'extension'} && $ENV{'EXTENSION'} ) {
+ print STDERR "Value of the --extension argument is not action, queue or ticket"
+ .", but environment variable EXTENSION is also defined. The former is ignored.";
}
# add ENV{'EXTENSION'} as X-RT-MailExtension to the message header
-if ( exists $ENV{'EXTENSION'} and my $value = $ENV{'EXTENSION'} ) {
+if ( my $value = ( $ENV{'EXTENSION'} || $opts{'extension'} ) ) {
# prepare value to avoid MIME format brakage
# strip trailing newline symbols
$value =~ s/(\r*\n)+$//;
Modified: rt/branches/3.7-EXPERIMENTAL/lib/t/regression/06mailgateway.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/t/regression/06mailgateway.t (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/t/regression/06mailgateway.t Tue Oct 10 05:00:11 2006
@@ -54,7 +54,7 @@
use strict;
use warnings;
-use Test::More tests => 96;
+use Test::More tests => 100;
use RT;
RT::LoadConfig();
@@ -93,20 +93,6 @@
ok (!$id, "No ticket id") or diag "by mistake ticket #$id";
}
-diag "Make sure that when we call the mailgate with wrong --extension, it fails" if $ENV{'TEST_VERBOSE'};
-{
- my $text = <<EOF;
-From: root\@localhost
-To: rt\@@{[RT->Config->Get('rtname')]}
-Subject: This is a test of new ticket creation
-
-Foob!
-EOF
- my ($status, $id) = create_ticket_via_gate($text, extension => 'bad-extension-arg' );
- is ($status >> 8, 1, "The mail gateway exited with a failure");
- ok (!$id, "No ticket id") or diag "by mistake ticket #$id";
-}
-
diag "Make sure that when we call the mailgate with wrong URL, it tempfails" if $ENV{'TEST_VERBOSE'};
{
my $text = <<EOF;
@@ -150,7 +136,6 @@
my $tick = latest_ticket();
isa_ok ($tick, 'RT::Ticket');
- ok ($tick->Id, "found ticket");
is ($tick->Id, $id, "correct ticket id");
ok ($tick->Subject eq 'This is a test of new ticket creation', "Created the ticket");
}
@@ -172,9 +157,8 @@
my $tick = latest_ticket();
isa_ok ($tick, 'RT::Ticket');
- ok ($tick->Id, "found ticket");
is ($tick->Id, $id, "correct ticket id");
- ok ($tick->Subject eq 'This is a test of the X-RT-Mail-Extension field', "Created the ticket");
+ is ($tick->Subject, 'This is a test of the X-RT-Mail-Extension field', "Created the ticket");
my $transactions = $tick->Transactions;
$transactions->OrderByCols({ FIELD => 'id', ORDER => 'DESC' });
@@ -193,6 +177,39 @@
);
}
+diag "Make sure that not standard --extension is passed" if $ENV{'TEST_VERBOSE'};
+{
+ my $text = <<EOF;
+From: root\@localhost
+To: rt\@@{[RT->Config->Get('rtname')]}
+Subject: This is a test of new ticket creation
+
+Foob!
+EOF
+ my ($status, $id) = create_ticket_via_gate($text, extension => 'some-extension-arg' );
+ is ($status >> 8, 0, "The mail gateway exited normally");
+ ok ($id, "Created ticket #$id");
+
+ my $tick = latest_ticket();
+ isa_ok ($tick, 'RT::Ticket');
+ is ($tick->Id, $id, "correct ticket id");
+
+ my $transactions = $tick->Transactions;
+ $transactions->OrderByCols({ FIELD => 'id', ORDER => 'DESC' });
+ $transactions->Limit( FIELD => 'Type', OPERATOR => '!=', VALUE => 'EmailRecord');
+ my $txn = $transactions->First;
+ isa_ok ($txn, 'RT::Transaction');
+ is ($txn->Type, 'Create', "correct type");
+
+ my $attachment = $txn->Attachments->First;
+ isa_ok ($attachment, 'RT::Attachment');
+ is (
+ $attachment->GetHeader('X-RT-Mail-Extension'),
+ 'some-extension-arg',
+ 'header is in place'
+ );
+}
+
diag "This is a test of new ticket creation as an unknown user" if $ENV{'TEST_VERBOSE'};
{
my $text = <<EOF;
More information about the Rt-commit
mailing list