diff options
author | ivan <ivan> | 2010-05-18 18:49:59 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-05-18 18:49:59 +0000 |
commit | e70abd21bab68b23488f7ef1ee2e693a3b365691 (patch) | |
tree | 75986ffa9ba6ab4f961f9033468a1344e1653408 /rt/t | |
parent | b4b0c7e72d7eaee2fbfc7022022c9698323203dd (diff) |
import rt 3.8.8
Diffstat (limited to 'rt/t')
-rw-r--r-- | rt/t/api/emailparser.t | 17 | ||||
-rw-r--r-- | rt/t/api/rights.t | 227 | ||||
-rw-r--r-- | rt/t/api/rights_show_ticket.t | 262 | ||||
-rw-r--r-- | rt/t/customfields/sort_order.t | 6 | ||||
-rw-r--r-- | rt/t/data/configs/apache2.2+fastcgi.conf | 4 | ||||
-rw-r--r-- | rt/t/data/configs/apache2.2+fastcgi.conf.in | 4 | ||||
-rw-r--r-- | rt/t/data/configs/apache2.2+mod_perl.conf | 1 | ||||
-rw-r--r-- | rt/t/data/configs/apache2.2+mod_perl.conf.in | 1 | ||||
-rw-r--r-- | rt/t/mail/charsets-outgoing.t | 99 | ||||
-rw-r--r-- | rt/t/ticket/merge.t | 49 | ||||
-rw-r--r-- | rt/t/web/cf_access.t | 12 | ||||
-rw-r--r-- | rt/t/web/cf_onqueue.t | 11 | ||||
-rw-r--r-- | rt/t/web/cf_select_one.t | 4 | ||||
-rw-r--r-- | rt/t/web/custom_frontpage.t | 2 | ||||
-rw-r--r-- | rt/t/web/dashboards.t | 8 | ||||
-rw-r--r-- | rt/t/web/search_rss.t | 74 | ||||
-rw-r--r-- | rt/t/web/ticket-create-utf8.t | 94 |
17 files changed, 666 insertions, 209 deletions
diff --git a/rt/t/api/emailparser.t b/rt/t/api/emailparser.t index 4807138cc..940c26fde 100644 --- a/rt/t/api/emailparser.t +++ b/rt/t/api/emailparser.t @@ -1,32 +1,19 @@ use strict; use warnings; -use RT; + use RT::Test tests => 4; +RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i ); -{ ok(require RT::EmailParser); - -} - -{ - is(RT::EmailParser::IsRTAddress("","rt\@example.com"),1, "Regexp matched rt address" ); is(RT::EmailParser::IsRTAddress("","frt\@example.com"),undef, "Regexp didn't match non-rt address" ); - -} - -{ - my @before = ("rt\@example.com", "frt\@example.com"); my @after = ("frt\@example.com"); ok(eq_array(RT::EmailParser::CullRTAddresses("",@before),@after), "CullRTAddresses only culls RT addresses"); - -} - 1; diff --git a/rt/t/api/rights.t b/rt/t/api/rights.t index 7bd332f13..a38bcea0c 100644 --- a/rt/t/api/rights.t +++ b/rt/t/api/rights.t @@ -47,96 +47,151 @@ # # END BPS TAGGED BLOCK }}} -use RT; -use RT::Test tests => 26; +use RT::Test tests => 30; -use RT::I18N; use strict; -no warnings 'once'; +use warnings; -use RT::Queue; -use RT::ACE; -use RT::User; -use RT::Group; -use RT::Ticket; +# clear all global right +{ + my $acl = RT::ACL->new($RT::SystemUser); + $acl->Limit( FIELD => 'RightName', OPERATOR => '!=', VALUE => 'SuperUser' ); + $acl->LimitToObject( $RT::System ); + while( my $ace = $acl->Next ) { + $ace->Delete; + } +} +my $queue = RT::Test->load_or_create_queue( Name => 'Regression' ); +ok $queue && $queue->id, 'loaded or created queue'; +my $qname = $queue->Name; + +my $user = RT::Test->load_or_create_user( + Name => 'user', Password => 'password', +); +ok $user && $user->id, 'loaded or created user'; + +{ + ok( !$user->HasRight( Right => 'OwnTicket', Object => $queue ), + "user can't own ticket" + ); + ok( !$user->HasRight( Right => 'ReplyToTicket', Object => $queue ), + "user can't reply to ticket" + ); +} -# clear all global right -my $acl = RT::ACL->new($RT::SystemUser); -$acl->Limit( FIELD => 'RightName', OPERATOR => '!=', VALUE => 'SuperUser' ); -$acl->LimitToObject( $RT::System ); -while( my $ace = $acl->Next ) { - $ace->Delete; +{ + my $group = RT::Group->new( $RT::SystemUser ); + ok( $group->LoadQueueRoleGroup( Queue => $queue->id, Type=> 'Owner' ), + "load queue owners role group" + ); + my $ace = RT::ACE->new( $RT::SystemUser ); + my ($ace_id, $msg) = $group->PrincipalObj->GrantRight( + Right => 'ReplyToTicket', Object => $queue + ); + ok( $ace_id, "Granted queue owners role group with ReplyToTicket right: $msg" ); + ok( $group->PrincipalObj->HasRight( Right => 'ReplyToTicket', Object => $queue ), + "role group can reply to ticket" + ); + ok( !$user->HasRight( Right => 'ReplyToTicket', Object => $queue ), + "user can't reply to ticket" + ); +} + +my $ticket; +{ + # new ticket + $ticket = RT::Ticket->new($RT::SystemUser); + my ($ticket_id) = $ticket->Create( Queue => $queue->id, Subject => 'test'); + ok( $ticket_id, 'new ticket created' ); + is( $ticket->Owner, $RT::Nobody->Id, 'owner of the new ticket is nobody' ); + + ok( !$user->HasRight( Right => 'OwnTicket', Object => $ticket ), + "user can't reply to ticket" + ); + my ($status, $msg) = $ticket->SetOwner( $user->id ); + ok( !$status, "no permissions to be an owner" ); +} + +{ + my ($status, $msg) = $user->PrincipalObj->GrantRight( + Object => $queue, Right => 'OwnTicket' + ); + ok( $status, "successfuly granted right: $msg" ); + ok( $user->HasRight( Right => 'OwnTicket', Object => $queue ), + "user can own ticket" + ); + ok( $user->HasRight( Right => 'OwnTicket', Object => $ticket ), + "user can own ticket" + ); + + ($status, $msg) = $ticket->SetOwner( $user->id ); + ok( $status, "successfuly set owner: $msg" ); + is( $ticket->Owner, $user->id, "set correct owner" ); + + ok( $user->HasRight( Right => 'ReplyToTicket', Object => $ticket ), + "user is owner and can reply to ticket" + ); } -my $rand_name = "rights". int rand($$); -# create new queue to be shure we don't mess with rights -my $queue = RT::Queue->new($RT::SystemUser); -my ($queue_id) = $queue->Create( Name => $rand_name); -ok( $queue_id, 'queue created for rights tests' ); - -# new privileged user to check rights -my $user = RT::User->new( $RT::SystemUser ); -my ($user_id) = $user->Create( Name => $rand_name, - EmailAddress => $rand_name .'@localhost', - Privileged => 1, - Password => 'qwe123', - ); -ok( !$user->HasRight( Right => 'OwnTicket', Object => $queue ), "user can't own ticket" ); -ok( !$user->HasRight( Right => 'ReplyToTicket', Object => $queue ), "user can't reply to ticket" ); - -my $group = RT::Group->new( $RT::SystemUser ); -ok( $group->LoadQueueRoleGroup( Queue => $queue_id, Type=> 'Owner' ), "load queue owners role group" ); -my $ace = RT::ACE->new( $RT::SystemUser ); -my ($ace_id, $msg) = $group->PrincipalObj->GrantRight( Right => 'ReplyToTicket', Object => $queue ); -ok( $ace_id, "Granted queue owners role group with ReplyToTicket right: $msg" ); -ok( $group->PrincipalObj->HasRight( Right => 'ReplyToTicket', Object => $queue ), "role group can reply to ticket" ); -ok( !$user->HasRight( Right => 'ReplyToTicket', Object => $queue ), "user can't reply to ticket" ); - -# new ticket -my $ticket = RT::Ticket->new($RT::SystemUser); -my ($ticket_id) = $ticket->Create( Queue => $queue_id, Subject => 'test'); -ok( $ticket_id, 'new ticket created' ); -is( $ticket->Owner, $RT::Nobody->Id, 'owner of the new ticket is nobody' ); - -my $status; -($status, $msg) = $user->PrincipalObj->GrantRight( Object => $queue, Right => 'OwnTicket' ); -ok( $status, "successfuly granted right: $msg" ); -ok( $user->HasRight( Right => 'OwnTicket', Object => $queue ), "user can own ticket" ); - -($status, $msg) = $ticket->SetOwner( $user_id ); -ok( $status, "successfuly set owner: $msg" ); -is( $ticket->Owner, $user_id, "set correct owner" ); - -ok( $user->HasRight( Right => 'ReplyToTicket', Object => $ticket ), "user is owner and can reply to ticket" ); - -# Testing of EquivObjects -$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 ); -($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" ); -($status, $msg) = $ticket->AddWatcher(Type => 'AdminCc', PrincipalId => $user->PrincipalId); -ok( $status, "successfuly added user as AdminCc"); -ok( $user->HasRight( Right => 'ModifyTicket', Object => $ticket ), "user is AdminCc and can modify ticket" ); - -my $ticket2 = RT::Ticket->new($RT::SystemUser); -my ($ticket2_id) = $ticket2->Create( Queue => $queue_id, Subject => 'test2'); -ok( $ticket2_id, 'new ticket created' ); -ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2 ), "user is not AdminCc and can't modify ticket2" ); - -# now we can finally test EquivObjects -my $equiv = [ $ticket ]; -ok( $user->HasRight( Right => 'ModifyTicket', Object => $ticket2, EquivObjects => $equiv ), - "user is not AdminCc but can modify ticket2 because of EquivObjects" ); - -# the first a third test below are the same, so they should both pass -my $equiv2 = []; -ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2, EquivObjects => $equiv2 ), - "user is not AdminCc and can't modify ticket2" ); -ok( $user->HasRight( Right => 'ModifyTicket', Object => $ticket, EquivObjects => $equiv2 ), - "user is AdminCc and can modify ticket" ); -ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2, EquivObjects => $equiv2 ), - "user is not AdminCc and can't modify ticket2 (same question different answer)" ); +{ + # Testing of EquivObjects + my $group = RT::Group->new( $RT::SystemUser ); + ok( $group->LoadQueueRoleGroup( Queue => $queue->id, Type=> 'AdminCc' ), + "load queue AdminCc role group" + ); + my $ace = RT::ACE->new( $RT::SystemUser ); + my ($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" + ); +} + +{ + my ($status, $msg) = $ticket->AddWatcher( + Type => 'AdminCc', PrincipalId => $user->PrincipalId + ); + ok( $status, "successfuly added user as AdminCc"); + ok( $user->HasRight( Right => 'ModifyTicket', Object => $ticket ), + "user is AdminCc and can modify ticket" + ); +} + +my $ticket2; +{ + $ticket2 = RT::Ticket->new($RT::SystemUser); + my ($id) = $ticket2->Create( Queue => $queue->id, Subject => 'test2'); + ok( $id, 'new ticket created' ); + ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2 ), + "user is not AdminCc and can't modify ticket2" + ); + + # now we can finally test EquivObjectsa + my $has = $user->HasRight( + Right => 'ModifyTicket', + Object => $ticket2, + EquivObjects => [$ticket], + ); + ok( $has, "user is not AdminCc but can modify ticket2 because of EquivObjects" ); +} + +{ + # the first a third test below are the same, so they should both pass + # make sure passed equive list is not changed + my @list = (); + ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2, EquivObjects => \@list ), + "user is not AdminCc and can't modify ticket2" + ); + ok( $user->HasRight( Right => 'ModifyTicket', Object => $ticket, EquivObjects => \@list ), + "user is AdminCc and can modify ticket" + ); + ok( !$user->HasRight( Right => 'ModifyTicket', Object => $ticket2, EquivObjects => \@list ), + "user is not AdminCc and can't modify ticket2 (same question different answer)" + ); +} diff --git a/rt/t/api/rights_show_ticket.t b/rt/t/api/rights_show_ticket.t new file mode 100644 index 000000000..3e1d0740f --- /dev/null +++ b/rt/t/api/rights_show_ticket.t @@ -0,0 +1,262 @@ +#!/usr/bin/perl -w + +use RT::Test tests => 264; + +use strict; +use warnings; + + +my $queue_a = RT::Test->load_or_create_queue( Name => 'A' ); +ok $queue_a && $queue_a->id, 'loaded or created queue_a'; +my $qa_id = $queue_a->id; + +my $queue_b = RT::Test->load_or_create_queue( Name => 'B' ); +ok $queue_b && $queue_b->id, 'loaded or created queue_b'; +my $qb_id = $queue_b->id; + +my $user_a = RT::Test->load_or_create_user( + Name => 'user_a', Password => 'password', +); +ok $user_a && $user_a->id, 'loaded or created user'; + +my $user_b = RT::Test->load_or_create_user( + Name => 'user_b', Password => 'password', +); +ok $user_b && $user_b->id, 'loaded or created user'; + +foreach my $option (0 .. 1 ) { RT->Config->Set( 'UseSQLForACLChecks' => $option ); + +diag "Testing with UseSQLForACLChecks => $option"; + +# Global Cc has right, a User is nobody +{ + cleanup(); + RT::Test->set_rights( + { Principal => 'Everyone', Right => [qw(SeeQueue)] }, + { Principal => 'Cc', Right => [qw(ShowTicket)] }, + ); + create_tickets_set(); + have_no_rights($user_a, $user_b); +} + +# Global Cc has right, a User is Queue Cc +{ + cleanup(); + RT::Test->set_rights( + { Principal => 'Everyone', Right => [qw(SeeQueue)] }, + { Principal => 'Cc', Right => [qw(ShowTicket)] }, + ); + create_tickets_set(); + have_no_rights($user_a, $user_b); + + my ($status, $msg) = $queue_a->AddWatcher( Type => 'Cc', PrincipalId => $user_a->id ); + ok($status, "user A is now queue A watcher"); + + foreach my $q ( + '', + "Queue = $qa_id OR Queue = $qb_id", + "Queue = $qb_id OR Queue = $qa_id", + ) { + my $tickets = RT::Tickets->new( RT::CurrentUser->new( $user_a ) ); + $q? $tickets->FromSQL($q) : $tickets->UnLimit; + my $found = 0; + while ( my $t = $tickets->Next ) { + $found++; + is( $t->Queue, $queue_a->id, "user sees tickets only in queue A" ); + } + is($found, 2, "user sees tickets"); + } + have_no_rights( $user_b ); +} + +# global Cc has right, a User is ticket Cc +{ + cleanup(); + RT::Test->set_rights( + { Principal => 'Everyone', Right => [qw(SeeQueue)] }, + { Principal => 'Cc', Right => [qw(ShowTicket)] }, + ); + my @tickets = create_tickets_set(); + have_no_rights($user_a, $user_b); + + my ($status, $msg) = $tickets[1]->AddWatcher( Type => 'Cc', PrincipalId => $user_a->id ); + ok($status, "user A is now queue A watcher"); + + foreach my $q ( + '', + "Queue = $qa_id OR Queue = $qb_id", + "Queue = $qb_id OR Queue = $qa_id", + ) { + my $tickets = RT::Tickets->new( RT::CurrentUser->new( $user_a ) ); + $q? $tickets->FromSQL($q) : $tickets->UnLimit; + my $found = 0; + while ( my $t = $tickets->Next ) { + $found++; + is( $t->Queue, $queue_a->id, "user sees tickets only in queue A" ); + is( $t->id, $tickets[1]->id, "correct ticket"); + } + is($found, 1, "user sees tickets"); + } + have_no_rights($user_b); +} + +# Queue Cc has right, a User is nobody +{ + cleanup(); + RT::Test->set_rights( + { Principal => 'Everyone', Right => [qw(SeeQueue)] }, + { Principal => 'Cc', Object => $queue_a, Right => [qw(ShowTicket)] }, + ); + create_tickets_set(); + have_no_rights($user_a, $user_b); +} + +# Queue Cc has right, Users are Queue Ccs +{ + cleanup(); + RT::Test->set_rights( + { Principal => 'Everyone', Right => [qw(SeeQueue)] }, + { Principal => 'Cc', Object => $queue_a, Right => [qw(ShowTicket)] }, + ); + create_tickets_set(); + have_no_rights($user_a, $user_b); + + my ($status, $msg) = $queue_a->AddWatcher( Type => 'Cc', PrincipalId => $user_a->id ); + ok($status, "user A is now queue A watcher"); + + ($status, $msg) = $queue_b->AddWatcher( Type => 'Cc', PrincipalId => $user_b->id ); + ok($status, "user B is now queue B watcher"); + + foreach my $q ( + '', + "Queue = $qa_id OR Queue = $qb_id", + "Queue = $qb_id OR Queue = $qa_id", + ) { + my $tickets = RT::Tickets->new( RT::CurrentUser->new( $user_a ) ); + $q? $tickets->FromSQL($q) : $tickets->UnLimit; + my $found = 0; + while ( my $t = $tickets->Next ) { + $found++; + is( $t->Queue, $queue_a->id, "user sees tickets only in queue A" ); + } + is($found, 2, "user sees tickets"); + } + have_no_rights( $user_b ); +} + +# Queue Cc has right, Users are ticket Ccs +{ + cleanup(); + RT::Test->set_rights( + { Principal => 'Everyone', Right => [qw(SeeQueue)] }, + { Principal => 'Cc', Object => $queue_a, Right => [qw(ShowTicket)] }, + ); + my @tickets = create_tickets_set(); + have_no_rights($user_a, $user_b); + + my ($status, $msg) = $tickets[1]->AddWatcher( Type => 'Cc', PrincipalId => $user_a->id ); + ok($status, "user A is now Cc on a ticket in queue A"); + + ($status, $msg) = $tickets[2]->AddWatcher( Type => 'Cc', PrincipalId => $user_b->id ); + ok($status, "user B is now Cc on a ticket in queue B"); + + foreach my $q ( + '', + "Queue = $qa_id OR Queue = $qb_id", + "Queue = $qb_id OR Queue = $qa_id", + ) { + my $tickets = RT::Tickets->new( RT::CurrentUser->new( $user_a ) ); + $q? $tickets->FromSQL($q) : $tickets->UnLimit; + my $found = 0; + while ( my $t = $tickets->Next ) { + $found++; + is( $t->Queue, $queue_a->id, "user sees tickets only in queue A" ); + is( $t->id, $tickets[1]->id, ) + } + is($found, 1, "user sees tickets"); + } + have_no_rights( $user_b ); +} + +# Users has direct right on queue +{ + cleanup(); + RT::Test->set_rights( + { Principal => 'Everyone', Right => [qw(SeeQueue)] }, + { Principal => $user_a, Object => $queue_a, Right => [qw(ShowTicket)] }, + ); + my @tickets = create_tickets_set(); + + foreach my $q ( + '', + "Queue = $qa_id OR Queue = $qb_id", + "Queue = $qb_id OR Queue = $qa_id", + ) { + my $tickets = RT::Tickets->new( RT::CurrentUser->new( $user_a ) ); + $q? $tickets->FromSQL($q) : $tickets->UnLimit; + my $found = 0; + while ( my $t = $tickets->Next ) { + $found++; + is( $t->Queue, $queue_a->id, "user sees tickets only in queue A" ); + } + is($found, 2, "user sees tickets"); + } + have_no_rights( $user_b ); +} + + +} + +sub have_no_rights { + $SIG{'INT'} = $SIG{'TERM'} = sub { print STDERR Carp::longmess('boo'); exit 1 }; + local $Test::Builder::Level = $Test::Builder::Level + 1; + foreach my $u ( @_ ) { + foreach my $q ( + '', + "Queue = $qa_id OR Queue = $qb_id", + "Queue = $qb_id OR Queue = $qa_id", + ) { + my $tickets = RT::Tickets->new( RT::CurrentUser->new( $u ) ); + $q? $tickets->FromSQL($q) : $tickets->UnLimit; + ok(!$tickets->First, "no tickets"); + } + } +} + +sub create_tickets_set{ + local $Test::Builder::Level = $Test::Builder::Level + 1; + my @res; + foreach my $q ($queue_a, $queue_b) { + foreach my $n (1 .. 2) { + my $ticket = RT::Ticket->new( $RT::SystemUser ); + my ($tid) = $ticket->Create( + Queue => $q->id, Subject => $q->Name .' - '. $n + ); + ok( $tid, "created ticket #$tid"); + push @res, $ticket; + } + } + return @res; +} + +sub cleanup { delete_tickets(); delete_watchers() }; + +sub delete_tickets { + my $tickets = RT::Tickets->new( $RT::SystemUser ); + $tickets->FromSQL( "Queue = $qa_id OR Queue = $qb_id" ); + while ( my $ticket = $tickets->Next ) { + $ticket->Delete; + } +} + +sub delete_watchers { + foreach my $q ($queue_a, $queue_b) { + foreach my $u ($user_a, $user_b) { + foreach my $t (qw(Cc AdminCc) ) { + $q->DeleteWatcher( Type => $t, PrincipalId => $u->id ) + if $q->IsWatcher( Type => $t, PrincipalId => $u->id ); + } + } + } +} + diff --git a/rt/t/customfields/sort_order.t b/rt/t/customfields/sort_order.t index 472eb6bf3..c5c808ceb 100644 --- a/rt/t/customfields/sort_order.t +++ b/rt/t/customfields/sort_order.t @@ -56,9 +56,9 @@ diag "reorder CFs: C, A and B" if $ENV{TEST_VERBOSE}; my @tmp = ($m->content =~ /(CF [ABC])/g); is_deeply(\@tmp, ['CF B', 'CF A', 'CF C']); - $m->follow_link_ok( {text => 'Move up', n => 2} ); - $m->follow_link_ok( {text => 'Move up', n => 1} ); - $m->follow_link_ok( {text => 'Move up', n => 2} ); + $m->follow_link_ok( {text => '[Up]', n => 3} ); + $m->follow_link_ok( {text => '[Up]', n => 2} ); + $m->follow_link_ok( {text => '[Up]', n => 3} ); @tmp = ($m->content =~ /(CF [ABC])/g); is_deeply(\@tmp, ['CF C', 'CF A', 'CF B']); diff --git a/rt/t/data/configs/apache2.2+fastcgi.conf b/rt/t/data/configs/apache2.2+fastcgi.conf index f9b3b1034..c9d9cb0b9 100644 --- a/rt/t/data/configs/apache2.2+fastcgi.conf +++ b/rt/t/data/configs/apache2.2+fastcgi.conf @@ -1,11 +1,11 @@ ServerRoot %%SERVER_ROOT%% PidFile %%PID_FILE%% +LockFile %%LOCK_FILE%% ServerAdmin root@localhost %%LOAD_MODULES%% -TypesConfig /etc/mime.types -FastCgiIpcDir /tmp +FastCgiIpcDir %%TMP_DIR%% <IfModule !mpm_netware_module> <IfModule !mpm_winnt_module> diff --git a/rt/t/data/configs/apache2.2+fastcgi.conf.in b/rt/t/data/configs/apache2.2+fastcgi.conf.in index c0c01d1a5..75cbadbca 100644 --- a/rt/t/data/configs/apache2.2+fastcgi.conf.in +++ b/rt/t/data/configs/apache2.2+fastcgi.conf.in @@ -1,11 +1,11 @@ ServerRoot %%SERVER_ROOT%% PidFile %%PID_FILE%% +LockFile %%LOCK_FILE%% ServerAdmin root@localhost %%LOAD_MODULES%% -TypesConfig /etc/mime.types -FastCgiIpcDir /tmp +FastCgiIpcDir %%TMP_DIR%% <IfModule !mpm_netware_module> <IfModule !mpm_winnt_module> diff --git a/rt/t/data/configs/apache2.2+mod_perl.conf b/rt/t/data/configs/apache2.2+mod_perl.conf index 341ae5024..9f4587e04 100644 --- a/rt/t/data/configs/apache2.2+mod_perl.conf +++ b/rt/t/data/configs/apache2.2+mod_perl.conf @@ -1,5 +1,6 @@ ServerRoot %%SERVER_ROOT%% PidFile %%PID_FILE%% +LockFile %%LOCK_FILE%% ServerAdmin root@localhost %%LOAD_MODULES%% diff --git a/rt/t/data/configs/apache2.2+mod_perl.conf.in b/rt/t/data/configs/apache2.2+mod_perl.conf.in index ed12c8690..3d28c2cca 100644 --- a/rt/t/data/configs/apache2.2+mod_perl.conf.in +++ b/rt/t/data/configs/apache2.2+mod_perl.conf.in @@ -1,5 +1,6 @@ ServerRoot %%SERVER_ROOT%% PidFile %%PID_FILE%% +LockFile %%LOCK_FILE%% ServerAdmin root@localhost %%LOAD_MODULES%% diff --git a/rt/t/mail/charsets-outgoing.t b/rt/t/mail/charsets-outgoing.t index ca44bbd27..e8f78cc1a 100644 --- a/rt/t/mail/charsets-outgoing.t +++ b/rt/t/mail/charsets-outgoing.t @@ -1,10 +1,22 @@ #!/usr/bin/perl use strict; use warnings; -use utf8; - -use RT::Test tests => 30; - +use Encode; + +use RT::Test tests => 78; + +my %string = ( + ru => { + test => "\x{442}\x{435}\x{441}\x{442}", + autoreply => "\x{410}\x{432}\x{442}\x{43e}\x{43e}\x{442}\x{432}\x{435}\x{442}", + support => "\x{43f}\x{43e}\x{434}\x{434}\x{435}\x{440}\x{436}\x{43a}\x{430}", + }, + latin1 => { + test => Encode::decode('latin1', "t\xE9st"), + autoreply => Encode::decode('latin1', "a\xFCtoreply"), + support => Encode::decode('latin1', "supp\xF5rt"), + }, +); RT::Test->set_mail_catcher; @@ -49,17 +61,13 @@ diag "basic test of autoreply" if $ENV{'TEST_VERBOSE'}; ok @mails, "got some outgoing emails"; } -my $str_ru_test = "\x{442}\x{435}\x{441}\x{442}"; -my $str_ru_autoreply = "\x{410}\x{432}\x{442}\x{43e}\x{43e}\x{442}\x{432}\x{435}\x{442}"; -my $str_ru_support = "\x{43f}\x{43e}\x{434}\x{434}\x{435}\x{440}\x{436}\x{43a}\x{430}"; - diag "non-ascii Subject with ascii prefix set in the template" if $ENV{'TEST_VERBOSE'}; -{ +foreach my $set ( 'ru', 'latin1' ) { my $ticket = RT::Ticket->new( $RT::SystemUser ); $ticket->Create( Queue => $queue->id, - Subject => $str_ru_test, + Subject => $string{$set}{test}, Requestor => 'root@localhost', ); my @mails = RT::Test->fetch_caught_mails; @@ -69,15 +77,17 @@ diag "non-ascii Subject with ascii prefix set in the template" foreach my $mail ( @mails ) { my $entity = parse_mail( $mail ); my $subject = Encode::decode_utf8( $entity->head->get('Subject') ); - $subject =~ /$str_ru_test/ + $subject =~ /$string{$set}{test}/ or do { $status = 0; diag "wrong subject: $subject" }; } ok $status, "all mails have correct data"; } +foreach my $tag_set ( 'ru', 'latin1' ) { + diag "set non-ascii subject tag for the queue" if $ENV{'TEST_VERBOSE'}; { - my ($status, $msg) = $queue->SetSubjectTag( $str_ru_support ); + my ($status, $msg) = $queue->SetSubjectTag( $string{$tag_set}{support} ); ok $status, "set subject tag for the queue" or diag "error: $msg"; } @@ -96,18 +106,18 @@ diag "ascii subject with non-ascii subject tag" if $ENV{'TEST_VERBOSE'}; foreach my $mail ( @mails ) { my $entity = parse_mail( $mail ); my $subject = Encode::decode_utf8( $entity->head->get('Subject') ); - $subject =~ /$str_ru_support/ + $subject =~ /$string{$tag_set}{support}/ or do { $status = 0; diag "wrong subject: $subject" }; } ok $status, "all mails have correct data"; } diag "non-ascii subject with non-ascii subject tag" if $ENV{'TEST_VERBOSE'}; -{ +foreach my $set ( 'ru', 'latin1' ) { my $ticket = RT::Ticket->new( $RT::SystemUser ); $ticket->Create( Queue => $queue->id, - Subject => $str_ru_test, + Subject => $string{$set}{test}, Requestor => 'root@localhost', ); my @mails = RT::Test->fetch_caught_mails; @@ -117,20 +127,25 @@ diag "non-ascii subject with non-ascii subject tag" if $ENV{'TEST_VERBOSE'}; foreach my $mail ( @mails ) { my $entity = parse_mail( $mail ); my $subject = Encode::decode_utf8( $entity->head->get('Subject') ); - $subject =~ /$str_ru_support/ + $subject =~ /$string{$tag_set}{support}/ or do { $status = 0; diag "wrong subject: $subject" }; - $subject =~ /$str_ru_test/ + $subject =~ /$string{$set}{test}/ or do { $status = 0; diag "wrong subject: $subject" }; } ok $status, "all mails have correct data"; } +} # subject tag + diag "return back the empty subject tag" if $ENV{'TEST_VERBOSE'}; { my ($status, $msg) = $queue->SetSubjectTag( undef ); ok $status, "set subject tag for the queue" or diag "error: $msg"; } + +foreach my $prefix_set ( 'ru', 'latin1' ) { + diag "add non-ascii subject prefix in the autoreply template" if $ENV{'TEST_VERBOSE'}; { my $template = RT::Template->new( $RT::SystemUser ); @@ -138,7 +153,7 @@ diag "add non-ascii subject prefix in the autoreply template" if $ENV{'TEST_VERB ok $template->id, "loaded autoreply tempalte"; my ($status, $msg) = $template->SetContent( - "Subject: $str_ru_autoreply { \$Ticket->Subject }\n" + "Subject: $string{$prefix_set}{autoreply} { \$Ticket->Subject }\n" ."\n" ."hi there it's an autoreply.\n" ."\n" @@ -161,7 +176,7 @@ diag "ascii subject with non-ascii subject prefix in template" if $ENV{'TEST_VER foreach my $mail ( @mails ) { my $entity = parse_mail( $mail ); my $subject = Encode::decode_utf8( $entity->head->get('Subject') ); - $subject =~ /$str_ru_autoreply/ + $subject =~ /$string{$prefix_set}{autoreply}/ or do { $status = 0; diag "wrong subject: $subject" }; } ok $status, "all mails have correct data"; @@ -169,11 +184,11 @@ diag "ascii subject with non-ascii subject prefix in template" if $ENV{'TEST_VER diag "non-ascii subject with non-ascii subject prefix in template" if $ENV{'TEST_VERBOSE'}; -{ +foreach my $set ( 'ru', 'latin1' ) { my $ticket = RT::Ticket->new( $RT::SystemUser ); $ticket->Create( Queue => $queue->id, - Subject => $str_ru_test, + Subject => $string{$set}{test}, Requestor => 'root@localhost', ); my @mails = RT::Test->fetch_caught_mails; @@ -183,27 +198,28 @@ diag "non-ascii subject with non-ascii subject prefix in template" foreach my $mail ( @mails ) { my $entity = parse_mail( $mail ); my $subject = Encode::decode_utf8( $entity->head->get('Subject') ); - $subject =~ /$str_ru_autoreply/ + $subject =~ /$string{$prefix_set}{autoreply}/ or do { $status = 0; diag "wrong subject: $subject" }; - $subject =~ /$str_ru_autoreply/ + $subject =~ /$string{$set}{test}/ or do { $status = 0; diag "wrong subject: $subject" }; } ok $status, "all mails have correct data"; } +foreach my $tag_set ( 'ru', 'latin1' ) { diag "set non-ascii subject tag for the queue" if $ENV{'TEST_VERBOSE'}; { - my ($status, $msg) = $queue->SetSubjectTag( $str_ru_support ); + my ($status, $msg) = $queue->SetSubjectTag( $string{$tag_set}{support} ); ok $status, "set subject tag for the queue" or diag "error: $msg"; } diag "non-ascii subject, non-ascii prefix in template and non-ascii tag" if $ENV{'TEST_VERBOSE'}; -{ +foreach my $set ( 'ru', 'latin1' ) { my $ticket = RT::Ticket->new( $RT::SystemUser ); $ticket->Create( Queue => $queue->id, - Subject => $str_ru_test, + Subject => $string{$set}{test}, Requestor => 'root@localhost', ); my @mails = RT::Test->fetch_caught_mails; @@ -213,24 +229,30 @@ diag "non-ascii subject, non-ascii prefix in template and non-ascii tag" foreach my $mail ( @mails ) { my $entity = parse_mail( $mail ); my $subject = Encode::decode_utf8( $entity->head->get('Subject') ); - $subject =~ /$str_ru_autoreply/ + $subject =~ /$string{$prefix_set}{autoreply}/ or do { $status = 0; diag "wrong subject: $subject" }; - $subject =~ /$str_ru_autoreply/ + $subject =~ /$string{$tag_set}{support}/ or do { $status = 0; diag "wrong subject: $subject" }; - $subject =~ /$str_ru_autoreply/ + $subject =~ /$string{$set}{test}/ or do { $status = 0; diag "wrong subject: $subject" }; } ok $status, "all mails have correct data"; } +} # subject tag + diag "flush subject tag of the queue" if $ENV{'TEST_VERBOSE'}; { my ($status, $msg) = $queue->SetSubjectTag( undef ); ok $status, "set subject tag for the queue" or diag "error: $msg"; } +} # prefix set + diag "don't change subject via template" if $ENV{'TEST_VERBOSE'}; +# clean DB has autoreply that always changes subject in template, +# we should test situation when subject is not changed from template { my $template = RT::Template->new( $RT::SystemUser ); $template->Load('Autoreply'); @@ -246,11 +268,11 @@ diag "don't change subject via template" if $ENV{'TEST_VERBOSE'}; } diag "non-ascii Subject without changes in template" if $ENV{'TEST_VERBOSE'}; -{ +foreach my $set ( 'ru', 'latin1' ) { my $ticket = RT::Ticket->new( $RT::SystemUser ); $ticket->Create( Queue => $queue->id, - Subject => $str_ru_test, + Subject => $string{$set}{test}, Requestor => 'root@localhost', ); my @mails = RT::Test->fetch_caught_mails; @@ -260,25 +282,26 @@ diag "non-ascii Subject without changes in template" if $ENV{'TEST_VERBOSE'}; foreach my $mail ( @mails ) { my $entity = parse_mail( $mail ); my $subject = Encode::decode_utf8( $entity->head->get('Subject') ); - $subject =~ /$str_ru_test/ + $subject =~ /$string{$set}{test}/ or do { $status = 0; diag "wrong subject: $subject" }; } ok $status, "all mails have correct data"; } +foreach my $tag_set ( 'ru', 'latin1' ) { diag "set non-ascii subject tag for the queue" if $ENV{'TEST_VERBOSE'}; { - my ($status, $msg) = $queue->SetSubjectTag( $str_ru_support ); + my ($status, $msg) = $queue->SetSubjectTag( $string{$tag_set}{support} ); ok $status, "set subject tag for the queue" or diag "error: $msg"; } diag "non-ascii Subject without changes in template and with non-ascii subject tag" if $ENV{'TEST_VERBOSE'}; -{ +foreach my $set ( 'ru', 'latin1' ) { my $ticket = RT::Ticket->new( $RT::SystemUser ); $ticket->Create( Queue => $queue->id, - Subject => $str_ru_test, + Subject => $string{$set}{test}, Requestor => 'root@localhost', ); my @mails = RT::Test->fetch_caught_mails; @@ -288,14 +311,16 @@ diag "non-ascii Subject without changes in template and with non-ascii subject t foreach my $mail ( @mails ) { my $entity = parse_mail( $mail ); my $subject = Encode::decode_utf8( $entity->head->get('Subject') ); - $subject =~ /$str_ru_test/ + $subject =~ /$string{$set}{test}/ or do { $status = 0; diag "wrong subject: $subject" }; - $subject =~ /$str_ru_support/ + $subject =~ /$string{$tag_set}{support}/ or do { $status = 0; diag "wrong subject: $subject" }; } ok $status, "all mails have correct data"; } +} # subject tag set + sub parse_mail { my $mail = shift; require RT::EmailParser; diff --git a/rt/t/ticket/merge.t b/rt/t/ticket/merge.t index a714cb6cc..7c72fe08f 100644 --- a/rt/t/ticket/merge.t +++ b/rt/t/ticket/merge.t @@ -5,7 +5,7 @@ use warnings; use RT; -use RT::Test tests => '17'; +use RT::Test tests => '29'; # validate that when merging two tickets, the comments from both tickets @@ -16,7 +16,10 @@ use RT::Test tests => '17'; ok ($id,$msg); my $t1 = RT::Ticket->new($RT::SystemUser); - my ($tid,$transid, $t1msg) =$t1->Create ( Queue => $queue->Name, Subject => 'Merge test. orig'); + my ($tid,$transid, $t1msg) =$t1->Create( + Queue => $queue->Name, + Subject => 'Merge test. orig', + ); ok ($tid, $t1msg); ($id, $msg) = $t1->Comment(Content => 'This is a Comment on the original'); ok($id,$msg); @@ -90,3 +93,45 @@ use RT::Test tests => '17'; ($id,$val) = $t->MergeInto($t2->id); ok($id,$val); } + +my $user = RT::Test->load_or_create_user( + Name => 'a user', Password => 'password', +); +ok $user && $user->id, 'loaded or created user'; + +# check rights +{ + RT::Test->set_rights( + { Principal => 'Everyone', Right => [qw(SeeQueue ShowTicket CreateTicket OwnTicket TakeTicket)] }, + { Principal => 'Owner', Right => [qw(ModifyTicket)] }, + ); + + my $t = RT::Ticket->new(RT::CurrentUser->new($user)); + $t->Create(Subject => 'Main', Queue => 'general'); + ok ($t->id, "Created ticket"); + + my $t2 = RT::Ticket->new(RT::CurrentUser->new($user)); + $t2->Create(Subject => 'Second', Queue => 'general'); + ok ($t2->id, "Created ticket"); + + foreach my $ticket ( $t, $t2 ) { + ok( !$ticket->CurrentUserHasRight('ModifyTicket'), "can not modify" ); + } + + my ($status,$msg) = $t->MergeInto($t2->id); + ok(!$status, "Can not merge: $msg"); + + ($status, $msg) = $t->SetOwner( $user->id ); + ok( $status, "User took ticket"); + ok( $t->CurrentUserHasRight('ModifyTicket'), "can modify after take" ); + + ($status,$msg) = $t->MergeInto($t2->id); + ok(!$status, "Can not merge: $msg"); + + ($status, $msg) = $t2->SetOwner( $user->id ); + ok( $status, "User took ticket"); + ok( $t2->CurrentUserHasRight('ModifyTicket'), "can modify after take" ); + + ($status,$msg) = $t->MergeInto($t2->id); + ok($status, "Merged tickets: $msg"); +} diff --git a/rt/t/web/cf_access.t b/rt/t/web/cf_access.t index 1022c6da6..183597b4a 100644 --- a/rt/t/web/cf_access.t +++ b/rt/t/web/cf_access.t @@ -43,16 +43,14 @@ my ( $cf, $cfid, $tid ); $m->form_name('EditCustomFields'); # Sort by numeric IDs in names - my @names = map { $_->[1] } - sort { $a->[0] <=> $b->[0] } - map { /Object-1-CF-(\d+)/ ? [ $1 => $_ ] : () } - grep defined, map $_->name, $m->current_form->inputs; + my @names = sort grep defined, + $m->current_form->find_input('AddCustomField')->possible_values; $cf = pop(@names); $cf =~ /(\d+)$/ or die "Hey this is impossible dude"; $cfid = $1; - $m->field( $cf => 1 ); # Associate the new CF with this queue - $m->field( $_ => undef ) for @names; # ...and not any other. ;-) - $m->submit; + $m->tick( AddCustomField => $cf => 1 ); # Associate the new CF with this queue + $m->tick( AddCustomField => $_ => 0 ) for @names; # ...and not any other. ;-) + $m->click('UpdateCFs'); $m->content_like( qr/Object created/, 'TCF added to the queue' ); } diff --git a/rt/t/web/cf_onqueue.t b/rt/t/web/cf_onqueue.t index dcd585277..bed4dd188 100644 --- a/rt/t/web/cf_onqueue.t +++ b/rt/t/web/cf_onqueue.t @@ -34,12 +34,11 @@ diag "Apply the new CF globally" if $ENV{'TEST_VERBOSE'}; $m->follow_link( url => 'Queues.html' ); $m->title_is(q/Edit Custom Fields for all queues/, 'global custom field for all queues configuration screen'); $m->content_like( qr/QueueCFTest/, 'CF QueueCFTest displayed on page' ); - $m->submit_form( - form_name => "EditCustomFields", - fields => { - 'Object--CF-1' => '1', - }, - ); + + $m->form_name('EditCustomFields'); + $m->tick( AddCustomField => 1 ); + $m->click('UpdateCFs'); + $m->content_like( qr/Object created/, 'CF QueueCFTest enabled globally' ); } diff --git a/rt/t/web/cf_select_one.t b/rt/t/web/cf_select_one.t index e009af7cf..39a808083 100644 --- a/rt/t/web/cf_select_one.t +++ b/rt/t/web/cf_select_one.t @@ -58,8 +58,8 @@ diag "apply the CF to General queue" if $ENV{'TEST_VERBOSE'}; $m->title_is(q/Edit Custom Fields for General/, 'admin-queue: general cfid'); $m->form_name('EditCustomFields'); - $m->field( "Object-". $queue->id ."-CF-$cfid" => 1 ); - $m->submit; + $m->tick( "AddCustomField" => $cfid ); + $m->click('UpdateCFs'); $m->content_like( qr/Object created/, 'TCF added to the queue' ); } diff --git a/rt/t/web/custom_frontpage.t b/rt/t/web/custom_frontpage.t index 45a390ab0..79ea56629 100644 --- a/rt/t/web/custom_frontpage.t +++ b/rt/t/web/custom_frontpage.t @@ -13,7 +13,7 @@ $user_obj->SetName('customer'); $user_obj->SetPrivileged(1); ($ret, $msg) = $user_obj->SetPassword('customer'); $user_obj->PrincipalObj->GrantRight(Right => 'LoadSavedSearch'); -$user_obj->PrincipalObj->GrantRight(Right => 'EditSavedSearch'); +$user_obj->PrincipalObj->GrantRight(Right => 'EditSavedSearches'); $user_obj->PrincipalObj->GrantRight(Right => 'CreateSavedSearch'); $user_obj->PrincipalObj->GrantRight(Right => 'ModifySelf'); diff --git a/rt/t/web/dashboards.t b/rt/t/web/dashboards.t index 9d98ce6e4..a816eb35c 100644 --- a/rt/t/web/dashboards.t +++ b/rt/t/web/dashboards.t @@ -133,14 +133,14 @@ $ticket->Create( ); $m->follow_link_ok({text => 'different dashboard'}); -$m->content_contains("20 highest priority tickets I own"); -$m->content_contains("20 newest unowned tickets"); +$m->content_contains("50 highest priority tickets I own"); +$m->content_contains("50 newest unowned tickets"); $m->content_lacks("Bookmarked Tickets"); $m->content_contains("dashboard test", "ticket subject"); $m->get_ok("/Dashboards/$id/This fragment left intentionally blank"); -$m->content_contains("20 highest priority tickets I own"); -$m->content_contains("20 newest unowned tickets"); +$m->content_contains("50 highest priority tickets I own"); +$m->content_contains("50 newest unowned tickets"); $m->content_lacks("Bookmarked Tickets"); $m->content_contains("dashboard test", "ticket subject"); diff --git a/rt/t/web/search_rss.t b/rt/t/web/search_rss.t new file mode 100644 index 000000000..454dc0369 --- /dev/null +++ b/rt/t/web/search_rss.t @@ -0,0 +1,74 @@ +#!/usr/bin/perl + +use strict; + +use RT::Test tests => 36; +RT::Test->started_ok; + +my $ticket = RT::Ticket->new($RT::SystemUser); +for ( 1 .. 5 ) { + $ticket->Create( + Subject => 'Ticket ' . $_, + Queue => 'General', + Owner => 'root', + Requestor => 'rss@localhost', + ); +} + +my $agent = RT::Test::Web->new; +ok $agent->login('root', 'password'), 'logged in as root'; + +$agent->get_ok('/Search/Build.html'); +$agent->form_name('BuildQuery'); +$agent->field('idOp', '>'); +$agent->field('ValueOfid', '0'); +$agent->submit('DoSearch'); +$agent->follow_link_ok({text=>'Show Results'}); + +for ( 1 .. 5 ) { + $agent->content_contains('Ticket ' . $_); +} +my $rdf_path = $agent->uri->path_query; +$rdf_path =~ s!Results\.html!Results.rdf!; + +$agent->follow_link_ok( { text => 'RSS' } ); +my $noauth_uri = $agent->uri; +is( $agent->content_type, 'application/rss+xml', 'content type' ); +for ( 1 .. 5 ) { + $agent->content_contains('Ticket ' . $_); +} +my $rss_content = $agent->content; +$agent->get_ok($rdf_path); +is($agent->content, $rss_content, 'old Results.rdf still works'); + +SKIP: { + eval { require XML::Simple; }; + skip 'no XML::Simple found', 6 if $@; + my $rss = XML::Simple::XMLin( $rss_content ); + is( scalar @{ $rss->{item} }, 5, 'item number' ); + for ( 1 .. 5 ) { + is( $rss->{item}[$_-1]{title}, 'Ticket ' . $_, 'title' . $_ ); + } +} + +# not login at all +my $agent_b = RT::Test::Web->new; +$agent_b->get_ok($noauth_uri); +is( $agent_b->content_type, 'application/rss+xml', 'content type' ); +is( $agent_b->content, $rss_content, 'content' ); +$agent_b->get_ok('/', 'back to homepage'); +$agent_b->content_lacks( 'Logout', 'still not login' ); + +# lets login as another user +my $user_b = RT::Test->load_or_create_user( + Name => 'user_b', Password => 'password', +); +ok $user_b && $user_b->id, 'loaded or created user'; +$agent_b->login('user_b', 'password'), 'logged in as user B'; +$agent_b->get_ok($noauth_uri); +is( $agent_b->content_type, 'application/rss+xml', 'content type' ); +is( $agent_b->content, $rss_content, 'content' ); +$agent_b->get_ok('/', 'back to homepage'); +$agent_b->content_contains( 'Logout', 'still loggedin' ); +$agent_b->content_contains( 'user_b', 'still loggedin as user_b' ); + diff --git a/rt/t/web/ticket-create-utf8.t b/rt/t/web/ticket-create-utf8.t index a4d7ae98d..f37eeec06 100644 --- a/rt/t/web/ticket-create-utf8.t +++ b/rt/t/web/ticket-create-utf8.t @@ -3,16 +3,21 @@ use strict; use warnings; -use RT::Test tests => 14; +use RT::Test tests => 41; $RT::Test::SKIP_REQUEST_WORK_AROUND = 1; use Encode; my $ru_test = "\x{442}\x{435}\x{441}\x{442}"; -my $ru_autoreply = "\x{410}\x{432}\x{442}\x{43e}\x{43e}\x{442}\x{432}\x{435}\x{442}"; my $ru_support = "\x{43f}\x{43e}\x{434}\x{434}\x{435}\x{440}\x{436}\x{43a}\x{430}"; +# latin-1 is very special in perl, we should test everything with latin-1 umlauts +# and not-ascii+not-latin1, for example cyrillic +my $l1_test = Encode::decode('latin-1', "t\xE9st"); +my $l1_support = Encode::decode('latin-1', "supp\xF6rt"); + + my $q = RT::Test->load_or_create_queue( Name => 'Regression' ); ok $q && $q->id, 'loaded or created queue'; @@ -25,59 +30,64 @@ my ($baseurl, $m) = RT::Test->started_ok; ok $m->login, 'logged in'; # create a ticket with a subject only -{ +foreach my $test_str ( $ru_test, $l1_test ) { ok $m->goto_create_ticket( $q ), "go to create ticket"; $m->form_number(3); - $m->field( Subject => $ru_test ); + $m->field( Subject => $test_str ); $m->submit; $m->content_like( - qr{<td\s+class="message-header-value"[^>]*>\s*\Q$ru_test\E\s*</td>}i, + qr{<td\s+class="message-header-value"[^>]*>\s*\Q$test_str\E\s*</td>}i, 'header on the page' ); my $ticket = RT::Test->last_ticket; - is $ticket->Subject, $ru_test, "correct subject"; + is $ticket->Subject, $test_str, "correct subject"; } # create a ticket with a subject and content -{ - ok $m->goto_create_ticket( $q ), "go to create ticket"; - $m->form_number(3); - $m->field( Subject => $ru_test ); - $m->field( Content => $ru_support ); - $m->submit; - - $m->content_like( - qr{<td\s+class="message-header-value"[^>]*>\s*\Q$ru_test\E\s*</td>}i, - 'header on the page' - ); - $m->content_like( - qr{\Q$ru_support\E}i, - 'content on the page' - ); - - my $ticket = RT::Test->last_ticket; - is $ticket->Subject, $ru_test, "correct subject"; +foreach my $test_str ( $ru_test, $l1_test ) { + foreach my $support_str ( $ru_support, $l1_support ) { + ok $m->goto_create_ticket( $q ), "go to create ticket"; + $m->form_number(3); + $m->field( Subject => $test_str ); + $m->field( Content => $support_str ); + $m->submit; + + $m->content_like( + qr{<td\s+class="message-header-value"[^>]*>\s*\Q$test_str\E\s*</td>}i, + 'header on the page' + ); + $m->content_like( + qr{\Q$support_str\E}i, + 'content on the page' + ); + + my $ticket = RT::Test->last_ticket; + is $ticket->Subject, $test_str, "correct subject"; + } } # create a ticket with a subject and content -{ - ok $m->goto_create_ticket( $q ), "go to create ticket"; - $m->form_number(3); - $m->field( Subject => $ru_test ); - $m->field( Content => $ru_support ); - $m->submit; - - $m->content_like( - qr{<td\s+class="message-header-value"[^>]*>\s*\Q$ru_test\E\s*</td>}i, - 'header on the page' - ); - $m->content_like( - qr{\Q$ru_support\E}i, - 'content on the page' - ); - - my $ticket = RT::Test->last_ticket; - is $ticket->Subject, $ru_test, "correct subject"; +foreach my $test_str ( $ru_test, $l1_test ) { + foreach my $support_str ( $ru_support, $l1_support ) { + ok $m->goto_create_ticket( $q ), "go to create ticket"; + $m->form_number(3); + $m->field( Subject => $test_str ); + $m->field( Content => $support_str ); + $m->submit; + + $m->content_like( + qr{<td\s+class="message-header-value"[^>]*>\s*\Q$test_str\E\s*</td>}i, + 'header on the page' + ); + $m->content_like( + qr{\Q$support_str\E}i, + 'content on the page' + ); + + my $ticket = RT::Test->last_ticket; + is $ticket->Subject, $test_str, "correct subject"; + } } + |