Last modified: 2012-04-06 08:40:58 UTC
Since the security patch https://gerrit.wikimedia.org/r/#change,3434 , the API has a broken test : php tests/phpunit/phpunit.php tests/phpunit/includes/api/ApiBlockTest.php 1) ApiBlockTest::testMakeNormalBlock UsageException: Invalid token
Marking high priority since that makes the API tests job to always be failing.
User.php, it's the request specific tokens at fault /** * Check given value against the token value stored in the session. * A match should confirm that the form was submitted from the * user's own login session, not a form submission from a third-party * site. * * @param $val String Input value to compare * @param $salt String Optional function-specific data for hashing * @param $request WebRequest object to use or null to use $wgRequest * @return Boolean: Whether the token matches */ public function matchEditToken( $val, $salt = '', $request = null ) { $sessionToken = $this->getEditToken( $salt, $request ); if ( $val != $sessionToken ) { wfDebug( "User::matchEditToken: broken session data\n" ); } return $val == $sessionToken; } Commenting out the pass of $request (so it falls back to null) fixes the issue. We've got discrepancy between code - the gettoken part of block passes the request, but prop=info doesn't, but the api itself does // Die if token required, but not provided (unless there is a gettoken parameter) $salt = $module->getTokenSalt(); if ( $salt !== false && !isset( $moduleParams['gettoken'] ) ) { if ( !isset( $moduleParams['token'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'token' ) ); } else { if ( !$this->getUser()->matchEditToken( $moduleParams['token'], $salt, $this->getRequest() ) ) { $this->dieUsageMsg( 'sessionfailure' ); } } } So the question is about the requests. Where should we be passing it, and where shouldn't we? I guess the request in the block/unblock should be removed to normalise them with the prop=info one. And then do the same in ApiMain::setupModule (ie not pass $this->request)
https://gerrit.wikimedia.org/r/4114
reopening, still happening on gallium :( ssh gallium sudo -s -u jenkins cd /var/lib/jenkins/jobs/MediaWiki-Tests-API ant phpunit-api phpunit-api: [exec] PHPUnit 3.5.15 by Sebastian Bergmann. [exec] [exec] ........I..E... [exec] [exec] Time: 1 second, Memory: 95.25Mb [exec] [exec] There was 1 error: [exec] [exec] 1) ApiBlockTest::testMakeNormalBlock [exec] UsageException: Invalid token [exec] [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/includes/api/ApiBase.php:1087 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/includes/api/ApiBase.php:1266 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/includes/api/ApiMain.php:603 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/includes/api/ApiMain.php:691 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/includes/api/ApiMain.php:342 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/includes/api/ApiTestCase.php:53 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/includes/api/ApiBlockTest.php:51 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/MediaWikiTestCase.php:66 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/MediaWikiPHPUnitCommand.php:45 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/phpunit.php:60 [exec] [exec] There was 1 incomplete test: [exec] [exec] 1) ApiTest::testApiListPages [exec] Somebody needs to finish loving me [exec] [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/includes/api/ApiTest.php:215 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/MediaWikiTestCase.php:66 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/MediaWikiPHPUnitCommand.php:45 [exec] /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace/tests/phpunit/phpunit.php:60 [exec] FAILURES! Tests: 15, Assertions: 45, Errors: 1, Incomplete: 1.
Another way, which only run the ApiBlockTest::testMakeNormalBlock test : ssh gallium sudo -s -u jenkins cd /var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace Then: php tests/phpunit/phpunit.php \ --conf /var/lib/jenkins/jobs/MediaWiki-Tests-API/workspace/LocalSettings.php \ tests/phpunit/includes/api/ApiBlockTest.php 1) ApiBlockTest::testMakeNormalBlock UsageException: Invalid token
Test marked as broken with https://gerrit.wikimedia.org/r/4159 so I can continue the Jenkins/Gerrit integration.
Irritating! reedy@ubuntu64-web-esxi:/var/www/wiki/w$ php tests/phpunit/phpunit.php tests/phpunit/includes/api/ApiBlockTest.php PHPUnit 3.6.10 by Sebastian Bergmann. Configuration read from /var/www/wiki/w/tests/phpunit/suite.xml . Time: 10 seconds, Memory: 70.25Mb OK (1 test, 4 assertions) reedy@ubuntu64-web-esxi:/var/www/wiki/w$
I am not sure what is the issue there, but it is certainly reproducible on gallium :/
jenkins@gallium:/var/lib/jenkins/jobs/MediaWiki-GIT-Fetching/workspace$ php tests/phpunit/phpunit.php --conf /var/lib/jenkins/jobs/MediaWiki-Tests-API/workspace/LocalSettings.php tests/phpunit/includes/api/ApiBlockTest.php PHPUnit 3.5.15 by Sebastian Bergmann. string(34) "1ebf829d30b805f7ed7a081c81d15c02+\" string(0) "" NULL string(34) "1ebf829d30b805f7ed7a081c81d15c02+\" . Time: 0 seconds, Memory: 34.25Mb OK (1 test, 4 assertions
The test has been enabled again by https://gerrit.wikimedia.org/r/4201 . I have had PHPUnit upgraded from 3.5.x to 3.6.10, maybe that helped fixing the issue we had. Or another changed fixed it.