1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-23 18:29:15 +03:00

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 <roadhero@gmail.com>
This commit is contained in:
Dennis Vorobyov
2026-05-24 16:40:02 +01:00
parent 366d165982
commit 544839869d
2 changed files with 21 additions and 2 deletions

View File

@@ -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);
}
}

View File

@@ -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',