diff options
author | Fabien Potencier <fabien.potencier@gmail.com> | 2013-02-05 15:08:32 +0100 |
---|---|---|
committer | Fabien Potencier <fabien.potencier@gmail.com> | 2013-02-05 15:08:32 +0100 |
commit | f02a0c86b6264fc461fc86d39704579439445d3e (patch) | |
tree | 966e6391e009d2761f7f3663944a6d96da3e0939 | |
parent | 43ddef96e495136b3902c3808ec05818f53b89c4 (diff) | |
download | symfony-security-f02a0c86b6264fc461fc86d39704579439445d3e.zip symfony-security-f02a0c86b6264fc461fc86d39704579439445d3e.tar.gz symfony-security-f02a0c86b6264fc461fc86d39704579439445d3e.tar.bz2 |
[Security] fixed interface implementation (closes #6974)
-rw-r--r-- | Core/Encoder/BCryptPasswordEncoder.php | 4 | ||||
-rw-r--r-- | Tests/Core/Encoder/BCryptPasswordEncoderTest.php | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/Core/Encoder/BCryptPasswordEncoder.php b/Core/Encoder/BCryptPasswordEncoder.php index cdf204b..1b7572d 100644 --- a/Core/Encoder/BCryptPasswordEncoder.php +++ b/Core/Encoder/BCryptPasswordEncoder.php @@ -58,7 +58,7 @@ class BCryptPasswordEncoder extends BasePasswordEncoder /** * {@inheritdoc} */ - public function encodePassword($raw, $salt = null) + public function encodePassword($raw, $salt) { if (function_exists('password_hash')) { return password_hash($raw, PASSWORD_BCRYPT, array('cost' => $this->cost)); @@ -76,7 +76,7 @@ class BCryptPasswordEncoder extends BasePasswordEncoder /** * {@inheritdoc} */ - public function isPasswordValid($encoded, $raw, $salt = null) + public function isPasswordValid($encoded, $raw, $salt) { if (function_exists('password_verify')) { return password_verify($raw, $encoded); diff --git a/Tests/Core/Encoder/BCryptPasswordEncoderTest.php b/Tests/Core/Encoder/BCryptPasswordEncoderTest.php index 0c1536a..bfaf5fc 100644 --- a/Tests/Core/Encoder/BCryptPasswordEncoderTest.php +++ b/Tests/Core/Encoder/BCryptPasswordEncoderTest.php @@ -66,16 +66,16 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase public function testResultLength() { $encoder = new BCryptPasswordEncoder($this->secureRandom, self::VALID_COST); - $result = $encoder->encodePassword(self::PASSWORD); + $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertEquals(60, strlen($result)); } public function testValidation() { $encoder = new BCryptPasswordEncoder($this->secureRandom, self::VALID_COST); - $result = $encoder->encodePassword(self::PASSWORD); - $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD)); - $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword')); + $result = $encoder->encodePassword(self::PASSWORD, null); + $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); + $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } public function testValidationKnownPassword() @@ -85,7 +85,7 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase ? '2y' : '2a').'$'; $encrypted = $prefix.'04$ABCDEFGHIJKLMNOPQRSTU.uTmwd4KMSHxbUsG7bng8x7YdA0PM1iq'; - $this->assertTrue($encoder->isPasswordValid($encrypted, self::PASSWORD)); + $this->assertTrue($encoder->isPasswordValid($encrypted, self::PASSWORD, null)); } public function testSecureRandomIsUsed() @@ -100,7 +100,7 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase ; $encoder = new BCryptPasswordEncoder($this->secureRandom, self::VALID_COST); - $result = $encoder->encodePassword(self::PASSWORD); + $result = $encoder->encodePassword(self::PASSWORD, null); $prefix = '$'.(version_compare(phpversion(), '5.3.7', '>=') ? '2y' : '2a').'$'; |