[Rt-commit] rtir branch 5.0/validate-get-rtir-default-queue created. 5.0.1-22-g152f61e8
BPS Git Server
git at git.bestpractical.com
Tue Nov 2 20:29:46 UTC 2021
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtir".
The branch, 5.0/validate-get-rtir-default-queue has been created
at 152f61e83729821e172043a14957d7d0aaee0f77 (commit)
- Log -----------------------------------------------------------------
commit 152f61e83729821e172043a14957d7d0aaee0f77
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Nov 3 04:06:26 2021 +0800
Add tests for default RTIR queue rights check
diff --git a/t/web/custom_frontpage.t b/t/web/custom_frontpage.t
index 437c8e37..a121a867 100644
--- a/t/web/custom_frontpage.t
+++ b/t/web/custom_frontpage.t
@@ -31,6 +31,24 @@ $m->click_button (name => 'SavedSearchSave');
$m->get ( $url.'RTIR/Prefs/Home.html' );
$m->content_contains('stupid tickets', 'saved search listed in rt at a glance items');
+# Grant rights for RTIR Constituency to get around warnings on create page
+my $constituency_cf = RT::CustomField->new(RT->SystemUser);
+$constituency_cf->Load('RTIR Constituency');
+$user_obj->PrincipalObj->GrantRight( Right => 'SeeCustomField', Object => $constituency_cf );
+
+$m->submit_form_ok( { form_name => 'CreateTicketInQueue' }, 'Try to create ticket' );
+$m->text_contains( 'Permission Denied', 'No permission to create ticket without SeeQueue' );
+$m->warning_like( qr/Permission Denied/, 'Permission denied warning' );
+
+$user_obj->PrincipalObj->GrantRight( Right => 'SeeQueue' );
+$m->submit_form_ok( { form_name => 'CreateTicketInQueue' }, 'Try to create ticket' );
+$m->text_lacks( 'Permission Denied', 'Has permission to view create page' );
+my $form = $m->form_name('TicketCreate');
+my $default_queue = RT::Queue->new( RT->SystemUser );
+$default_queue->Load( RT->Config->Get('RTIR_DefaultQueue') );
+is( $form->value('Queue'), $default_queue->Id, 'Queue selection dropdown populated and pre-selected' );
+
+
ok $m->login('root', 'password', logout => 1), 'we did log in as root';
my $args = {
commit ec63ca9100e4e4e127c72b86e7c9dabc85eb9003
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Nov 2 03:51:44 2021 +0800
Load queue object in GetRTIRDefaultQueue to make sure it's valid and visible
This is initially to avoid info leak, especially when the config is set
to a name.
To be consistent with documentation, now it always returns ID if found.
Previously it could be NAME if config is set to a name like "Incident
Reports", which is the default value.
diff --git a/html/Callbacks/RTIR/Elements/Tabs/Privileged b/html/Callbacks/RTIR/Elements/Tabs/Privileged
index 419b62da..eabfbde0 100644
--- a/html/Callbacks/RTIR/Elements/Tabs/Privileged
+++ b/html/Callbacks/RTIR/Elements/Tabs/Privileged
@@ -608,7 +608,7 @@ PageWidgets()->child('simple_search')->raw_html( $m->scomp(
SendTo => RT::IR->HREFTo('index.html', IncludeWebPath => 0),
Placeholder => 'Search Incidents'
) );
-PageWidgets()->child( create_ticket => raw_html => $HTML::Mason::Commands::m->scomp('/Elements/CreateTicket', SendTo => '/RTIR/Create.html?Queue=' . RT::IR::GetRTIRDefaultQueue()) );
+PageWidgets()->child( create_ticket => raw_html => $HTML::Mason::Commands::m->scomp('/Elements/CreateTicket', SendTo => '/RTIR/Create.html?Queue=' . (RT::IR::GetRTIRDefaultQueue() // '')) );
if ( $request_path =~ m{$re_rtir_path(?:Incident/)?Create\.html} ) {
if ( $request_path =~ m{${re_rtir_path}Incident/Create\.html} ) {
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 2fd6b31a..14fe33b3 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -280,8 +280,9 @@ sub GetRTIRDefaultQueue {
my $queue;
$queue = RT->Config->Get( "RTIR_DefaultQueue", $HTML::Mason::Commands::session{'CurrentUser'} );
-
- return $queue;
+ my $obj = RT::Queue->new( $HTML::Mason::Commands::session{'CurrentUser'} );
+ $obj->Load($queue);
+ return defined $obj->Name ? $obj->Id : undef;
}
=head2 Lifecycles
-----------------------------------------------------------------------
hooks/post-receive
--
rtir
More information about the rt-commit
mailing list