X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fpassword%2FPasswordPolicyChecksTest.php;h=7dfb3cf5f1b0ccb7b6f653bcef29b444121bb3d2;hb=c8e482371407477ecd4f0a1b5778e565d3963a93;hp=af34282fb316e6dde301c36c806f07b2d13e2eb0;hpb=f873b499650ef5d27570f9cb96d01d1477f9e089;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/password/PasswordPolicyChecksTest.php b/tests/phpunit/includes/password/PasswordPolicyChecksTest.php index af34282fb3..7dfb3cf5f1 100644 --- a/tests/phpunit/includes/password/PasswordPolicyChecksTest.php +++ b/tests/phpunit/includes/password/PasswordPolicyChecksTest.php @@ -42,7 +42,7 @@ class PasswordPolicyChecksTest extends MediaWikiTestCase { 'Password is shorter than minimal policy' ); $this->assertTrue( - $statusShort->isOk(), + $statusShort->isOK(), 'Password is shorter than minimal policy, not fatal' ); } @@ -67,7 +67,7 @@ class PasswordPolicyChecksTest extends MediaWikiTestCase { 'Password is shorter than minimum login policy' ); $this->assertFalse( - $statusShort->isOk(), + $statusShort->isOK(), 'Password is shorter than minimum login policy, fatal' ); } @@ -90,7 +90,7 @@ class PasswordPolicyChecksTest extends MediaWikiTestCase { $this->assertFalse( $statusLong->isGood(), 'Password is longer than maximal policy' ); - $this->assertFalse( $statusLong->isOk(), + $this->assertFalse( $statusLong->isOK(), 'Password is longer than maximal policy, fatal' ); } @@ -111,7 +111,7 @@ class PasswordPolicyChecksTest extends MediaWikiTestCase { 'user' // password ); $this->assertFalse( $statusLong->isGood(), 'Password matches username' ); - $this->assertTrue( $statusLong->isOk(), 'Password matches username, not fatal' ); + $this->assertTrue( $statusLong->isOK(), 'Password matches username, not fatal' ); } /** @@ -130,7 +130,30 @@ class PasswordPolicyChecksTest extends MediaWikiTestCase { 'Passpass1' // password ); $this->assertFalse( $statusLong->isGood(), 'Password matches blacklist' ); - $this->assertTrue( $statusLong->isOk(), 'Password matches blacklist, not fatal' ); + $this->assertTrue( $statusLong->isOK(), 'Password matches blacklist, not fatal' ); } + public static function providePopularBlacklist() { + return [ + [ false, 'sitename' ], + [ false, 'password' ], + [ false, '12345' ], + [ true, 'hqY98gCZ6qM8s8' ], + ]; + } + + /** + * @covers PasswordPolicyChecks::checkPopularPasswordBlacklist + * @dataProvider providePopularBlacklist + */ + public function testCheckPopularPasswordBlacklist( $expected, $password ) { + global $IP; + $this->setMwGlobals( [ + 'wgSitename' => 'sitename', + 'wgPopularPasswordFile' => "$IP/serialized/commonpasswords.cdb" + ] ); + $user = User::newFromName( 'username' ); + $status = PasswordPolicyChecks::checkPopularPasswordBlacklist( PHP_INT_MAX, $user, $password ); + $this->assertSame( $expected, $status->isGood() ); + } }