2010-12-14 16:26:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
2019-05-13 14:18:07 +00:00
|
|
|
use MediaWiki\Block\DatabaseBlock;
|
2018-12-06 20:35:40 +00:00
|
|
|
use MediaWiki\Block\Restriction\PageRestriction;
|
Separate Block into AbstractBlock, Block and SystemBlock
This commit splits the existing Block class into AbstractBlock, Block
and SystemBlock.
Before this patch, the Block class represents several types of
blocks, which can be separated into blocks stored in the database,
and temporary blocks created by the system. These are now
represented by Block and SystemBlock, which inherit from
AbstractBlock.
This lays the foundations for:
* enforcing block parameters from multiple blocks that apply to a
user/IP address
* improvements to the Block API, including the addition of services
Breaking changes: functions expecting a Block object should still
expect a Block object if it came from the database, but other
functions may now need to expect an AbstractBlock or SystemBlock
object. (Note that an alternative naming scheme, in which the
abstract class is called Block and the subclasses are DatabaseBlock
and SystemBlock, avoids this breakage. However, it introduces more
breakages to calls to static Block methods and new Block
instantiations.)
Changes to tests: system blocks don't set the $blockCreateAccount or
$mExipry block properties, so remove/change any tests that assume
they do.
Bug: T222737
Change-Id: I83bceb5e5049e254c90ace060f8f8fad44696c67
2019-03-18 22:09:49 +00:00
|
|
|
use MediaWiki\Block\SystemBlock;
|
2018-07-29 12:24:54 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2010-12-14 16:26:35 +00:00
|
|
|
/**
|
|
|
|
|
* @group Database
|
2013-10-24 20:30:43 +00:00
|
|
|
*
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::getPermissionErrors
|
|
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::getPermissionErrorsInternal
|
2010-12-14 16:26:35 +00:00
|
|
|
*/
|
2011-06-22 21:02:07 +00:00
|
|
|
class TitlePermissionTest extends MediaWikiLangTestCase {
|
2011-10-14 21:18:38 +00:00
|
|
|
|
|
|
|
|
/**
|
2012-10-08 10:56:20 +00:00
|
|
|
* @var string
|
2011-10-14 21:18:38 +00:00
|
|
|
*/
|
2012-10-08 10:56:20 +00:00
|
|
|
protected $userName, $altUserName;
|
2011-10-14 21:18:38 +00:00
|
|
|
|
|
|
|
|
/**
|
2012-10-08 10:56:20 +00:00
|
|
|
* @var Title
|
2011-10-14 21:18:38 +00:00
|
|
|
*/
|
2012-10-08 10:56:20 +00:00
|
|
|
protected $title;
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
/**
|
|
|
|
|
* @var User
|
|
|
|
|
*/
|
|
|
|
|
protected $user, $anonUser, $userUser, $altUser;
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
protected function setUp() {
|
|
|
|
|
parent::setUp();
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
$localZone = 'UTC';
|
|
|
|
|
$localOffset = date( 'Z' ) / 60;
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->setMwGlobals( [
|
2012-10-08 10:56:20 +00:00
|
|
|
'wgLocaltimezone' => $localZone,
|
|
|
|
|
'wgLocalTZoffset' => $localOffset,
|
2016-02-17 09:09:32 +00:00
|
|
|
'wgNamespaceProtection' => [
|
2012-10-08 10:56:20 +00:00
|
|
|
NS_MEDIAWIKI => 'editinterface',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
] );
|
2014-07-09 15:40:35 +00:00
|
|
|
// Without this testUserBlock will use a non-English context on non-English MediaWiki
|
|
|
|
|
// installations (because of how Title::checkUserBlock is implemented) and fail.
|
|
|
|
|
RequestContext::resetMain();
|
2012-10-08 10:56:20 +00:00
|
|
|
|
|
|
|
|
$this->userName = 'Useruser';
|
|
|
|
|
$this->altUserName = 'Altuseruser';
|
|
|
|
|
date_default_timezone_set( $localZone );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title = Title::makeTitle( NS_MAIN, "Main Page" );
|
2013-11-23 14:56:42 +00:00
|
|
|
if ( !isset( $this->userUser ) || !( $this->userUser instanceof User ) ) {
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->userUser = User::newFromName( $this->userName );
|
2011-04-23 19:28:35 +00:00
|
|
|
|
2016-03-18 13:55:54 +00:00
|
|
|
if ( !$this->userUser->getId() ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->userUser = User::createNew( $this->userName, [
|
2010-12-14 16:26:35 +00:00
|
|
|
"email" => "test@example.com",
|
2016-02-17 09:09:32 +00:00
|
|
|
"real_name" => "Test User" ] );
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->userUser->load();
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
2011-04-23 19:28:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->altUser = User::newFromName( $this->altUserName );
|
2016-03-18 13:55:54 +00:00
|
|
|
if ( !$this->altUser->getId() ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->altUser = User::createNew( $this->altUserName, [
|
2010-12-14 16:26:35 +00:00
|
|
|
"email" => "alttest@example.com",
|
2016-02-17 09:09:32 +00:00
|
|
|
"real_name" => "Test User Alt" ] );
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->altUser->load();
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->anonUser = User::newFromId( 0 );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->user = $this->userUser;
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
2018-08-13 02:46:23 +00:00
|
|
|
$this->overrideMwServices();
|
2011-06-22 21:02:07 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
protected function setUserPerm( $perm ) {
|
|
|
|
|
// Setting member variables is evil!!!
|
|
|
|
|
|
|
|
|
|
if ( is_array( $perm ) ) {
|
|
|
|
|
$this->user->mRights = $perm;
|
|
|
|
|
} else {
|
|
|
|
|
$this->user->mRights = [ $perm ];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
protected function setTitle( $ns, $title = "Main_Page" ) {
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title = Title::makeTitle( $ns, $title );
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
protected function setUser( $userName = null ) {
|
2010-12-14 16:26:35 +00:00
|
|
|
if ( $userName === 'anon' ) {
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->user = $this->anonUser;
|
2011-06-17 16:05:35 +00:00
|
|
|
} elseif ( $userName === null || $userName === $this->userName ) {
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->user = $this->userUser;
|
2010-12-14 16:26:35 +00:00
|
|
|
} else {
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->user = $this->altUser;
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2018-10-09 01:21:00 +00:00
|
|
|
*
|
|
|
|
|
* This test is failing per T201776.
|
|
|
|
|
*
|
|
|
|
|
* @group Broken
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkQuickPermissions
|
2013-10-21 21:09:13 +00:00
|
|
|
*/
|
|
|
|
|
public function testQuickPermissions() {
|
2018-07-29 12:24:54 +00:00
|
|
|
$prefix = MediaWikiServices::getInstance()->getContentLanguage()->
|
|
|
|
|
getFormattedNsText( NS_PROJECT );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setUser( 'anon' );
|
|
|
|
|
$this->setTitle( NS_TALK );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "createtalk" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_TALK );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "createpage" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ "nocreatetext" ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_TALK );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'nocreatetext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "createpage" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "createtalk" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'nocreatetext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setUser( $this->userName );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->setTitle( NS_TALK );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "createtalk" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_TALK );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "createpage" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_TALK );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "createpage" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "createtalk" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setUser( 'anon' );
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'cant-move-user-page' ], [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '/subpage' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move-rootuserpages" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '/subpage' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move-rootuserpages" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'cant-move-user-page' ], [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '/subpage' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move-rootuserpages" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '/subpage' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move-rootuserpages" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setUser( $this->userName );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->setTitle( NS_FILE, "img.png" );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_FILE, "img.png" );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "movefile" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenotallowed' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setUser( 'anon' );
|
|
|
|
|
$this->setTitle( NS_FILE, "img.png" );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenotallowedfile' ], [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_FILE, "img.png" );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "movefile" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setUser( $this->userName );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->runGroupPermissions( 'move', [ [ 'movenotallowedfile' ] ] );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2014-04-24 12:50:36 +00:00
|
|
|
$this->runGroupPermissions(
|
|
|
|
|
'move',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ]
|
2014-04-24 12:50:36 +00:00
|
|
|
);
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setUser( 'anon' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->runGroupPermissions( 'move', [ [ 'movenotallowedfile' ] ] );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2014-04-24 12:50:36 +00:00
|
|
|
$this->runGroupPermissions(
|
|
|
|
|
'move',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ],
|
|
|
|
|
[ [ 'movenotallowedfile' ], [ 'movenologintext' ] ]
|
2014-04-24 12:50:36 +00:00
|
|
|
);
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-10-12 11:09:08 +00:00
|
|
|
if ( $this->isWikitextNS( NS_MAIN ) ) {
|
2015-09-11 13:44:59 +00:00
|
|
|
// NOTE: some content models don't allow moving
|
2013-05-15 01:12:35 +00:00
|
|
|
// @todo find a Wikitext namespace for testing
|
2012-10-12 11:09:08 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
|
|
|
|
$this->setUser( 'anon' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->runGroupPermissions( 'move', [] );
|
2012-10-12 11:09:08 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->runGroupPermissions( 'move', [ [ 'movenotallowed' ] ],
|
|
|
|
|
[ [ 'movenologintext' ] ] );
|
2012-10-12 11:09:08 +00:00
|
|
|
|
|
|
|
|
$this->setUser( $this->userName );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->runGroupPermissions( 'move', [ [ 'movenotallowed' ] ] );
|
2012-10-12 11:09:08 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->runGroupPermissions( 'move', [] );
|
2012-10-12 11:09:08 +00:00
|
|
|
|
|
|
|
|
$this->setUser( 'anon' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'move' );
|
2012-10-12 11:09:08 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2012-10-12 11:09:08 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( '' );
|
2012-10-12 11:09:08 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'movenotallowed' ] ], $res );
|
2012-10-12 11:09:08 +00:00
|
|
|
}
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_USER );
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setUser( $this->userName );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ "move", "move-rootuserpages" ] );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'cant-move-to-user-page' ] ], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setUser( 'anon' );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ "move", "move-rootuserpages" ] );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_USER, "User/subpage" );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ "move", "move-rootuserpages" ] );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "move" );
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [], $res );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setUser( 'anon' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$check = [
|
|
|
|
|
'edit' => [
|
|
|
|
|
[ [ 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
[],
|
2014-04-24 12:50:36 +00:00
|
|
|
true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'protect' => [
|
|
|
|
|
[ [
|
2014-04-24 12:50:36 +00:00
|
|
|
'badaccess-groups',
|
2016-02-17 09:09:32 +00:00
|
|
|
"[[$prefix:Administrators|Administrators]]", 1 ],
|
|
|
|
|
[ 'protect-cantedit'
|
|
|
|
|
] ],
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'protect-cantedit' ] ],
|
|
|
|
|
[ [ 'protect-cantedit' ] ],
|
2014-04-24 12:50:36 +00:00
|
|
|
false
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'' => [ [], [], [], true ]
|
|
|
|
|
];
|
2012-10-10 17:18:12 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
foreach ( [ "edit", "protect", "" ] as $action ) {
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( null );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $check[$action][0],
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, true ) );
|
2015-01-15 00:18:02 +00:00
|
|
|
$this->assertEquals( $check[$action][0],
|
|
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, 'full' ) );
|
|
|
|
|
$this->assertEquals( $check[$action][0],
|
|
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
global $wgGroupPermissions;
|
|
|
|
|
$old = $wgGroupPermissions;
|
2016-02-17 09:09:32 +00:00
|
|
|
$wgGroupPermissions = [];
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals( $check[$action][1],
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, true ) );
|
2015-01-15 00:18:02 +00:00
|
|
|
$this->assertEquals( $check[$action][1],
|
|
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, 'full' ) );
|
|
|
|
|
$this->assertEquals( $check[$action][1],
|
|
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$wgGroupPermissions = $old;
|
|
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( $action );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $check[$action][2],
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, true ) );
|
2015-01-15 00:18:02 +00:00
|
|
|
$this->assertEquals( $check[$action][2],
|
|
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, 'full' ) );
|
|
|
|
|
$this->assertEquals( $check[$action][2],
|
|
|
|
|
$this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( $action );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $check[$action][3],
|
2012-10-10 17:18:12 +00:00
|
|
|
$this->title->userCan( $action, $this->user, true ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $check[$action][3],
|
2012-10-10 17:18:12 +00:00
|
|
|
$this->title->quickUserCan( $action, $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
# count( User::getGroupsWithPermissions( $action ) ) < 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
protected function runGroupPermissions( $action, $result, $result2 = null ) {
|
2010-12-14 16:26:35 +00:00
|
|
|
global $wgGroupPermissions;
|
|
|
|
|
|
2013-02-14 11:36:35 +00:00
|
|
|
if ( $result2 === null ) {
|
|
|
|
|
$result2 = $result;
|
|
|
|
|
}
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$wgGroupPermissions['autoconfirmed']['move'] = false;
|
|
|
|
|
$wgGroupPermissions['user']['move'] = false;
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $result, $res );
|
|
|
|
|
|
|
|
|
|
$wgGroupPermissions['autoconfirmed']['move'] = true;
|
|
|
|
|
$wgGroupPermissions['user']['move'] = false;
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $result2, $res );
|
|
|
|
|
|
|
|
|
|
$wgGroupPermissions['autoconfirmed']['move'] = true;
|
|
|
|
|
$wgGroupPermissions['user']['move'] = true;
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $result2, $res );
|
|
|
|
|
|
|
|
|
|
$wgGroupPermissions['autoconfirmed']['move'] = false;
|
|
|
|
|
$wgGroupPermissions['user']['move'] = true;
|
2010-12-31 22:08:13 +00:00
|
|
|
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( $result2, $res );
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkSpecialsAndNSPermissions
|
2013-10-21 21:09:13 +00:00
|
|
|
*/
|
|
|
|
|
public function testSpecialsAndNSPermissions() {
|
2012-10-08 10:56:20 +00:00
|
|
|
global $wgNamespaceProtection;
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setUser( $this->userName );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_SPECIAL );
|
2011-04-23 19:28:35 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ], [ 'ns-specialprotected' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'bogus' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( '' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$wgNamespaceProtection[NS_USER] = [ 'bogus' ];
|
2012-10-08 10:56:20 +00:00
|
|
|
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->setTitle( NS_USER );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( '' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ],
|
|
|
|
|
[ 'namespaceprotected', 'User', 'bogus' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MEDIAWIKI );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'bogus' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'protectedinterface', 'bogus' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MEDIAWIKI );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'bogus' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'protectedinterface', 'bogus' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$wgNamespaceProtection = null;
|
2012-10-08 10:56:20 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'bogus' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( true,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( '' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserConfigPermissions
|
2013-10-21 21:09:13 +00:00
|
|
|
*/
|
2018-02-13 00:15:30 +00:00
|
|
|
public function testJsConfigEditPermissions() {
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setUser( $this->userName );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2013-06-10 17:33:48 +00:00
|
|
|
$this->setTitle( NS_USER, $this->userName . '/test.js' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$this->runConfigEditPermissions(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
|
2018-10-03 16:47:14 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-10-04 13:52:41 +00:00
|
|
|
[ [ 'badaccess-groups' ] ]
|
2013-06-10 17:33:48 +00:00
|
|
|
);
|
2018-02-13 00:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserConfigPermissions
|
2018-02-13 00:20:05 +00:00
|
|
|
*/
|
|
|
|
|
public function testJsonConfigEditPermissions() {
|
2018-10-03 16:47:14 +00:00
|
|
|
$prefix = MediaWikiServices::getInstance()->getContentLanguage()->
|
|
|
|
|
getFormattedNsText( NS_PROJECT );
|
2018-02-13 00:20:05 +00:00
|
|
|
$this->setUser( $this->userName );
|
|
|
|
|
|
|
|
|
|
$this->setTitle( NS_USER, $this->userName . '/test.json' );
|
|
|
|
|
$this->runConfigEditPermissions(
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
|
|
|
|
|
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
|
|
|
|
|
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-10-03 16:47:14 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
|
2018-10-04 13:52:41 +00:00
|
|
|
[ [ 'badaccess-groups' ] ]
|
2018-02-13 00:20:05 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-13 00:15:30 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserConfigPermissions
|
2018-02-13 00:15:30 +00:00
|
|
|
*/
|
|
|
|
|
public function testCssConfigEditPermissions() {
|
|
|
|
|
$this->setUser( $this->userName );
|
2013-06-10 17:33:48 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_USER, $this->userName . '/test.css' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$this->runConfigEditPermissions(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
|
2018-10-03 16:47:14 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
|
2018-10-04 13:52:41 +00:00
|
|
|
[ [ 'badaccess-groups' ] ]
|
2013-06-10 17:33:48 +00:00
|
|
|
);
|
2018-02-13 00:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserConfigPermissions
|
2018-02-13 00:15:30 +00:00
|
|
|
*/
|
|
|
|
|
public function testOtherJsConfigEditPermissions() {
|
|
|
|
|
$this->setUser( $this->userName );
|
2013-06-10 17:33:48 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->altUserName . '/test.js' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$this->runConfigEditPermissions(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
|
2018-10-03 16:47:14 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-10-04 13:52:41 +00:00
|
|
|
[ [ 'badaccess-groups' ] ]
|
2013-06-10 17:33:48 +00:00
|
|
|
);
|
2018-02-13 00:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserConfigPermissions
|
2018-02-13 00:20:05 +00:00
|
|
|
*/
|
|
|
|
|
public function testOtherJsonConfigEditPermissions() {
|
|
|
|
|
$this->setUser( $this->userName );
|
|
|
|
|
|
|
|
|
|
$this->setTitle( NS_USER, $this->altUserName . '/test.json' );
|
|
|
|
|
$this->runConfigEditPermissions(
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
|
|
|
|
|
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
|
|
|
|
|
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-10-03 16:47:14 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
|
2018-10-04 13:52:41 +00:00
|
|
|
[ [ 'badaccess-groups' ] ]
|
2018-02-13 00:20:05 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-13 00:15:30 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserConfigPermissions
|
2018-02-13 00:15:30 +00:00
|
|
|
*/
|
|
|
|
|
public function testOtherCssConfigEditPermissions() {
|
|
|
|
|
$this->setUser( $this->userName );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->altUserName . '/test.css' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$this->runConfigEditPermissions(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
|
2018-10-03 16:47:14 +00:00
|
|
|
[ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
|
2018-10-04 13:52:41 +00:00
|
|
|
[ [ 'badaccess-groups' ] ]
|
2013-06-10 17:33:48 +00:00
|
|
|
);
|
2018-02-13 00:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserConfigPermissions
|
2018-02-13 00:15:30 +00:00
|
|
|
*/
|
|
|
|
|
public function testOtherNonConfigEditPermissions() {
|
|
|
|
|
$this->setUser( $this->userName );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->setTitle( NS_USER, $this->altUserName . '/tempo' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$this->runConfigEditPermissions(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-02-13 00:15:30 +00:00
|
|
|
|
2018-02-13 00:20:05 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-10-03 16:47:14 +00:00
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-10-04 13:52:41 +00:00
|
|
|
[ [ 'badaccess-groups' ] ]
|
2018-10-03 16:47:14 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo This should use data providers like the other methods here.
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserConfigPermissions
|
2018-10-03 16:47:14 +00:00
|
|
|
*/
|
|
|
|
|
public function testPatrolActionConfigEditPermissions() {
|
|
|
|
|
$this->setUser( 'anon' );
|
|
|
|
|
$this->setTitle( NS_USER, 'ToPatrolOrNotToPatrol' );
|
|
|
|
|
$this->runConfigEditPermissions(
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
|
|
|
|
[ [ 'badaccess-group0' ] ],
|
2018-10-04 13:52:41 +00:00
|
|
|
[ [ 'badaccess-groups' ] ]
|
2013-06-10 17:33:48 +00:00
|
|
|
);
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-13 00:15:30 +00:00
|
|
|
protected function runConfigEditPermissions(
|
|
|
|
|
$resultNone,
|
|
|
|
|
$resultMyCss,
|
2018-02-13 00:20:05 +00:00
|
|
|
$resultMyJson,
|
2018-02-13 00:15:30 +00:00
|
|
|
$resultMyJs,
|
|
|
|
|
$resultUserCss,
|
2018-02-13 00:20:05 +00:00
|
|
|
$resultUserJson,
|
2018-10-03 16:47:14 +00:00
|
|
|
$resultUserJs,
|
|
|
|
|
$resultPatrol
|
2018-02-13 00:15:30 +00:00
|
|
|
) {
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( '' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
|
|
|
|
|
$this->assertEquals( $resultNone, $result );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'editmyusercss' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
|
|
|
|
|
$this->assertEquals( $resultMyCss, $result );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'editmyuserjson' );
|
2018-02-13 00:20:05 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
|
|
|
|
|
$this->assertEquals( $resultMyJson, $result );
|
|
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'editmyuserjs' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
|
|
|
|
|
$this->assertEquals( $resultMyJs, $result );
|
2013-06-10 17:33:48 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'editusercss' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
|
|
|
|
|
$this->assertEquals( $resultUserCss, $result );
|
2013-06-10 17:33:48 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'edituserjson' );
|
2018-02-13 00:20:05 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
|
|
|
|
|
$this->assertEquals( $resultUserJson, $result );
|
|
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( 'edituserjs' );
|
2018-02-13 00:15:30 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
|
|
|
|
|
$this->assertEquals( $resultUserJs, $result );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( '' );
|
2018-10-03 20:42:55 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'patrol', $this->user );
|
2018-10-04 13:52:41 +00:00
|
|
|
$this->assertEquals( reset( $resultPatrol[0] ), reset( $result[0] ) );
|
2018-10-03 20:42:55 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ 'edituserjs', 'edituserjson', 'editusercss' ] );
|
2018-02-13 00:15:30 +00:00
|
|
|
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
|
|
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ] ], $result );
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2018-10-09 01:21:00 +00:00
|
|
|
*
|
|
|
|
|
* This test is failing per T201776.
|
|
|
|
|
*
|
|
|
|
|
* @group Broken
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkPageRestrictions
|
2013-10-21 21:09:13 +00:00
|
|
|
*/
|
|
|
|
|
public function testPageRestrictions() {
|
2018-07-29 12:24:54 +00:00
|
|
|
$prefix = MediaWikiServices::getInstance()->getContentLanguage()->
|
|
|
|
|
getFormattedNsText( NS_PROJECT );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MAIN );
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->mRestrictionsLoaded = true;
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "edit" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->title->mRestrictions = [ "bogus" => [ 'bogus', "sysop", "protect", "" ] ];
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'edit',
|
|
|
|
|
$this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals( true,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->quickUserCan( 'edit', $this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->title->mRestrictions = [ "edit" => [ 'bogus', "sysop", "protect", "" ],
|
|
|
|
|
"bogus" => [ 'bogus', "sysop", "protect", "" ] ];
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ],
|
|
|
|
|
[ 'protectedpagetext', 'bogus', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'editprotected', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'bogus' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus',
|
|
|
|
|
$this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'protectedpagetext', 'bogus', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'editprotected', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'edit' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'edit',
|
|
|
|
|
$this->user ) );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ],
|
|
|
|
|
[ 'protectedpagetext', 'bogus', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'editprotected', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'bogus' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus',
|
|
|
|
|
$this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ],
|
|
|
|
|
[ 'protectedpagetext', 'bogus', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'editprotected', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'edit' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'edit',
|
|
|
|
|
$this->user ) );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ "edit", "editprotected" ] );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ],
|
|
|
|
|
[ 'protectedpagetext', 'bogus', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'bogus' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus',
|
|
|
|
|
$this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [
|
|
|
|
|
[ 'protectedpagetext', 'bogus', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'edit' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'edit',
|
|
|
|
|
$this->user ) );
|
2013-06-28 17:20:00 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->mCascadeRestriction = true;
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( "edit" );
|
2013-06-28 17:20:00 +00:00
|
|
|
$this->assertEquals( false,
|
|
|
|
|
$this->title->quickUserCan( 'bogus', $this->user ) );
|
|
|
|
|
$this->assertEquals( false,
|
|
|
|
|
$this->title->quickUserCan( 'edit', $this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ],
|
|
|
|
|
[ 'protectedpagetext', 'bogus', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'editprotected', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'bogus' ] ],
|
2013-06-28 17:20:00 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus',
|
|
|
|
|
$this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'protectedpagetext', 'bogus', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'editprotected', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'edit' ] ],
|
2013-06-28 17:20:00 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'edit',
|
|
|
|
|
$this->user ) );
|
|
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ "edit", "editprotected" ] );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->quickUserCan( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->quickUserCan( 'edit', $this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'badaccess-group0' ],
|
|
|
|
|
[ 'protectedpagetext', 'bogus', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'bogus' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'bogus' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus',
|
|
|
|
|
$this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'protectedpagetext', 'bogus', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'edit' ],
|
|
|
|
|
[ 'protectedpagetext', 'protect', 'edit' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'edit',
|
|
|
|
|
$this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-13 00:15:30 +00:00
|
|
|
/**
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkCascadingSourcesRestrictions
|
2018-02-13 00:15:30 +00:00
|
|
|
*/
|
2013-10-21 21:09:13 +00:00
|
|
|
public function testCascadingSourcesRestrictions() {
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->setTitle( NS_MAIN, "test page" );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ "edit", "bogus" ] );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->title->mCascadeSources = [
|
2014-04-24 12:50:36 +00:00
|
|
|
Title::makeTitle( NS_MAIN, "Bogus" ),
|
|
|
|
|
Title::makeTitle( NS_MAIN, "UnBogus" )
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
|
|
|
|
$this->title->mCascadingRestrictions = [
|
2016-05-12 21:43:06 +00:00
|
|
|
"bogus" => [ 'bogus', "sysop", "protect", "" ]
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'bogus', $this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [
|
|
|
|
|
[ "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n", 'bogus' ],
|
|
|
|
|
[ "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n", 'bogus' ],
|
|
|
|
|
[ "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n", 'bogus' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals( true,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'edit', $this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-21 21:09:13 +00:00
|
|
|
/**
|
|
|
|
|
* @todo This test method should be split up into separate test methods and
|
|
|
|
|
* data providers
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkActionPermissions
|
2013-10-21 21:09:13 +00:00
|
|
|
*/
|
|
|
|
|
public function testActionPermissions() {
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ "createpage" ] );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->setTitle( NS_MAIN, "test page" );
|
2014-10-11 05:43:02 +00:00
|
|
|
$this->title->mTitleProtection['permission'] = '';
|
2016-03-19 00:08:06 +00:00
|
|
|
$this->title->mTitleProtection['user'] = $this->user->getId();
|
Clean up handling of 'infinity'
There's a bunch of stuff that probably only works because the database
representation of infinity is actually 'infinity' on all databases
besides Oracle, and Oracle in general isn't maintained.
Generally, we should probably use 'infinity' everywhere except where
directly dealing with the database.
* Many extension callers of Language::formatExpiry() with $format !==
true are assuming it'll return 'infinity', none are checking for
$db->getInfinity().
* And Language::formatExpiry() would choke if passed 'infinity', despite
callers doing this.
* And Language::formatExpiry() could be more useful for the API if we
can override the string returned for infinity.
* As for core, Title is using Language::formatExpiry() with TS_MW which
is going to be changing anyway. Extension callers mostly don't exist.
* Block already normalizes its mExpiry field (and ->getExpiry()),
but some stuff is comparing it with $db->getInfinity() anyway. A few
external users set mExpiry to $db->getInfinity(), but this is mostly
because SpecialBlock::parseExpiryInput() returns $db->getInfinity()
while most callers (including all extensions) are assuming 'infinity'.
* And for that matter, Block should use $db->decodeExpiry() instead of
manually doing it, once we make that safe to call with 'infinity' for
all the extensions passing $db->getInfinity() to Block's contructor.
* WikiPage::doUpdateRestrictions() and some of its callers are using
$db->getInfinity(), when all the inserts using that value are using
$db->encodeExpiry() which will convert 'infinity'.
This also cleans up a slave-lag issue I noticed in ApiBlock while
testing.
Bug: T92550
Change-Id: I5eb68c1fb6029da8289276ecf7c81330575029ef
2015-03-12 16:37:04 +00:00
|
|
|
$this->title->mTitleProtection['expiry'] = 'infinity';
|
2014-10-11 05:43:02 +00:00
|
|
|
$this->title->mTitleProtection['reason'] = 'test';
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->mCascadeRestriction = false;
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'titleprotected', 'Useruser', 'test' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'create', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2014-10-11 05:43:02 +00:00
|
|
|
$this->title->mTitleProtection['permission'] = 'editprotected';
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ 'createpage', 'protect' ] );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'titleprotected', 'Useruser', 'test' ] ],
|
2013-06-28 17:20:00 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
|
|
|
|
|
$this->assertEquals( false,
|
|
|
|
|
$this->title->userCan( 'create', $this->user ) );
|
|
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ 'createpage', 'editprotected' ] );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( true,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'create', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ 'createpage' ] );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'titleprotected', 'Useruser', 'test' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'create', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MEDIA, "test page" );
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ "move" ] );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'move', $this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'immobile-source-namespace', 'Media' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-10-12 11:09:08 +00:00
|
|
|
$this->setTitle( NS_HELP, "test page" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( true,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'move', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->mInterwiki = "no";
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'immobile-source-page' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'move', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
$this->setTitle( NS_MEDIA, "test page" );
|
|
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'move-target', $this->user ) );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'immobile-target-namespace', 'Media' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-10-12 11:09:08 +00:00
|
|
|
$this->setTitle( NS_HELP, "test page" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( true,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'move-target', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->mInterwiki = "no";
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'immobile-target-page' ] ],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
$this->assertEquals( false,
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->userCan( 'move-target', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-13 00:15:30 +00:00
|
|
|
/**
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserBlock
|
2018-02-13 00:15:30 +00:00
|
|
|
*/
|
2013-10-21 21:09:13 +00:00
|
|
|
public function testUserBlock() {
|
2016-08-26 01:29:58 +00:00
|
|
|
$this->setMwGlobals( [
|
|
|
|
|
'wgEmailConfirmToEdit' => true,
|
|
|
|
|
'wgEmailAuthentication' => true,
|
2019-04-14 13:28:06 +00:00
|
|
|
'wgBlockDisablesLogin' => false,
|
2016-08-26 01:29:58 +00:00
|
|
|
] );
|
2019-03-07 20:02:07 +00:00
|
|
|
$this->overrideMwServices();
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2019-05-30 13:51:37 +00:00
|
|
|
$this->setUserPerm( [ 'createpage', 'edit', 'move', 'rollback', 'patrol', 'upload', 'purge' ] );
|
2012-10-12 11:09:08 +00:00
|
|
|
$this->setTitle( NS_HELP, "test page" );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2016-08-26 01:29:58 +00:00
|
|
|
# $wgEmailConfirmToEdit only applies to 'edit' action
|
|
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
|
2016-08-26 01:29:58 +00:00
|
|
|
$this->assertContains( [ 'confirmedittext' ],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
|
|
|
|
|
|
|
|
|
|
$this->setMwGlobals( 'wgEmailConfirmToEdit', false );
|
2019-03-07 20:02:07 +00:00
|
|
|
$this->overrideMwServices();
|
|
|
|
|
|
2016-08-26 01:29:58 +00:00
|
|
|
$this->assertNotContains( [ 'confirmedittext' ],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
# $wgEmailConfirmToEdit && !$user->isEmailConfirmed() && $action != 'createaccount'
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [],
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target',
|
|
|
|
|
$this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
|
|
|
|
global $wgLang;
|
|
|
|
|
$prev = time();
|
|
|
|
|
$now = time() + 120;
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->user->mBlockedby = $this->user->getId();
|
2019-05-13 14:18:07 +00:00
|
|
|
$this->user->mBlock = new DatabaseBlock( [
|
2014-05-22 14:45:46 +00:00
|
|
|
'address' => '127.0.8.1',
|
|
|
|
|
'by' => $this->user->getId(),
|
|
|
|
|
'reason' => 'no reason given',
|
|
|
|
|
'timestamp' => $prev + 3600,
|
|
|
|
|
'auto' => true,
|
|
|
|
|
'expiry' => 0
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2019-03-22 15:16:40 +00:00
|
|
|
$this->user->mBlock->setTimestamp( 0 );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertEquals( [ [ 'autoblockedtext',
|
2013-02-14 11:36:35 +00:00
|
|
|
'[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
|
|
|
|
|
'Useruser', null, 'infinite', '127.0.8.1',
|
2016-02-17 09:09:32 +00:00
|
|
|
$wgLang->timeanddate( wfTimestamp( TS_MW, $prev ), true ) ] ],
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target',
|
2013-02-14 11:36:35 +00:00
|
|
|
$this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-10-10 17:18:12 +00:00
|
|
|
$this->assertEquals( false, $this->title->userCan( 'move-target', $this->user ) );
|
2011-05-04 11:51:38 +00:00
|
|
|
// quickUserCan should ignore user blocks
|
2012-10-10 17:18:12 +00:00
|
|
|
$this->assertEquals( true, $this->title->quickUserCan( 'move-target', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2012-07-02 11:11:01 +00:00
|
|
|
global $wgLocalTZoffset;
|
2010-12-14 16:26:35 +00:00
|
|
|
$wgLocalTZoffset = -60;
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->user->mBlockedby = $this->user->getName();
|
2019-05-13 14:18:07 +00:00
|
|
|
$this->user->mBlock = new DatabaseBlock( [
|
2014-05-22 14:45:46 +00:00
|
|
|
'address' => '127.0.8.1',
|
|
|
|
|
'by' => $this->user->getId(),
|
|
|
|
|
'reason' => 'no reason given',
|
|
|
|
|
'timestamp' => $now,
|
|
|
|
|
'auto' => false,
|
|
|
|
|
'expiry' => 10,
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
|
|
|
|
$this->assertEquals( [ [ 'blockedtext',
|
2013-02-14 11:36:35 +00:00
|
|
|
'[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
|
|
|
|
|
'Useruser', null, '23:00, 31 December 1969', '127.0.8.1',
|
2016-02-17 09:09:32 +00:00
|
|
|
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ],
|
2010-12-31 22:08:13 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
# $action != 'read' && $action != 'createaccount' && $user->isBlockedFrom( $this )
|
|
|
|
|
# $user->blockedFor() == ''
|
|
|
|
|
# $user->mBlock->mExpiry == 'infinity'
|
2016-12-01 16:51:03 +00:00
|
|
|
|
|
|
|
|
$this->user->mBlockedby = $this->user->getName();
|
Separate Block into AbstractBlock, Block and SystemBlock
This commit splits the existing Block class into AbstractBlock, Block
and SystemBlock.
Before this patch, the Block class represents several types of
blocks, which can be separated into blocks stored in the database,
and temporary blocks created by the system. These are now
represented by Block and SystemBlock, which inherit from
AbstractBlock.
This lays the foundations for:
* enforcing block parameters from multiple blocks that apply to a
user/IP address
* improvements to the Block API, including the addition of services
Breaking changes: functions expecting a Block object should still
expect a Block object if it came from the database, but other
functions may now need to expect an AbstractBlock or SystemBlock
object. (Note that an alternative naming scheme, in which the
abstract class is called Block and the subclasses are DatabaseBlock
and SystemBlock, avoids this breakage. However, it introduces more
breakages to calls to static Block methods and new Block
instantiations.)
Changes to tests: system blocks don't set the $blockCreateAccount or
$mExipry block properties, so remove/change any tests that assume
they do.
Bug: T222737
Change-Id: I83bceb5e5049e254c90ace060f8f8fad44696c67
2019-03-18 22:09:49 +00:00
|
|
|
$this->user->mBlock = new SystemBlock( [
|
2016-12-01 16:51:03 +00:00
|
|
|
'address' => '127.0.8.1',
|
|
|
|
|
'by' => $this->user->getId(),
|
|
|
|
|
'reason' => 'no reason given',
|
|
|
|
|
'timestamp' => $now,
|
|
|
|
|
'systemBlock' => 'test',
|
|
|
|
|
] );
|
2018-12-06 20:35:40 +00:00
|
|
|
|
|
|
|
|
$errors = [ [ 'systemblockedtext',
|
2016-12-01 16:51:03 +00:00
|
|
|
'[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
|
Separate Block into AbstractBlock, Block and SystemBlock
This commit splits the existing Block class into AbstractBlock, Block
and SystemBlock.
Before this patch, the Block class represents several types of
blocks, which can be separated into blocks stored in the database,
and temporary blocks created by the system. These are now
represented by Block and SystemBlock, which inherit from
AbstractBlock.
This lays the foundations for:
* enforcing block parameters from multiple blocks that apply to a
user/IP address
* improvements to the Block API, including the addition of services
Breaking changes: functions expecting a Block object should still
expect a Block object if it came from the database, but other
functions may now need to expect an AbstractBlock or SystemBlock
object. (Note that an alternative naming scheme, in which the
abstract class is called Block and the subclasses are DatabaseBlock
and SystemBlock, avoids this breakage. However, it introduces more
breakages to calls to static Block methods and new Block
instantiations.)
Changes to tests: system blocks don't set the $blockCreateAccount or
$mExipry block properties, so remove/change any tests that assume
they do.
Bug: T222737
Change-Id: I83bceb5e5049e254c90ace060f8f8fad44696c67
2019-03-18 22:09:49 +00:00
|
|
|
'Useruser', 'test', 'infinite', '127.0.8.1',
|
2018-12-06 20:35:40 +00:00
|
|
|
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ];
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( $errors,
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
|
|
|
|
|
$this->assertEquals( $errors,
|
2016-12-01 16:51:03 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
|
2018-12-06 20:35:40 +00:00
|
|
|
$this->assertEquals( $errors,
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'rollback', $this->user ) );
|
|
|
|
|
$this->assertEquals( $errors,
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'patrol', $this->user ) );
|
|
|
|
|
$this->assertEquals( $errors,
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'upload', $this->user ) );
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'purge', $this->user ) );
|
2018-08-27 01:45:18 +00:00
|
|
|
|
|
|
|
|
// partial block message test
|
|
|
|
|
$this->user->mBlockedby = $this->user->getName();
|
2019-05-13 14:18:07 +00:00
|
|
|
$this->user->mBlock = new DatabaseBlock( [
|
2018-08-27 01:45:18 +00:00
|
|
|
'address' => '127.0.8.1',
|
|
|
|
|
'by' => $this->user->getId(),
|
|
|
|
|
'reason' => 'no reason given',
|
|
|
|
|
'timestamp' => $now,
|
|
|
|
|
'sitewide' => false,
|
|
|
|
|
'expiry' => 10,
|
|
|
|
|
] );
|
|
|
|
|
|
2018-12-06 20:35:40 +00:00
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'rollback', $this->user ) );
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'patrol', $this->user ) );
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'upload', $this->user ) );
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'purge', $this->user ) );
|
|
|
|
|
|
|
|
|
|
$this->user->mBlock->setRestrictions( [
|
|
|
|
|
( new PageRestriction( 0, $this->title->getArticleID() ) )->setTitle( $this->title ),
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
$errors = [ [ 'blockedtext-partial',
|
2018-08-27 01:45:18 +00:00
|
|
|
'[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
|
|
|
|
|
'Useruser', null, '23:00, 31 December 1969', '127.0.8.1',
|
2018-12-06 20:35:40 +00:00
|
|
|
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ];
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( $errors,
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
|
|
|
|
|
$this->assertEquals( $errors,
|
2018-08-27 01:45:18 +00:00
|
|
|
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
|
2018-12-06 20:35:40 +00:00
|
|
|
$this->assertEquals( $errors,
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'rollback', $this->user ) );
|
|
|
|
|
$this->assertEquals( $errors,
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'patrol', $this->user ) );
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'upload', $this->user ) );
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'purge', $this->user ) );
|
2019-02-16 06:08:10 +00:00
|
|
|
|
|
|
|
|
// Test no block.
|
|
|
|
|
$this->user->mBlockedby = null;
|
|
|
|
|
$this->user->mBlock = null;
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( [],
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
2019-02-20 03:18:14 +00:00
|
|
|
|
|
|
|
|
/**
|
2019-03-07 20:02:07 +00:00
|
|
|
* @covers \MediaWiki\Permissions\PermissionManager::checkUserBlock
|
2019-02-20 03:18:14 +00:00
|
|
|
*
|
|
|
|
|
* Tests to determine that the passed in permission does not get mixed up with
|
|
|
|
|
* an action of the same name.
|
|
|
|
|
*/
|
|
|
|
|
public function testUserBlockAction() {
|
|
|
|
|
global $wgLang;
|
|
|
|
|
|
|
|
|
|
$tester = $this->getMockBuilder( Action::class )
|
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
|
|
|
|
$tester->method( 'getName' )
|
|
|
|
|
->willReturn( 'tester' );
|
|
|
|
|
$tester->method( 'getRestriction' )
|
|
|
|
|
->willReturn( 'test' );
|
|
|
|
|
$tester->method( 'requiresUnblock' )
|
|
|
|
|
->willReturn( false );
|
|
|
|
|
|
|
|
|
|
$this->setMwGlobals( [
|
|
|
|
|
'wgActions' => [
|
|
|
|
|
'tester' => $tester,
|
|
|
|
|
],
|
|
|
|
|
'wgGroupPermissions' => [
|
|
|
|
|
'*' => [
|
|
|
|
|
'tester' => true,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
$now = time();
|
|
|
|
|
$this->user->mBlockedby = $this->user->getName();
|
2019-05-13 14:18:07 +00:00
|
|
|
$this->user->mBlock = new DatabaseBlock( [
|
2019-02-20 03:18:14 +00:00
|
|
|
'address' => '127.0.8.1',
|
|
|
|
|
'by' => $this->user->getId(),
|
|
|
|
|
'reason' => 'no reason given',
|
|
|
|
|
'timestamp' => $now,
|
|
|
|
|
'auto' => false,
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
$errors = [ [ 'blockedtext',
|
|
|
|
|
'[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
|
|
|
|
|
'Useruser', null, 'infinite', '127.0.8.1',
|
|
|
|
|
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ];
|
|
|
|
|
|
|
|
|
|
$this->assertEquals( $errors,
|
|
|
|
|
$this->title->getUserPermissionsErrors( 'tester', $this->user ) );
|
|
|
|
|
}
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|