/** @dataProvider provideTokenClasses */ public function testTokenRetrieval($id, $class) { // Make sure we have the right to get the token global $wgGroupPermissions; $wgGroupPermissions['*'][$class::getRight()] = true; RequestContext::getMain()->getUser()->clearInstanceCache(); // Reread above global // We should be getting anonymous user token $expected = $class::getToken(); $this->assertNotSame(false, $expected, 'We did not get a valid token'); $actionString = TranslateUtils::getTokenAction($id); $params = wfCgiToArray($actionString); $req = new FauxRequest($params); $api = new ApiMain($req); $api->execute(); if (defined('ApiResult::META_CONTENT')) { $data = $api->getResult()->getResultData(null, array('Strip' => 'all')); } else { $data = $api->getResultData(); } if (isset($data['query'])) { foreach ($data['query']['pages'] as $page) { $this->assertSame($expected, $page[$id . 'token']); } } else { $this->assertArrayHasKey('tokens', $data, 'Result has tokens'); $this->assertSame($expected, $data['tokens'][$id . 'token']); } }
/** * @deprecated since MediaWiki core 1.25 */ public function getParamDescription() { $action = TranslateUtils::getTokenAction('translationstash'); return array('subaction' => 'Action', 'title' => 'Title of the translation unit page', 'translation' => 'Translation made by the user', 'metadata' => 'Json object', 'token' => "A token previously acquired with {$action}", 'username' => 'Optionally the user whose stash to get. ' . 'Only privileged users can do this'); }
/** * @deprecated since MediaWiki core 1.25 */ public function getParamDescription() { $action = TranslateUtils::getTokenAction('aggregategroups'); return array('do' => 'What to do with aggregate message group', 'group' => 'Message group id', 'aggregategroup' => 'Aggregate message group id', 'groupname' => 'Aggregate message group name', 'groupdescription' => 'Aggregate message group description', 'token' => "A token previously acquired with {$action}"); }
/** * @deprecated since MediaWiki core 1.25 */ public function getParamDescription() { $action = TranslateUtils::getTokenAction('translationreview'); return array('revision' => 'The revision number to review', 'token' => "A token previously acquired with {$action}"); }
/** * @deprecated since MediaWiki core 1.25 */ public function getParamDescription() { $action = TranslateUtils::getTokenAction('groupreview'); return array('group' => 'Message group', 'language' => 'Language code', 'state' => 'The new state for the group', 'token' => "A token previously acquired with {$action}"); }
/** * @deprecated since MediaWiki core 1.25 */ public function getParamDescription() { $action = TranslateUtils::getTokenAction('translatesandbox'); return array('do' => 'What to do', 'userid' => 'User ids of the users being managed. Use 0 for creations.', 'token' => "A token previously acquired with {$action}", 'username' => 'Username when creating user', 'password' => 'Password when creating user', 'email' => 'Email when creating user'); }