4require_once 
'Services/Password/classes/encoders/class.ilBcryptPasswordEncoder.php';
 
    5require_once 
'Services/Password/test/ilPasswordBaseTest.php';
 
   88        vfs\vfsStream::setup();
 
   89        $this->
setTestDirectory(vfs\vfsStream::newDirectory(
'tests')->at(vfs\vfsStreamWrapper::getRoot()));
 
  100        if (version_compare(phpversion(), 
'5.3.7', 
'<')) {
 
  101            $this->markTestSkipped(
'Requires PHP >= 5.3.7');
 
  111        for (
$i = 4; 
$i <= 31; 
$i++) {
 
  135            'ignore_security_flaw' => 
true,
 
  138        $this->assertTrue($security_flaw_ignoring_encoder->isSecurityFlawIgnored());
 
  141            'ignore_security_flaw' => 
false,
 
  144        $this->assertFalse($security_flaw_respecting_encoder->isSecurityFlawIgnored());
 
  147            'cost' => self::VALID_COSTS,
 
  150        $this->assertInstanceOf(
'ilBcryptPasswordEncoder', $encoder);
 
  151        $this->assertEquals(self::VALID_COSTS, $encoder->getCosts());
 
  152        $this->assertFalse($encoder->isSecurityFlawIgnored());
 
  153        $encoder->setClientSalt(self::CLIENT_SALT);
 
  164        $this->assertEquals(4, $encoder->
getCosts());
 
  201        $encoder->
setCosts(self::VALID_COSTS);
 
  202        $encoded_password = $encoder->
encodePassword(self::PASSWORD, self::PASSWORD_SALT);
 
  203        $this->assertTrue($encoder->
isPasswordValid($encoded_password, self::PASSWORD, self::PASSWORD_SALT));
 
  204        $this->assertFalse($encoder->
isPasswordValid($encoded_password, self::WRONG_PASSWORD, self::PASSWORD_SALT));
 
  215        $encoder->
setCosts(self::VALID_COSTS);
 
  216        $encoder->
encodePassword(str_repeat(
'a', 5000), self::PASSWORD_SALT);
 
  224        $encoder->
setCosts(self::VALID_COSTS);
 
  225        $this->assertFalse($encoder->
isPasswordValid(
'encoded', str_repeat(
'a', 5000), self::PASSWORD_SALT));
 
  249        $this->assertEquals(
'bcrypt', $encoder->
getName());
 
  259        $encoder->setClientSalt(
null);
 
  260        $encoder->setCosts(self::VALID_COSTS);
 
  261        $encoder->encodePassword(self::PASSWORD, self::PASSWORD_SALT);
 
  271        $encoder->setClientSalt(
null);
 
  272        $encoder->setCosts(self::VALID_COSTS);
 
  273        $encoder->isPasswordValid(
'12121212', self::PASSWORD, self::PASSWORD_SALT);
 
  285        $this->assertEquals(self::CLIENT_SALT, $encoder->getClientSalt());
 
  296        $this->assertNotNull($encoder->getClientSalt());
 
  316        $encoder->setBackwardCompatibility(
true);
 
  317        $this->assertTrue($encoder->isBackwardCompatibilityEnabled());
 
  318        $encoder->setBackwardCompatibility(
false);
 
  319        $this->assertFalse($encoder->isBackwardCompatibilityEnabled());
 
  330        $encoder->setClientSalt(self::CLIENT_SALT);
 
  331        $encoder->setBackwardCompatibility(
true);
 
  332        $encoded_password = $encoder->encodePassword(self::PASSWORD, self::PASSWORD_SALT);
 
  333        $this->assertTrue($encoder->isPasswordValid($encoded_password, self::PASSWORD, self::PASSWORD_SALT));
 
  334        $this->assertEquals(
'$2a$', substr($encoded_password, 0, 4));
 
  337        $another_encoder->setClientSalt(self::CLIENT_SALT);
 
  338        $another_encoder->setBackwardCompatibility(
false);
 
  339        $another_encoded_password = $another_encoder->encodePassword(self::PASSWORD, self::PASSWORD_SALT);
 
  340        $this->assertEquals(
'$2y$', substr($another_encoded_password, 0, 4));
 
  341        $this->assertTrue($another_encoder->isPasswordValid($encoded_password, self::PASSWORD, self::PASSWORD_SALT));
 
  351        $encoder->setClientSalt(self::CLIENT_SALT);
 
  352        $encoder->setBackwardCompatibility(
true);
 
  353        $encoder->encodePassword(self::PASSWORD . chr(195), self::PASSWORD_SALT);
 
  362        $encoder->setClientSalt(self::CLIENT_SALT);
 
  363        $encoder->setBackwardCompatibility(
true);
 
  364        $encoder->setIsSecurityFlawIgnored(
true);
 
  365        $encoder->encodePassword(self::PASSWORD . chr(195), self::PASSWORD_SALT);
 
An exception for terminatinating execution or to throw for unit testing.
testClientSaltIsGeneratedWhenNoClientSaltExistsYet()
setTestDirectoryUrl($test_directory_url)
testInstanceCanBeCreatedAndInitializedWithClientSalt()
testPasswordVerificationShouldFailIfTheRawPasswordExceedsTheSupportedLength(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated
getInstanceWithConfiguredDataDirectory()
skipIfPhpVersionIsNotSupported()
testPasswordShouldBeCorrectlyEncodedAndVerified(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated
setTestDirectory($test_directory)
testCostsCanBeRetrievedWhenCostsAreSet(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testBackwardCompatibilityCanBeRetrievedWhenBackwardCompatibilityIsSet()
testCostsCannotBeSetBelowRange(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated @expectedException ilPasswordException
testCostsCanBeSetInRange($costs, ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated @dataProvider costsProvider
testExceptionIsRaisedIfSaltIsMissingIsOnEncoding()
@expectedException ilPasswordException
testExceptionIsRaisedIfTheRawPasswordContainsA8BitCharacterAndBackwardCompatibilityIsEnabled()
@expectedException ilPasswordException
testInstanceCanBeCreated()
testExceptionIsRaisedIfSaltIsMissingIsOnVerification()
@expectedException ilPasswordException
testExceptionIsNotRaisedIfTheRawPasswordContainsA8BitCharacterAndBackwardCompatibilityIsEnabledWithIgnoredSecurityFlaw()
testEncoderReliesOnSalts(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testExceptionIsRaisedIfThePasswordExceedsTheSupportedLengthOnEncoding(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated @expectedException ilPasswordException
testBackwardCompatibility()
testEncoderDoesNotSupportReencoding(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testCostsCannotBeSetAboveRange(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated @expectedException ilPasswordException
testNameShouldBeBcrypt(ilBcryptPasswordEncoder $encoder)
@depends testInstanceCanBeCreated
testExceptionIsRaisedWhenClientSaltCouldNotBeGeneratedInCaseNoClientSaltExistsYet()
@expectedException ilPasswordException
const SALT_STORAGE_FILENAME
encodePassword($raw, $salt)
{{Encodes the raw password.string The encoded password}}
requiresReencoding($encoded)
{{{Returns whether or not the a encoded password needs to be re-encoded.boolean}}}
isPasswordValid($encoded, $raw, $salt)
{{Checks a raw password against an encoded password.The raw password has to be injected into the enco...
requiresSalt()
{{Returns whether or not the encoder requires a salt.boolean}}
assertException($exception_class)