Remove Argon2PasswordTest::testPartialConfig(). It's irreparably slow and doesn't seem to test anything useful, just that the defaults are the defaults. It was added in PS5 of Ifdf648f5d8a734a663e6 as part of a change which removed explicit cost defaults from DefaultSettings.php. Reduce time costs of some other tests. The time to execute tests in this directory is reduced from ~1.3s to ~0.5s. Bug: T225730 Change-Id: I30b846b5364ad2030e2547da6c58db13eaf401f2
88 lines
2.2 KiB
PHP
88 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group large
|
|
* @covers Argon2Password
|
|
* @covers Password
|
|
* @covers ParameterizedPassword
|
|
*/
|
|
class Argon2PasswordTest extends PasswordTestCase {
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
if ( !defined( 'PASSWORD_ARGON2I' ) ) {
|
|
$this->markTestSkipped( 'Argon2 support not found' );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Return an array of configs to be used for this class's password type.
|
|
*
|
|
* @return array[]
|
|
*/
|
|
protected function getTypeConfigs() {
|
|
return [
|
|
'argon2' => [
|
|
'class' => Argon2Password::class,
|
|
'algo' => 'argon2i',
|
|
'memory_cost' => 1024,
|
|
'time_cost' => 2,
|
|
'threads' => 2,
|
|
]
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function providePasswordTests() {
|
|
$result = [
|
|
[
|
|
true,
|
|
':argon2:$argon2i$v=19$m=1024,t=2,p=2$RHpGTXJPeFlSV2NDTEswNA$VeW7rumZY4pL8XO4KeQkKD43r5uX3eazVJRtrFN7lNc',
|
|
'password',
|
|
],
|
|
[
|
|
true,
|
|
':argon2:$argon2i$v=19$m=2048,t=5,p=3$MHFKSnh6WWZEWkpKa09SUQ$vU92h/8hkByL5VKW1P9amCj054pZILGKznAvKWAivZE',
|
|
'password',
|
|
],
|
|
[
|
|
true,
|
|
':argon2:$argon2i$v=19$m=1024,t=2,p=2$bFJ4TzM5RWh2T0VmeFhDTA$AHFUFZRh69aZYBqyxn6tpujpEcf2JP8wgRCPU3nw3W4',
|
|
"pass\x00word",
|
|
],
|
|
[
|
|
false,
|
|
':argon2:$argon2i$v=19$m=1024,t=2,p=2$UGZqTWJRUkI1alVNTGRUbA$RcASw9XUWjCDO9WNnuVkGkEylURUW/CcNwSffdFwN74',
|
|
'password',
|
|
],
|
|
// argon2id
|
|
[
|
|
true,
|
|
':argon2:$argon2id$v=19$m=65536,t=1,p=1$SS51Z0U2bkQ5Mk1GYUNQOQ$jdN3UnHn6MHOaOeWiX+RqRhcwVPLLDlEAKPvDt/qKIY',
|
|
'password'
|
|
]
|
|
];
|
|
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideNeedsUpdate
|
|
*/
|
|
public function testNeedsUpdate( $updateExpected, $hash ) {
|
|
$password = $this->passwordFactory->newFromCiphertext( $hash );
|
|
$this->assertSame( $updateExpected, $password->needsUpdate() );
|
|
}
|
|
|
|
public function provideNeedsUpdate() {
|
|
return [
|
|
[ false, ':argon2:$argon2i$v=19$m=1024,t=2,p=2$bFJ4TzM5RWh2T0VmeFhDTA$AHFUFZRh69aZYBqyxn6tpujpEcf2JP8wgRCPU3nw3W4' ],
|
|
[ false, ':argon2:$argon2i$v=19$m=1024,t=2,p=2$<whatever>' ],
|
|
[ true, ':argon2:$argon2i$v=19$m=666,t=2,p=2$<whatever>' ],
|
|
[ true, ':argon2:$argon2i$v=19$m=1024,t=666,p=2$<whatever>' ],
|
|
[ true, ':argon2:$argon2i$v=19$m=1024,t=2,p=666$<whatever>' ],
|
|
];
|
|
}
|
|
}
|