X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fpassword%2FPasswordPolicyChecksTest.php;h=2d20f2c0ce8ddd05bbcf08007e4d6b441f5dc0e4;hp=7dfb3cf5f1b0ccb7b6f653bcef29b444121bb3d2;hb=4260b0f8a9bb89d92c39a61d8c48a31007b7240f;hpb=a2254d32bf816c28f2a3fb4088b5e4356cff4c48 diff --git a/tests/phpunit/includes/password/PasswordPolicyChecksTest.php b/tests/phpunit/includes/password/PasswordPolicyChecksTest.php index 7dfb3cf5f1..7ee1ec95e4 100644 --- a/tests/phpunit/includes/password/PasswordPolicyChecksTest.php +++ b/tests/phpunit/includes/password/PasswordPolicyChecksTest.php @@ -150,10 +150,48 @@ class PasswordPolicyChecksTest extends MediaWikiTestCase { global $IP; $this->setMwGlobals( [ 'wgSitename' => 'sitename', - 'wgPopularPasswordFile' => "$IP/serialized/commonpasswords.cdb" + 'wgPopularPasswordFile' => "$IP/includes/password/commonpasswords.cdb" ] ); $user = User::newFromName( 'username' ); $status = PasswordPolicyChecks::checkPopularPasswordBlacklist( PHP_INT_MAX, $user, $password ); $this->assertSame( $expected, $status->isGood() ); } + + public static function provideLargeBlacklist() { + return [ + [ false, 'testpass' ], + [ false, 'password' ], + [ false, '12345' ], + [ true, 'DKn17egcA4' ], + [ true, 'testwikijenkinspass' ], + ]; + } + + /** + * @covers PasswordPolicyChecks::checkPasswordNotInLargeBlacklist + * @dataProvider provideLargeBlacklist + */ + public function testCheckNotInLargeBlacklist( $expected, $password ) { + $user = User::newFromName( 'username' ); + $status = PasswordPolicyChecks::checkPasswordNotInLargeBlacklist( true, $user, $password ); + $this->assertSame( $expected, $status->isGood() ); + } + + /** + * Verify that all password policy description messages actually exist. + * Messages used on Special:PasswordPolicies + * @coversNothing + */ + public function testPasswordPolicyDescriptionsExist() { + global $wgPasswordPolicy; + $lang = Language::factory( 'en' ); + + foreach ( array_keys( $wgPasswordPolicy['checks'] ) as $check ) { + $msgKey = 'passwordpolicies-policy-' . strtolower( $check ); + $this->assertTrue( + wfMessage( $msgKey )->useDatabase( false )->inLanguage( $lang )->exists(), + "Message '$msgKey' required by '$check' must exist" + ); + } + } }