diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2020-03-18 06:04:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-18 06:04:12 +0300 |
commit | f0c246cb3a4db3021da7552f6779d56613799414 (patch) | |
tree | 42ddf7a9c2e086df78ffc40dfc23af74f8dd3a39 /tests/PHPUnit/Framework | |
parent | e493fee87c983e02001a7d9438cefe58141a38af (diff) |
App specific token_auths (#15410)
* some initial work
* add security page
* backing up some code
* more functionality
* adjust more UI parts
* adjust more code
* more tweaks
* add todo note
* few tweaks
* make sure date is in right format
* fix not existing column
* few fixes
* available hashes
* use different hash algo so tests run on php 5
* fix name of aglorithm
* trying to fix some tests
* another try to fix some tests
* more fixes
* more fixes
* few fixes
* update template
* fix some tests
* fix test
* fixing some tests
* various test fixes
* more fixes
* few more tests
* more tests
* various tweaks
* add translations
* add some ui tests
* fix selector
* tweaks
* trying to fix some ui tests
* fallback to regular authentication if needed
* fix call authenticate on null
* fix user settings
* fix some tests
* few fixes
* fix more ui tests
* update schema
* Update plugins/CoreHome/angularjs/widget-loader/widgetloader.directive.js
Co-Authored-By: Stefan Giehl <stefan@matomo.org>
* fix maps are not showing data
* trying to fix some tests
* set correct token
* trying to fix tracking failure
* minor tweaks and fixes
* fix more tests
* fix screenshot test
* trigger event so brute force logic is executed
* test no fallback to actual authentication
* allow fallback
* apply review feedback
* fix some tests
* fix tests
* make sure location values from query params are limited properly before attempting a db insert
* make sure plugin uninstall migration reloads plugins, make sure 4.0.0-b1 migration removes unique index that is no longer used, use defaults extra file in SqlDump to get test to run on travis
* Fix UI tests.
* update expected screenshot
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
Diffstat (limited to 'tests/PHPUnit/Framework')
-rw-r--r-- | tests/PHPUnit/Framework/Fixture.php | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index 307daa838c..5fb6dae988 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -81,6 +81,7 @@ class Fixture extends \PHPUnit\Framework\Assert const ADMIN_USER_LOGIN = 'superUserLogin'; const ADMIN_USER_PASSWORD = 'superUserPass'; + const ADMIN_USER_TOKEN = 'c4ca4238a0b923820dcc509a6f75849b'; const PERSIST_FIXTURE_DATA_ENV = 'PERSIST_FIXTURE_DATA'; @@ -716,7 +717,9 @@ class Fixture extends \PHPUnit\Framework\Assert $model = new \Piwik\Plugins\UsersManager\Model(); $user = $model->getUser(self::ADMIN_USER_LOGIN); - return $user['token_auth']; + if (!empty($user)) { + return self::ADMIN_USER_TOKEN; + } } public static function createSuperUser($removeExisting = true) @@ -725,7 +728,6 @@ class Fixture extends \PHPUnit\Framework\Assert $login = self::ADMIN_USER_LOGIN; $password = $passwordHelper->hash(UsersManager::getPasswordHash(self::ADMIN_USER_PASSWORD)); - $token = APIUsersManager::getInstance()->createTokenAuth($login); $model = new \Piwik\Plugins\UsersManager\Model(); $user = $model->getUser($login); @@ -734,19 +736,26 @@ class Fixture extends \PHPUnit\Framework\Assert $model->deleteUserOnly($login); } - if (!empty($user) && !$removeExisting) { - $token = $user['token_auth']; - } if (empty($user) || $removeExisting) { - $model->addUser($login, $password, 'hello@example.org', $login, $token, Date::now()->getDatetime()); + $model->addUser($login, $password, 'hello@example.org', $login, Date::now()->getDatetime()); } else { - $model->updateUser($login, $password, 'hello@example.org', $login, $token); + $model->updateUser($login, $password, 'hello@example.org', $login); + } + try { + if (!$model->getUserByTokenAuth(self::ADMIN_USER_TOKEN)) { + $model->addTokenAuth($login,self::ADMIN_USER_TOKEN, 'Admin user token', Date::now()->getDatetime()); + } + } catch (Exception $e) { + // duplicate entry errors are expected + if (strpos($e->getMessage(), 'Duplicate entry') === false) { + throw $e; + } } $setSuperUser = empty($user) || !empty($user['superuser_access']); $model->setSuperUserAccess($login, $setSuperUser); - return $model->getUserByTokenAuth($token); + return $model->getUser($login); } /** |