示例#1
0
 public function test_requiresAuthentication_shouldReturnFalse_IfDisabled()
 {
     $oldConfig = TrackerConfig::getConfigValue('bulk_requests_require_authentication');
     TrackerConfig::setConfigValue('bulk_requests_require_authentication', 0);
     $this->assertFalse($this->requests->requiresAuthentication());
     TrackerConfig::setConfigValue('bulk_requests_require_authentication', $oldConfig);
 }
示例#2
0
 public function test_isAuthenticated_ShouldBeAuthenticatedIfCheckIsDisabledInConfig()
 {
     $oldConfig = TrackerConfig::getConfigValue('tracking_requests_require_authentication');
     TrackerConfig::setConfigValue('tracking_requests_require_authentication', 0);
     $this->assertTrue($this->request->isAuthenticated());
     TrackerConfig::setConfigValue('tracking_requests_require_authentication', $oldConfig);
 }
示例#3
0
 public function test_loadTrackerEnvironment_shouldSetGlobalsDebugVar()
 {
     $this->assertTrue(!array_key_exists('PIWIK_TRACKER_DEBUG', $GLOBALS));
     $oldConfig = Tracker\TrackerConfig::getConfigValue('debug');
     Tracker\TrackerConfig::setConfigValue('debug', 1);
     Tracker::loadTrackerEnvironment();
     $this->assertTrue($this->tracker->isDebugModeEnabled());
     Tracker\TrackerConfig::setConfigValue('debug', $oldConfig);
     // reset
     $this->assertTrue($GLOBALS['PIWIK_TRACKER_DEBUG']);
 }
示例#4
0
 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);
 }
示例#5
0
 public function test_getCookiePath_ShouldReturnConfigValue()
 {
     $oldPath = TrackerConfig::getConfigValue('cookie_path');
     TrackerConfig::setConfigValue('cookie_path', 'test');
     $this->assertEquals('test', $this->request->getCookiePath());
     TrackerConfig::setConfigValue('cookie_path', $oldPath);
 }
 public function test_process_shouldNotProcessAnything_IfRecordStatisticsIsDisabled()
 {
     $this->addRequestSetsToQueue(8);
     $record = TrackerConfig::getConfigValue('record_statistics');
     TrackerConfig::setConfigValue('record_statistics', 0);
     $tracker = $this->process();
     TrackerConfig::setConfigValue('record_statistics', $record);
     $this->assertSame(0, $tracker->getCountOfLoggedRequests());
     $this->assertSame(8, $this->queue->getNumberOfRequestSetsInAllQueues());
 }