diff options
author | Ivan Kohler <ivan@freeside.biz> | 2012-06-07 16:58:33 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2012-06-07 16:58:33 -0700 |
commit | 21a232b78413718d8a68867ba7eb4f52a287f9b6 (patch) | |
tree | 988115f9363144a2afdac9e3d9914964a7725105 /rt/t/mail | |
parent | c24d6e2242ae0e026684b8f95decf156aba6e75e (diff) |
rt 4.0.6
Diffstat (limited to 'rt/t/mail')
-rw-r--r-- | rt/t/mail/dashboard-chart-with-utf8.t | 82 | ||||
-rw-r--r-- | rt/t/mail/rfc2231-attachment.t | 28 | ||||
-rw-r--r-- | rt/t/mail/specials-in-encodedwords.t | 40 |
3 files changed, 150 insertions, 0 deletions
diff --git a/rt/t/mail/dashboard-chart-with-utf8.t b/rt/t/mail/dashboard-chart-with-utf8.t new file mode 100644 index 000000000..6d07b963b --- /dev/null +++ b/rt/t/mail/dashboard-chart-with-utf8.t @@ -0,0 +1,82 @@ +use strict; +use warnings; + +use RT::Test tests => 15; +use utf8; + +my $root = RT::Test->load_or_create_user( Name => 'root' ); + +my ( $baseurl, $m ) = RT::Test->started_ok; +ok( $m->login, 'logged in' ); +my $ticket = RT::Ticket->new( $RT::SystemUser ); +$ticket->Create( + Queue => 'General', + Subject => 'test äöü', +); +ok( $ticket->id, 'created ticket' ); + +$m->get_ok(q{/Search/Chart.html?Query=Subject LIKE 'test äöü'}); +$m->submit_form( + form_name => 'SaveSearch', + fields => { + SavedSearchDescription => 'chart foo', + SavedSearchOwner => 'RT::User-' . $root->id, + }, + button => 'SavedSearchSave', +); + +# first, create and populate a dashboard +$m->get_ok('/Dashboards/Modify.html?Create=1'); +$m->form_name('ModifyDashboard'); +$m->field( 'Name' => 'dashboard foo' ); +$m->click_button( value => 'Create' ); + +$m->follow_link_ok( { text => 'Content' } ); +my $form = $m->form_name('Dashboard-Searches-body'); +my @input = $form->find_input('Searches-body-Available'); +my ($dashboards_component) = + map { ( $_->possible_values )[1] } + grep { ( $_->value_names )[1] =~ /^Chart/ } @input; +$form->value( 'Searches-body-Available' => $dashboards_component ); +$m->click_button( name => 'add' ); +$m->content_contains('Dashboard updated'); + +$m->follow_link_ok( { text => 'Subscription' } ); +$m->form_name('SubscribeDashboard'); +$m->field( 'Frequency' => 'daily' ); +$m->field( 'Hour' => '06:00' ); +$m->click_button( name => 'Save' ); +$m->content_contains('Subscribed to dashboard dashboard foo'); + +my $c = $m->get(q{/Search/Chart?Query=Subject LIKE 'test äöü'}); +my $image = $c->content; +RT::Test->run_and_capture( + command => $RT::SbinPath . '/rt-email-dashboards', all => 1 +); + +my @mails = RT::Test->fetch_caught_mails; +is @mails, 1, "got a dashboard mail"; + +# can't use parse_mail here is because it deletes all attachments +# before we can call bodyhandle :/ +use RT::EmailParser; +my $parser = RT::EmailParser->new; +my $mail = $parser->ParseMIMEEntityFromScalar( $mails[0] ); +like( + $mail->head->get('Subject'), + qr/Daily Dashboard: dashboard foo/, + 'mail subject' +); + +my ($mail_image) = grep { $_->mime_type eq 'image/png' } $mail->parts; +ok( $mail_image, 'mail contains image attachment' ); + +my $handle = $mail_image->bodyhandle; + +my $mail_image_data = ''; +if ( my $io = $handle->open('r') ) { + while ( defined( $_ = $io->getline ) ) { $mail_image_data .= $_ } + $io->close; +} +is( $mail_image_data, $image, 'image in mail is the same one in web' ); + diff --git a/rt/t/mail/rfc2231-attachment.t b/rt/t/mail/rfc2231-attachment.t new file mode 100644 index 000000000..fc74c4720 --- /dev/null +++ b/rt/t/mail/rfc2231-attachment.t @@ -0,0 +1,28 @@ +use strict; +use warnings; + +use utf8; +use RT::Test tests => undef; +my ($baseurl, $m) = RT::Test->started_ok; +ok $m->login, 'logged in as root'; + +diag "encoded attachment filename with parameter continuations"; +{ + my $mail = RT::Test->file_content( + RT::Test::get_relocatable_file( + 'rfc2231-attachment-filename-continuations', + (File::Spec->updir(), 'data', 'emails') + ) + ); + + my ( $status, $id ) = RT::Test->send_via_mailgate($mail); + is( $status >> 8, 0, "The mail gateway exited normally" ); + ok( $id, "Created ticket" ); + + $m->get_ok("/Ticket/Display.html?id=$id"); + $m->content_contains("新しいテキスト ドキュメント.txt", "found full filename"); +} + +undef $m; +done_testing; + diff --git a/rt/t/mail/specials-in-encodedwords.t b/rt/t/mail/specials-in-encodedwords.t new file mode 100644 index 000000000..f9da9c6e9 --- /dev/null +++ b/rt/t/mail/specials-in-encodedwords.t @@ -0,0 +1,40 @@ +use strict; +use warnings; + +use RT::Test tests => undef; + +diag "specials (, and ;) in MIME encoded-words aren't treated as specials"; +{ + # RT decodes too early in the game (i.e. before parsing), so it needs to + # ensure special characters in encoded words are properly escaped/quoted + # after decoding + + RT->Config->Set( ParseNewMessageForTicketCcs => 1 ); + my $mail = <<'.'; +From: root@localhost +Subject: testing mime encoded specials +Cc: a@example.com, =?utf8?q?d=40example.com=2ce=40example.com=3b?= + <b@example.com>; c@example.com +Content-Type: text/plain; charset=utf8 + +here's some content +. + + my ( $status, $id ) = RT::Test->send_via_mailgate($mail); + is( $status >> 8, 0, "The mail gateway exited normally" ); + ok( $id, "Created ticket" ); + + my $ticket = RT::Ticket->new( RT->SystemUser ); + $ticket->Load($id); + ok $ticket->id, 'loaded ticket'; + + my @cc = @{$ticket->Cc->UserMembersObj->ItemsArrayRef}; + is scalar @cc, 3, "three ccs"; + for my $addr (qw(a b c)) { + ok( (scalar grep { $_->EmailAddress eq "$addr\@example.com" } @cc), + "found $addr" ); + } +} + +done_testing; + |