[Rt-commit] rt branch, 4.4/admin-users-skip-internal-users, created. rt-4.4.4-410-g4d0e0ae56e

? sunnavy sunnavy at bestpractical.com
Tue May 4 17:33:29 EDT 2021


The branch, 4.4/admin-users-skip-internal-users has been created
        at  4d0e0ae56edd2820914baace5d253dfba89815ad (commit)

- Log -----------------------------------------------------------------
commit 4cc816622a0e9fcc0273fe0efd409a057ffe21a4
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 5 04:18:55 2021 +0800

    Skip internal users in user list on admin page
    
    It could cause confusion to list internal users here and internal users
    are not supposed to be edited anyway.

diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index 487a57ce64..234adcf51e 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -242,6 +242,18 @@ sub LimitToUnprivileged {
     $self->MemberOfGroup( RT->UnprivilegedUsers->id);
 }
 
+=head2 LimitToEndUsers
+
+Limits to end users only, i.e. no internal users "RT_System" and "Nobody".
+
+=cut
+
+sub LimitToEndUsers {
+    my $self = shift;
+    for my $user ( RT->SystemUser, RT->Nobody ) {
+        $self->Limit( FIELD => 'id', VALUE => $user->Id, OPERATOR => '!=', ENTRYAGGREGATOR => 'AND' );
+    }
+}
 
 sub Limit {
     my $self = shift;
diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
index a5e7e4c9f5..1785813892 100644
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -198,6 +198,8 @@ else {
     $caption = loc("All users");
 }
 
+$users->LimitToEndUsers;
+
 $Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Users'};
 my $Rows = RT->Config->Get('AdminSearchResultRows')->{'Users'} || 50;
 

commit 4d0e0ae56edd2820914baace5d253dfba89815ad
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 5 04:48:24 2021 +0800

    Test IncludeSystemGroups option on admin user page

diff --git a/t/web/admin_user.t b/t/web/admin_user.t
index 1079598f8c..9d17ca6225 100644
--- a/t/web/admin_user.t
+++ b/t/web/admin_user.t
@@ -149,6 +149,34 @@ $m->click( 'Go' );
 $m->text_lacks( $_->Name ) for $users[0];
 $m->text_contains( $_->Name ) for @users[1..3];
 
+ok( $users[3]->SetPrivileged(0) );
+$m->get_ok( $url . '/Admin/Users/index.html' );
+$m->form_name('UsersAdmin');
+$m->click('Go');
+$m->text_contains( $_->Name, 'Found privileged users' ) for @users[ 0 .. 2 ];
+$m->text_lacks( 'user4', 'No unprivileged users' );
+
+# Nobody/RT_System is so common that could appear in the page, here we test
+# links instead
+ok( !$m->find_link( text => 'Nobody' ), 'No user Nobody' );
+ok( !$m->find_link( text => 'RT_System' ), 'No user RT_System' );
+
+$m->form_name('UsersAdmin');
+$m->field( IncludeSystemGroups => 'Unprivileged' );
+$m->click('Go');
+$m->text_lacks( $_->Name, 'No privileged users' ) for @users[ 0 .. 2 ];
+$m->text_contains( 'user4', 'Found unprivileged users' );
+ok( !$m->find_link( text => 'Nobody' ), 'No user Nobody' );
+ok( !$m->find_link( text => 'RT_System' ), 'No user RT_System' );
+
+$m->form_name('UsersAdmin');
+$m->field( IncludeSystemGroups => 'All' );
+$m->click('Go');
+$m->text_contains( $_->Name, 'Found privileged users' ) for @users[ 0 .. 2 ];
+$m->text_contains( 'user4', 'Found unprivileged users' );
+ok( !$m->find_link( text => 'Nobody' ), 'No user Nobody' );
+ok( !$m->find_link( text => 'RT_System' ), 'No user RT_System' );
+
 # TODO more /Admin/Users tests
 
 done_testing;

-----------------------------------------------------------------------


More information about the rt-commit mailing list