summaryrefslogtreecommitdiff
path: root/rt/t/api
diff options
context:
space:
mode:
Diffstat (limited to 'rt/t/api')
-rw-r--r--rt/t/api/action-createtickets.t2
-rw-r--r--rt/t/api/date.t30
-rw-r--r--rt/t/api/group.t22
-rw-r--r--rt/t/api/rights.t50
-rw-r--r--rt/t/api/rights_show_ticket.t1
-rw-r--r--rt/t/api/searchbuilder.t26
6 files changed, 97 insertions, 34 deletions
diff --git a/rt/t/api/action-createtickets.t b/rt/t/api/action-createtickets.t
index c37e2ed12..ceed4231c 100644
--- a/rt/t/api/action-createtickets.t
+++ b/rt/t/api/action-createtickets.t
@@ -105,7 +105,7 @@ is ($dependson->FirstCustomFieldValue('GlobalCF'), 'A Value',
'global custom field was set');
is ($dependson->FirstCustomFieldValue('QueueCF'), 'Another Value',
'queue custom field was set');
-unlike ($dependson->Subject, qr/{/, "The subject doesn't have braces in it. that means we're interpreting expressions");
+unlike ($dependson->Subject, qr/\{/, "The subject doesn't have braces in it. that means we're interpreting expressions");
is ($t->ReferredToBy->Count,1, "It's only referred to by one other ticket");
is ($t->ReferredToBy->First->BaseObj->Id,$t->DependsOn->First->TargetObj->Id, "The same ticket that depends on it refers to it.");
use RT::Action::CreateTickets;
diff --git a/rt/t/api/date.t b/rt/t/api/date.t
index 728a4a2bc..cc1c694cc 100644
--- a/rt/t/api/date.t
+++ b/rt/t/api/date.t
@@ -94,7 +94,7 @@ my $current_user;
'1970-01-01T00:00:00Z',
"W3CDTF format with defaults");
is($date->Get(Format =>'RFC2822'),
- 'Thu, 1 Jan 1970 00:00:00 +0000',
+ 'Thu, 01 Jan 1970 00:00:00 +0000',
"RFC2822 format with defaults");
is($date->Get(Format =>'LocalizedDateTime'),
'Thu, Jan 1, 1970 12:00:00 AM',
@@ -107,7 +107,7 @@ my $current_user;
'1970-01-01',
"W3CDTF format without time part");
is($date->RFC2822(Time => 0),
- 'Thu, 1 Jan 1970',
+ 'Thu, 01 Jan 1970',
"RFC2822 format without time part");
is($date->LocalizedDateTime(Time => 0),
'Thu, Jan 1, 1970',
@@ -137,7 +137,7 @@ my $current_user;
"RFC2822 format without date part and seconds");
is($date->RFC2822(DayOfWeek => 0),
- '1 Jan 1970 00:00:00 +0000',
+ '01 Jan 1970 00:00:00 +0000',
"RFC2822 format without 'day of week' part");
is($date->RFC2822(DayOfWeek => 0, Date => 0),
'00:00:00 +0000',
@@ -163,7 +163,7 @@ my $current_user;
'1970-01-01',
"'Date' method, W3CDTF format");
is($date->Date(Format => 'RFC2822'),
- 'Thu, 1 Jan 1970',
+ 'Thu, 01 Jan 1970',
"'Date' method, RFC2822 format");
is($date->Date(Time => 1),
'1970-01-01',
@@ -195,7 +195,7 @@ my $current_user;
'1970-01-01T00:00:00Z',
"'DateTime' method, W3CDTF format");
is($date->DateTime(Format =>'RFC2822'),
- 'Thu, 1 Jan 1970 00:00:00 +0000',
+ 'Thu, 01 Jan 1970 00:00:00 +0000',
"'DateTime' method, RFC2822 format");
is($date->DateTime(Date => 0, Time => 0),
'1970-01-01 00:00:00',
@@ -209,14 +209,14 @@ my $current_user;
$date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-01-01 15:10:00' );
is($date->ISO( Timezone => 'user' ), '2005-01-01 18:10:00', "ISO");
is($date->W3CDTF( Timezone => 'user' ), '2005-01-01T18:10:00+03:00', "W3C DTF");
- is($date->RFC2822( Timezone => 'user' ), 'Sat, 1 Jan 2005 18:10:00 +0300', "RFC2822");
+ is($date->RFC2822( Timezone => 'user' ), 'Sat, 01 Jan 2005 18:10:00 +0300', "RFC2822");
# DST
$date = RT::Date->new( $current_user );
$date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-07-01 15:10:00' );
is($date->ISO( Timezone => 'user' ), '2005-07-01 19:10:00', "ISO");
is($date->W3CDTF( Timezone => 'user' ), '2005-07-01T19:10:00+04:00', "W3C DTF");
- is($date->RFC2822( Timezone => 'user' ), 'Fri, 1 Jul 2005 19:10:00 +0400', "RFC2822");
+ is($date->RFC2822( Timezone => 'user' ), 'Fri, 01 Jul 2005 19:10:00 +0400', "RFC2822");
}
{ # negative timezone
@@ -225,14 +225,14 @@ my $current_user;
$date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-01-01 15:10:00' );
is($date->ISO( Timezone => 'user' ), '2005-01-01 10:10:00', "ISO");
is($date->W3CDTF( Timezone => 'user' ), '2005-01-01T10:10:00-05:00', "W3C DTF");
- is($date->RFC2822( Timezone => 'user' ), 'Sat, 1 Jan 2005 10:10:00 -0500', "RFC2822");
+ is($date->RFC2822( Timezone => 'user' ), 'Sat, 01 Jan 2005 10:10:00 -0500', "RFC2822");
# DST
$date = RT::Date->new( $current_user );
$date->Set( Format => 'ISO', Timezone => 'utc', Value => '2005-07-01 15:10:00' );
is($date->ISO( Timezone => 'user' ), '2005-07-01 11:10:00', "ISO");
is($date->W3CDTF( Timezone => 'user' ), '2005-07-01T11:10:00-04:00', "W3C DTF");
- is($date->RFC2822( Timezone => 'user' ), 'Fri, 1 Jul 2005 11:10:00 -0400', "RFC2822");
+ is($date->RFC2822( Timezone => 'user' ), 'Fri, 01 Jul 2005 11:10:00 -0400', "RFC2822");
}
warning_like
@@ -306,8 +306,6 @@ my $year = (localtime(time))[5] + 1900;
{ # set+datemanip format(Time::ParseDate)
my $date = RT::Date->new(RT->SystemUser);
- $date->Set(Format => 'unknown', Value => 'weird date');
- is($date->Unix, 0, "date was wrong");
RT->Config->Set( Timezone => 'Europe/Moscow' );
$date->Set(Format => 'datemanip', Value => '2005-11-28 15:10:00');
@@ -325,7 +323,9 @@ my $year = (localtime(time))[5] + 1900;
{ # set+unknown format(Time::ParseDate)
my $date = RT::Date->new(RT->SystemUser);
- $date->Set(Format => 'unknown', Value => 'weird date');
+ warnings_like {
+ $date->Set(Format => 'unknown', Value => 'weird date');
+ } qr{Couldn't parse date 'weird date' by Time::ParseDate};
is($date->Unix, 0, "date was wrong");
RT->Config->Set( Timezone => 'Europe/Moscow' );
@@ -456,12 +456,12 @@ my $year = (localtime(time))[5] + 1900;
RT->Config->Set( DateTimeFormat => 'RFC2822' );
$date->Unix(1);
- is($date->AsString, 'Thu, 1 Jan 1970 00:00:01 +0000', "correct string");
+ is($date->AsString, 'Thu, 01 Jan 1970 00:00:01 +0000', "correct string");
RT->Config->Set( DateTimeFormat => { Format => 'RFC2822', Seconds => 0 } );
$date->Unix(1);
- is($date->AsString, 'Thu, 1 Jan 1970 00:00 +0000', "correct string");
- is($date->AsString(Seconds => 1), 'Thu, 1 Jan 1970 00:00:01 +0000', "correct string");
+ is($date->AsString, 'Thu, 01 Jan 1970 00:00 +0000', "correct string");
+ is($date->AsString(Seconds => 1), 'Thu, 01 Jan 1970 00:00:01 +0000', "correct string");
}
{ # DurationAsString
diff --git a/rt/t/api/group.t b/rt/t/api/group.t
index 2c1ca73cf..d55fc5c4a 100644
--- a/rt/t/api/group.t
+++ b/rt/t/api/group.t
@@ -20,11 +20,19 @@ ok($ng->LoadUserDefinedGroup('TestGroup'), "Loaded testgroup");
is($ng->id , $group->id, "Loaded the right group");
-ok (($id,$msg) = $ng->AddMember('1'), "Added a member to the group");
+my @users = (undef);
+for my $number (1..3) {
+ my $user = RT::User->new(RT->SystemUser);
+ $user->Create( Name => "User $number" );
+ push @users, $user->id;
+}
+
+
+ok (($id,$msg) = $ng->AddMember( $users[1] ), "Added a member to the group");
ok($id, $msg);
-ok (($id,$msg) = $ng->AddMember('2' ), "Added a member to the group");
+ok (($id,$msg) = $ng->AddMember( $users[2] ), "Added a member to the group");
ok($id, $msg);
-ok (($id,$msg) = $ng->AddMember('3' ), "Added a member to the group");
+ok (($id,$msg) = $ng->AddMember( $users[3] ), "Added a member to the group");
ok($id, $msg);
# Group 1 now has members 1, 2 ,3
@@ -34,7 +42,7 @@ ok (my ($id_2, $msg_2) = $group_2->CreateUserDefinedGroup( Name => 'TestGroup2',
isnt ($id_2 , 0, "Created group 2 ok- $msg_2 ");
ok (($id,$msg) = $group_2->AddMember($ng->PrincipalId), "Made TestGroup a member of testgroup2");
ok($id, $msg);
-ok (($id,$msg) = $group_2->AddMember('1' ), "Added member RT_System to the group TestGroup2");
+ok (($id,$msg) = $group_2->AddMember( $users[1] ), "Added member User 1 to the group TestGroup2");
ok($id, $msg);
# Group 2 how has 1, g1->{1, 2,3}
@@ -48,12 +56,12 @@ ok($id, $msg);
# g3 now has g2->{1, g1->{1,2,3}}
my $principal_1 = RT::Principal->new(RT->SystemUser);
-$principal_1->Load('1');
+$principal_1->Load( $users[1] );
my $principal_2 = RT::Principal->new(RT->SystemUser);
-$principal_2->Load('2');
+$principal_2->Load( $users[2] );
-ok (($id,$msg) = $group_3->AddMember('1' ), "Added member RT_System to the group TestGroup2");
+ok (($id,$msg) = $group_3->AddMember( $users[1] ), "Added member User 1 to the group TestGroup2");
ok($id, $msg);
# g3 now has 1, g2->{1, g1->{1,2,3}}
diff --git a/rt/t/api/rights.t b/rt/t/api/rights.t
index 107fb2b35..5cf3a0008 100644
--- a/rt/t/api/rights.t
+++ b/rt/t/api/rights.t
@@ -1,17 +1,14 @@
-use RT::Test nodata => 1, tests => 30;
+use RT::Test nodata => 1, tests => 38;
use strict;
use warnings;
+use Test::Warn;
+
+sub reset_rights { RT::Test->set_rights }
+
# 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;
- }
-}
+reset_rights;
my $queue = RT::Test->load_or_create_queue( Name => 'Regression' );
ok $queue && $queue->id, 'loaded or created queue';
@@ -146,3 +143,38 @@ my $ticket2;
"user is not AdminCc and can't modify ticket2 (same question different answer)"
);
}
+
+my $queue2 = RT::Test->load_or_create_queue( Name => 'Rights' );
+ok $queue2 && $queue2->id, 'loaded or created queue';
+
+my $user2 = RT::Test->load_or_create_user(
+ Name => 'user2', Password => 'password',
+);
+ok $user2 && $user2->id, 'Created user: ' . $user2->Name . ' with id ' . $user2->Id;
+
+warning_like {
+ ok( !$user2->HasRight( Right => 'Foo', Object => $queue2 ),
+ "HasRight false for invalid right Foo"
+ );
+} qr/Invalid right\. Couldn't canonicalize right 'Foo'/,
+ 'Got warning on invalid right';
+
+
+note "Right name canonicalization";
+{
+ reset_rights;
+ my ($ok, $msg) = $user->PrincipalObj->GrantRight(
+ Right => "showticket",
+ Object => RT->System,
+ );
+ ok $ok, "Granted showticket: $msg";
+ ok $user->HasRight( Right => "ShowTicket", Object => RT->System ), "HasRight ShowTicket";
+
+ reset_rights;
+ ($ok, $msg) = $user->PrincipalObj->GrantRight(
+ Right => "ShowTicket",
+ Object => RT->System,
+ );
+ ok $ok, "Granted ShowTicket: $msg";
+ ok $user->HasRight( Right => "showticket", Object => RT->System ), "HasRight showticket";
+}
diff --git a/rt/t/api/rights_show_ticket.t b/rt/t/api/rights_show_ticket.t
index c8107fe07..b7bec70de 100644
--- a/rt/t/api/rights_show_ticket.t
+++ b/rt/t/api/rights_show_ticket.t
@@ -207,7 +207,6 @@ diag "Testing with UseSQLForACLChecks => $option";
}
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 (
diff --git a/rt/t/api/searchbuilder.t b/rt/t/api/searchbuilder.t
index 8562bfc2b..84568718d 100644
--- a/rt/t/api/searchbuilder.t
+++ b/rt/t/api/searchbuilder.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
use RT;
-use RT::Test tests => 11;
+use RT::Test tests => 19;
{
@@ -37,3 +37,27 @@ is_deeply(\@items_ids, \@sorted_ids, "ItemsArrayRef sorts alphabetically by name
}
+#20767: CleanSlate doesn't clear RT::SearchBuilder's flags for handling Disabled columns
+{
+ my $items;
+
+ ok(my $queues = RT::Queues->new(RT->SystemUser), 'Created a queues object');
+ ok( $queues->UnLimit(),'Unlimited the result set of the queues object');
+
+ # sanity check
+ is( $queues->{'handled_disabled_column'} => undef, 'handled_disabled_column IS NOT set' );
+ is( $queues->{'find_disabled_rows'} => undef, 'find_disabled_rows IS NOT set ' );
+
+ $queues->LimitToDeleted;
+
+ # sanity check
+ ok( $queues->{'handled_disabled_column'}, 'handled_disabled_column IS set' );
+ ok( $queues->{'find_disabled_rows'}, 'find_disabled_rows IS set ' );
+
+ $queues->CleanSlate;
+
+ # these fail without the overloaded CleanSlate method
+ is( $queues->{'handled_disabled_column'} => undef, 'handled_disabled_column IS NOT set' );
+ is( $queues->{'find_disabled_rows'} => undef, 'find_disabled_rows IS NOT set ' );
+}
+