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>2016-12-01 03:46:49 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2016-12-01 03:46:49 +0300
commit48c8ca9e4da5a01695aa3c0d49d301ce35b3d35d (patch)
tree3b02ec7fd3a717878f78e6284c45581dd2013dd9 /tests
parent107147670f46b234afadefe82e0c384b10c41279 (diff)
Tracking API: when overriding the request datetime with an invalid token_auth, don't track the request (#10899)
* refs #10890 ignore tracking requests with custom timestamp, accept timestamps up to 1 day in past, added config for timestamps that require auth * fix test * update travis yml * update travis * update travis * fix test * added changelog entry * .travis.yml file is out of date, auto-updating .travis.yml file. * .travis.yml file is out of date, auto-updating .travis.yml file. * .travis.yml file is out of date, auto-updating .travis.yml file. * .travis.yml file is out of date, auto-updating .travis.yml file. * .travis.yml file is out of date, auto-updating .travis.yml file. * .travis.yml file is out of date, auto-updating .travis.yml file. * New config.ini.php setting: `tracking_requests_require_authentication_when_custom_timestamp_newer_than`
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Fixtures/ManySitesImportedLogs.php2
-rw-r--r--tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php5
-rw-r--r--tests/PHPUnit/Unit/Tracker/RequestTest.php12
3 files changed, 15 insertions, 4 deletions
diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
index 3a107c26bd..f89fc4948b 100644
--- a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
+++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php
@@ -41,6 +41,8 @@ class ManySitesImportedLogs extends Fixture
GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
LocationProvider::setCurrentProvider('geoip_php');
+ self::createSuperUser();
+
$this->trackVisits();
$this->setupSegments();
}
diff --git a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
index d7fe5e51a6..c190cb2f77 100644
--- a/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
+++ b/tests/PHPUnit/Fixtures/OneVisitorTwoVisits.php
@@ -13,6 +13,7 @@ use Piwik\Db;
use Piwik\Plugins\Goals\API as APIGoals;
use Piwik\Plugins\SitesManager\API as APISitesManager;
use Piwik\Tests\Framework\Fixture;
+use Piwik\Tracker\Cache;
/**
* This fixture adds one website and tracks two visits by one visitor.
@@ -84,8 +85,12 @@ class OneVisitorTwoVisits extends Fixture
APISitesManager::getInstance()->setSiteSpecificUserAgentExcludeEnabled(false);
}
+ self::createSuperUser();
$t = self::getTracker($idSite, $dateTime, $defaultInit = true);
+ Cache::clearCacheGeneral();
+ Cache::regenerateCacheWebsiteAttributes(array($idSite));
+
if ($this->useThirdPartyCookies) {
$t->DEBUG_APPEND_URL = '&forceUseThirdPartyCookie=1';
}
diff --git a/tests/PHPUnit/Unit/Tracker/RequestTest.php b/tests/PHPUnit/Unit/Tracker/RequestTest.php
index e3964369ff..43f8a1bc7f 100644
--- a/tests/PHPUnit/Unit/Tracker/RequestTest.php
+++ b/tests/PHPUnit/Unit/Tracker/RequestTest.php
@@ -49,9 +49,13 @@ class RequestTest extends UnitTestCase
$this->assertSame($this->time, $request->getCurrentTimestamp());
}
- public function test_cdt_ShouldReturnTheCurrentTimestamp_IfNotAuthenticatedAndTimestampIsNotRecent()
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Custom timestamp is 86500 seconds old
+ */
+ public function test_cdt_ShouldNotTrackTheRequest_IfNotAuthenticatedAndTimestampIsNotRecent()
{
- $request = $this->buildRequest(array('cdt' => '' . $this->time - 28800));
+ $request = $this->buildRequest(array('cdt' => '' . $this->time - 86500));
$this->assertSame($this->time, $request->getCurrentTimestamp());
}
@@ -64,9 +68,9 @@ class RequestTest extends UnitTestCase
public function test_cdt_ShouldReturnTheCustomTimestamp_IfAuthenticatedAndValid()
{
- $request = $this->buildRequest(array('cdt' => '' . ($this->time - 28800)));
+ $request = $this->buildRequest(array('cdt' => '' . ($this->time - 86500)));
$request->setIsAuthenticated();
- $this->assertSame('' . ($this->time - 28800), $request->getCurrentTimestamp());
+ $this->assertSame('' . ($this->time - 86500), $request->getCurrentTimestamp());
}
public function test_cdt_ShouldReturnTheCustomTimestamp_IfTimestampIsInFuture()