[Rt-commit] rt branch, 4.0/owners-from-disabled-groups, created. rt-4.0.4-172-gb7eb9cb
Thomas Sibley
trs at bestpractical.com
Mon Jan 9 15:38:49 EST 2012
The branch, 4.0/owners-from-disabled-groups has been created
at b7eb9cbcc34931857fc2403eeab30d0663a17e72 (commit)
- Log -----------------------------------------------------------------
commit b7eb9cbcc34931857fc2403eeab30d0663a17e72
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Jan 9 15:34:04 2012 -0500
Test that RT::Users->WhoHaveRight doesn't pick up disabled groups
This test file currently fails. The bug is noticeable in the owner
lists since SelectOwner is the only place which uses WhoHaveRight.
Fixing it requires checking Disabled on the Principals table joined
against Groups (not Users, which is already joined). Alternatively, we
should be able to check Disabled on CachedGroupMembers as long as we
make sure the check always goes through CGM instead of sometimes
GroupMembers and sometimes CGM.
diff --git a/t/web/owner_disabled_group_19221.t b/t/web/owner_disabled_group_19221.t
new file mode 100644
index 0000000..f64af90
--- /dev/null
+++ b/t/web/owner_disabled_group_19221.t
@@ -0,0 +1,65 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my $queue = RT::Test->load_or_create_queue( Name => 'Test' );
+ok $queue && $queue->id, 'loaded or created queue';
+
+my $user = RT::Test->load_or_create_user(
+ Name => 'ausername',
+ Privileged => 1,
+);
+ok $user && $user->id, 'loaded or created user';
+
+my $group = RT::Group->new(RT->SystemUser);
+my ($ok, $msg) = $group->CreateUserDefinedGroup(Name => 'Disabled Group');
+ok($ok, $msg);
+
+($ok, $msg) = $group->AddMember( $user->PrincipalId );
+ok($ok, $msg);
+
+ok( RT::Test->set_rights({
+ Principal => $group,
+ Object => $queue,
+ Right => [qw(OwnTicket)]
+}), 'set rights');
+
+RT->Config->Set( AutocompleteOwners => 0 );
+my ($base, $m) = RT::Test->started_ok;
+ok $m->login, 'logged in';
+
+diag "user from group shows up in create form";
+{
+ $m->get_ok('/', 'open home page');
+ $m->form_name('CreateTicketInQueue');
+ $m->select( 'Queue', $queue->id );
+ $m->submit;
+
+ $m->content_contains('Create a new ticket', 'opened create ticket page');
+ my $form = $m->form_name('TicketCreate');
+ my $input = $form->find_input('Owner');
+ is $input->value, RT->Nobody->Id, 'correct owner selected';
+ ok((scalar grep { $_ == $user->Id } $input->possible_values), 'user from group is in dropdown');
+}
+
+diag "user from disabled group DOESN'T shows up in create form";
+{
+ ($ok, $msg) = $group->SetDisabled(1);
+ ok($ok, $msg);
+
+ $m->get_ok('/', 'open home page');
+ $m->form_name('CreateTicketInQueue');
+ $m->select( 'Queue', $queue->id );
+ $m->submit;
+
+ $m->content_contains('Create a new ticket', 'opened create ticket page');
+ my $form = $m->form_name('TicketCreate');
+ my $input = $form->find_input('Owner');
+ is $input->value, RT->Nobody->Id, 'correct owner selected';
+ ok((not scalar grep { $_ == $user->Id } $input->possible_values), 'user from disabled group is NOT in dropdown');
+}
+
+undef $m;
+done_testing;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list