mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-13 17:27:20 +00:00
Fixup T372998 backport
Use isHidden due to ca23e9f06b
from
T363906 being in REL1_43+
Bug: T372998
Change-Id: Ib802822e47aa9d4c848069d0509a4d23374e6b0e
This commit is contained in:
parent
762a7113f6
commit
1be07b32ee
|
@ -116,9 +116,9 @@ class CheckMatch extends ApiBase {
|
|||
|
||||
// TODO: Replace with dependency injection once security patch is uploaded publicly.
|
||||
$afFilterLookup = AbuseFilterServices::getFilterLookup();
|
||||
$privacyLevel = $afFilterLookup->getFilter( $row->afl_filter_id, $row->afl_global )
|
||||
->getPrivacyLevel();
|
||||
$canSeeDetails = $this->afPermManager->canSeeLogDetailsForFilter( $performer, $privacyLevel );
|
||||
$hidden = $afFilterLookup->getFilter( $row->afl_filter_id, $row->afl_global )
|
||||
->isHidden();
|
||||
$canSeeDetails = $this->afPermManager->canSeeLogDetailsForFilter( $performer, $hidden );
|
||||
if ( !$canSeeDetails ) {
|
||||
$this->dieWithError( 'apierror-permissiondenied-generic', 'cannotseedetails' );
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use ApiTestCase;
|
|||
use FormatJson;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use MediaWiki\Extension\AbuseFilter\Filter\ExistingFilter;
|
||||
use MediaWiki\Extension\AbuseFilter\Filter\Flags;
|
||||
use MediaWiki\Extension\AbuseFilter\FilterLookup;
|
||||
use MediaWiki\Extension\AbuseFilter\Parser\Exception\InternalException;
|
||||
use MediaWiki\Extension\AbuseFilter\Parser\FilterEvaluator;
|
||||
|
@ -14,6 +13,7 @@ use MediaWiki\Extension\AbuseFilter\Parser\ParserStatus;
|
|||
use MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerFactory;
|
||||
use MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerStatus;
|
||||
use MediaWiki\Extension\AbuseFilter\Variables\VariableHolder;
|
||||
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@ use Title;
|
|||
*/
|
||||
class CheckMatchTest extends ApiTestCase {
|
||||
use AbuseFilterApiTestTrait;
|
||||
use MockAuthorityTrait;
|
||||
|
||||
/**
|
||||
* @covers ::execute
|
||||
|
@ -103,13 +104,14 @@ class CheckMatchTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testExecuteWhenPerformerCannotSeeLogId() {
|
||||
$this->setExpectedApiException( 'apierror-permissiondenied-generic', 'cannotseedetails' );
|
||||
// Mock the FilterLookup service to return that the filter with the ID 1 is hidden.
|
||||
$mockLookup = $this->createMock( FilterLookup::class );
|
||||
$mockLookup->method( 'getFilter' )
|
||||
->with( 1, false )
|
||||
->willReturnCallback( function () {
|
||||
$filterObj = $this->createMock( ExistingFilter::class );
|
||||
$filterObj->method( 'getPrivacyLevel' )->willReturn( Flags::FILTER_HIDDEN );
|
||||
$filterObj->method( 'isHidden' )->willReturn( true );
|
||||
return $filterObj;
|
||||
} );
|
||||
$this->setService( FilterLookup::SERVICE_NAME, $mockLookup );
|
||||
|
@ -121,7 +123,6 @@ class CheckMatchTest extends ApiTestCase {
|
|||
)->addLogEntries( [ 1 => [ 'warn' ] ] );
|
||||
// Execute the API using a user with the 'abusefilter-modify' right but without the
|
||||
// 'abusefilter-log-detail' right, while specifying a filter abuse filter log ID of 1
|
||||
$this->expectApiErrorCode( 'cannotseedetails' );
|
||||
$this->doApiRequest(
|
||||
[
|
||||
'action' => 'abusefiltercheckmatch',
|
||||
|
|
Loading…
Reference in a new issue