4 require_once
'Services/Password/classes/encoders/class.ilBcryptPhpPasswordEncoder.php';
5 require_once
'Services/Password/test/ilPasswordBaseTest.php';
41 if (version_compare(phpversion(),
'5.5.0',
'<')) {
42 $this->markTestSkipped(
'Requires PHP >= 5.5.0');
52 for (
$i = 4;
$i <= 31;
$i++) {
66 $this->assertTrue((
int) $default_costs_encoder->getCosts() > 4 && (int) $default_costs_encoder->getCosts() < 32);
69 'cost' => self::VALID_COSTS
71 $this->assertInstanceOf(
'ilBcryptPhpPasswordEncoder', $encoder);
72 $this->assertEquals(self::VALID_COSTS, $encoder->getCosts());
82 $this->assertEquals(4, $encoder->
getCosts());
119 $encoder->
setCosts(self::VALID_COSTS);
121 $this->assertTrue($encoder->
isPasswordValid($encoded_password, self::PASSWORD,
''));
122 $this->assertFalse($encoder->
isPasswordValid($encoded_password, self::WRONG_PASSWORD,
''));
133 $encoder->
setCosts(self::VALID_COSTS);
142 $encoder->
setCosts(self::VALID_COSTS);
143 $this->assertFalse($encoder->
isPasswordValid(
'encoded', str_repeat(
'a', 5000),
''));
151 $this->assertEquals(
'bcryptphp', $encoder->
getName());
162 $this->assertTrue($costs_default > 4 && $costs_default < 32);
163 $this->assertTrue($costs_target > 4 && $costs_target < 32);
164 $this->assertInternalType(
'int', $costs_default);
165 $this->assertInternalType(
'int', $costs_target);
166 $this->assertNotEquals($costs_default, $costs_target);
182 $raw = self::PASSWORD;
testCostsCanBeDeterminedDynamically(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testCostsCannotBeSetAboveRange(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated ilPasswordException
testEncoderDoesNotRelyOnSalts(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
benchmarkCost($time_target=0.05)
skipIfPhpVersionIsNotSupported()
requiresSalt()
{Returns whether or not the encoder requires a salt.boolean}
testCostsCanBeSetInRange($costs, ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated costsProvider
isPasswordValid($encoded, $raw, $salt)
{Checks a raw password against an encoded password.The raw password has to be injected into the encod...
testInstanceCanBeCreated()
requiresReencoding($encoded)
{Returns whether or not the a encoded password needs to be re-encoded.string boolean} ...
testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated ilPasswordException
testNameShouldBeBcryptPhp(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testPasswordShouldBeCorrectlyEncodedAndVerified(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testReencodingIsDetectedWhenNecessary(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testCostsCannotBeSetBelowRange(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated ilPasswordException
encodePassword($raw, $salt)
{Encodes the raw password.The password to encode The salt string The encoded password} ...
assertException($exception_class)
testCostsCanBeRetrievedWhenCostsAreSet(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated
testPasswordVerificationShouldFailIfTheRawPasswordExceedsTheSupportedLength(ilBcryptPhpPasswordEncoder $encoder)
testInstanceCanBeCreated