Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2020-02-20 02:20:38 +0300
committerGitHub <noreply@github.com>2020-02-20 02:20:38 +0300
commit2ca0084054e596e2bcce1edff76d62040bf0b23a (patch)
tree3c8fa9bc5d4547bc163c5d3a2aed72391d6bdf95 /tests
parentf3852c0f84e56783211fb4e62eed1da410828b15 (diff)
Fallback to JSON renderer if no valid format is given (#15590)
* Fallback to JSON renderer if no valid format is given Prevents exceptions like these which we are getting quite often due to security researchers trying different inputs > Call to a member function getResponseException() on null","file":"\/core\/API\/Request.php","line":279,"request_id":"3e2b6","backtrace":" on \/var\/www\/html\/core\/API\/Request.php(279)\n#0 \/plugins\/API\/Controller.php(41) Ideally will add a test but probably won't find the time soon. * Add failing test. * Fix test. Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/System/ApiGetReportMetadataTest.php8
-rw-r--r--tests/PHPUnit/System/expected/test_apiGetReportMetadata_defaultFormatValue__Actions.getPageTitles_day.asldjkf3
2 files changed, 11 insertions, 0 deletions
diff --git a/tests/PHPUnit/System/ApiGetReportMetadataTest.php b/tests/PHPUnit/System/ApiGetReportMetadataTest.php
index 0ac96175cd..a33f3a6663 100644
--- a/tests/PHPUnit/System/ApiGetReportMetadataTest.php
+++ b/tests/PHPUnit/System/ApiGetReportMetadataTest.php
@@ -75,6 +75,14 @@ class ApiGetReportMetadataTest extends SystemTestCase
array('Actions.getPageTitles', array('idSite' => $idSite, 'date' => $dateTime,
'testSuffix' => '_pageTitleZeroString')),
+ // Test w/ no format, should default to format=json
+ ['Actions.getPageTitles', [
+ 'idSite' => $idSite,
+ 'date' => $dateTime,
+ 'testSuffix' => '_defaultFormatValue',
+ 'format' => 'asldjkf',
+ ]],
+
// test php renderer w/ array data
array('API.getDefaultMetricTranslations', array('idSite' => $idSite, 'date' => $dateTime,
'format' => 'php', 'testSuffix' => '_phpRenderer')),
diff --git a/tests/PHPUnit/System/expected/test_apiGetReportMetadata_defaultFormatValue__Actions.getPageTitles_day.asldjkf b/tests/PHPUnit/System/expected/test_apiGetReportMetadata_defaultFormatValue__Actions.getPageTitles_day.asldjkf
new file mode 100644
index 0000000000..dd2f5f75aa
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_apiGetReportMetadata_defaultFormatValue__Actions.getPageTitles_day.asldjkf
@@ -0,0 +1,3 @@
+Error: Renderer format 'asldjkf' not valid. Try any of the following instead: console, csv, html, json, json2, original, php, rss, tsv, xml.
+
+ --&gt; To temporarily debug this error further, set const PIWIK_PRINT_ERROR_BACKTRACE=true; in index.php \ No newline at end of file