diff options
Diffstat (limited to 'AntiSpoof/tests/phpunit')
4 files changed, 39 insertions, 3 deletions
diff --git a/AntiSpoof/tests/phpunit/AntiSpoofAuthenticationRequestTest.php b/AntiSpoof/tests/phpunit/AntiSpoofAuthenticationRequestTest.php index a4855389..abd18be7 100644 --- a/AntiSpoof/tests/phpunit/AntiSpoofAuthenticationRequestTest.php +++ b/AntiSpoof/tests/phpunit/AntiSpoofAuthenticationRequestTest.php @@ -2,6 +2,9 @@ use MediaWiki\Auth\AuthenticationRequestTestCase; +/** + * @covers AntiSpoofAuthenticationRequest + */ class AntiSpoofAuthenticationRequestTest extends AuthenticationRequestTestCase { protected function getInstance( array $args = [] ) { diff --git a/AntiSpoof/tests/phpunit/AntiSpoofPreAuthenticationProviderTest.php b/AntiSpoof/tests/phpunit/AntiSpoofPreAuthenticationProviderTest.php index abac19aa..2a0c56f2 100644 --- a/AntiSpoof/tests/phpunit/AntiSpoofPreAuthenticationProviderTest.php +++ b/AntiSpoof/tests/phpunit/AntiSpoofPreAuthenticationProviderTest.php @@ -3,6 +3,7 @@ use MediaWiki\Auth\AuthManager; /** + * @covers AntiSpoofPreAuthenticationProvider * @group Database */ class AntiSpoofPreAuthenticationProviderTest extends MediaWikiTestCase { @@ -43,7 +44,7 @@ class AntiSpoofPreAuthenticationProviderTest extends MediaWikiTestCase { * @dataProvider provideTestForAccountCreation */ public function testTestForAccountCreation( - $enabled, $isLegal, $conflicts, $creator, $reqs, $error + $enabled, $isLegal, $conflicts, $creator, $reqs, $error ) { $provider = $this->getMockBuilder( AntiSpoofPreAuthenticationProvider::class ) ->setConstructorArgs( [ [ 'antiSpoofAccounts' => $enabled ] ] ) @@ -56,6 +57,8 @@ class AntiSpoofPreAuthenticationProviderTest extends MediaWikiTestCase { $provider->setLogger( new \Psr\Log\NullLogger() ); $spoofUser->expects( $this->any() )->method( 'isLegal' )->willReturn( $isLegal ); + $spoofUser->expects( $this->any() )->method( 'getErrorStatus' ) + ->willReturn( Status::newFatal( 'unittest' ) ); $spoofUser->expects( $this->any() )->method( 'getConflicts' )->willReturn( $conflicts ); /** @var StatusValue $status */ diff --git a/AntiSpoof/tests/phpunit/AntiSpoofTest.php b/AntiSpoof/tests/phpunit/AntiSpoofTest.php index d65df3ba..9a5edb99 100644 --- a/AntiSpoof/tests/phpunit/AntiSpoofTest.php +++ b/AntiSpoof/tests/phpunit/AntiSpoofTest.php @@ -1,4 +1,9 @@ <?php + +/** + * @covers AntiSpoof + * @group AntiSpoof + */ class AntiSpoofTest extends MediaWikiTestCase { public function providePositives() { @@ -10,14 +15,16 @@ class AntiSpoofTest extends MediaWikiTestCase { [ 'Sabbut', 'ЅаЬЬцт' ], [ 'BetoCG', 'ВетоС6' ], [ 'Wanda', 'vv4ndá' ], - [ 'Mario', 'rnAr10' ] + [ 'Mario', 'rnAr10' ], + [ 'CEASAR', 'ceasar' ], + [ 'ceasar', 'CEASAR' ], + [ 'jimmy wales', 'j1mmy w4l35' ] ]; } /** * Some very basic normalization checks * - * @covers AntiSpoof::checkUnicodeString * @dataProvider providePositives */ public function testCheckUnicodeString( $userName, $spooferName ) { @@ -29,4 +36,26 @@ class AntiSpoofTest extends MediaWikiTestCase { $this->assertEquals( $a[1], $b[1] ); } + + public function provideMixedCharSets() { + return [ + /** Format: username -> spoofing attempt */ + [ 'Recursive O Tester', 'Recursive Θ Tester' ], + [ 'Recursive 0 Tester', 'Recursive Θ Tester' ], + ]; + } + + /** + * Test mixed character set strings failure. + * + * @dataProvider provideMixedCharSets + */ + public function testCheckStringMixedCharSetFailure( $userName, $spooferName ) { + $a = AntiSpoof::checkUnicodeString( $userName ); + $b = AntiSpoof::checkUnicodeString( $spooferName ); + + $this->assertEquals( 'OK', $a[0] ); + $this->assertEquals( 'ERROR', $b[0] ); + $this->assertEquals( 'Contains incompatible mixed scripts', $b[1] ); + } } diff --git a/AntiSpoof/tests/phpunit/SpoofUserTest.php b/AntiSpoof/tests/phpunit/SpoofUserTest.php index 4229d19c..a84e50c3 100644 --- a/AntiSpoof/tests/phpunit/SpoofUserTest.php +++ b/AntiSpoof/tests/phpunit/SpoofUserTest.php @@ -1,6 +1,7 @@ <?php /** + * @covers SpoofUser * @group Database */ class SpoofUserTest extends MediaWikiTestCase { |