From 4bc46c347e19bc032861aa37cf903a250f247a78 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Fri, 31 Jan 2014 02:44:51 +0000 Subject: refs #4564 we have to get the token from the piwik_tests database --- misc/cron/updatetoken.php | 5 +++++ misc/log-analytics/import_logs.py | 11 ++++++++++- tests/PHPUnit/Fixtures/ManySitesImportedLogs.php | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/misc/cron/updatetoken.php b/misc/cron/updatetoken.php index 351d980c1d..f7cba2ab20 100644 --- a/misc/cron/updatetoken.php +++ b/misc/cron/updatetoken.php @@ -29,6 +29,11 @@ if (!Common::isPhpCliMode()) { return; } +$testmode = in_array('--testmode', $_SERVER['argv']); +if ($testmode) { + Config::getInstance()->setTestEnvironment(); +} + $token = Db::get()->fetchOne("SELECT token_auth FROM " . Common::prefixTable("user") . " WHERE superuser_access = 1 diff --git a/misc/log-analytics/import_logs.py b/misc/log-analytics/import_logs.py index 14443a7cb0..29f5447a19 100755 --- a/misc/log-analytics/import_logs.py +++ b/misc/log-analytics/import_logs.py @@ -490,6 +490,10 @@ class Configuration(object): help="Make URL path lowercase so paths with the same letters but different cases are " "treated the same." ) + option_parser.add_option( + '--enable-testmode', dest='enable_testmode', default=False, action='store_true', + help="If set, it will try to get the token_auth from the piwik_tests directory" + ) return option_parser @@ -592,7 +596,12 @@ class Configuration(object): os.path.join(os.path.dirname(__file__), '../../misc/cron/updatetoken.php'), ) - filename = subprocess.check_output("php " + updatetokenfile, shell=True); + + process = "php " + updatetokenfile + if self.options.enable_testmode: + process = process + " --testmode" + + filename = subprocess.check_output(process, shell=True); credentials = open(filename, 'r').readline() credentials = credentials.split('\t') return credentials[1] diff --git a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php index d3665dc9bf..9390bab9ec 100644 --- a/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php +++ b/tests/PHPUnit/Fixtures/ManySitesImportedLogs.php @@ -128,6 +128,7 @@ class Test_Piwik_Fixture_ManySitesImportedLogs extends Test_Piwik_BaseFixture // We do not pass the "--token_auth" parameter here to make sure import_logs.py finds the auth_token // automatically if needed $opts = array('--idsite' => $this->idSite, + '--enable-testmode' => '1', '--recorders' => '4', '--recorder-max-payload-size' => '2'); @@ -145,6 +146,7 @@ class Test_Piwik_Fixture_ManySitesImportedLogs extends Test_Piwik_BaseFixture // We do not pass the "--token_auth" parameter here to make sure import_logs.py finds the auth_token // automatically if needed $opts = array('--add-sites-new-hosts' => false, + '--enable-testmode' => '1', '--recorders' => '4', '--recorder-max-payload-size' => '1'); -- cgit v1.2.3