From 21% to 82%. * Added missing @covers, broadened @covers where appropriate. * Added tests for some code that lacked them. * Added a parameter to control the use of hash_pbkdf2() so that the pure PHP fallback could be tested. In the non-fallback test, force the use of the extension, and mark it skipped if it is not installed. Bug: T167003 Change-Id: I987e1a89ec343907f4ead7f6192b2d4deb58ac16
63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @covers LayeredParameterizedPassword
|
|
* @covers Password
|
|
*/
|
|
class LayeredParameterizedPasswordTest extends PasswordTestCase {
|
|
protected function getTypeConfigs() {
|
|
return [
|
|
'testLargeLayeredTop' => [
|
|
'class' => 'LayeredParameterizedPassword',
|
|
'types' => [
|
|
'testLargeLayeredBottom',
|
|
'testLargeLayeredBottom',
|
|
'testLargeLayeredBottom',
|
|
'testLargeLayeredBottom',
|
|
'testLargeLayeredFinal',
|
|
],
|
|
],
|
|
'testLargeLayeredBottom' => [
|
|
'class' => 'Pbkdf2Password',
|
|
'algo' => 'sha512',
|
|
'cost' => 1024,
|
|
'length' => 512,
|
|
],
|
|
'testLargeLayeredFinal' => [
|
|
'class' => 'BcryptPassword',
|
|
'cost' => 5,
|
|
]
|
|
];
|
|
}
|
|
|
|
protected function getValidTypes() {
|
|
return [ 'testLargeLayeredFinal' ];
|
|
}
|
|
|
|
public static function providePasswordTests() {
|
|
// @codingStandardsIgnoreStart Generic.Files.LineLength.TooLong
|
|
return [
|
|
[
|
|
true,
|
|
':testLargeLayeredTop:sha512:1024:512!sha512:1024:512!sha512:1024:512!sha512:1024:512!5!vnRy+2SrSA0fHt3dwhTP5g==!AVnwfZsAQjn+gULv7FSGjA==!xvHUX3WcpkeSn1lvjWcvBg==!It+OC/N9tu+d3ByHhuB0BQ==!Tb.gqUOiD.aWktVwHM.Q/O!7CcyMfXUPky5ptyATJsR2nq3vUqtnBC',
|
|
'testPassword123'
|
|
],
|
|
];
|
|
// @codingStandardsIgnoreEnd
|
|
}
|
|
|
|
/**
|
|
* @covers LayeredParameterizedPassword::partialCrypt
|
|
*/
|
|
public function testLargeLayeredPartialUpdate() {
|
|
/** @var ParameterizedPassword $partialPassword */
|
|
$partialPassword = $this->passwordFactory->newFromType( 'testLargeLayeredBottom' );
|
|
$partialPassword->crypt( 'testPassword123' );
|
|
|
|
/** @var LayeredParameterizedPassword $totalPassword */
|
|
$totalPassword = $this->passwordFactory->newFromType( 'testLargeLayeredTop' );
|
|
$totalPassword->partialCrypt( $partialPassword );
|
|
|
|
$this->assertTrue( $totalPassword->equals( 'testPassword123' ) );
|
|
}
|
|
}
|