2016-05-07 11:21:02 +00:00
|
|
|
<?php
|
2019-06-05 16:27:36 +00:00
|
|
|
|
2016-05-07 11:21:02 +00:00
|
|
|
use MediaWiki\Auth\AuthManager;
|
2022-04-08 13:20:08 +00:00
|
|
|
use MediaWiki\Extension\TitleBlacklist\TitleBlacklistAuthenticationRequest;
|
|
|
|
use MediaWiki\Extension\TitleBlacklist\TitleBlacklistPreAuthenticationProvider;
|
2021-05-07 12:33:56 +00:00
|
|
|
use MediaWiki\Tests\Unit\Auth\AuthenticationProviderTestTrait;
|
2016-05-07 11:21:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group Database
|
2022-04-08 13:20:08 +00:00
|
|
|
* @covers \MediaWiki\Extension\TitleBlacklist\TitleBlacklistPreAuthenticationProvider
|
2016-05-07 11:21:02 +00:00
|
|
|
*/
|
2021-05-07 12:33:56 +00:00
|
|
|
class TitleBlacklistPreAuthenticationProviderTest extends MediaWikiIntegrationTestCase {
|
|
|
|
use AuthenticationProviderTestTrait;
|
|
|
|
|
2016-05-07 11:21:02 +00:00
|
|
|
/**
|
|
|
|
* @dataProvider provideGetAuthenticationRequests
|
|
|
|
*/
|
2023-12-27 23:53:21 +00:00
|
|
|
public function testGetAuthenticationRequests( $action, $provideUser, $expectedReqs ) {
|
|
|
|
$username = $provideUser ? $this->getTestSysop()->getUser()->getName() : null;
|
|
|
|
|
2016-05-07 11:21:02 +00:00
|
|
|
$provider = new TitleBlacklistPreAuthenticationProvider();
|
2021-05-07 12:33:56 +00:00
|
|
|
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
|
2016-05-07 11:21:02 +00:00
|
|
|
$reqs = $provider->getAuthenticationRequests( $action, [ 'username' => $username ] );
|
|
|
|
$this->assertEquals( $expectedReqs, $reqs );
|
|
|
|
}
|
|
|
|
|
2023-05-20 12:16:31 +00:00
|
|
|
public static function provideGetAuthenticationRequests() {
|
2016-05-07 11:21:02 +00:00
|
|
|
return [
|
2023-12-27 23:53:21 +00:00
|
|
|
[ AuthManager::ACTION_LOGIN, false, [] ],
|
|
|
|
[ AuthManager::ACTION_CREATE, false, [] ],
|
|
|
|
[ AuthManager::ACTION_CREATE, true, [ new TitleBlacklistAuthenticationRequest() ] ],
|
|
|
|
[ AuthManager::ACTION_CHANGE, false, [] ],
|
|
|
|
[ AuthManager::ACTION_REMOVE, false, [] ],
|
2016-05-07 11:21:02 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|