X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fpassword%2FPasswordTestCase.php;h=80b9838d8eba111846d2f78c5e47d8e8706f46b6;hb=1abc89fc7651e122ca53fe874eecb89f30b5ba35;hp=7820d535ff51022fed8a2908219ad9ef17cfed3f;hpb=04d7d46b1d39340121698ba76fd8e433f60929c9;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/password/PasswordTestCase.php b/tests/phpunit/includes/password/PasswordTestCase.php index 7820d535ff..80b9838d8e 100644 --- a/tests/phpunit/includes/password/PasswordTestCase.php +++ b/tests/phpunit/includes/password/PasswordTestCase.php @@ -49,10 +49,13 @@ abstract class PasswordTestCase extends MediaWikiTestCase { * An array of tests in the form of (bool, string, string), where the first * element is whether the second parameter (a password hash) and the third * parameter (a password) should match. - * * @return array + * @throws MWException + * @abstract */ - abstract public function providePasswordTests(); + public static function providePasswordTests() { + throw new MWException( "Not implemented" ); + } /** * @dataProvider providePasswordTests @@ -75,8 +78,7 @@ abstract class PasswordTestCase extends MediaWikiTestCase { /** * @dataProvider providePasswordTests - * @covers InvalidPassword::equals - * @covers InvalidPassword::toString + * @covers InvalidPassword */ public function testInvalidUnequalNormal( $shouldMatch, $hash, $password ) { $invalid = $this->passwordFactory->newFromCiphertext( null ); @@ -85,4 +87,26 @@ abstract class PasswordTestCase extends MediaWikiTestCase { $this->assertFalse( $invalid->equals( $normal ) ); $this->assertFalse( $normal->equals( $invalid ) ); } + + protected function getValidTypes() { + return array_keys( $this->getTypeConfigs() ); + } + + public function provideTypes( $type ) { + $params = []; + foreach ( $this->getValidTypes() as $type ) { + $params[] = [ $type ]; + } + return $params; + } + + /** + * @dataProvider provideTypes + */ + public function testCrypt( $type ) { + $fromType = $this->passwordFactory->newFromType( $type ); + $fromType->crypt( 'password' ); + $fromPlaintext = $this->passwordFactory->newFromPlaintext( 'password', $fromType ); + $this->assertTrue( $fromType->equals( $fromPlaintext ) ); + } }