diff options
author | ivan <ivan> | 2008-03-02 04:11:51 +0000 |
---|---|---|
committer | ivan <ivan> | 2008-03-02 04:11:51 +0000 |
commit | c648976f0b7975f2328ebd7ba8c711fad0ca4195 (patch) | |
tree | f3d176ec300a46c253ba25a988b897bce02fe174 /rt/lib/t | |
parent | 5e05724a635a22776f1b973f5d7e77989da4e048 (diff) | |
parent | 8103c1fc1b2c27a6855feadf26f91b980a54bc52 (diff) |
This commit was generated by cvs2svn to compensate for changes in r6255,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'rt/lib/t')
-rw-r--r-- | rt/lib/t/regression/00-mason-syntax.t | 7 | ||||
-rw-r--r-- | rt/lib/t/regression/01ticket_link_searching.t | 96 | ||||
-rw-r--r-- | rt/lib/t/regression/02basic_web.t | 27 | ||||
-rw-r--r-- | rt/lib/t/regression/03web_compiliation_errors.t | 14 | ||||
-rw-r--r-- | rt/lib/t/regression/04send_email.t | 130 | ||||
-rw-r--r-- | rt/lib/t/regression/06-mime_decoding.t | 23 | ||||
-rw-r--r-- | rt/lib/t/regression/06mailgateway.t | 76 | ||||
-rw-r--r-- | rt/lib/t/regression/07acl.t | 96 | ||||
-rw-r--r-- | rt/lib/t/regression/07rights.t | 2 | ||||
-rw-r--r-- | rt/lib/t/regression/08web_cf_access.t | 15 | ||||
-rw-r--r-- | rt/lib/t/regression/12-search.t | 59 | ||||
-rw-r--r-- | rt/lib/t/regression/13-attribute-tests.t | 24 | ||||
-rw-r--r-- | rt/lib/t/regression/14linking.t | 112 | ||||
-rw-r--r-- | rt/lib/t/regression/21query-builder.t | 77 | ||||
-rw-r--r-- | rt/lib/t/regression/22search_tix_by_txn.t | 6 | ||||
-rw-r--r-- | rt/lib/t/regression/22search_tix_by_watcher.t | 201 | ||||
-rw-r--r-- | rt/lib/t/regression/23-web_attachments.t | 10 | ||||
-rw-r--r-- | rt/lib/t/regression/23cfsort.t | 75 | ||||
-rw-r--r-- | rt/lib/t/regression/26command_line.t | 32 |
19 files changed, 743 insertions, 339 deletions
diff --git a/rt/lib/t/regression/00-mason-syntax.t b/rt/lib/t/regression/00-mason-syntax.t index 96674cacf..a94c7efc1 100644 --- a/rt/lib/t/regression/00-mason-syntax.t +++ b/rt/lib/t/regression/00-mason-syntax.t @@ -25,6 +25,7 @@ find( { }, 'html'); ok($ok, "mason syntax is ok"); +use HTML::Mason; use HTML::Mason::Compiler; use HTML::Mason::Compiler::ToObject; @@ -36,7 +37,11 @@ sub compile_file { close $fh or die "couldn't close '$file': $!"; my $compiler = new HTML::Mason::Compiler::ToObject; - $compiler->compile( comp_source => $text, name => 'my' ); + $compiler->compile( + comp_source => $text, + name => 'my', + $HTML::Mason::VERSION >= 1.36? (comp_path => 'my'): (), + ); return 1; } diff --git a/rt/lib/t/regression/01ticket_link_searching.t b/rt/lib/t/regression/01ticket_link_searching.t index 6d10221c1..a402c7376 100644 --- a/rt/lib/t/regression/01ticket_link_searching.t +++ b/rt/lib/t/regression/01ticket_link_searching.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Test::More tests => 25; +use Test::More tests => 30; use strict; use RT; @@ -17,54 +17,46 @@ my $queue = new RT::Queue($CurrentUser); $queue->Load('General') || Abort(loc("Queue could not be loaded.")); my $child_ticket = new RT::Ticket( $CurrentUser ); - -my ( $childid ) = $child_ticket->Create - ( Subject => 'test child', - Queue => $queue->Id); - -ok($childid != 0); +my ($childid) = $child_ticket->Create( + Subject => 'test child', + Queue => $queue->Id, +); +ok($childid, "We created a child ticket"); my $parent_ticket = new RT::Ticket( $CurrentUser ); +my ($parentid) = $parent_ticket->Create( + Subject => 'test parent', + Children => [ $childid ], + Queue => $queue->Id, +); +ok($parentid, "We created a parent ticket"); -my ( $parentid ) = $parent_ticket->Create - ( Subject => 'test parent', - Children => [$childid], - Queue => $queue->Id); - -ok($parentid != 0, "We created a parent ticket"); my $Collection = RT::Tickets->new($CurrentUser); -$Collection->LimitMemberOf ($parentid); - -ok ($Collection->First); -is ($Collection->First->id, $childid, "We found the collection of all children of $parentid with Limit"); +$Collection->LimitMemberOf( $parentid ); is($Collection->Count,1, "We found only one result"); +ok($Collection->First); +is($Collection->First->id, $childid, "We found the collection of all children of $parentid with Limit"); $Collection = RT::Tickets->new($CurrentUser); -$Collection->FromSQL( "MemberOf = $parentid"); -is ($Collection->First->id, $childid, "We found the collection of all children of $parentid with TicketSQL"); -is($Collection->Count,1, "We found only one result"); - - - +$Collection->FromSQL("MemberOf = $parentid"); +is($Collection->Count, 1, "We found only one result"); +ok($Collection->First); +is($Collection->First->id, $childid, "We found the collection of all children of $parentid with TicketSQL"); $Collection = RT::Tickets->new($CurrentUser); $Collection->LimitHasMember ($childid); - -ok ($Collection->First); -is ($Collection->First->id, $parentid, "We found the collection of all parents of $childid with Limit"); is($Collection->Count,1, "We found only one result"); - +ok($Collection->First); +is($Collection->First->id, $parentid, "We found the collection of all parents of $childid with Limit"); $Collection = RT::Tickets->new($CurrentUser); $Collection->FromSQL("HasMember = $childid"); - -ok ($Collection->First); -is ($Collection->First->id, $parentid, "We found the collection of all parents of $childid with TicketSQL"); is($Collection->Count,1, "We found only one result"); - +ok($Collection->First); +is($Collection->First->id, $parentid, "We found the collection of all parents of $childid with TicketSQL"); # Now we find a collection of all the tickets which have no members. they should have no children. @@ -75,12 +67,10 @@ my %has; while (my $t = $Collection->Next) { ++$has{$t->id}; } -ok ($has{$childid} , "The collection has our child - $childid"); +ok( $has{$childid}, "The collection has our child - $childid"); ok( !$has{$parentid}, "The collection doesn't have our parent - $parentid"); - - # Now we find a collection of all the tickets which are not members of anything. they should have no parents. $Collection = RT::Tickets->new($CurrentUser); $Collection->LimitMemberOf(''); @@ -102,28 +92,27 @@ ok( !$has{$childid}, "The collection doesn't have our child - $childid"); $Collection = RT::Tickets->new($CurrentUser); $Collection->FromSQL ("HasMember IS NULL"); # must contain parent; must not contain child - %has = (); +%has = (); while (my $t = $Collection->Next) { ++$has{$t->id}; } -ok (!$has{$parentid} , "The collection doesn't have our parent - $parentid"); +ok( !$has{$parentid}, "The collection doesn't have our parent - $parentid"); ok( $has{$childid}, "The collection has our child - $childid"); # Now we find a collection of all the tickets which have no members. they should have no children. # Alternate syntax $Collection = RT::Tickets->new($CurrentUser); -$Collection->FromSQL ("HasMember = ''"); +$Collection->FromSQL("HasMember = ''"); # must contain parent; must not contain child - %has = (); +%has = (); while (my $t = $Collection->Next) { ++$has{$t->id}; } -ok (!$has{$parentid} , "The collection doesn't have our parent - $parentid"); +ok( !$has{$parentid}, "The collection doesn't have our parent - $parentid"); ok( $has{$childid}, "The collection has our child - $childid"); - # Now we find a collection of all the tickets which are not members of anything. they should have no parents. $Collection = RT::Tickets->new($CurrentUser); $Collection->FromSQL("MemberOf IS NULL"); @@ -132,8 +121,8 @@ $Collection->FromSQL("MemberOf IS NULL"); while (my $t = $Collection->Next) { ++$has{$t->id}; } -ok ($has{$parentid} , "The collection has our parent - $parentid"); -ok(!$has{$childid}, "The collection doesn't have our child - $childid"); +ok( $has{$parentid}, "The collection has our parent - $parentid"); +ok( !$has{$childid}, "The collection doesn't have our child - $childid"); # Now we find a collection of all the tickets which are not members of anything. they should have no parents. @@ -144,12 +133,27 @@ $Collection->FromSQL("MemberOf = ''"); while (my $t = $Collection->Next) { ++$has{$t->id}; } -ok ($has{$parentid} , "The collection has our parent - $parentid"); -ok(!$has{$childid}, "The collection doesn't have our child - $childid"); +ok( $has{$parentid}, "The collection has our parent - $parentid"); +ok( !$has{$childid}, "The collection doesn't have our child - $childid"); +# Now we find a collection of all the tickets which are not members of the parent ticket +$Collection = RT::Tickets->new($CurrentUser); +$Collection->FromSQL("MemberOf != $parentid"); +%has = (); +while (my $t = $Collection->Next) { + ++$has{$t->id}; +} +ok( $has{$parentid}, "The collection has our parent - $parentid"); +ok( !$has{$childid}, "The collection doesn't have our child - $childid"); +$Collection = RT::Tickets->new($CurrentUser); +$Collection->LimitMemberOf($parentid, OPERATOR => '!='); +%has = (); +while (my $t = $Collection->Next) { + ++$has{$t->id}; +} +ok( $has{$parentid}, "The collection has our parent - $parentid"); +ok( !$has{$childid}, "The collection doesn't have our child - $childid"); 1; - - diff --git a/rt/lib/t/regression/02basic_web.t b/rt/lib/t/regression/02basic_web.t index d3376d011..3b8619b66 100644 --- a/rt/lib/t/regression/02basic_web.t +++ b/rt/lib/t/regression/02basic_web.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; -use Test::More tests => 17; +use Test::More tests => 19; use WWW::Mechanize; use HTTP::Request::Common; use HTTP::Cookies; @@ -16,10 +16,10 @@ my $agent = WWW::Mechanize->new(); $agent->cookie_jar($cookie_jar); use RT; -RT::LoadConfig; - +RT::LoadConfig(); # get the top page my $url = $RT::WebURL; +diag $url; $agent->get($url); is ($agent->{'status'}, 200, "Loaded a page"); @@ -44,17 +44,20 @@ 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); +$agent->form_number(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' => "Ticket with utf8 body"); $agent->field('Content' => $string); ok($agent->submit(), "Created new ticket with $string as Content"); -ok( $agent->{'content'} =~ qr{$string} , "Found the content"); +like( $agent->{'content'}, qr{$string} , "Found the content"); +ok($agent->{redirected_uri}, "Did redirection"); + + $agent->get($url."Ticket/Create.html?Queue=1"); is ($agent->{'status'}, 200, "Loaded Create.html"); -$agent->form(3); +$agent->form_number(3); # Start with a string containing characters in latin1 my $string = "I18N Web Testing æøå"; Encode::from_to($string, 'iso-8859-1', 'utf8'); @@ -62,9 +65,15 @@ $agent->field('Subject' => $string); $agent->field('Content' => "Ticket with utf8 subject"); ok($agent->submit(), "Created new ticket with $string as Subject"); -ok( $agent->{'content'} =~ qr{$string} , "Found the content"); +like( $agent->{'content'}, qr{$string} , "Found the content"); +# Update time worked in hours +$agent->follow_link( text_regex => qr/Basics/ ); +$agent->submit_form( form_number => 3, + fields => { TimeWorked => 5, 'TimeWorked-TimeUnits' => "hours" } +); +like ($agent->{'content'}, qr/to '300'/, "5 hours is 300 minutes"); # }}} @@ -82,14 +91,14 @@ ok($agent->form_name('BuildQuery')); $agent->field("AttachmentField", "Subject"); $agent->field("AttachmentOp", "LIKE"); $agent->field("ValueOfAttachment", "aaa"); -$agent->submit(); +$agent->submit("AddClause"); # set the next value ok($agent->form_name('BuildQuery')); $agent->field("AttachmentField", "Subject"); $agent->field("AttachmentOp", "LIKE"); $agent->field("ValueOfAttachment", "bbb"); -$agent->submit(); +$agent->submit("AddClause"); ok($agent->form_name('BuildQuery')); diff --git a/rt/lib/t/regression/03web_compiliation_errors.t b/rt/lib/t/regression/03web_compiliation_errors.t index f2e62c98d..29e56d67b 100644 --- a/rt/lib/t/regression/03web_compiliation_errors.t +++ b/rt/lib/t/regression/03web_compiliation_errors.t @@ -12,19 +12,18 @@ 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); use RT; -RT::LoadConfig; +RT::LoadConfig(); # get the top page my $url = $RT::WebURL; +diag "Base URL is '$url'" if $ENV{TEST_VERBOSE}; $agent->get($url); is ($agent->{'status'}, 200, "Loaded a page"); - # {{{ test a login # follow the link marked "Login" @@ -45,20 +44,19 @@ use File::Find; find ( \&wanted , 'html/'); sub wanted { - -f && /\.html$/ && $_ !~ /Logout.html$/ && test_get($File::Find::name); + -f && /\.html$/ && $_ !~ /Logout.html$/ && test_get($File::Find::name); } sub test_get { my $file = shift; - - $file =~ s#^html/##; + $file =~ s#^html/##; + diag( "testing $url/$file" ) if $ENV{TEST_VERBOSE}; 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"); - + ok( $agent->{'content'} !~ /raw error/i, "Didn't get a Mason compilation error on $file"); } # }}} diff --git a/rt/lib/t/regression/04send_email.t b/rt/lib/t/regression/04send_email.t index 09e6e6f84..a175ffaee 100644 --- a/rt/lib/t/regression/04send_email.t +++ b/rt/lib/t/regression/04send_email.t @@ -1,10 +1,12 @@ #!/usr/bin/perl -w use strict; -use Test::More tests => 137; +use Test::More tests => 142; + use RT; RT::LoadConfig(); RT::Init; + use RT::EmailParser; use RT::Tickets; use RT::Action::SendEmail; @@ -20,17 +22,29 @@ $everyone->PrincipalObj->GrantRight(Right =>'SuperUser'); is (__PACKAGE__, 'main', "We're operating in the main package"); - { -no warnings qw/redefine/; -sub RT::Action::SendEmail::SendMessage { + 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"); + } } +# some utils +sub first_txn { return $_[0]->Transactions->First } +sub first_attach { return first_txn($_[0])->Attachments->First } + +sub count_txns { return $_[0]->Transactions->Count } +sub count_attachs { return first_txn($_[0])->Attachments->Count } + +sub file_content +{ + open my $fh, "<:raw", $_[0] or die "couldn't open file '$_[0]': $!"; + local $/; + return scalar <$fh>; } # instrument SendEmail to pass us what it's about to send. @@ -40,7 +54,7 @@ my $parser = RT::EmailParser->new(); # Let's test to make sure a multipart/report is processed correctly -my $content = `cat $RT::BasePath/lib/t/data/multipart-report` || die "couldn't find new content"; +my $content = file_content("$RT::BasePath/lib/t/data/multipart-report"); # be as much like the mail gateway as possible. use RT::Interface::Email; @@ -53,7 +67,7 @@ my $tick= $tickets->First(); isa_ok($tick, "RT::Ticket", "got a ticket object"); ok ($tick->Id, "found ticket ".$tick->Id); -ok ($tick->Transactions->First->Content =~ /The original message was received/, "It's the bounce"); +ok (first_txn($tick)->Content =~ /The original message was received/, "It's the bounce"); # make sure it fires scrips. @@ -96,7 +110,7 @@ is ($#scrips_fired, 1, "Fired 2 scrips on ticket creation"); # create an iso 8859-1 ticket @scrips_fired = (); -$content = `cat $RT::BasePath/lib/t/data/new-ticket-from-iso-8859-1` || die "couldn't find new content"; +$content = file_content("$RT::BasePath/lib/t/data/new-ticket-from-iso-8859-1"); @@ -114,7 +128,7 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $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"); +ok (first_txn($tick)->Content =~ /H\x{e5}vard/, "It's signed by havard. yay"); # make sure it fires scrips. @@ -144,7 +158,7 @@ $RT::EmailOutputEncoding = 'iso-8859-1'; # create an iso 8859-1 ticket @scrips_fired = (); - $content = `cat $RT::BasePath/lib/t/data/new-ticket-from-iso-8859-1` || die "couldn't find new content"; + $content = file_content("$RT::BasePath/lib/t/data/new-ticket-from-iso-8859-1"); # be as much like the mail gateway as possible. use RT::Interface::Email; @@ -156,7 +170,7 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $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"); +ok (first_txn($tick)->Content =~ /H\x{e5}vard/, "It's signed by havard. yay"); # make sure it fires scrips. @@ -238,7 +252,7 @@ sub iso8859_redef_sendmessage { # {{{ test a multipart alternative containing a text-html part with an umlaut - $content = `cat $RT::BasePath/lib/t/data/multipart-alternative-with-umlaut` || die "couldn't find new content"; + $content = file_content("$RT::BasePath/lib/t/data/multipart-alternative-with-umlaut"); $parser->ParseMIMEEntityFromScalar($content); @@ -246,16 +260,17 @@ $parser->ParseMIMEEntityFromScalar($content); # be as much like the mail gateway as possible. ¨auts_redef_sendmessage; - %args = (message => $content, queue => 1, action => 'correspond'); - RT::Interface::Email::Gateway(\%args); - $tickets = RT::Tickets->new($RT::SystemUser); +%args = (message => $content, queue => 1, action => 'correspond'); +RT::Interface::Email::Gateway(\%args); +$tickets = RT::Tickets->new($RT::SystemUser); $tickets->OrderBy(FIELD => 'id', ORDER => 'DESC'); $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); - $tick = $tickets->First(); +$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"); +ok (first_txn($tick)->Content =~ /causes Error/, "We recorded the content right as text-plain"); +is (count_attachs($tick) , 3 , "Has three attachments, presumably a text-plain, a text-html and a multipart alternative"); sub umlauts_redef_sendmessage { no warnings qw/redefine/; @@ -266,7 +281,7 @@ sub umlauts_redef_sendmessage { # {{{ test a text-html message with an umlaut - $content = `cat $RT::BasePath/lib/t/data/text-html-with-umlaut` || die "couldn't find new content"; + $content = file_content("$RT::BasePath/lib/t/data/text-html-with-umlaut"); $parser->ParseMIMEEntityFromScalar($content); @@ -282,29 +297,28 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $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"); +ok (first_attach($tick)->Content =~ /causes Error/, "We recorded the content as containing 'causes error'") or diag( first_attach($tick)->Content ); +ok (first_attach($tick)->ContentType =~ /text\/html/, "We recorded the content as text/html"); +is (count_attachs($tick), 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; + my $self = shift; + my $MIME = shift; 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->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 - $content = `cat $RT::BasePath/lib/t/data/text-html-in-russian` || die "couldn't find new content"; + $content = file_content("$RT::BasePath/lib/t/data/text-html-in-russian"); $parser->ParseMIMEEntityFromScalar($content); @@ -320,8 +334,8 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $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"); +ok (first_attach($tick)->ContentType =~ /text\/html/, "We recorded the content right as text-html"); +ok (count_attachs($tick) ==1 , "Has one attachment, presumably a text-html and a multipart alternative"); sub text_html_russian_redef_sendmessage { no warnings qw/redefine/; @@ -347,7 +361,7 @@ sub text_html_russian_redef_sendmessage { unshift (@RT::EmailInputEncodings, 'koi8-r'); $RT::EmailOutputEncoding = 'koi8-r'; -$content = `cat $RT::BasePath/lib/t/data/russian-subject-no-content-type` || die "couldn't find new content"; +$content = file_content("$RT::BasePath/lib/t/data/russian-subject-no-content-type"); $parser->ParseMIMEEntityFromScalar($content); @@ -362,8 +376,8 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $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"); +ok (first_attach($tick)->ContentType =~ /text\/plain/, "We recorded the content type right"); +ok (count_attachs($tick) ==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/; @@ -375,7 +389,7 @@ sub text_plain_russian_redef_sendmessage { my $subject = $MIME->head->get("subject"); chomp($subject); #is( $subject , /^=\?KOI8-R\?B\?W2V4YW1wbGUuY39tICM3XSDUxdPUINTF09Q=\?=/ , "The $subject is encoded correctly"); - }; + }; '; } @@ -386,7 +400,7 @@ $RT::EmailOutputEncoding = 'utf-8'; # {{{ test a message containing a nested RFC 822 message - $content = `cat $RT::BasePath/lib/t/data/nested-rfc-822` || die "couldn't find new content"; + $content = file_content("$RT::BasePath/lib/t/data/nested-rfc-822"); ok ($content, "Loaded nested-rfc-822 to test"); $parser->ParseMIMEEntityFromScalar($content); @@ -402,8 +416,8 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $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"); +ok (first_attach($tick)->ContentType =~ /multipart\/mixed/, "We recorded the content type right"); +is (count_attachs($tick) , 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 { @@ -414,9 +428,9 @@ sub text_plain_nested_redef_sendmessage { my $subject = $MIME->head->get("subject"); $subject = MIME::Base64::decode_base64( $subject); chomp($subject); - # TODO, why does this test fail + # TODO, why does this test fail #ok($subject =~ qr{Niv\x{e5}er}, "The subject matches the word - $subject"); - 1; + 1; }'; } @@ -425,7 +439,7 @@ sub text_plain_nested_redef_sendmessage { # {{{ test a multipart alternative containing a uuencoded mesage generated by lotus notes - $content = `cat $RT::BasePath/lib/t/data/notes-uuencoded` || die "couldn't find new content"; + $content = file_content("$RT::BasePath/lib/t/data/notes-uuencoded"); $parser->ParseMIMEEntityFromScalar($content); @@ -441,8 +455,8 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $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"); +ok (first_txn($tick)->Content =~ /from Lotus Notes/, "We recorded the content right"); +is (count_attachs($tick) , 3 , "Has three attachments"); sub notes_redef_sendmessage { no warnings qw/redefine/; @@ -453,7 +467,7 @@ sub notes_redef_sendmessage { # {{{ test a multipart that crashes the file-based mime-parser works - $content = `cat $RT::BasePath/lib/t/data/crashes-file-based-parser` || die "couldn't find new content"; + $content = file_content("$RT::BasePath/lib/t/data/crashes-file-based-parser"); $parser->ParseMIMEEntityFromScalar($content); @@ -469,8 +483,8 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $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"); +ok (first_txn($tick)->Content =~ /FYI/, "We recorded the content right"); +is (count_attachs($tick) , 5 , "Has three attachments"); sub crashes_redef_sendmessage { no warnings qw/redefine/; @@ -483,7 +497,7 @@ sub crashes_redef_sendmessage { # {{{ test a multi-line RT-Send-CC header - $content = `cat $RT::BasePath/lib/t/data/rt-send-cc` || die "couldn't find new content"; + $content = file_content("$RT::BasePath/lib/t/data/rt-send-cc"); $parser->ParseMIMEEntityFromScalar($content); @@ -497,7 +511,7 @@ $tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0'); $tick= $tickets->First(); ok ($tick->Id, "found ticket ".$tick->Id); -my $cc = $tick->Transactions->First->Attachments->First->GetHeader('RT-Send-Cc'); +my $cc = first_attach($tick)->GetHeader('RT-Send-Cc'); ok ($cc =~ /test1/, "Found test 1"); ok ($cc =~ /test2/, "Found test 2"); ok ($cc =~ /test3/, "Found test 3"); @@ -506,6 +520,30 @@ ok ($cc =~ /test5/, "Found test 5"); # }}} +diag q{regression test for #5248 from rt3.fsck.com} if $ENV{TEST_VERBOSE}; +{ + my $content = file_content("$RT::BasePath/lib/t/data/subject-with-folding-ws"); + my ($status, $msg, $ticket) = RT::Interface::Email::Gateway( + { message => $content, queue => 1, action => 'correspond' } + ); + ok ($status, 'created ticket') or diag "error: $msg"; + ok ($ticket->id, "found ticket ". $ticket->id); + is ($ticket->Subject, 'test', 'correct subject'); +} + +diag q{regression test for #5248 from rt3.fsck.com} if $ENV{TEST_VERBOSE}; +{ + my $content = file_content("$RT::BasePath/lib/t/data/very-long-subject"); + my ($status, $msg, $ticket) = RT::Interface::Email::Gateway( + { message => $content, queue => 1, action => 'correspond' } + ); + ok ($status, 'created ticket') or diag "error: $msg"; + ok ($ticket->id, "found ticket ". $ticket->id); + is ($ticket->Subject, '0123456789'x20, 'correct subject'); +} + + + # Don't taint the environment $everyone->PrincipalObj->RevokeRight(Right =>'SuperUser'); 1; diff --git a/rt/lib/t/regression/06-mime_decoding.t b/rt/lib/t/regression/06-mime_decoding.t index 98af18513..2dca4f191 100644 --- a/rt/lib/t/regression/06-mime_decoding.t +++ b/rt/lib/t/regression/06-mime_decoding.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 7; use_ok("RT"); @@ -41,3 +41,24 @@ diag q{'=' char in a trailing part after an encoded part} if $ENV{TEST_VERBOSE}; ); } +diag q{regression test for #5248 from rt3.fsck.com} if $ENV{TEST_VERBOSE}; +{ + my $str = qq{Subject: =?ISO-8859-1?Q?Re=3A_=5BXXXXXX=23269=5D_=5BComment=5D_Frag?=} + . qq{\n =?ISO-8859-1?Q?e_zu_XXXXXX--xxxxxx_/_Xxxxx=FCxxxxxxxxxx?=}; + is( + RT::I18N::DecodeMIMEWordsToUTF8($str), + qq{Subject: Re: [XXXXXX#269] [Comment] Frage zu XXXXXX--xxxxxx / Xxxxxüxxxxxxxxxx}, + "right decoding" + ); +} + +diag q{newline and encoded file name} if $ENV{TEST_VERBOSE}; +{ + my $str = qq{application/vnd.ms-powerpoint;\n\tname="=?ISO-8859-1?Q?Main_presentation.ppt?="}; + is( + RT::I18N::DecodeMIMEWordsToUTF8($str), + qq{application/vnd.ms-powerpoint;\tname="Main presentation.ppt"}, + "right decoding" + ); +} + diff --git a/rt/lib/t/regression/06mailgateway.t b/rt/lib/t/regression/06mailgateway.t index 12b55885e..5fc502926 100644 --- a/rt/lib/t/regression/06mailgateway.t +++ b/rt/lib/t/regression/06mailgateway.t @@ -52,19 +52,20 @@ rt-mailgate - Mail interface to RT3. =cut use strict; -use Test::More tests => 104; +use Test::More tests => 109; use RT; RT::LoadConfig(); RT::Init(); use RT::I18N; +use Digest::MD5 qw(md5_base64); no warnings 'once'; my $url = join( ':', grep $_, "http://localhost", $RT::WebPort ) . $RT::WebPath ."/"; # Make sure that when we call the mailgate wrong, it tempfails -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url http://this.test.for.non-connection.is.expected.to.generate.an.error"), "Opened the mailgate - The error below is expected - $@"); print MAIL <<EOF; From: root\@localhost @@ -81,7 +82,7 @@ is ( $? >> 8, 75, "The error message above is expected The mail gateway exited w # {{{ Test new ticket creation by root who is privileged and superuser -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --debug --url $url --queue general --action correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: root\@localhost @@ -107,10 +108,36 @@ ok ($tick->Subject eq 'This is a test of new ticket creation', "Created the tick # }}} +# {{{ Test new ticket creation without --action argument + +$! = 0; +ok(open(MAIL, "|$RT::BinPath/rt-mailgate --debug --url $url --queue general"), "Opened the mailgate - $!"); +print MAIL <<EOF; +From: root\@localhost +To: rt\@$RT::rtname +Subject: using mailgate without --action arg + +Blah! +Foob! +EOF +close (MAIL); + +#Check the return value +is ($? >> 8, 0, "The mail gateway exited normally. yay"); + +$tickets = RT::Tickets->new($RT::SystemUser); +$tickets->OrderBy(FIELD => 'id', ORDER => 'DESC'); +$tickets->Limit(FIELD => 'id', OPERATOR => '>', VALUE => '0'); +$tick = $tickets->First; +isa_ok ($tick,'RT::Ticket'); +ok ($tick->Id, "found ticket ".$tick->Id); +is ($tick->Subject, 'using mailgate without --action arg', "using mailgate without --action arg"); + +# }}} # {{{This is a test of new ticket creation as an unknown user -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: doesnotexist\@$RT::rtname @@ -132,7 +159,7 @@ ok ($tick->Id, "found ticket ".$tick->Id); ok ($tick->Subject ne 'This is a test of new ticket creation as an unknown user', "failed to create the new ticket from an unprivileged account"); my $u = RT::User->new($RT::SystemUser); $u->Load("doesnotexist\@$RT::rtname"); -ok( $u->Id == 0, " user does not exist and was not created by failed ticket submission"); +ok( !$u->Id, " user does not exist and was not created by failed ticket submission"); # }}} @@ -147,7 +174,7 @@ my ($val,$msg) = $g->PrincipalObj->GrantRight(Right => 'CreateTicket'); ok ($val, "Granted everybody the right to create tickets - $msg"); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: doesnotexist\@$RT::rtname @@ -181,7 +208,7 @@ ok( $u->Id != 0, " user does not exist and was created by ticket submission"); #($val,$msg) = $g->PrincipalObj->GrantRight(Right => 'CreateTicket'); #ok ($val, "Granted everybody the right to create tickets - $msg"); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: doesnotexist-2\@$RT::rtname @@ -197,7 +224,7 @@ is ($? >> 8, 0, "The mail gateway exited normally. yay"); $u = RT::User->new($RT::SystemUser); $u->Load('doesnotexist-2@$RT::rtname'); -ok( $u->Id == 0, " user does not exist and was not created by ticket correspondence submission"); +ok( !$u->Id, " user does not exist and was not created by ticket correspondence submission"); # }}} @@ -207,7 +234,7 @@ ok( $u->Id == 0, " user does not exist and was not created by ticket corresponde ($val,$msg) = $g->PrincipalObj->GrantRight(Right => 'ReplyToTicket'); ok ($val, "Granted everybody the right to reply to tickets - $msg"); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: doesnotexist-2\@$RT::rtname @@ -234,7 +261,7 @@ ok( $u->Id != 0, " user exists and was created by ticket correspondence submissi #($val,$msg) = $g->PrincipalObj->GrantRight(Right => 'CreateTicket'); #ok ($val, "Granted everybody the right to create tickets - $msg"); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action comment"), "Opened the mailgate - $!"); print MAIL <<EOF; From: doesnotexist-3\@$RT::rtname @@ -251,7 +278,7 @@ is ($? >> 8, 0, "The mail gateway exited normally. yay"); $u = RT::User->new($RT::SystemUser); $u->Load("doesnotexist-3\@$RT::rtname"); -ok( $u->Id == 0, " user does not exist and was not created by ticket comment submission"); +ok( !$u->Id, " user does not exist and was not created by ticket comment submission"); # }}} # {{{ can another random reply to a ticket after being granted privs? answer should be yes @@ -260,7 +287,7 @@ ok( $u->Id == 0, " user does not exist and was not created by ticket comment sub ($val,$msg) = $g->PrincipalObj->GrantRight(Right => 'CommentOnTicket'); ok ($val, "Granted everybody the right to reply to tickets - $msg"); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action comment"), "Opened the mailgate - $!"); print MAIL <<EOF; From: doesnotexist-3\@$RT::rtname @@ -302,7 +329,7 @@ $entity->attach(Path => $LOGO_FILE, Encoding => 'base64'); # Create a ticket with a binary attachment -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action correspond"), "Opened the mailgate - $!"); $entity->print(\*MAIL); @@ -324,8 +351,7 @@ my $file = `cat $LOGO_FILE`; ok ($file, "Read in the logo image"); - use Digest::MD5; -warn "for the raw file the content is ".Digest::MD5::md5_base64($file); +diag( "for the raw file the content is ". md5_base64($file) ); @@ -337,7 +363,7 @@ my $attachment = $attachments->First; ok($attachment->Id); my $acontent = $attachment->Content; - warn "coming from the database, the content is ".Digest::MD5::md5_base64($acontent); +diag( "coming from the database, the content is ". md5_base64($acontent) ); is( $acontent, $file, 'The attachment isn\'t screwed up in the database.'); # Log in as root @@ -361,7 +387,7 @@ is($file, $r->content, 'The attachment isn\'t screwed up in download'); # {{{ Simple I18N testing -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; @@ -396,7 +422,7 @@ is ($unitick->Transactions->First->Content, $unitick->Transactions->First->Attac ok($unitick->Transactions->First->Attachments->First->Content =~ /$unistring/i, $unitick->Id." appears to be unicode ". $unitick->Transactions->First->Attachments->First->Id); # supposedly I18N fails on the second message sent in. -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue general --action correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; @@ -456,7 +482,7 @@ my ($id) = $tick->Create( Queue => 'ext-mailgate', Subject => 'test'); ok( $id, 'new ticket created' ); is( $tick->Owner, $RT::Nobody->Id, 'owner of the new ticket is nobody' ); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take"), "Opened the mailgate - $!"); print MAIL <<EOF; From: root\@localhost @@ -481,7 +507,7 @@ is( $tick->Owner, $RT::Nobody->Id, 'set owner back to nobody'); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $RT::WebURL --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $@"); print MAIL <<EOF; From: root\@localhost @@ -505,7 +531,7 @@ $txns->OrderBy( FIELD => 'id', ORDER => 'DESC' ); is( $tick->Transactions->Count, 6, 'no superfluous transactions'); is( $txns->First->Subject, "[$RT::rtname \#$id] correspondence", 'successfuly add correspond within take via email' ); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action resolve --debug"), "Opened the mailgate - $!"); print MAIL <<EOF; From: root\@localhost @@ -537,7 +563,7 @@ $tick = RT::Ticket->new($RT::SystemUser); ($id) = $tick->Create( Queue => $qid, Subject => 'test' ); ok( $id, 'create new ticket' ); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take"), "Opened the mailgate - $!"); print MAIL <<EOF; From: ext-mailgate\@localhost @@ -555,7 +581,7 @@ ok( $status, "successfuly granted right: $msg" ); my $ace_id = $status; ok( $user->HasRight( Right => 'ReplyToTicket', Object => $tick ), "User can reply to ticket" ); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action correspond-take"), "Opened the mailgate - $!"); print MAIL <<EOF; From: ext-mailgate\@localhost @@ -570,7 +596,7 @@ DBIx::SearchBuilder::Record::Cachable->FlushCache; cmp_ok( $tick->Owner, '!=', $user->id, "we didn't change owner" ); is( $tick->Transactions->Count, 3, "one transactions added" ); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: ext-mailgate\@localhost @@ -611,7 +637,7 @@ ok( $status, "successfuly granted right: $msg" ); ($status, $msg) = $user->PrincipalObj->GrantRight( Object => $queue, Right => 'TakeTicket' ); ok( $status, "successfuly granted right: $msg" ); -$! = ''; +$! = 0; ok(open(MAIL, "|$RT::BinPath/rt-mailgate --url $url --queue ext-mailgate --action take-correspond"), "Opened the mailgate - $!"); print MAIL <<EOF; From: ext-mailgate\@localhost diff --git a/rt/lib/t/regression/07acl.t b/rt/lib/t/regression/07acl.t index e30a59bef..efd87016d 100644 --- a/rt/lib/t/regression/07acl.t +++ b/rt/lib/t/regression/07acl.t @@ -1,9 +1,9 @@ #!/usr/bin/perl -w - +use strict; use WWW::Mechanize; use HTTP::Cookies; -use Test::More qw/no_plan/; +use Test::More tests => 34; use RT; RT::LoadConfig(); RT::Init(); @@ -20,6 +20,7 @@ ok($ret, "ACL test password set. $msg"); # Now test the web interface, making sure objects come and go as # required. + my $cookie_jar = HTTP::Cookies->new; my $agent = WWW::Mechanize->new(); @@ -27,62 +28,53 @@ my $agent = WWW::Mechanize->new(); $agent->cookie_jar($cookie_jar); - +no warnings 'once'; # get the top page -my $url = $RT::WebURL; -$agent->get($url); - -is ($agent->{'status'}, 200, "Loaded a page - $RT::WebURL"); -# {{{ 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' => 'customer-'.$$ ); -$agent->field( 'pass' => 'customer' ); -# 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"); +login($agent, $user_obj); # Test for absence of Configure and Preferences tabs. -ok(!$agent->find_link( url => "$RT::WebPath/Admin/", +ok(!$agent->find_link( url => $RT::WebPath . "/Admin/", text => 'Configuration'), "No config tab" ); -ok(!$agent->find_link( url => "$RT::WebPath/User/Prefs.html", +ok(!$agent->find_link( url => $RT::WebPath . "/User/Prefs.html", text => 'Preferences'), "No prefs pane" ); # Now test for their presence, one at a time. Sleep for a bit after # ACL changes, thanks to the 10s ACL cache. -$user_obj->PrincipalObj->GrantRight(Right => 'ShowConfigTab'); -$agent->reload(); +my ($grantid,$grantmsg) =$user_obj->PrincipalObj->GrantRight(Right => 'ShowConfigTab', Object => $RT::System); + +ok($grantid,$grantmsg); + +$agent->reload; + ok($agent->{'content'} =~ /Logout/i, "Reloaded page successfully"); -ok($agent->find_link( url => "$RT::WebPath/Admin/", +ok($agent->find_link( url => $RT::WebPath . "/Admin/", text => 'Configuration'), "Found config tab" ); -$user_obj->PrincipalObj->RevokeRight(Right => 'ShowConfigTab'); -$user_obj->PrincipalObj->GrantRight(Right => 'ModifySelf'); +my ($revokeid,$revokemsg) =$user_obj->PrincipalObj->RevokeRight(Right => 'ShowConfigTab'); +ok ($revokeid,$revokemsg); +($grantid,$grantmsg) =$user_obj->PrincipalObj->GrantRight(Right => 'ModifySelf'); +ok ($grantid,$grantmsg); $agent->reload(); ok($agent->{'content'} =~ /Logout/i, "Reloaded page successfully"); -ok($agent->find_link( url => "$RT::WebPath/User/Prefs.html", +ok($agent->find_link( url => $RT::WebPath . "/User/Prefs.html", text => 'Preferences'), "Found prefs pane" ); -$user_obj->PrincipalObj->RevokeRight(Right => 'ModifySelf'); - +($revokeid,$revokemsg) = $user_obj->PrincipalObj->RevokeRight(Right => 'ModifySelf'); +ok ($revokeid,$revokemsg); # Good. Now load the search page and test Load/Save Search. -$agent->follow_link( url => "$RT::WebPath/Search/Build.html", +$agent->follow_link( url => $RT::WebPath . "/Search/Build.html", text => 'Tickets'); is($agent->{'status'}, 200, "Fetched search builder page"); ok($agent->{'content'} !~ /Load saved search/i, "No search loading box"); ok($agent->{'content'} !~ /Saved searches/i, "No saved searches box"); -$user_obj->PrincipalObj->GrantRight(Right => 'LoadSavedSearch'); +($grantid,$grantmsg) = $user_obj->PrincipalObj->GrantRight(Right => 'LoadSavedSearch'); +ok($grantid,$grantmsg); $agent->reload(); ok($agent->{'content'} =~ /Load saved search/i, "Search loading box exists"); ok($agent->{'content'} !~ /input\s+type=.submit.\s+name=.Save./i, "Still no saved searches box"); -$user_obj->PrincipalObj->GrantRight(Right => 'CreateSavedSearch'); +($grantid,$grantmsg) =$user_obj->PrincipalObj->GrantRight(Right => 'CreateSavedSearch'); +ok ($grantid,$grantmsg); $agent->reload(); ok($agent->{'content'} =~ /Load saved search/i, "Search loading box still exists"); @@ -93,22 +85,24 @@ ok($agent->{'content'} =~ /input\s+type=.submit.\s+name=.Save./i, # via SelectOwner. my $queue_obj = RT::Queue->new($RT::SystemUser); -($ret, $msg) = $queue_obj->Create(Name => 'CustomerQueue', +($ret, $msg) = $queue_obj->Create(Name => 'CustomerQueue-'.$$, Description => 'queue for SelectOwner testing'); ok($ret, "SelectOwner test queue creation. $msg"); my $group_obj = RT::Group->new($RT::SystemUser); -($ret, $msg) = $group_obj->CreateUserDefinedGroup(Name => 'CustomerGroup', +($ret, $msg) = $group_obj->CreateUserDefinedGroup(Name => 'CustomerGroup-'.$$, Description => 'group for SelectOwner testing'); ok($ret, "SelectOwner test group creation. $msg"); # Add our customer to the customer group, and give it queue rights. ($ret, $msg) = $group_obj->AddMember($user_obj->PrincipalObj->Id()); ok($ret, "Added customer to its group. $msg"); -$group_obj->PrincipalObj->GrantRight(Right => 'OwnTicket', +($grantid,$grantmsg) =$group_obj->PrincipalObj->GrantRight(Right => 'OwnTicket', Object => $queue_obj); -$group_obj->PrincipalObj->GrantRight(Right => 'SeeQueue', + +ok($grantid,$grantmsg); +($grantid,$grantmsg) =$group_obj->PrincipalObj->GrantRight(Right => 'SeeQueue', Object => $queue_obj); - +ok ($grantid,$grantmsg); # Now. When we look at the search page we should be able to see # ourself in the list of possible owners. @@ -117,4 +111,28 @@ ok($agent->form_name('BuildQuery'), "Yep, form is still there"); my $input = $agent->current_form->find_input('ValueOfActor'); ok(grep(/customer-$$/, $input->value_names()), "Found self in the actor listing"); +sub login { + my $agent = shift; + + my $url = $RT::WebURL; + $agent->get($url); + is( $agent->{'status'}, 200, + "Loaded a page - $url" ); + + # {{{ 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' => $user_obj->Name ); + $agent->field( 'pass' => 'customer' ); + + # 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" ); +} 1; diff --git a/rt/lib/t/regression/07rights.t b/rt/lib/t/regression/07rights.t index d34627705..6c35a0717 100644 --- a/rt/lib/t/regression/07rights.t +++ b/rt/lib/t/regression/07rights.t @@ -112,7 +112,7 @@ ok( $user->HasRight( Right => 'ReplyToTicket', Object => $ticket ), "user is own $group = RT::Group->new( $RT::SystemUser ); ok( $group->LoadQueueRoleGroup( Queue => $queue_id, Type=> 'AdminCc' ), "load queue AdminCc role group" ); $ace = RT::ACE->new( $RT::SystemUser ); -my ($ace_id, $msg) = $group->PrincipalObj->GrantRight( Right => 'ModifyTicket', Object => $queue ); +($ace_id, $msg) = $group->PrincipalObj->GrantRight( Right => 'ModifyTicket', Object => $queue ); ok( $ace_id, "Granted queue AdminCc role group with ModifyTicket right: $msg" ); ok( $group->PrincipalObj->HasRight( Right => 'ModifyTicket', Object => $queue ), "role group can modify ticket" ); ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket ), "user is not AdminCc and can't modify ticket" ); diff --git a/rt/lib/t/regression/08web_cf_access.t b/rt/lib/t/regression/08web_cf_access.t index 012d73381..c352bbcf8 100644 --- a/rt/lib/t/regression/08web_cf_access.t +++ b/rt/lib/t/regression/08web_cf_access.t @@ -2,13 +2,14 @@ use strict; use Test::More tests => 15; -use RT; -RT::LoadConfig; -RT::Init; +BEGIN { + use RT; + RT::LoadConfig; + RT::Init; +} use Test::WWW::Mechanize; -$RT::WebURL ||= 0; # avoid stupid warning -my $BaseURL = $RT::WebURL; +use constant BaseURL => $RT::WebURL; use constant ImageFile => $RT::MasonComponentRoot .'/NoAuth/images/bplogo.gif'; use constant ImageFileContent => do { local $/; @@ -20,7 +21,7 @@ use constant ImageFileContent => do { my $m = Test::WWW::Mechanize->new; isa_ok($m, 'Test::WWW::Mechanize'); -$m->get( $BaseURL."?user=root;pass=password" ); +$m->get( BaseURL."?user=root;pass=password" ); $m->content_like(qr/Logout/, 'we did log in'); $m->follow_link( text => 'Configuration' ); $m->title_is(q/RT Administration/, 'admin screen'); @@ -85,7 +86,7 @@ $m->title_like(qr/testing img cf creation/, "its title is the Subject"); $m->follow_link( text => 'bplogo.gif' ); $m->content_is(ImageFileContent, "it links to the uploaded image"); -$m->get( $BaseURL ); +$m->get( BaseURL ); $m->follow_link( text => 'Tickets' ); $m->follow_link( text => 'New Query' ); diff --git a/rt/lib/t/regression/12-search.t b/rt/lib/t/regression/12-search.t index 9cc4aa441..210d4fe33 100644 --- a/rt/lib/t/regression/12-search.t +++ b/rt/lib/t/regression/12-search.t @@ -6,7 +6,7 @@ use strict; use warnings; -use Test::More tests => 35; +use Test::More tests => 44; use_ok('RT'); RT::LoadConfig(); RT::Init(); @@ -38,6 +38,24 @@ ok($cf3->id, "Created the SearchTest3 CF"); my $cflabel3 = "CustomField-".$cf3->id; +# There was a bug involving a missing join to ObjectCustomFields that +# caused spurious results on negative searches if another custom field +# with the same name existed on a different queue. Hence, we make +# duplicate CFs on a different queue here +my $dup = RT::Queue->new($RT::SystemUser); +$dup->Create(Name => $queue . "-Copy"); +ok ($dup->id, "Created the duplicate queue"); +my $dupcf = RT::CustomField->new($RT::SystemUser); +$dupcf->Create(Name => 'SearchTest', Type => 'Freeform', MaxValues => 0, Queue => $dup->id); +ok($dupcf->id, "Created the duplicate SearchTest CF"); +$dupcf = RT::CustomField->new($RT::SystemUser); +$dupcf->Create(Name => 'SearchTest2', Type => 'Freeform', MaxValues => 0, Queue => $dup->id); +ok($dupcf->id, "Created the SearchTest2 CF"); +$dupcf = RT::CustomField->new($RT::SystemUser); +$dupcf->Create(Name => 'SearchTest3', Type => 'Freeform', MaxValues => 0, Queue => $dup->id); +ok($dupcf->id, "Created the SearchTest3 CF"); + + # setup some tickets # we'll need a small pile of them, to test various combinations and nulls. # there's probably a way to think harder and do this with fewer @@ -148,8 +166,7 @@ is($tix->Count, 5, "matched LIKE subject"); $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND CF.SearchTest IS NULL"); - - is($tix->Count, 2, "IS null CF"); +is($tix->Count, 2, "IS null CF"); $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND Requestors LIKE 'search1'"); @@ -163,14 +180,9 @@ $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND Requestors LIKE 'search'"); is($tix->Count, 6, "LIKE requestor"); -TODO: { - - local $TODO = "Can't search for 'no requestor"; - $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND Requestors IS NULL"); - is($tix->Count, 1, "Search for no requestor"); - -}; +$tix = RT::Tickets->new($RT::SystemUser); +$tix->FromSQL("Queue = '$queue' AND Requestors IS NULL"); +is($tix->Count, 1, "Search for no requestor"); $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND Subject = 'SearchTest1'"); @@ -223,13 +235,32 @@ is($tix->Count, 4, "like cf and like subject"); $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("CF.SearchTest IS NULL AND CF.SearchTest2 = 'bar2'"); - - is($tix->Count, 1, "null cf and is cf"); +is($tix->Count, 1, "null cf and is cf"); $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND CF.SearchTest IS NULL AND CF.SearchTest2 IS NULL"); +is($tix->Count, 1, "null cf and null cf"); - is($tix->Count, 1, "null cf and null cf"); +# tests with the same CF listed twice +$tix = RT::Tickets->new($RT::SystemUser); +$tix->FromSQL("CF.{SearchTest} = 'foo1'"); +is($tix->Count, 1, "is cf.{name} format"); + +$tix = RT::Tickets->new($RT::SystemUser); +$tix->FromSQL("CF.SearchTest = 'foo1' OR CF.SearchTest = 'foo3'"); +is($tix->Count, 2, "is cf1 or is cf1"); + +$tix = RT::Tickets->new($RT::SystemUser); +$tix->FromSQL("CF.SearchTest = 'foo1' OR CF.SearchTest IS NULL"); +is($tix->Count, 3, "is cf1 or null cf1"); + +$tix = RT::Tickets->new($RT::SystemUser); +$tix->FromSQL("(CF.SearchTest = 'foo1' OR CF.SearchTest = 'foo3') AND (CF.SearchTest2 = 'bar1' OR CF.SearchTest2 = 'bar2')"); +is($tix->Count, 1, "(is cf1 or is cf1) and (is cf2 or is cf2)"); + +$tix = RT::Tickets->new($RT::SystemUser); +$tix->FromSQL("CF.SearchTest = 'foo1' OR CF.SearchTest = 'foo3' OR CF.SearchTest2 = 'bar1' OR CF.SearchTest2 = 'bar2'"); +is($tix->Count, 3, "is cf1 or is cf1 or is cf2 or is cf2"); diff --git a/rt/lib/t/regression/13-attribute-tests.t b/rt/lib/t/regression/13-attribute-tests.t index 945bbcfb0..fdac94e63 100644 --- a/rt/lib/t/regression/13-attribute-tests.t +++ b/rt/lib/t/regression/13-attribute-tests.t @@ -1,5 +1,6 @@ - -use Test::More tests => 24; +use strict; +use warnings; +use Test::More tests => 34; use RT; RT::LoadConfig(); RT::Init(); @@ -19,6 +20,8 @@ ok($user->id, "Created a test user"); ok(1, $user->Attributes->BuildSelectQuery); my $attr = $user->Attributes; +# XXX: Order by id as some tests depend on it +$attr->OrderByCols({ FIELD => 'id' }); ok(1, $attr->BuildSelectQuery); @@ -28,6 +31,12 @@ ok (UNIVERSAL::isa($attr,'RT::Attributes'), 'got the attributes object'); ($id, $msg) = $user->AddAttribute(Name => 'TestAttr', Content => 'The attribute has content'); ok ($id, $msg); is ($attr->Count,1, " One attr after adidng a first one"); + +my $first_attr = $user->FirstAttribute('TestAttr'); +ok($first_attr, "got some sort of attribute"); +isa_ok($first_attr, 'RT::Attribute'); +is($first_attr->Content, 'The attribute has content', "got the right content back"); + ($id, $msg) = $attr->DeleteEntry(Name => $runid); ok(!$id, "Deleted non-existant entry - $msg"); is ($attr->Count,1, "1 attr after deleting an empty attr"); @@ -37,11 +46,22 @@ is ("@names", "TestAttr"); ($id, $msg) = $user->AddAttribute(Name => $runid, Content => "First"); +ok($id, $msg); + +my $runid_attr = $user->FirstAttribute($runid); +ok($runid_attr, "got some sort of attribute"); +isa_ok($runid_attr, 'RT::Attribute'); +is($runid_attr->Content, 'First', "got the right content back"); is ($attr->Count,2, " Two attrs after adding an attribute named $runid"); ($id, $msg) = $user->AddAttribute(Name => $runid, Content => "Second"); ok($id, $msg); +$runid_attr = $user->FirstAttribute($runid); +ok($runid_attr, "got some sort of attribute"); +isa_ok($runid_attr, 'RT::Attribute'); +is($runid_attr->Content, 'First', "got the first content back still"); + is ($attr->Count,3, " Three attrs after adding a secondvalue to $runid"); ($id, $msg) = $attr->DeleteEntry(Name => $runid, Content => "First"); ok($id, $msg); diff --git a/rt/lib/t/regression/14linking.t b/rt/lib/t/regression/14linking.t index 6fdf61405..c8e57eadd 100644 --- a/rt/lib/t/regression/14linking.t +++ b/rt/lib/t/regression/14linking.t @@ -1,4 +1,4 @@ -use Test::More tests => '39'; +use Test::More tests => '70'; use_ok('RT'); use_ok('RT::Ticket'); use_ok('RT::ScripConditions'); @@ -12,7 +12,9 @@ RT::Init(); use File::Temp qw/tempfile/; my ($fh, $filename) = tempfile( UNLINK => 1, SUFFIX => '.rt'); my $link_scrips_orig = $RT::LinkTransactionsRun1Scrip; +my $link_acl_chacks_orig = $RT::StrictLinkACL; $RT::LinkTransactionsRun1Scrip = 1; +$RT::StrictLinkACL = 1; my $condition = RT::ScripCondition->new( $RT::SystemUser ); $condition->Load('User Defined'); @@ -68,32 +70,123 @@ my $scrip = RT::Scrip->new($RT::SystemUser); ok($id, "Scrip created"); my $u1 = RT::User->new($RT::SystemUser); -($id,$msg) =$u1->Create(Name => "LinkTestUser.$$"); - +($id,$msg) = $u1->Create(Name => "LinkTestUser.$$"); ok ($id,$msg); +my $creator = RT::CurrentUser->new($u1->id); + ($id,$msg) = $u1->PrincipalObj->GrantRight ( Object => $q1, Right => 'CreateTicket'); ok ($id,$msg); + +diag('Create tickets without rights to link') if $ENV{'TEST_VERBOSE'}; +{ + # on q2 we have no rights, yet + my $parent = RT::Ticket->new( $RT::SystemUser ); + ($id,$tid,$msg) = $parent->Create( Subject => 'Link test 1', Queue => $q2->id ); + ok($id,$msg); + my $child = RT::Ticket->new( $creator ); + ($id,$tid,$msg) = $child->Create( Subject => 'Link test 1', Queue => $q1->id, MemberOf => $parent->id ); + ok($id,$msg); + $child->CurrentUser( $RT::SystemUser ); + is($child->_Links('Base')->Count, 0, 'link was not created, no permissions'); + is($child->_Links('Target')->Count, 0, 'link was not create, no permissions'); +} + +diag('Create tickets with rights checks on one end of a link') if $ENV{'TEST_VERBOSE'}; +{ + # on q2 we have no rights, but use checking one only on thing + local $RT::StrictLinkACL = 0; + my $parent = RT::Ticket->new( $RT::SystemUser ); + ($id,$tid,$msg) = $parent->Create( Subject => 'Link test 1', Queue => $q2->id ); + ok($id,$msg); + my $child = RT::Ticket->new( $creator ); + ($id,$tid,$msg) = $child->Create( Subject => 'Link test 1', Queue => $q1->id, MemberOf => $parent->id ); + ok($id,$msg); + $child->CurrentUser( $RT::SystemUser ); + is($child->_Links('Base')->Count, 1, 'link was created'); + is($child->_Links('Target')->Count, 0, 'link was created only one'); + # no scrip run on second ticket accroding to config option + is(link_count($filename), 0, "scrips ok"); +} + ($id,$msg) = $u1->PrincipalObj->GrantRight ( Object => $q1, Right => 'ModifyTicket'); ok ($id,$msg); -my $tid; +diag('try to add link without rights') if $ENV{'TEST_VERBOSE'}; +{ + # on q2 we have no rights, yet + my $parent = RT::Ticket->new( $RT::SystemUser ); + ($id,$tid,$msg) = $parent->Create( Subject => 'Link test 1', Queue => $q2->id ); + ok($id,$msg); + my $child = RT::Ticket->new( $creator ); + ($id,$tid,$msg) = $child->Create( Subject => 'Link test 1', Queue => $q1->id ); + ok($id,$msg); + my ($id, $msg) = $child->AddLink(Type => 'MemberOf', Target => $parent->id); + ok(!$id, $msg); + is(link_count($filename), 0, "scrips ok"); + $child->CurrentUser( $RT::SystemUser ); + is($child->_Links('Base')->Count, 0, 'link was not created, no permissions'); + is($child->_Links('Target')->Count, 0, 'link was not create, no permissions'); +} -my $creator = RT::CurrentUser->new($u1->id); +diag('add link with rights only on base') if $ENV{'TEST_VERBOSE'}; +{ + # on q2 we have no rights, but use checking one only on thing + local $RT::StrictLinkACL = 0; + my $parent = RT::Ticket->new( $RT::SystemUser ); + ($id,$tid,$msg) = $parent->Create( Subject => 'Link test 1', Queue => $q2->id ); + ok($id,$msg); + my $child = RT::Ticket->new( $creator ); + ($id,$tid,$msg) = $child->Create( Subject => 'Link test 1', Queue => $q1->id ); + ok($id,$msg); + my ($id, $msg) = $child->AddLink(Type => 'MemberOf', Target => $parent->id); + ok($id, $msg); + is(link_count($filename), 1, "scrips ok"); + $child->CurrentUser( $RT::SystemUser ); + is($child->_Links('Base')->Count, 1, 'link was created'); + is($child->_Links('Target')->Count, 0, 'link was created only one'); + $child->CurrentUser( $creator ); + + # turn off feature and try to delete link, we should fail + $RT::StrictLinkACL = 1; + my ($id, $msg) = $child->AddLink(Type => 'MemberOf', Target => $parent->id); + ok(!$id, $msg); + is(link_count($filename), 1, "scrips ok"); + $child->CurrentUser( $RT::SystemUser ); + $child->_Links('Base')->_DoCount; + is($child->_Links('Base')->Count, 1, 'link was not deleted'); + $child->CurrentUser( $creator ); + + # try to delete link, we should success as feature is active + $RT::StrictLinkACL = 0; + my ($id, $msg) = $child->DeleteLink(Type => 'MemberOf', Target => $parent->id); + ok($id, $msg); + is(link_count($filename), 0, "scrips ok"); + $child->CurrentUser( $RT::SystemUser ); + $child->_Links('Base')->_DoCount; + is($child->_Links('Base')->Count, 0, 'link was deleted'); +} +my $tid; my $ticket = RT::Ticket->new( $creator); ok($ticket->isa('RT::Ticket')); ($id,$tid, $msg) = $ticket->Create(Subject => 'Link test 1', Queue => $q1->id); ok ($id,$msg); +diag('try link to itself') if $ENV{'TEST_VERBOSE'}; +{ + my ($id, $msg) = $ticket->AddLink(Type => 'RefersTo', Target => $ticket->id); + ok(!$id, $msg); + is(link_count($filename), 0, "scrips ok"); +} my $ticket2 = RT::Ticket->new($RT::SystemUser); ($id, $tid, $msg) = $ticket2->Create(Subject => 'Link test 2', Queue => $q2->id); ok ($id, $msg); - ($id,$msg) =$ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id); ok(!$id,$msg); ok(link_count($filename) == 0, "scrips ok"); + ($id,$msg) = $u1->PrincipalObj->GrantRight ( Object => $q2, Right => 'CreateTicket'); ok ($id,$msg); ($id,$msg) = $u1->PrincipalObj->GrantRight ( Object => $q2, Right => 'ModifyTicket'); @@ -104,6 +197,9 @@ ok(link_count($filename) == 1, "scrips ok"); ($id,$msg) =$ticket->AddLink(Type => 'RefersTo', Target => -1); ok(!$id,$msg); ok(link_count($filename) == 1, "scrips ok"); +($id,$msg) = $ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id); +ok($id,$msg); +is(link_count($filename), 1, "scrips ok"); my $transactions = $ticket2->Transactions; $transactions->Limit( FIELD => 'Type', VALUE => 'AddLink' ); @@ -121,6 +217,7 @@ ok( $transactions->First->Field eq 'ReferredToBy'); ok( $transactions->First->OldValue eq $ticket->URI ); $RT::LinkTransactionsRun1Scrip = 0; + ($id,$msg) =$ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id); ok($id,$msg); ok(link_count($filename) == 2, "scrips ok"); @@ -130,6 +227,9 @@ ok(link_count($filename) == 0, "scrips ok"); # restore $RT::LinkTransactionsRun1Scrip = $link_scrips_orig; +$RT::StrictLinkACL = $link_acl_checks_orig; + +exit(0); sub link_count { diff --git a/rt/lib/t/regression/21query-builder.t b/rt/lib/t/regression/21query-builder.t index be04599bc..a0cecb2f3 100644 --- a/rt/lib/t/regression/21query-builder.t +++ b/rt/lib/t/regression/21query-builder.t @@ -1,7 +1,9 @@ #!/usr/bin/perl use strict; -use Test::More tests => 31; +use warnings; + +use Test::More tests => 39; use Test::WWW::Mechanize; use HTTP::Request::Common; use HTTP::Cookies; @@ -16,7 +18,20 @@ my $agent = Test::WWW::Mechanize->new(); $agent->cookie_jar($cookie_jar); use RT; -RT::LoadConfig; +RT::LoadConfig(); +RT::Init(); + +# create a regression queue if it doesn't exist +{ + my $queue = RT::Queue->new( $RT::SystemUser ); + $queue->Load( 'Regression' ); + if ( $queue->id ) { + ok(1, "queue 'Regression' exists - #". $queue->id ); + } else { + $queue->Create( Name => 'Regression' ); + ok($queue->id, "created queue 'Regression'"); + } +} # get the top page my $url = $RT::WebURL; @@ -65,6 +80,7 @@ $agent->submit(); ok($agent->form_name('BuildQuery'), "found the form a third time"); sub getQueryFromForm { + $agent->form_name('BuildQuery'); # This pulls out the "hidden input" query from the page my $q = $agent->current_form->find_input("Query")->value; $q =~ s/^\s+//g; @@ -126,38 +142,37 @@ $agent->select("clauses", ["1"]); $agent->click("Up"); ok($agent->form_name('BuildQuery'), "found the form again"); -TODO: { - local $TODO = "query builder incorrectly changes OR to AND"; - is(getQueryFromForm, "( id > 1234 ) OR Queue != 'Regression'", "moved up"); -} +is(getQueryFromForm, "( id > 1234 ) OR Queue != 'Regression'", "moved up"); $agent->select("clauses", ["0"]); # this is a null clause - $agent->click("Up"); - ok($agent->form_name('BuildQuery'), "found the form again"); - $agent->content_like(qr/error: can\S+t move up/, "i shouldn't have been able to hit up"); $agent->click("Left"); - ok($agent->form_name('BuildQuery'), "found the form again"); - $agent->content_like(qr/error: can\S+t move left/, "i shouldn't have been able to hit left"); $agent->select("clauses", ["1"]); $agent->select("ValueOfStatus" => "stalled"); - $agent->submit; ok($agent->form_name('BuildQuery'), "found the form again"); is_deeply(selectedClauses, ["2"], 'the one we added is selected'); -TODO: { - local $TODO = "query builder incorrectly changes OR to AND"; - is(getQueryFromForm, "( id > 1234 AND Status = 'stalled' ) OR Queue != 'Regression'", "added new one"); +is( getQueryFromForm, "( id > 1234 AND Status = 'stalled' ) OR Queue != 'Regression'", "added new one" ); + +# click advanced, enter "C1 OR ( C2 AND C3 )", apply, aggregators should stay the same. +{ + my $response = $agent->get($url."Search/Edit.html"); + ok( $response->is_success, "Fetched /Search/Edit.html" ); + ok($agent->form_number(3), "found the form"); + $agent->field("Query", "Status = 'new' OR ( Status = 'open' AND Subject LIKE 'office' )"); + $agent->submit; + is( getQueryFromForm, + "Status = 'new' OR ( Status = 'open' AND Subject LIKE 'office' )", + "no aggregators change" + ); } - - # - new items go one level down # - add items at currently selected level # - if nothing is selected, add at end, one level down @@ -200,5 +215,33 @@ TODO: { # }}} +# create a custom field with nonascii name and try to add a condition +{ + my $cf = RT::CustomField->new( $RT::SystemUser ); + $cf->LoadByName( Name => "\x{442}", Queue => 0 ); + if ( $cf->id ) { + is($cf->Type, 'Freeform', 'loaded and type is correct'); + } else { + my ($return, $msg) = $cf->Create( + Name => "\x{442}", + Queue => 0, + Type => 'Freeform', + ); + ok($return, 'created CF') or diag "error: $msg"; + } + + my $response = $agent->get($url."Search/Build.html?NewQuery=1"); + ok( $response->is_success, "Fetched " . $url."Search/Build.html" ); + + ok($agent->form_name('BuildQuery'), "found the form once"); + $agent->field("ValueOf'CF.{\321\202}'", "\321\201"); + $agent->submit(); + is( getQueryFromForm, + "'CF.{\321\202}' LIKE '\321\201'", + "no changes, no duplicate condition with badly encoded text" + ); + + $cf->delete(); +} 1; diff --git a/rt/lib/t/regression/22search_tix_by_txn.t b/rt/lib/t/regression/22search_tix_by_txn.t index f43fc6401..bec61b5ad 100644 --- a/rt/lib/t/regression/22search_tix_by_txn.t +++ b/rt/lib/t/regression/22search_tix_by_txn.t @@ -3,10 +3,9 @@ use warnings; use strict; -#use Test::More tests => 26; -use Test::More qw/no_plan/; +use Test::More tests => 10; -$ENV{'TZ'} = 'GMT'; +BEGIN{ $ENV{'TZ'} = 'GMT'}; use RT; RT::LoadConfig(); @@ -37,4 +36,3 @@ is($txnobj->CreatedObj->ISO,'2005-08-05 20:00:56'); $tix->FromSQL(qq{Updated = "2005-08-05" AND Subject = "$SUBJECT"}); is( $tix->Count, 1); -exit 0; diff --git a/rt/lib/t/regression/22search_tix_by_watcher.t b/rt/lib/t/regression/22search_tix_by_watcher.t index dd87de989..4dd11af1e 100644 --- a/rt/lib/t/regression/22search_tix_by_watcher.t +++ b/rt/lib/t/regression/22search_tix_by_watcher.t @@ -1,23 +1,19 @@ #!/usr/bin/perl -w + use strict; use warnings; -use Test::More qw/no_plan/; +use Test::More tests => 79; use_ok('RT'); RT::LoadConfig(); RT::Init(); use RT::Ticket; -my $q = RT::Queue->new($RT::SystemUser); -my $queue = 'SearchTests-'.rand(200); -$q->Create(Name => $queue); - -my @data = ( - { Subject => '1', Requestor => 'bravo@example.com' }, - { Subject => '2', Cc => 'alpha@example.com' }, -); +my $q = RT::Queue->new( $RT::SystemUser ); +my $queue = 'SearchTests-'. rand(200); +$q->Create( Name => $queue ); -my $total = 0; +my ($total, @data, @tickets, %test) = (0, ()); sub add_tix_from_data { my @res = (); @@ -33,102 +29,118 @@ sub add_tix_from_data { } return @res; } -add_tix_from_data(); -{ - my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue'"); - is($tix->Count, $total, "found $total tickets"); -} +sub run_tests { + my $query_prefix = join ' OR ', map 'id = '. $_->id, @tickets; + foreach my $key ( sort keys %test ) { + my $tix = RT::Tickets->new($RT::SystemUser); + $tix->FromSQL( "( $query_prefix ) AND ( $key )" ); -{ - my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND Requestor = 'bravo\@example.com'"); - is($tix->Count, 1, "found ticket(s)"); - is($tix->First->RequestorAddresses, 'bravo@example.com',"correct requestor"); -} + my $error = 0; -{ - my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND Cc = 'alpha\@example.com'"); - is($tix->Count, 1, "found ticket(s)"); - is($tix->First->CcAddresses, 'alpha@example.com', "correct Cc"); -} + my $count = 0; + $count++ foreach grep $_, values %{ $test{$key} }; + is($tix->Count, $count, "found correct number of ticket(s) by '$key'") or $error = 1; -{ - my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND (Cc = 'alpha\@example.com' OR Requestor = 'bravo\@example.com')"); - is($tix->Count, 2, "found ticket(s)"); - my @mails; - while (my $t = $tix->Next) { - push @mails, $t->RequestorAddresses; - push @mails, $t->CcAddresses; + my $good_tickets = 1; + while ( my $ticket = $tix->Next ) { + next if $test{$key}->{ $ticket->Subject }; + diag $ticket->Subject ." ticket has been found when it's not expected"; + $good_tickets = 0; + } + ok( $good_tickets, "all tickets are good with '$key'" ) or $error = 1; + + diag "Wrong SQL query for '$key':". $tix->BuildSelectQuery if $error; } - @mails = sort grep $_, @mails; - is_deeply(\@mails, ['alpha@example.com', 'bravo@example.com'], "correct addresses"); } -{ - my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND (Cc = 'alpha\@example.com' AND Requestor = 'bravo\@example.com')"); - is($tix->Count, 0, "found ticket(s)"); -} +@data = ( + { Subject => 'xy', Requestor => ['x@example.com', 'y@example.com'] }, + { Subject => 'x', Requestor => 'x@example.com' }, + { Subject => 'y', Requestor => 'y@example.com' }, + { Subject => '-', }, + { Subject => 'z', Requestor => 'z@example.com' }, +); +%test = ( + 'Requestor = "x@example.com"' => { xy => 1, x => 1, y => 0, '-' => 0, z => 0 }, + 'Requestor != "x@example.com"' => { xy => 0, x => 0, y => 1, '-' => 1, z => 1 }, -{ - my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND Cc != 'alpha\@example.com'"); - is($tix->Count, 1, "found ticket(s)"); - is($tix->First->RequestorAddresses, 'bravo@example.com',"correct requestor"); -} + 'Requestor = "y@example.com"' => { xy => 1, x => 0, y => 1, '-' => 0, z => 0 }, + 'Requestor != "y@example.com"' => { xy => 0, x => 1, y => 0, '-' => 1, z => 1 }, -@data = ( { Subject => '3' } ); -add_tix_from_data(); + 'Requestor LIKE "@example.com"' => { xy => 1, x => 1, y => 1, '-' => 0, z => 1 }, + 'Requestor NOT LIKE "@example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 0 }, -{ - my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND Cc != 'alpha\@example.com'"); - is($tix->Count, 2, "found ticket(s)"); - my @mails; - while (my $t = $tix->Next) { push @mails, ($t->CcAddresses||'') } - is( scalar(grep 'alpha@example.com' eq $_, @mails), 0, "no tickets with non required data"); -} + 'Requestor IS NULL' => { xy => 0, x => 0, y => 0, '-' => 1, z => 0 }, + 'Requestor IS NOT NULL' => { xy => 1, x => 1, y => 1, '-' => 0, z => 1 }, -{ - # has no requestor search - my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND Requestor IS NULL"); - is($tix->Count, 2, "found ticket(s)"); - my @mails; - while (my $t = $tix->Next) { push @mails, ($t->RequestorAddresses||'') } - is( scalar(grep $_, @mails), 0, "no tickets with non required data"); -} +# this test is a todo, we run it later +# 'Requestor = "x@example.com" AND Requestor = "y@example.com"' => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 }, + 'Requestor = "x@example.com" OR Requestor = "y@example.com"' => { xy => 1, x => 1, y => 1, '-' => 0, z => 0 }, + + 'Requestor != "x@example.com" AND Requestor != "y@example.com"' => { xy => 0, x => 0, y => 0, '-' => 1, z => 1 }, + 'Requestor != "x@example.com" OR Requestor != "y@example.com"' => { xy => 0, x => 1, y => 1, '-' => 1, z => 1 }, + + 'Requestor = "x@example.com" AND Requestor != "y@example.com"' => { xy => 0, x => 1, y => 0, '-' => 0, z => 0 }, + 'Requestor = "x@example.com" OR Requestor != "y@example.com"' => { xy => 1, x => 1, y => 0, '-' => 1, z => 1 }, + 'Requestor != "x@example.com" AND Requestor = "y@example.com"' => { xy => 0, x => 0, y => 1, '-' => 0, z => 0 }, + 'Requestor != "x@example.com" OR Requestor = "y@example.com"' => { xy => 1, x => 0, y => 1, '-' => 1, z => 1 }, +); +@tickets = add_tix_from_data(); { - # has at least one requestor search my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND Requestor IS NOT NULL"); - is($tix->Count, 1, "found ticket(s)"); - my @mails; - while (my $t = $tix->Next) { push @mails, ($t->RequestorAddresses||'') } - is( scalar(grep !$_, @mails), 0, "no tickets with non required data"); + $tix->FromSQL("Queue = '$queue'"); + is($tix->Count, $total, "found $total tickets"); } - -@data = ( { Subject => '3', Requestor => 'charly@example.com' } ); -add_tix_from_data(); - +run_tests(); + +TODO: { + local $TODO = "we can't generate this query yet"; + %test = ( + 'Requestor = "x@example.com" AND Requestor = "y@example.com"' + => { xy => 1, x => 0, y => 0, '-' => 0, z => 0 }, + ); + run_tests(); +} + +@data = ( + { Subject => 'xy', Cc => ['x@example.com'], Requestor => [ 'y@example.com' ] }, + { Subject => 'x-', Cc => ['x@example.com'], Requestor => [] }, + { Subject => '-y', Cc => [], Requestor => [ 'y@example.com' ] }, + { Subject => '-', }, + { Subject => 'zz', Cc => ['z@example.com'], Requestor => [ 'z@example.com' ] }, + { Subject => 'z-', Cc => ['z@example.com'], Requestor => [] }, + { Subject => '-z', Cc => [], Requestor => [ 'z@example.com' ] }, +); +%test = ( + 'Cc = "x@example.com" AND Requestor = "y@example.com"' => + { xy => 1, 'x-' => 0, '-y' => 0, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 }, + 'Cc = "x@example.com" OR Requestor = "y@example.com"' => + { xy => 1, 'x-' => 1, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 }, + + 'Cc != "x@example.com" AND Requestor = "y@example.com"' => + { xy => 0, 'x-' => 0, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 }, + 'Cc != "x@example.com" OR Requestor = "y@example.com"' => + { xy => 1, 'x-' => 0, '-y' => 1, '-' => 1, zz => 1, 'z-' => 1, '-z' => 1 }, + + 'Cc IS NULL AND Requestor = "y@example.com"' => + { xy => 0, 'x-' => 0, '-y' => 1, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 }, + 'Cc IS NULL OR Requestor = "y@example.com"' => + { xy => 1, 'x-' => 0, '-y' => 1, '-' => 1, zz => 0, 'z-' => 0, '-z' => 1 }, + + 'Cc IS NOT NULL AND Requestor = "y@example.com"' => + { xy => 1, 'x-' => 0, '-y' => 0, '-' => 0, zz => 0, 'z-' => 0, '-z' => 0 }, + 'Cc IS NOT NULL OR Requestor = "y@example.com"' => + { xy => 1, 'x-' => 1, '-y' => 1, '-' => 0, zz => 1, 'z-' => 1, '-z' => 0 }, +); +@tickets = add_tix_from_data(); { - # has no requestor search my $tix = RT::Tickets->new($RT::SystemUser); - $tix->FromSQL("Queue = '$queue' AND - (Requestor = 'bravo\@example.com' OR Requestor = 'charly\@example.com')"); - is($tix->Count, 2, "found ticket(s)"); - my @mails; - while (my $t = $tix->Next) { push @mails, ($t->RequestorAddresses||'') } - is_deeply( [sort @mails], - ['bravo@example.com', 'charly@example.com'], - "requestor addresses are correct" - ); + $tix->FromSQL("Queue = '$queue'"); + is($tix->Count, $total, "found $total tickets"); } +run_tests(); # owner is special watcher because reference is duplicated in two places, # owner was an ENUM field now it's WATCHERFIELD, but should support old @@ -137,12 +149,12 @@ my $nobody = RT::Nobody(); { my $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND Owner = '". $nobody->id ."'"); - is($tix->Count, 4, "found ticket(s)"); + ok($tix->Count, "found ticket(s)"); } { my $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND Owner = '". $nobody->Name ."'"); - is($tix->Count, 4, "found ticket(s)"); + ok($tix->Count, "found ticket(s)"); } { my $tix = RT::Tickets->new($RT::SystemUser); @@ -158,7 +170,7 @@ my $nobody = RT::Nobody(); { my $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND Owner.Name LIKE 'nob'"); - is($tix->Count, 4, "found ticket(s)"); + ok($tix->Count, "found ticket(s)"); } { @@ -176,7 +188,7 @@ my $nobody = RT::Nobody(); my $tix = RT::Tickets->new($RT::SystemUser); $tix->FromSQL("Queue = '$queue' AND Owner = 'Nobody'"); - is($tix->Count, 4, "found ticket(s)"); + is($tix->Count, $total, "found ticket(s)"); } { @@ -189,7 +201,7 @@ my $nobody = RT::Nobody(); ok($id, "granted OwnTicket right to Everyone on '$queue'") or diag("error: $msg"); my $u = RT::User->new( $RT::SystemUser ); - $u->LoadByCols( EmailAddress => 'alpha@example.com' ); + $u->LoadOrCreateByEmail('alpha@example.com'); ok($u->id, "loaded user"); @data = ( { Subject => '4', Owner => $u->id } ); my($t) = add_tix_from_data(); @@ -197,7 +209,7 @@ my $nobody = RT::Nobody(); my $u_alpha_id = $u->id; $u = RT::User->new( $RT::SystemUser ); - $u->LoadByCols( EmailAddress => 'bravo@example.com' ); + $u->LoadOrCreateByEmail('bravo@example.com'); ok($u->id, "loaded user"); @data = ( { Subject => '5', Owner => $u->id } ); ($t) = add_tix_from_data(); @@ -212,4 +224,5 @@ my $nobody = RT::Nobody(); is($tix->Count, 2, "found ticket(s)"); } + exit(0) diff --git a/rt/lib/t/regression/23-web_attachments.t b/rt/lib/t/regression/23-web_attachments.t index d9d1a8440..adc38adb5 100644 --- a/rt/lib/t/regression/23-web_attachments.t +++ b/rt/lib/t/regression/23-web_attachments.t @@ -22,17 +22,17 @@ $m->content_like(qr/Logout/, 'we did log in'); my $qid; { - $m->content =~ /<SELECT\s+NAME\s*="Queue">.*?<OPTION\s+VALUE="(\d+)"\s*\d*>\s*\Q$queue_name\E\s*<\/OPTION>/msi; + $m->content =~ /<SELECT\s+NAME\s*="Queue"\s*>.*?<OPTION\s+VALUE="(\d+)".*?>\s*\Q$queue_name\E\s*<\/OPTION>/msig; ok( $qid = $1, "found id of the '$queue_name' queue"); } -$m->form_number(1); +$m->form_name('CreateTicketInQueue'); $m->field('Queue', $qid); $m->submit; is($m->status, 200, "request successful"); $m->content_like(qr/Create a new ticket/, 'ticket create page'); -$m->form('TicketCreate'); +$m->form_name('TicketCreate'); $m->field('Subject', 'Attachments test'); $m->field('Attach', LogoFile); $m->field('Content', 'Some content'); @@ -44,12 +44,12 @@ $m->content_like(qr/Some content/, 'and content'); $m->content_like(qr/Download bplogo\.gif/, 'page has file name'); $m->follow_link_ok({text => 'Reply'}, "reply to the ticket"); -$m->form('TicketUpdate'); +$m->form_name('TicketUpdate'); $m->field('Attach', LogoFile); $m->click('AddMoreAttach'); is($m->status, 200, "request successful"); -$m->form('TicketUpdate'); +$m->form_name('TicketUpdate'); $m->field('Attach', FaviconFile); $m->field('UpdateContent', 'Message'); $m->click('SubmitTicket'); diff --git a/rt/lib/t/regression/23cfsort.t b/rt/lib/t/regression/23cfsort.t index e90fa36b2..85decc707 100644 --- a/rt/lib/t/regression/23cfsort.t +++ b/rt/lib/t/regression/23cfsort.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -use Test::More tests => 15; +use Test::More tests => 21; use RT; RT::LoadConfig(); RT::Init(); @@ -19,9 +19,11 @@ my($ret,$msg); # ---- Create a queue to test with. my $queue = "CFSortQueue-$$"; -my $queue_obj = RT::Queue->new($RT::SystemUser); -($ret, $msg) = $queue_obj->Create(Name => $queue, - Description => 'queue for custom field sort testing'); +my $queue_obj = RT::Queue->new( $RT::SystemUser ); +($ret, $msg) = $queue_obj->Create( + Name => $queue, + Description => 'queue for custom field sort testing' +); ok($ret, "$queue test queue creation. $msg"); # ---- Create some custom fields. We're not currently using all of @@ -34,7 +36,7 @@ my $cfC = RT::CustomField->new($RT::SystemUser); ($ret, $msg) = $cfO->Create( Name => 'Order', Queue => 0, SortOrder => 1, - Description => q[Something to compare results for, since we can't guarantee ticket ID], + Description => q{Something to compare results for, since we can't guarantee ticket ID}, Type=> 'FreeformSingle'); ok($ret, "Custom Field Order created"); @@ -86,7 +88,8 @@ sub check_order { } my $results = join (" ",@results); my $order = join(" ",@order); - is( $results, $order , "Ordered correctly: $order"); + @_ = ($results, $order , "Ordered correctly: $order"); + goto \&is; } # The real tests start here @@ -110,9 +113,23 @@ check_order( $tx, 2, 1); # in Tickets_Overlay. $tx = new RT::Tickets( $RT::SystemUser ); $tx->FromSQL(qq[queue="$queue"] ); -$tx->OrderBy( FIELD => "CF.{Charlie}", ORDER => 'DES' ); +$tx->OrderBy( FIELD => "CF.{Charlie}", ORDER => 'DESC' ); +diag $tx->BuildSelectQuery; is($tx->Count,2); +TODO: { + local $TODO = 'order by CF fail'; check_order( $tx, 1, 2); +} + +$tx = new RT::Tickets( $RT::SystemUser ); +$tx->FromSQL(qq[queue="$queue"] ); +$tx->OrderBy( FIELD => "CF.{Charlie}", ORDER => 'ASC' ); +diag $tx->BuildSelectQuery; +is($tx->Count,2); +TODO: { + local $TODO = 'order by CF fail'; +check_order( $tx, 2, 1); +} # Add a new ticket, to test sorting on multiple columns. my $t3 = RT::Ticket->new($RT::SystemUser); @@ -126,18 +143,50 @@ $t3->AddCustomFieldValue(Field => $cfC->Id, Value => 'AAA'); $tx = new RT::Tickets( $RT::SystemUser ); $tx->FromSQL(qq[queue="$queue"] ); -$tx->OrderByCols({FIELD => "CF.${queue}.{Charlie}", ORDER => 'ASC'}, - {FIELD => "CF.${queue}.{Alpha}", ORDER => 'DES'} - ); +$tx->OrderByCols( + { FIELD => "CF.${queue}.{Charlie}", ORDER => 'ASC' }, + { FIELD => "CF.${queue}.{Alpha}", ORDER => 'DES' }, +); is($tx->Count,3); +TODO: { + local $TODO = 'order by CF fail'; check_order( $tx, 3, 2, 1); +} + +$tx = new RT::Tickets( $RT::SystemUser ); +$tx->FromSQL(qq[queue="$queue"] ); +$tx->OrderByCols( + { FIELD => "CF.${queue}.{Charlie}", ORDER => 'DES' }, + { FIELD => "CF.${queue}.{Alpha}", ORDER => 'ASC' }, +); +is($tx->Count,3); +TODO: { + local $TODO = 'order by CF fail'; +check_order( $tx, 1, 2, 3); +} # Reverse the order of the secondary column, which changes the order # of the first two tickets. $tx = new RT::Tickets( $RT::SystemUser ); $tx->FromSQL(qq[queue="$queue"] ); -$tx->OrderByCols({FIELD => "CF.${queue}.{Charlie}", ORDER => 'ASC'}, - {FIELD => "CF.${queue}.{Alpha}", ORDER => 'ASC'} - ); +$tx->OrderByCols( + { FIELD => "CF.${queue}.{Charlie}", ORDER => 'ASC' }, + { FIELD => "CF.${queue}.{Alpha}", ORDER => 'ASC' }, +); is($tx->Count,3); +TODO: { + local $TODO = 'order by CF fail'; check_order( $tx, 2, 3, 1); +} + +$tx = new RT::Tickets( $RT::SystemUser ); +$tx->FromSQL(qq[queue="$queue"] ); +$tx->OrderByCols( + { FIELD => "CF.${queue}.{Charlie}", ORDER => 'DES' }, + { FIELD => "CF.${queue}.{Alpha}", ORDER => 'DES' }, +); +is($tx->Count,3); +TODO: { + local $TODO = 'order by CF fail'; +check_order( $tx, 1, 3, 2); +} diff --git a/rt/lib/t/regression/26command_line.t b/rt/lib/t/regression/26command_line.t index 841e2d1c2..457c63aa5 100644 --- a/rt/lib/t/regression/26command_line.t +++ b/rt/lib/t/regression/26command_line.t @@ -3,7 +3,7 @@ use strict; use Test::Expect; #use Test::More qw/no_plan/; -use Test::More tests => 202; +use Test::More tests => 218; use RT; RT::LoadConfig(); @@ -90,6 +90,18 @@ TODO: { # }}} + +# Set up a custom field for editing tests +my $cf = RT::CustomField->new($RT::SystemUser); +my ($val,$msg) = $cf->Create(Name => 'MyCF'.$$, Type => 'FreeformSingle', Queue => $queue_id); +ok($val,$msg); + +my $othercf = RT::CustomField->new($RT::SystemUser); +($val,$msg) = $othercf->Create(Name => 'My CF'.$$, Type => 'FreeformSingle', Queue => $queue_id); +ok($val,$msg); + + + # add a comment to ticket expect_send("comment -m 'comment-$$' $ticket_id", "Adding a comment..."); expect_like(qr/Message recorded/, "Added the comment"); @@ -135,6 +147,24 @@ expect_send("edit ticket/$ticket_id set queue=nonexistent-$$", 'Changing to none expect_like(qr/queue does not exist/i, 'Errored out'); expect_send("show ticket/$ticket_id -f queue", 'Verifying lack of change...'); expect_like(qr/Queue: EditedQueue$$/, 'Verified lack of change'); + +# Test reading and setting custom fields without spaces +expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking initial value'); +expect_like(qr/CF-myCF$$:/i, 'Verified initial empty value'); +expect_send("edit ticket/$ticket_id set 'CF-myCF$$=VALUE' ", 'Changing CF...'); +expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); +expect_send("show ticket/$ticket_id -f CF-myCF$$", 'Checking new value'); +expect_like(qr/CF-myCF$$: VALUE/i, 'Verified change'); +# Test reading and setting custom fields with spaces +expect_send("show ticket/$ticket_id -f 'CF-my CF$$'", 'Checking initial value'); +expect_like(qr/my CF$$:/i, 'Verified change'); +expect_send("edit ticket/$ticket_id set 'CF-my CF$$=VALUE' ", 'Changing CF...'); +expect_like(qr/Ticket $ticket_id updated/, 'Changed cf'); +expect_send("show ticket/$ticket_id -f 'CF-my CF$$'", 'Checking new value'); +expect_like(qr/my CF$$: VALUE/i, 'Verified change'); +expect_send("ls 'id = $ticket_id' -f 'CF-my CF$$'", 'Checking new value'); +expect_like(qr/my CF$$: VALUE/i, 'Verified change'); + # ... # change a ticket's ...[other properties]... # ... |