From 544839869dfa0097b86cbcdfd53a1839aefb867a Mon Sep 17 00:00:00 2001 From: Dennis Vorobyov Date: Sun, 24 May 2026 16:40:02 +0100 Subject: [PATCH] Fix #19841 - Add test coverage for port-stripping in processes privileges link Update the processlist test fixture to use a host with a port suffix (Host1:12345) and assert that the rendered privileges link URL contains the bare hostname while the Host column display retains the full value. Signed-off-by: Dennis Vorobyov --- .../Processes/RefreshControllerTest.php | 21 ++++++++++++++++++- test/classes/Stubs/DbiDummy.php | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/classes/Controllers/Server/Status/Processes/RefreshControllerTest.php b/test/classes/Controllers/Server/Status/Processes/RefreshControllerTest.php index 10113aea61..fa3eb11637 100644 --- a/test/classes/Controllers/Server/Status/Processes/RefreshControllerTest.php +++ b/test/classes/Controllers/Server/Status/Processes/RefreshControllerTest.php @@ -44,7 +44,7 @@ class RefreshControllerTest extends AbstractTestCase { $process = [ 'User' => 'User1', - 'Host' => 'Host1', + 'Host' => 'Host1:12345', 'Id' => 'Id1', 'Db' => 'db1', 'Command' => 'Command1', @@ -98,5 +98,24 @@ class RefreshControllerTest extends AbstractTestCase //validate 8: $process['info'] self::assertStringContainsString($process['Info'], $html); + + // The Host column shows the full value including port + self::assertStringContainsString('Host1:12345', $html); + + // The privileges link must use the bare hostname (port stripped) so the + // link target matches mysql.user.Host which never contains port numbers. + self::assertStringContainsString( + Url::getFromRoute('/server/privileges', [ + 'username' => $process['User'], + 'hostname' => 'Host1', + 'dbname' => $process['Db'], + 'tablename' => '', + 'routinename' => '', + ]), + $html + ); + + // The privileges link must NOT contain the raw host:port value as hostname + self::assertStringNotContainsString('hostname=Host1%3A12345', $html); } } diff --git a/test/classes/Stubs/DbiDummy.php b/test/classes/Stubs/DbiDummy.php index adb760689c..32f00a82a8 100644 --- a/test/classes/Stubs/DbiDummy.php +++ b/test/classes/Stubs/DbiDummy.php @@ -2174,7 +2174,7 @@ class DbiDummy implements DbiExtension [ 'query' => 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `process` DESC', 'columns' => ['Id', 'User', 'Host', 'db', 'Command', 'Time', 'State', 'Info'], - 'result' => [['Id1', 'User1', 'Host1', 'db1', 'Command1', 'Time1', 'State1', 'Info1']], + 'result' => [['Id1', 'User1', 'Host1:12345', 'db1', 'Command1', 'Time1', 'State1', 'Info1']], ], [ 'query' => 'SELECT UNIX_TIMESTAMP() - 36000',