Skip to content

Commit 43f8ddc

Browse files
committed
Add a test case for a null user agent
Ref: phpmyadmin/phpmyadmin#20163
1 parent b2c531c commit 43f8ddc

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"pma_version": "5.2.4-dev",
3+
"browser_name": "OTHER",
4+
"browser_version": 0,
5+
"user_os": "Other",
6+
"server_software": "nginx/1.29.5",
7+
"user_agent_string": null,
8+
"locale": "en",
9+
"configuration_storage": "enabled",
10+
"php_version": "8.5.3",
11+
"script_name": "index.php",
12+
"exception_type": "js"
13+
}

tests/TestCase/Controller/IncidentsControllerTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,32 @@ public function testCreateInvalidEmptyReport(): void
178178
$this->assertSame(false, $result['success']);
179179
}
180180

181+
public function testCreateIncidentFromBugReportUANull(): void
182+
{
183+
// Test invalid Notification email configuration
184+
Configure::write('NotificationEmailsTo', '');
185+
186+
$bugReport = file_get_contents(TESTS . 'Fixture' . DS . 'report_ua_null_js.json');
187+
$bugReportDecoded = json_decode($bugReport, true);
188+
$this->configRequest(['input' => $bugReport]);
189+
$this->post('/incidents/create');
190+
$this->assertResponseCode(200);
191+
$result = json_decode($this->_response->getBody(), true);
192+
$this->assertNotNull($result);
193+
$this->assertSame(true, $result['success']);
194+
195+
$report = $this->Reports->find(
196+
'all',
197+
order: ['Reports.created desc']
198+
)->all()->first();
199+
$subject = 'A new report has been submitted '
200+
. 'on the Error Reporting Server: '
201+
. $report['id'];
202+
$this->assertEquals('5.2.4-dev', $report['pma_version']);
203+
204+
$this->assertNoMailSent();
205+
}
206+
181207
public function testCreateInvalidReport(): void
182208
{
183209
// Test invalid Notification email configuration

tests/TestCase/Model/Table/IncidentsTableTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,15 @@ public function testGetClosestReport(): void
387387
$this->assertEquals($returnedReport, $result);
388388
}
389389

390+
public function testCreateIncidentFromBugReportUANull(): void
391+
{
392+
$bugReport = file_get_contents(TESTS . 'Fixture' . DS . 'report_ua_null_js.json');
393+
$bugReport = json_decode($bugReport, true);
394+
395+
$result = $this->Incidents->createIncidentFromBugReport($bugReport);
396+
$this->assertEquals(1, count($result['incidents']));
397+
}
398+
390399
public function testCreateIncidentFromBugReport(): void
391400
{
392401
$bugReport = file_get_contents(TESTS . 'Fixture' . DS . 'report_js.json');

0 commit comments

Comments
 (0)