public function getRawBulkRequest() { if (!is_null($this->rawData)) { return $this->rawData; } return parent::getRawBulkRequest(); }
public function test_initRequestsAndTokenAuth_ShouldResolveUrls() { $token = md5(2); $params = array('piwik.php?idsite=1', '', 'piwik.php?idsite=3&rec=0', array('idsite' => '2')); $request = $this->buildRequestRawData($params, $token); $result = $this->requests->initRequestsAndTokenAuth($request); /** @var Request[] $requests */ $requests = $result[0]; $this->assertEquals(array('idsite' => '1'), $requests[0]->getParams()); $this->assertEquals(array('idsite' => '3', 'rec' => '0'), $requests[1]->getParams()); $this->assertEquals(array('idsite' => '2'), $requests[2]->getParams()); $this->assertCount(3, $requests); }
public static function setTestEnvironment($args = null, $requestMethod = null) { if (is_null($args)) { $requests = new Requests(); $args = $requests->getRequestsArrayFromBulkRequest($requests->getRawBulkRequest()); $args = $_GET + $args; } if (is_null($requestMethod) && array_key_exists('REQUEST_METHOD', $_SERVER)) { $requestMethod = $_SERVER['REQUEST_METHOD']; } elseif (is_null($requestMethod)) { $requestMethod = 'GET'; } // Do not run scheduled tasks during tests if (!defined('DEBUG_FORCE_SCHEDULED_TASKS')) { TrackerConfig::setConfigValue('scheduled_tasks_min_interval', 0); } // if nothing found in _GET/_POST and we're doing a POST, assume bulk request. in which case, // we have to bypass authentication if (empty($args) && $requestMethod == 'POST') { TrackerConfig::setConfigValue('tracking_requests_require_authentication', 0); } // Tests can force the use of 3rd party cookie for ID visitor if (Common::getRequestVar('forceEnableFingerprintingAcrossWebsites', false, null, $args) == 1) { TrackerConfig::setConfigValue('enable_fingerprinting_across_websites', 1); } // Tests can force the use of 3rd party cookie for ID visitor if (Common::getRequestVar('forceUseThirdPartyCookie', false, null, $args) == 1) { TrackerConfig::setConfigValue('use_third_party_id_cookie', 1); } // Tests using window_look_back_for_visitor if (Common::getRequestVar('forceLargeWindowLookBackForVisitor', false, null, $args) == 1 || strpos(json_encode($args, true), '"forceLargeWindowLookBackForVisitor":"1"') !== false) { TrackerConfig::setConfigValue('window_look_back_for_visitor', 2678400); } // Tests can force the enabling of IP anonymization if (Common::getRequestVar('forceIpAnonymization', false, null, $args) == 1) { self::getDatabase(); // make sure db is initialized $privacyConfig = new PrivacyManagerConfig(); $privacyConfig->ipAddressMaskLength = 2; \Piwik\Plugins\PrivacyManager\IPAnonymizer::activate(); \Piwik\Tracker\Cache::deleteTrackerCache(); Filesystem::clearPhpCaches(); } $pluginsDisabled = array('Provider'); // Disable provider plugin, because it is so slow to do many reverse ip lookups PluginManager::getInstance()->setTrackerPluginsNotToLoad($pluginsDisabled); }
public function test_authenticateRequests_shouldNotFail_IfEmptyRequestSetGiven() { $this->requests->authenticateRequests(array()); $this->assertTrue(true); }