1 <?php declare(strict_types=1);
4 require_once
'Services/Password/classes/encoders/class.ilBcryptPhpPasswordEncoder.php';
5 require_once
'Services/Password/test/ilPasswordBaseTest.php';
28 if (version_compare(phpversion(),
'5.5.0',
'<')) {
29 $this->markTestSkipped(
'Requires PHP >= 5.5.0');
39 for (
$i = 4;
$i <= 31;
$i++) {
40 $data[sprintf(
"Costs: %s", (
string)
$i)] = [(string) $i];
55 $this->assertTrue((
int) $default_costs_encoder->getCosts() > 4 && (int) $default_costs_encoder->getCosts() < 32);
58 'cost' => self::VALID_COSTS
60 $this->assertInstanceOf(
'ilBcryptPhpPasswordEncoder', $encoder);
61 $this->assertEquals(self::VALID_COSTS, $encoder->getCosts());
75 $this->assertEquals($expected, $encoder->
getCosts());
85 $this->expectException(ilPasswordException::class);
96 $this->expectException(ilPasswordException::class);
122 $encoder->
setCosts(self::VALID_COSTS);
124 $this->assertTrue($encoder->
isPasswordValid($encoded_password, self::PASSWORD,
''));
125 $this->assertFalse($encoder->
isPasswordValid($encoded_password, self::WRONG_PASSWORD,
''));
137 $this->expectException(ilPasswordException::class);
138 $encoder->
setCosts(self::VALID_COSTS);
150 $encoder->
setCosts(self::VALID_COSTS);
151 $this->assertFalse($encoder->
isPasswordValid(
'encoded', str_repeat(
'a', 5000),
''));
160 $this->assertEquals(
'bcryptphp', $encoder->
getName());
173 $this->assertTrue($costs_default > 4 && $costs_default < 32);
174 $this->assertTrue($costs_target > 4 && $costs_target < 32);
175 $this->assertIsInt($costs_default);
176 $this->assertIsInt($costs_target);
177 $this->assertNotEquals($costs_default, $costs_target);
196 $raw = self::PASSWORD;
testCostsCanBeDeterminedDynamically(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testCostsCannotBeSetAboveRange(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testCostsCanBeSetInRange(string $costs, ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated costsProvider
testEncoderDoesNotRelyOnSalts(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
skipIfPhpVersionIsNotSupported()
encodePassword(string $raw, string $salt)
testInstanceCanBeCreated()
benchmarkCost(float $time_target=0.05)
requiresReencoding(string $encoded)
testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testNameShouldBeBcryptPhp(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testPasswordShouldBeCorrectlyEncodedAndVerified(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testReencodingIsDetectedWhenNecessary(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testCostsCannotBeSetBelowRange(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
isPasswordValid(string $encoded, string $raw, string $salt)
testCostsCanBeRetrievedWhenCostsAreSet(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testPasswordVerificationShouldFailIfTheRawPasswordExceedsTheSupportedLength(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated