diff options
Diffstat (limited to 'rt/lib/t')
-rw-r--r-- | rt/lib/t/00smoke.t.in | 14 | ||||
-rw-r--r-- | rt/lib/t/01harness.t.in | 12 | ||||
-rw-r--r-- | rt/lib/t/02regression.t | 7 | ||||
-rw-r--r-- | rt/lib/t/02regression.t.in | 47 | ||||
-rw-r--r-- | rt/lib/t/03web.pl | 78 | ||||
-rw-r--r-- | rt/lib/t/03web.pl.in | 170 | ||||
-rw-r--r-- | rt/lib/t/04_send_email.pl | 25 | ||||
-rw-r--r-- | rt/lib/t/04_send_email.pl.in | 506 | ||||
-rw-r--r-- | rt/lib/t/05cronsupport.pl.in | 84 | ||||
-rw-r--r-- | rt/lib/t/regression/00placeholder | 1 |
10 files changed, 107 insertions, 837 deletions
diff --git a/rt/lib/t/00smoke.t.in b/rt/lib/t/00smoke.t.in deleted file mode 100644 index 288dd4aae..000000000 --- a/rt/lib/t/00smoke.t.in +++ /dev/null @@ -1,14 +0,0 @@ -#!@PERL@ - -use Test::More qw(no_plan); - -use lib "@RT_LIB_PATH@"; -use RT; -ok(RT::LoadConfig); -ok(RT::Init, "Basic initialization and DB connectivity"); - -use File::Find; -File::Find::find({wanted => \&wanted}, 'lib/'); -sub wanted { /^*\.pm\z/s && ok(require $_, "Requiring '$_'"); } - - diff --git a/rt/lib/t/01harness.t.in b/rt/lib/t/01harness.t.in deleted file mode 100644 index d132330c2..000000000 --- a/rt/lib/t/01harness.t.in +++ /dev/null @@ -1,12 +0,0 @@ -#!@PERL@ - -use Test::More qw(no_plan); - -use lib "@RT_LIB_PATH@"; -use RT; -ok(RT::LoadConfig); -ok(RT::Init, "Basic initialization and DB connectivity"); - -my $test = shift @ARGV; -require $test; - diff --git a/rt/lib/t/02regression.t b/rt/lib/t/02regression.t index 4504cc76a..4cc131815 100644 --- a/rt/lib/t/02regression.t +++ b/rt/lib/t/02regression.t @@ -34,11 +34,14 @@ is($q2->CommentAddress, 'comment@a'); use File::Find; -File::Find::find({wanted => \&wanted_autogen}, 'lib/t/autogen'); +File::Find::find({wanted => \&wanted_autogen, + preprocess => sub {return sort @_}}, 'lib/t/autogen'); sub wanted_autogen { /^autogen.*\.t\z/s && require $_; } -File::Find::find({wanted => \&wanted_regression}, 'lib/t/regression'); +File::Find::find({wanted => \&wanted_regression, + preprocess => sub {return sort @_}}, 'lib/t/regression'); sub wanted_regression { /^*\.t\z/s && require $_; } require "/opt/rt3/lib/t/03web.pl"; require "/opt/rt3/lib/t/04_send_email.pl"; +require "/opt/rt3/lib/t/05cronsupport.pl"; diff --git a/rt/lib/t/02regression.t.in b/rt/lib/t/02regression.t.in deleted file mode 100644 index c2e3277a9..000000000 --- a/rt/lib/t/02regression.t.in +++ /dev/null @@ -1,47 +0,0 @@ -#!@PERL@ - -use Test::More qw(no_plan); - -use lib "@RT_LIB_PATH@"; -use RT; -ok(RT::LoadConfig); -ok(RT::Init, "Basic initialization and DB connectivity"); - -# Create a new queue -use_ok(RT::Queue); -my $q = RT::Queue->new($RT::SystemUser); - -$q->Load('regression'); -if ($q->id != 0) { - die "Regression tests not starting with a clean DB. Bailing"; -} - -my ($id, $msg) = $q->Create( Name => 'Regression', - Description => 'A regression test queue', - CorrespondAddress => 'correspond@a', - CommentAddress => 'comment@a'); - -isnt($id, 0, "Queue was created sucessfully - $msg"); - -my $q2 = RT::Queue->new($RT::SystemUser); - -ok($q2->Load($id)); -is($q2->id, $id, "Sucessfully loaded the queue again"); -is($q2->Name, 'Regression'); -is($q2->Description, 'A regression test queue'); -is($q2->CorrespondAddress, 'correspond@a'); -is($q2->CommentAddress, 'comment@a'); - - -use File::Find; -File::Find::find({wanted => \&wanted_autogen, - preprocess => sub {return sort @_}}, 'lib/t/autogen'); -sub wanted_autogen { /^autogen.*\.t\z/s && require $_; } - -File::Find::find({wanted => \&wanted_regression, - preprocess => sub {return sort @_}}, 'lib/t/regression'); -sub wanted_regression { /^*\.t\z/s && require $_; } - -require "@RT_LIB_PATH@/t/03web.pl"; -require "@RT_LIB_PATH@/t/04_send_email.pl"; -require "@RT_LIB_PATH@/t/05cronsupport.pl"; diff --git a/rt/lib/t/03web.pl b/rt/lib/t/03web.pl index 94ad3e97e..597ad109e 100644 --- a/rt/lib/t/03web.pl +++ b/rt/lib/t/03web.pl @@ -67,7 +67,83 @@ ok( $agent->{'content'} =~ qr{$string} , "Found the content"); # }}} +# {{{ Query Builder tests + +my $response = $agent->get($url."Search/Build.html"); +ok( $response->is_success, "Fetched " . $url."Search/Build.html" ); + +# Parsing TicketSQL +# +# Adding items + +# set the first value +ok($agent->form_name('BuildQuery')); +$agent->field("AttachmentField", "Subject"); +$agent->field("AttachmentOp", "LIKE"); +$agent->field("ValueOfAttachment", "aaa"); +$agent->submit(); + +# set the next value +ok($agent->form_name('BuildQuery')); +$agent->field("AttachmentField", "Subject"); +$agent->field("AttachmentOp", "LIKE"); +$agent->field("ValueOfAttachment", "bbb"); +$agent->submit(); + +ok($agent->form_name('BuildQuery')); + +# get the query +my $query = $agent->current_form->find_input("Query")->value; +# strip whitespace from ends +$query =~ s/^\s*//g; +$query =~ s/\s*$//g; + +# collapse other whitespace +$query =~ s/\s+/ /g; + +is ($query, "Subject LIKE 'aaa' AND Subject LIKE 'bbb'"); + +# - new items go one level down +# - add items at currently selected level +# - if nothing is selected, add at end, one level down +# +# move left +# - error if nothing selected +# - same item should be selected after move +# - can't move left if you're at the top level +# +# move right +# - error if nothing selected +# - same item should be selected after move +# - can always move right (no max depth...should there be?) +# +# move up +# - error if nothing selected +# - same item should be selected after move +# - can't move up if you're first in the list +# +# move down +# - error if nothing selected +# - same item should be selected after move +# - can't move down if you're last in the list +# +# toggle +# - error if nothing selected +# - change all aggregators in the grouping +# - don't change any others +# +# delete +# - error if nothing selected +# - delete currently selected item +# - delete all children of a grouping +# - if delete leaves a node with no children, delete that, too +# - what should be selected? +# +# Clear +# - clears entire query +# - clears it from the session, too +# }}} use File::Find; find ( \&wanted , 'html/'); @@ -83,7 +159,7 @@ sub test_get { $file =~ s#^html/##; ok ($agent->get("$url/$file", "GET $url/$file")); is ($agent->{'status'}, 200, "Loaded $file"); - ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file "); +# ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file "); ok( $agent->{'content'} !~ /Not logged in/i, "Still logged in for $file"); ok( $agent->{'content'} !~ /System error/i, "Didn't get a Mason compilation error on $file"); diff --git a/rt/lib/t/03web.pl.in b/rt/lib/t/03web.pl.in deleted file mode 100644 index 25c26e711..000000000 --- a/rt/lib/t/03web.pl.in +++ /dev/null @@ -1,170 +0,0 @@ -#!@PERL@ - -use strict; -use WWW::Mechanize; -use HTTP::Request::Common; -use HTTP::Cookies; -use LWP; -use Encode; - -my $cookie_jar = HTTP::Cookies->new; -my $agent = WWW::Mechanize->new(); - -# give the agent a place to stash the cookies - -$agent->cookie_jar($cookie_jar); - - -# get the top page -my $url = "http://localhost".$RT::WebPath."/"; -$agent->get($url); - -is ($agent->{'status'}, 200, "Loaded a page"); - - -# {{{ test a login - -# follow the link marked "Login" - -ok($agent->{form}->find_input('user')); - -ok($agent->{form}->find_input('pass')); -ok ($agent->{'content'} =~ /username:/i); -$agent->field( 'user' => 'root' ); -$agent->field( 'pass' => 'password' ); -# the field isn't named, so we have to click link 0 -$agent->click(0); -is($agent->{'status'}, 200, "Fetched the page ok"); -ok( $agent->{'content'} =~ /Logout/i, "Found a logout link"); - - - -$agent->get($url."Ticket/Create.html?Queue=1"); -is ($agent->{'status'}, 200, "Loaded Create.html"); -$agent->form(3); -# Start with a string containing characters in latin1 -my $string = "I18N Web Testing æøå"; -Encode::from_to($string, 'iso-8859-1', 'utf8'); -$agent->field('Subject' => "Foo"); -$agent->field('Content' => $string); -ok($agent->submit(), "Created new ticket with $string"); - -ok( $agent->{'content'} =~ qr{$string} , "Found the content"); - -$agent->get($url."Ticket/Create.html?Queue=1"); -is ($agent->{'status'}, 200, "Loaded Create.html"); -$agent->form(3); -# Start with a string containing characters in latin1 -my $string = "I18N Web Testing æøå"; -Encode::from_to($string, 'iso-8859-1', 'utf8'); -$agent->field('Subject' => $string); -$agent->field('Content' => "BAR"); -ok($agent->submit(), "Created new ticket with $string"); - -ok( $agent->{'content'} =~ qr{$string} , "Found the content"); - - - -# }}} - -# {{{ Query Builder tests - -my $response = $agent->get($url."Search/Build.html"); -ok( $response->is_success, "Fetched " . $url."Search/Build.html" ); - -# Parsing TicketSQL -# -# Adding items - -# set the first value -ok($agent->form_name('BuildQuery')); -$agent->field("AttachmentField", "Subject"); -$agent->field("AttachmentOp", "LIKE"); -$agent->field("ValueOfAttachment", "aaa"); -$agent->submit(); - -# set the next value -ok($agent->form_name('BuildQuery')); -$agent->field("AttachmentField", "Subject"); -$agent->field("AttachmentOp", "LIKE"); -$agent->field("ValueOfAttachment", "bbb"); -$agent->submit(); - -ok($agent->form_name('BuildQuery')); - -# get the query -my $query = $agent->current_form->find_input("Query")->value; -# strip whitespace from ends -$query =~ s/^\s*//g; -$query =~ s/\s*$//g; - -# collapse other whitespace -$query =~ s/\s+/ /g; - -is ($query, "Subject LIKE 'aaa' AND Subject LIKE 'bbb'"); - -# - new items go one level down -# - add items at currently selected level -# - if nothing is selected, add at end, one level down -# -# move left -# - error if nothing selected -# - same item should be selected after move -# - can't move left if you're at the top level -# -# move right -# - error if nothing selected -# - same item should be selected after move -# - can always move right (no max depth...should there be?) -# -# move up -# - error if nothing selected -# - same item should be selected after move -# - can't move up if you're first in the list -# -# move down -# - error if nothing selected -# - same item should be selected after move -# - can't move down if you're last in the list -# -# toggle -# - error if nothing selected -# - change all aggregators in the grouping -# - don't change any others -# -# delete -# - error if nothing selected -# - delete currently selected item -# - delete all children of a grouping -# - if delete leaves a node with no children, delete that, too -# - what should be selected? -# -# Clear -# - clears entire query -# - clears it from the session, too - -# }}} - -use File::Find; -find ( \&wanted , 'html/'); - -sub wanted { - -f && /\.html$/ && $_ !~ /Logout.html$/ && test_get($File::Find::name); -} - -sub test_get { - my $file = shift; - - - $file =~ s#^html/##; - ok ($agent->get("$url/$file", "GET $url/$file")); - is ($agent->{'status'}, 200, "Loaded $file"); -# ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file "); - ok( $agent->{'content'} !~ /Not logged in/i, "Still logged in for $file"); - ok( $agent->{'content'} !~ /System error/i, "Didn't get a Mason compilation error on $file"); - -} - -# }}} - -1; diff --git a/rt/lib/t/04_send_email.pl b/rt/lib/t/04_send_email.pl index c384eedfa..973d9d2e2 100644 --- a/rt/lib/t/04_send_email.pl +++ b/rt/lib/t/04_send_email.pl @@ -476,6 +476,31 @@ sub crashes_redef_sendmessage { # }}} +# {{{ test a multi-line RT-Send-CC header + +my $content = `cat /opt/rt3/lib/t/data/rt-send-cc` || die "couldn't find new content"; + +$parser->ParseMIMEEntityFromScalar($content); + + + +my %args = (message => $content, queue => 1, action => 'correspond'); + RT::Interface::Email::Gateway(\%args); +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); + +my $cc = $tick->Transactions->First->Attachments->First->GetHeader('RT-Send-Cc'); +ok ($cc =~ /test1/, "Found test 1"); +ok ($cc =~ /test2/, "Found test 2"); +ok ($cc =~ /test3/, "Found test 3"); +ok ($cc =~ /test4/, "Found test 4"); +ok ($cc =~ /test5/, "Found test 5"); + +# }}} + # Don't taint the environment $everyone->PrincipalObj->RevokeRight(Right =>'SuperUser'); 1; diff --git a/rt/lib/t/04_send_email.pl.in b/rt/lib/t/04_send_email.pl.in deleted file mode 100644 index 39ab0d271..000000000 --- a/rt/lib/t/04_send_email.pl.in +++ /dev/null @@ -1,506 +0,0 @@ -#!@PERL@ -w - -use strict; -use RT::EmailParser; -use RT::Tickets; -use RT::Action::SendEmail; - -my @_outgoing_messages; -my @scrips_fired; - -#We're not testing acls here. -my $everyone = RT::Group->new($RT::SystemUser); -$everyone->LoadSystemInternalGroup('Everyone'); -$everyone->PrincipalObj->GrantRight(Right =>'SuperUser'); - - -is (__PACKAGE__, 'main', "We're operating in the main package"); - - -{ -no warnings qw/redefine/; -sub RT::Action::SendEmail::SendMessage { - my $self = shift; - my $MIME = shift; - - main::_fired_scrip($self->ScripObj); - main::ok(ref($MIME) eq 'MIME::Entity', "hey, look. it's a mime entity"); -} - -} - -# instrument SendEmail to pass us what it's about to send. -# create a regular ticket - -my $parser = RT::EmailParser->new(); - - -# Let's test to make sure a multipart/report is processed correctly -my $content = `cat @RT_LIB_PATH@/t/data/multipart-report` || die "couldn't find new content"; -# be as much like the mail gateway as possible. -use RT::Interface::Email; - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Content =~ /The original message was received/, "It's the bounce"); - - -# make sure it fires scrips. -is ($#scrips_fired, 1, "Fired 2 scrips on ticket creation"); - -undef @scrips_fired; - - - - -$parser->ParseMIMEEntityFromScalar('From: root@localhost -To: rt@example.com -Subject: This is a test of new ticket creation as an unknown user - -Blah! -Foob!'); - - -use Data::Dumper; - -my $ticket = RT::Ticket->new($RT::SystemUser); -my ($id, $tid, $msg ) = $ticket->Create(Requestor => ['root@localhost'], Queue => 'general', Subject => 'I18NTest', MIMEObj => $parser->Entity); -ok ($id,$msg); -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); -ok ($tick->Subject eq 'I18NTest', "failed to create the new ticket from an unprivileged account"); - -# make sure it fires scrips. -is ($#scrips_fired, 1, "Fired 2 scrips on ticket creation"); -# make sure it sends an autoreply -# make sure it sends a notification to adminccs - - -# we need to swap out SendMessage to test the new things we care about; -&utf8_redef_sendmessage; - -# create an iso 8859-1 ticket -@scrips_fired = (); - -my $content = `cat @RT_LIB_PATH@/t/data/new-ticket-from-iso-8859-1` || die "couldn't find new content"; - - - -$parser->ParseMIMEEntityFromScalar($content); - - -# be as much like the mail gateway as possible. -use RT::Interface::Email; - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Content =~ /H\x{e5}vard/, "It's signed by havard. yay"); - - -# make sure it fires scrips. -is ($#scrips_fired, 1, "Fired 2 scrips on ticket creation"); -# make sure it sends an autoreply - - -# make sure it sends a notification to adminccs - -# If we correspond, does it do the right thing to the outbound messages? - -$parser->ParseMIMEEntityFromScalar($content); -my ($id, $msg) = $tick->Comment(MIMEObj => $parser->Entity); -ok ($id, $msg); - -$parser->ParseMIMEEntityFromScalar($content); -($id, $msg) = $tick->Correspond(MIMEObj => $parser->Entity); -ok ($id, $msg); - - - - - -# we need to swap out SendMessage to test the new things we care about; -&iso8859_redef_sendmessage; -$RT::EmailOutputEncoding = 'iso-8859-1'; -# create an iso 8859-1 ticket -@scrips_fired = (); - -my $content = `cat @RT_LIB_PATH@/t/data/new-ticket-from-iso-8859-1` || die "couldn't find new content"; -# be as much like the mail gateway as possible. -use RT::Interface::Email; - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Content =~ /H\x{e5}vard/, "It's signed by havard. yay"); - - -# make sure it fires scrips. -is ($#scrips_fired, 1, "Fired 2 scrips on ticket creation"); -# make sure it sends an autoreply - - -# make sure it sends a notification to adminccs - - -# If we correspond, does it do the right thing to the outbound messages? - -$parser->ParseMIMEEntityFromScalar($content); -my ($id, $msg) = $tick->Comment(MIMEObj => $parser->Entity); -ok ($id, $msg); - -$parser->ParseMIMEEntityFromScalar($content); -($id, $msg) = $tick->Correspond(MIMEObj => $parser->Entity); -ok ($id, $msg); - - -sub _fired_scrip { - my $scrip = shift; - push @scrips_fired, $scrip; -} - -sub utf8_redef_sendmessage { - no warnings qw/redefine/; - eval ' - sub RT::Action::SendEmail::SendMessage { - my $self = shift; - my $MIME = shift; - - my $scrip = $self->ScripObj->id; - ok(1, $self->ScripObj->ConditionObj->Name . " ".$self->ScripObj->ActionObj->Name); - main::_fired_scrip($self->ScripObj); - $MIME->make_singlepart; - main::ok( ref($MIME) eq \'MIME::Entity\', - "hey, look. it\'s a mime entity" ); - main::ok( ref( $MIME->head ) eq \'MIME::Head\', - "its mime header is a mime header. yay" ); - main::ok( $MIME->head->get(\'Content-Type\') =~ /utf-8/, - "Its content type is utf-8" ); - my $message_as_string = $MIME->bodyhandle->as_string(); - use Encode; - $message_as_string = Encode::decode_utf8($message_as_string); - main::ok( - $message_as_string =~ /H\x{e5}vard/, -"The message\'s content contains havard\'s name. this will fail if it\'s not utf8 out"); - - }'; -} - -sub iso8859_redef_sendmessage { - no warnings qw/redefine/; - eval ' - sub RT::Action::SendEmail::SendMessage { - my $self = shift; - my $MIME = shift; - - my $scrip = $self->ScripObj->id; - ok(1, $self->ScripObj->ConditionObj->Name . " ".$self->ScripObj->ActionObj->Name); - main::_fired_scrip($self->ScripObj); - $MIME->make_singlepart; - main::ok( ref($MIME) eq \'MIME::Entity\', - "hey, look. it\'s a mime entity" ); - main::ok( ref( $MIME->head ) eq \'MIME::Head\', - "its mime header is a mime header. yay" ); - main::ok( $MIME->head->get(\'Content-Type\') =~ /iso-8859-1/, - "Its content type is iso-8859-1 - " . $MIME->head->get("Content-Type") ); - my $message_as_string = $MIME->bodyhandle->as_string(); - use Encode; - $message_as_string = Encode::decode("iso-8859-1",$message_as_string); - main::ok( - $message_as_string =~ /H\x{e5}vard/, "The message\'s content contains havard\'s name. this will fail if it\'s not utf8 out"); - - }'; -} - -# {{{ test a multipart alternative containing a text-html part with an umlaut - -my $content = `cat @RT_LIB_PATH@/t/data/multipart-alternative-with-umlaut` || die "couldn't find new content"; - -$parser->ParseMIMEEntityFromScalar($content); - - -# be as much like the mail gateway as possible. -¨auts_redef_sendmessage; - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Content =~ /causes Error/, "We recorded the content right as text-plain"); -is ($tick->Transactions->First->Attachments->Count , 3 , "Has three attachments, presumably a text-plain, a text-html and a multipart alternative"); - -sub umlauts_redef_sendmessage { - no warnings qw/redefine/; - eval 'sub RT::Action::SendEmail::SendMessage { }'; -} - -# }}} - -# {{{ test a text-html message with an umlaut - -my $content = `cat @RT_LIB_PATH@/t/data/text-html-with-umlaut` || die "couldn't find new content"; - -$parser->ParseMIMEEntityFromScalar($content); - - -# be as much like the mail gateway as possible. -&text_html_umlauts_redef_sendmessage; - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Attachments->First->Content =~ /causes Error/, "We recorded the content as containing 'causes error'"); -ok ($tick->Transactions->First->Attachments->First->ContentType =~ /text\/html/, "We recorded the content as text/html"); -ok ($tick->Transactions->First->Attachments->Count ==1 , "Has one attachment, presumably a text-html and a multipart alternative"); - -sub text_html_umlauts_redef_sendmessage { - no warnings qw/redefine/; - eval 'sub RT::Action::SendEmail::SendMessage { - my $self = shift; - my $MIME = shift; - use Data::Dumper; - return (1) unless ($self->ScripObj->ScripActionObj->Name eq "Notify AdminCcs" ); - ok (is $MIME->parts, 2, "generated correspondence mime entityis composed of three parts"); - is ($MIME->head->mime_type , "multipart/mixed", "The first part is a multipart mixed". $MIME->head->mime_type); - is ($MIME->parts(0)->head->mime_type , "text/plain", "The second part is a plain"); - is ($MIME->parts(1)->head->mime_type , "text/html", "The third part is an html "); - }'; -} - -# }}} - -# {{{ test a text-html message with russian characters - -my $content = `cat @RT_LIB_PATH@/t/data/text-html-in-russian` || die "couldn't find new content"; - -$parser->ParseMIMEEntityFromScalar($content); - - -# be as much like the mail gateway as possible. -&text_html_russian_redef_sendmessage; - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Attachments->First->ContentType =~ /text\/html/, "We recorded the content right as text-html"); -ok ($tick->Transactions->First->Attachments->Count ==1 , "Has one attachment, presumably a text-html and a multipart alternative"); - -sub text_html_russian_redef_sendmessage { - no warnings qw/redefine/; - eval 'sub RT::Action::SendEmail::SendMessage { - my $self = shift; - my $MIME = shift; - use Data::Dumper; - return (1) unless ($self->ScripObj->ScripActionObj->Name eq "Notify AdminCcs" ); - ok (is $MIME->parts, 2, "generated correspondence mime entityis composed of three parts"); - is ($MIME->head->mime_type , "multipart/mixed", "The first part is a multipart mixed". $MIME->head->mime_type); - is ($MIME->parts(0)->head->mime_type , "text/plain", "The second part is a plain"); - is ($MIME->parts(1)->head->mime_type , "text/html", "The third part is an html "); - my $content_1251; - $content_1251 = $MIME->parts(1)->bodyhandle->as_string(); - ok ($content_1251 =~ qr{Ó÷eáíûé Öeíòp "ÊÀÄÐÛ ÄÅËÎÂÎÃÎ ÌÈÐÀ" ïpèãëaøaeò ía òpeíèíã:}, -"Content matches drugim in codepage 1251" ); - }'; -} - -# }}} - -# {{{ test a message containing a russian subject and NO content type - -unshift (@RT::EmailInputEncodings, 'koi8-r'); -$RT::EmailOutputEncoding = 'koi8-r'; -my $content = `cat @RT_LIB_PATH@/t/data/russian-subject-no-content-type` || die "couldn't find new content"; - -$parser->ParseMIMEEntityFromScalar($content); - - -# be as much like the mail gateway as possible. -&text_plain_russian_redef_sendmessage; -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Attachments->First->ContentType =~ /text\/plain/, "We recorded the content type right"); -ok ($tick->Transactions->First->Attachments->Count ==1 , "Has one attachment, presumably a text-plain"); -is ($tick->Subject, "\x{442}\x{435}\x{441}\x{442} \x{442}\x{435}\x{441}\x{442}", "Recorded the subject right"); -sub text_plain_russian_redef_sendmessage { - no warnings qw/redefine/; - eval 'sub RT::Action::SendEmail::SendMessage { - my $self = shift; - my $MIME = shift; - return (1) unless ($self->ScripObj->ScripActionObj->Name eq "Notify AdminCcs" ); - is ($MIME->head->mime_type , "text/plain", "The only part is text/plain "); - my $subject = $MIME->head->get("subject"); - chomp($subject); - #is( $subject , /^=\?KOI8-R\?B\?W2V4YW1wbGUuY39tICM3XSDUxdPUINTF09Q=\?=/ , "The $subject is encoded correctly"); - }; - '; -} - -shift @RT::EmailInputEncodings; -$RT::EmailOutputEncoding = 'utf-8'; -# }}} - - -# {{{ test a message containing a nested RFC 822 message - -my $content = `cat @RT_LIB_PATH@/t/data/nested-rfc-822` || die "couldn't find new content"; -ok ($content, "Loaded nested-rfc-822 to test"); - -$parser->ParseMIMEEntityFromScalar($content); - - -# be as much like the mail gateway as possible. -&text_plain_nested_redef_sendmessage; -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); -is ($tick->Subject, "[Jonas Liljegren] Re: [Para] Niv\x{e5}er?"); -ok ($tick->Transactions->First->Attachments->First->ContentType =~ /multipart\/mixed/, "We recorded the content type right"); -is ($tick->Transactions->First->Attachments->Count , 5 , "Has one attachment, presumably a text-plain and a message RFC 822 and another plain"); -sub text_plain_nested_redef_sendmessage { - no warnings qw/redefine/; - eval 'sub RT::Action::SendEmail::SendMessage { - my $self = shift; - my $MIME = shift; - return (1) unless ($self->ScripObj->ScripActionObj->Name eq "Notify AdminCcs" ); - is ($MIME->head->mime_type , "multipart/mixed", "It is a mixed multipart"); - my $subject = $MIME->head->get("subject"); - $subject = MIME::Base64::decode_base64( $subject); - chomp($subject); - # TODO, why does this test fail - #ok($subject =~ qr{Niv\x{e5}er}, "The subject matches the word - $subject"); - 1; - }'; -} - -# }}} - - -# {{{ test a multipart alternative containing a uuencoded mesage generated by lotus notes - -my $content = `cat @RT_LIB_PATH@/t/data/notes-uuencoded` || die "couldn't find new content"; - -$parser->ParseMIMEEntityFromScalar($content); - - -# be as much like the mail gateway as possible. -¬es_redef_sendmessage; - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Content =~ /from Lotus Notes/, "We recorded the content right"); -is ($tick->Transactions->First->Attachments->Count , 3 , "Has three attachments"); - -sub notes_redef_sendmessage { - no warnings qw/redefine/; - eval 'sub RT::Action::SendEmail::SendMessage { }'; -} - -# }}} - -# {{{ test a multipart that crashes the file-based mime-parser works - -my $content = `cat @RT_LIB_PATH@/t/data/crashes-file-based-parser` || die "couldn't find new content"; - -$parser->ParseMIMEEntityFromScalar($content); - - -# be as much like the mail gateway as possible. -&crashes_redef_sendmessage; - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -ok ($tick->Transactions->First->Content =~ /FYI/, "We recorded the content right"); -is ($tick->Transactions->First->Attachments->Count , 5 , "Has three attachments"); - -sub crashes_redef_sendmessage { - no warnings qw/redefine/; - eval 'sub RT::Action::SendEmail::SendMessage { }'; -} - - - -# }}} - -# {{{ test a multi-line RT-Send-CC header - -my $content = `cat @RT_LIB_PATH@/t/data/rt-send-cc` || die "couldn't find new content"; - -$parser->ParseMIMEEntityFromScalar($content); - - - -my %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); -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); - -my $cc = $tick->Transactions->First->Attachments->First->GetHeader('RT-Send-Cc'); -ok ($cc =~ /test1/, "Found test 1"); -ok ($cc =~ /test2/, "Found test 2"); -ok ($cc =~ /test3/, "Found test 3"); -ok ($cc =~ /test4/, "Found test 4"); -ok ($cc =~ /test5/, "Found test 5"); - -# }}} - -# Don't taint the environment -$everyone->PrincipalObj->RevokeRight(Right =>'SuperUser'); -1; diff --git a/rt/lib/t/05cronsupport.pl.in b/rt/lib/t/05cronsupport.pl.in deleted file mode 100644 index a6b3d7451..000000000 --- a/rt/lib/t/05cronsupport.pl.in +++ /dev/null @@ -1,84 +0,0 @@ -#!@PERL@ -w - -use strict; - -### Set up some testing data. Test the testing data because why not? - -# Create a user with rights, a queue, and some tickets. -my $user_obj = RT::User->new($RT::SystemUser); -my ($ret, $msg) = $user_obj->LoadOrCreateByEmail('tara@example.com'); -ok($ret, 'record test user creation'); -$user_obj->SetName('tara'); -$user_obj->PrincipalObj->GrantRight(Right => 'SuperUser'); -my $CurrentUser = RT::CurrentUser->new('tara'); - -# Create our template, which will be used for tests of RT::Action::Record*. - -my $template_content = 'RT-Send-Cc: tla@example.com -RT-Send-Bcc: jesse@example.com - -This is a content string with no content.'; - -my $template_obj = RT::Template->new($CurrentUser); -$template_obj->Create(Queue => '0', - Name => 'recordtest', - Description => 'testing Record actions', - Content => $template_content, - ); - -# Create a queue and some tickets. - -my $queue_obj = RT::Queue->new($CurrentUser); -($ret, $msg) = $queue_obj->Create(Name => 'recordtest', Description => 'queue for Action::Record testing'); -ok($ret, 'record test queue creation'); - -my $ticket1 = RT::Ticket->new($CurrentUser); -my ($id, $tobj, $msg2) = $ticket1->Create(Queue => $queue_obj, - Requestor => ['tara@example.com'], - Subject => 'bork bork bork', - Priority => 22, - ); -ok($id, 'record test ticket creation 1'); -my $ticket2 = RT::Ticket->new($CurrentUser); -($id, $tobj, $msg2) = $ticket2->Create(Queue => $queue_obj, - Requestor => ['root@localhost'], - Subject => 'hurdy gurdy' - ); -ok($id, 'record test ticket creation 2'); - - -### OK. Have data, will travel. - -# First test the search. - -ok(require RT::Search::FromSQL, "Search::FromSQL loaded"); -my $ticketsqlstr = "Requestor.EmailAddress = '" . $CurrentUser->EmailAddress . - "' AND Priority > '20'"; -my $search = RT::Search::FromSQL->new(Argument => $ticketsqlstr, TicketsObj => RT::Tickets->new($CurrentUser), - ); -is(ref($search), 'RT::Search::FromSQL', "search created"); -ok($search->Prepare(), "fromsql search run"); -my $counter = 0; -while(my $t = $search->TicketsObj->Next() ) { - is($t->Id(), $ticket1->Id(), "fromsql search results 1"); - $counter++; -} -is ($counter, 1, "fromsql search results 2"); - -# Right. Now test the actions. - -ok(require RT::Action::RecordComment); -ok(require RT::Action::RecordCorrespondence); - -my ($comment_act, $correspond_act); -ok($comment_act = RT::Action::RecordComment->new(TicketObj => $ticket1, TemplateObj => $template_obj, CurrentUser => $CurrentUser), "RecordComment created"); -ok($correspond_act = RT::Action::RecordCorrespondence->new(TicketObj => $ticket2, TemplateObj => $template_obj, CurrentUser => $CurrentUser), "RecordCorrespondence created"); -ok($comment_act->Prepare(), "Comment prepared"); -ok($correspond_act->Prepare(), "Correspond prepared"); -ok($comment_act->Commit(), "Comment committed"); -ok($correspond_act->Commit(), "Correspondence committed"); - -# Now test for loop suppression. -my ($trans, $desc, $transaction) = $ticket2->Comment(MIMEObj => $template_obj->MIMEObj); -my $bogus_action = RT::Action::RecordComment->new(TicketObj => $ticket1, TemplateObj => $template_obj, TransactionObj => $transaction, CurrentUser => $CurrentUser); -ok(!$bogus_action->Prepare(), "Comment aborted to prevent loop"); diff --git a/rt/lib/t/regression/00placeholder b/rt/lib/t/regression/00placeholder deleted file mode 100644 index 0afc6045c..000000000 --- a/rt/lib/t/regression/00placeholder +++ /dev/null @@ -1 +0,0 @@ -1; |