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:
authorMatthieu Aubry <mattab@users.noreply.github.com>2016-08-23 04:16:54 +0300
committerGitHub <noreply@github.com>2016-08-23 04:16:54 +0300
commit58d7fb3f8065eaee299396fc2347ecdb8f9bdc77 (patch)
tree54abe04737a53ae35615eb853b27f1290304ae5f /tests
parentc941d6ade984c9705c864796891dc0589dad3911 (diff)
Create index.htm files in all tmp/ sub-folder as an additional safety net (#10414)
* Create index.htm files in tmp/ folder as safe net * UI test * silent fail * fix unit test * Minor Improvement to description * Fix release checklist * Fix release checklist * UI test * UI test logic * Actually make methods public to keep BC
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/ReleaseCheckListTest.php7
-rw-r--r--tests/PHPUnit/Unit/FilesystemTest.php21
m---------tests/UI/expected-ui-screenshots0
-rw-r--r--tests/UI/specs/Installation_spec.js14
-rw-r--r--tests/index.html3
5 files changed, 40 insertions, 5 deletions
diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
index 265f60c372..d42a310626 100644
--- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php
+++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
@@ -257,6 +257,7 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase
{
$files = Filesystem::globr(PIWIK_INCLUDE_PATH, '*.php');
+ $tested = 0;
foreach($files as $file) {
// skip files in these folders
if (strpos($file, '/libs/') !== false) {
@@ -279,7 +280,10 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase
$start = fgets($handle, strlen($expectedStart) + 1 );
$this->assertEquals($start, $expectedStart, "File $file does not start with $expectedStart");
+ $tested++;
}
+
+ $this->assertGreaterThan(2000, $tested, 'should have tested at least thousand of php files');
}
public function test_jsfilesDoNotContainFakeSpaces()
@@ -494,7 +498,8 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase
|| strpos($file, "tests/resources/Updater/") !== false
|| strpos($file, "Twig/Tests/") !== false
|| strpos($file, "processed/") !== false
- || strpos($file, "/vendor/") !== false;
+ || strpos($file, "/vendor/") !== false
+ || (strpos($file, "tmp/") !== false && strpos($file, 'index.php') !== false);
$isLib = strpos($file, "lib/xhprof") !== false || strpos($file, "phpunit/phpunit") !== false;
return ($isIniFile && $isIniFileInTests) || $isTestResultFile || $isLib;
diff --git a/tests/PHPUnit/Unit/FilesystemTest.php b/tests/PHPUnit/Unit/FilesystemTest.php
index 86894d13e1..1c2d69d69f 100644
--- a/tests/PHPUnit/Unit/FilesystemTest.php
+++ b/tests/PHPUnit/Unit/FilesystemTest.php
@@ -93,6 +93,8 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
'/DataTable/Bridges.php',
'/DataTable/DataTableInterface.php',
'/DataTable/Filter',
+ '/DataTable/index.htm', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+ '/DataTable/index.php', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
'/DataTable/Manager.php',
'/DataTable/Map.php',
'/DataTable/Renderer',
@@ -100,17 +102,26 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
'/DataTable/Row',
'/DataTable/Row.php',
'/DataTable/Simple.php',
+ '/DataTable/Filter/index.htm', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+ '/DataTable/Filter/index.php', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
'/DataTable/Renderer/Console.php',
'/DataTable/Renderer/Csv.php',
'/DataTable/Renderer/Html.php',
+ '/DataTable/Renderer/index.htm', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+ '/DataTable/Renderer/index.php', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
'/DataTable/Renderer/Json.php',
'/DataTable/Renderer/Php.php',
'/DataTable/Renderer/Rss.php',
'/DataTable/Renderer/Tsv.php',
'/DataTable/Renderer/Xml',
'/DataTable/Renderer/Xml.php',
+ '/DataTable/Renderer/Xml/index.htm', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+ '/DataTable/Renderer/Xml/index.php', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
'/DataTable/Renderer/Xml/Other.php',
- '/DataTable/Row/DataTableSummaryRow.php'
+ '/DataTable/Row/DataTableSummaryRow.php',
+ '/DataTable/Row/index.htm', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+ '/DataTable/Row/index.php', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+
), $result);
}
@@ -121,12 +132,18 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(
'/DataTable/Filter',
'/DataTable/Row',
+ '/DataTable/Filter/index.htm', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+ '/DataTable/Filter/index.php', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
'/DataTable/Renderer/Json.php',
'/DataTable/Renderer/Php.php',
'/DataTable/Renderer/Rss.php',
'/DataTable/Renderer/Xml',
+ '/DataTable/Renderer/Xml/index.htm', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+ '/DataTable/Renderer/Xml/index.php', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
'/DataTable/Renderer/Xml/Other.php',
'/DataTable/Row/DataTableSummaryRow.php',
+ '/DataTable/Row/index.htm', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
+ '/DataTable/Row/index.php', // this was is created as side effect of "Target files" being within the tmp/ folder, @see createIndexFilesToPreventDirectoryListing
), $result);
}
@@ -137,7 +154,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase
// make sure there is a difference between those folders
$result = Filesystem::directoryDiff($source, $target);
- $this->assertCount(8, $result);
+ $this->assertCount(14, $result);
Filesystem::unlinkTargetFilesNotPresentInSource($source, $target);
diff --git a/tests/UI/expected-ui-screenshots b/tests/UI/expected-ui-screenshots
-Subproject de03748b515438b7a4c0d2fc6852e35d2714cb6
+Subproject d5689fd6b53879aa18b9ed40851e4d9160d6601
diff --git a/tests/UI/specs/Installation_spec.js b/tests/UI/specs/Installation_spec.js
index 3ddfdc3587..bc24ec0248 100644
--- a/tests/UI/specs/Installation_spec.js
+++ b/tests/UI/specs/Installation_spec.js
@@ -51,8 +51,22 @@ describe("Installation", function () {
}, done);
});
+ var pageUrl;
+ it("should have already created a tmp/sessions/index.htm file to prevent directory listing", function (done) {
+ expect.screenshot('nothing_to_see_here').to.be.capture(function (page) {
+ pageUrl = page.getCurrentUrl();
+
+ // page.load will load by default the proxy ie. http://localhost/piwik/tests/PHPUnit/proxy/
+ // but we need here to check in: http://localhost/piwik/tmp/sessions/
+ page.load("../../../tmp/sessions/index.htm");
+
+ }, done);
+ });
+
it("should display the database setup page when next is clicked on the system check page", function (done) {
expect.screenshot("db_setup").to.be.capture(function (page) {
+ page.load(pageUrl);
+
page.click('.next-step .btn');
}, done);
});
diff --git a/tests/index.html b/tests/index.html
index 9078a41907..ac14989274 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -6,8 +6,7 @@
<ul>
<li><a href="https://github.com/piwik/piwik/blob/master/tests/README.md">Setup PHPUnit tests</a></li>
- <li><a href="javascript/">Run piwik.js Javascript unit & integration tests</a>. <br/><i>Note: the Javascript tests
- are not executed in Jenkins so must be run manually on major browsers after any change to piwik.js</i></li>
+ <li><a href="javascript/">Run piwik.js Javascript unit & integration tests</a>. <br/></li>
</ul>
<p>If you are new to the wonderful world of testing, <a href='https://github.com/piwik/piwik/blob/master/tests/README.md'>see the README</a> for an introduction.</p>