8000 merged branch jakzal/testfix/bcrypt-before-5-3-7 (PR #8009) · symfony/symfony@4b3ae5d · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b3ae5d

Browse files
committed
merged branch jakzal/testfix/bcrypt-before-5-3-7 (PR #8009)
This PR was merged into the master branch. Discussion ---------- [Security] Disabled the BCryptPasswordEncoder tests for PHP < 5.3.7 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no (segfault) | Fixed tickets | #7994 | License | MIT | Doc PR | - See ircmaxell/password_compat#10 (comment). Commits ------- 3beaf52 [Security] Disabled the BCryptPasswordEncoder tests for PHP versions lower than 5.3.7.
2 parents 1c61996 + 3beaf52 commit 4b3ae5d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,17 @@ public function __construct($cost)
4646
}
4747

4848
/**
49-
* {@inheritdoc}
49+
* Encodes the raw password.
50+
*
51+
* It doesn't work with PHP versions lower than 5.3.7, since
52+
* the password compat library uses CRYPT_BLOWFISH hash type with
53+
* the "$2y$" salt prefix (which is not available in the early PHP versions).
54+
* @see https://github.com/ircmaxell/password_compat/issues/10#issuecomment-11203833
55+
*
56+
* @param string $raw The password to encode
57+
* @param string $salt The salt
58+
*
59+
* @return string The encoded password
5060
*/
5161
public function encodePassword($raw, $salt)
5262
{

src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,27 @@ public function testCostInRange()
4747

4848
public function testResultLength()
4949
{
50+
$this->skipIfPhpVersionIsNotSupported();
51+
5052
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
5153
$result = $encoder->encodePassword(self::PASSWORD, null);
5254
$this->assertEquals(60, strlen($result));
5355
}
5456

5557
public function testValidation()
5658
{
59+
$this->skipIfPhpVersionIsNotSupported();
60+
5761
$encoder = new BCryptPasswordEncoder(self::VALID_COST);
5862
$result = $encoder->encodePassword(self::PASSWORD, null);
5963
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
6064
$this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
6165
}
66+
67+
private function skipIfPhpVersionIsNotSupported()
68+
{
69+
if (version_compare(phpversion(), '5.3.7', '<')) {
70+
$this->markTestSkipped('Requires PHP >= 5.3.7');
71+
}
72+
}
6273
}

0 commit comments

Comments
 (0)
0