8000 [Security] Disabled the BCryptPasswordEncoder tests for PHP < 5.3.7 by jakzal · Pull Request #8009 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Disabled the BCryptPasswordEncoder tests for PHP < 5.3.7 #8009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ public function __construct($cost)
}

/**
* {@inheritdoc}
* Encodes the raw password.
*
* It doesn't work with PHP versions lower than 5.3.7, since
* the password compat library uses CRYPT_BLOWFISH hash type with
* the "$2y$" salt prefix (which is not available in the early PHP versions).
* @see https://github.com/ircmaxell/password_compat/issues/10#issuecomment-11203833
*
* @param string $raw The password to encode
* @param string $salt The salt
*
* @return string The encoded password
*/
public function encodePassword($raw, $salt)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,27 @@ public function testCostInRange()

public function testResultLength()
{
$this->skipIfPhpVersionIsNotSupported();

$encoder = new BCryptPasswordEncoder(self::VALID_COST);
$result = $encoder->encodePassword(self::PASSWORD, null);
$this->assertEquals(60, strlen($result));
}

public function testValidation()
{
$this->skipIfPhpVersionIsNotSupported();

$encoder = new BCryptPasswordEncoder(self::VALID_COST);
$result = $encoder->encodePassword(self::PASSWORD, null);
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
$this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
}

private function skipIfPhpVersionIsNotSupported()
{
if (version_compare(phpversion(), '5.3.7', '<')) {
$this->markTestSkipped('Requires PHP >= 5.3.7');
}
}
}
0