Last modified: 2012-04-06 08:40:58 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 35646 - ApiBlockTest::testMakeNormalBlock() broken
ApiBlockTest::testMakeNormalBlock() broken
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: High major (vote)
: ---
Assigned To: Nobody - You can work on this!
: platformeng
Depends on:
Blocks: 34141
  Show dependency treegraph
 
Reported: 2012-04-02 15:21 UTC by Antoine "hashar" Musso (WMF)
Modified: 2012-04-06 08:40 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Antoine "hashar" Musso (WMF) 2012-04-02 15:21:57 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
Comment 1 Antoine "hashar" Musso (WMF) 2012-04-02 15:22:55 UTC
Marking high priority since that makes the API tests job to always be failing.
Comment 2 Sam Reed (reedy) 2012-04-02 18:09:01 UTC
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)
Comment 3 Sam Reed (reedy) 2012-04-02 18:12:14 UTC
https://gerrit.wikimedia.org/r/4114
Comment 4 Antoine "hashar" Musso (WMF) 2012-04-03 12:30:12 UTC
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.
Comment 5 Antoine "hashar" Musso (WMF) 2012-04-03 12:33:10 UTC
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
Comment 6 Antoine "hashar" Musso (WMF) 2012-04-03 13:09:30 UTC
Test marked as broken with https://gerrit.wikimedia.org/r/4159  so I can continue the Jenkins/Gerrit integration.
Comment 7 Sam Reed (reedy) 2012-04-03 13:32:41 UTC
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$
Comment 8 Antoine "hashar" Musso (WMF) 2012-04-03 14:07:03 UTC
I am not sure what is the issue there, but it is certainly reproducible on gallium :/
Comment 9 Sam Reed (reedy) 2012-04-03 14:25:09 UTC
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
Comment 10 Antoine "hashar" Musso (WMF) 2012-04-06 08:40:58 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links