Mailing List Archive

rt branch 5.0/update-menu-to-respect-UsernameFormat created. rt-5.0.3-78-g0a0a5ad039
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 "rt".

The branch, 5.0/update-menu-to-respect-UsernameFormat has been created
at 0a0a5ad039e3c4b0d07359884d73c9fef2cd3daf (commit)

- Log -----------------------------------------------------------------
commit 0a0a5ad039e3c4b0d07359884d73c9fef2cd3daf
Author: Brian Conry <bconry@bestpractical.com>
Date: Fri Aug 5 10:56:49 2022 -0500

Update tests for menu text change

Commit 7284f3554b changed the menu text for the logged-in user in the
default configuration.

This change addesses the test breakkage from that change.

diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index 861bd35341..564a10d1a7 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -140,7 +140,7 @@ sub logged_in_as {
return 0;
}
RT::Interface::Web::EscapeHTML(\$user);
- unless ( $self->content =~ m{<span class="current-user">\Q$user\E</span>}i ) {
+ unless ( $self->content =~ m{<span class="current-user hidden">\Q$user\E</span>}i ) {
Test::More::diag("Page has no user name");
return 0;
}
diff --git a/t/externalauth/ldap_escaping.t b/t/externalauth/ldap_escaping.t
index b46c3ffe69..5c64b3adc5 100644
--- a/t/externalauth/ldap_escaping.t
+++ b/t/externalauth/ldap_escaping.t
@@ -92,7 +92,7 @@ diag "paren in the username";
# $m->login chokes on ( in 4.0.5
$m->get_ok($m->rt_base_url . "?user=j(doe;pass=password");
$m->content_like(qr/Logout/i, 'contains logout link');
- $m->content_contains('<span class="current-user">j&#40;doe</span>', 'contains logged in user name');
+ $m->content_contains('<span class="current-user hidden">j&#40;doe</span>', 'contains logged in user name');

my $testuser = RT::User->new($RT::SystemUser);
my ($ok,$msg) = $testuser->Load( 'j(doe' );
diff --git a/t/web/basic_auth.t b/t/web/basic_auth.t
index ff77f29f26..b0ef5dc821 100644
--- a/t/web/basic_auth.t
+++ b/t/web/basic_auth.t
@@ -20,7 +20,7 @@ $m->get($url, $m->auth_header( root => "password" ));
is($m->status, 200, "Request with right creds gets 200");

$m->content_like(
- qr{<span class="current-user">\Qroot\E</span>}i,
+ qr{<span class="current-user hidden">\Qroot\E</span>}i,
"Has user on the page"
);
$m->content_unlike(qr/Logout/i, "Has no logout button, no WebFallbackToRTLogin");

commit 7284f3554b466f720a29feebc4c4f8e8ed3a2d87
Author: Brian Conry <bconry@bestpractical.com>
Date: Fri Aug 5 09:31:23 2022 -0500

Update menus to respect config $UsernameFormat

Previously when building the menus RT always used the User->Name method
for the "Logged in as ..." menu.

While technically accurate, it isn't necessarily the most user-friendly,
particularly when External Authentication is in use and RT's "Name"
field may be set to something that's good for identification but that
the user may not use on a regular basis.

Using ->Format will respect User and System preferences.

A hidden component that's otherwise identical to the previous behavior
is added for those cases (hopefully just tests) where it's useful to
inspect the page contents for the ->Name of the current user.

diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
index 7260a75c78..139e23d944 100644
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@ -279,8 +279,11 @@ sub BuildMainNav {
_BuildAdminMenu( $request_path, $top, $widgets, $page, %args );
}

- my $username = '<span class="current-user">'
+ my $username = '<span class="current-user hidden">'
. $HTML::Mason::Commands::m->interp->apply_escapes($current_user->Name, 'h')
+ . '</span>'
+ . '<span class="current-user">'
+ . $HTML::Mason::Commands::m->interp->apply_escapes($current_user->Format, 'h')
. '</span>';
my $about_me = $top->child( 'preferences' =>
title => loc('Logged in as [_1]', $username),
@@ -1680,8 +1683,11 @@ sub BuildSelfServiceNav {
$top->child( "assets", title => loc("Assets"), path => "/SelfService/Asset/" )
if $current_user->HasRight( Right => 'ShowAssetsMenu', Object => RT->System );

- my $username = '<span class="current-user">'
+ my $username = '<span class="current-user hidden">'
. $HTML::Mason::Commands::m->interp->apply_escapes($current_user->Name, 'h')
+ . '</span>'
+ . '<span class="current-user">'
+ . $HTML::Mason::Commands::m->interp->apply_escapes($current_user->Format, 'h')
. '</span>';
my $about_me = $top->child( preferences =>
title => loc('Logged in as [_1]', $username),

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


hooks/post-receive
--
rt
_______________________________________________
rt-commit mailing list
rt-commit@lists.bestpractical.com
https://lists.bestpractical.com/mailman/listinfo/rt-commit