+ *
+ * @group legacy
*/
class Argon2iPasswordEncoderTest extends TestCase
{
const PASSWORD = 'password';
- public function testValidationWithConfig()
+ protected function setUp()
{
- if (!Argon2iPasswordEncoder::isSupported() || Argon2idPasswordEncoder::isDefaultSodiumAlgorithm()) {
+ if (!Argon2iPasswordEncoder::isSupported()) {
$this->markTestSkipped('Argon2i algorithm is not supported.');
}
+ }
+ public function testValidationWithConfig()
+ {
$encoder = new Argon2iPasswordEncoder(8, 4, 1);
$result = $encoder->encodePassword(self::PASSWORD, null);
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
@@ -36,10 +40,6 @@ public function testValidationWithConfig()
public function testValidation()
{
- if (!Argon2iPasswordEncoder::isSupported() || Argon2idPasswordEncoder::isDefaultSodiumAlgorithm()) {
- $this->markTestSkipped('Argon2i algorithm is not supported.');
- }
-
$encoder = new Argon2iPasswordEncoder();
$result = $encoder->encodePassword(self::PASSWORD, null);
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
@@ -51,20 +51,12 @@ public function testValidation()
*/
public function testEncodePasswordLength()
{
- if (!Argon2iPasswordEncoder::isSupported() || Argon2idPasswordEncoder::isDefaultSodiumAlgorithm()) {
- $this->markTestSkipped('Argon2i algorithm is not supported.');
- }
-
$encoder = new Argon2iPasswordEncoder();
$encoder->encodePassword(str_repeat('a', 4097), 'salt');
}
public function testCheckPasswordLength()
{
- if (!Argon2iPasswordEncoder::isSupported() || Argon2idPasswordEncoder::isDefaultSodiumAlgorithm()) {
- $this->markTestSkipped('Argon2i algorithm is not supported.');
- }
-
$encoder = new Argon2iPasswordEncoder();
$result = $encoder->encodePassword(str_repeat('a', 4096), null);
$this->assertFalse($encoder->isPasswordValid($result, str_repeat('a', 4097), null));
@@ -73,29 +65,8 @@ public function testCheckPasswordLength()
public function testUserProvidedSaltIsNotUsed()
{
- if (!Argon2iPasswordEncoder::isSupported() || Argon2idPasswordEncoder::isDefaultSodiumAlgorithm()) {
- $this->markTestSkipped('Argon2i algorithm is not supported.');
- }
-
$encoder = new Argon2iPasswordEncoder();
$result = $encoder->encodePassword(self::PASSWORD, 'salt');
$this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, 'anotherSalt'));
}
-
- /**
- * @group legacy
- * @exectedDeprecation Using "Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder" while only the "argon2id" algorithm is supported is deprecated since Symfony 4.3, use "Symfony\Component\Security\Core\Encoder\Argon2idPasswordEncoder" instead.
- * @exectedDeprecation Calling "Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder::isPasswordValid()" with a password hashed using argon2id is deprecated since Symfony 4.3, use "Symfony\Component\Security\Core\Encoder\Argon2idPasswordEncoder" instead.
- */
- public function testEncodeWithArgon2idSupportOnly()
- {
- if (!Argon2iPasswordEncoder::isSupported() || !Argon2idPasswordEncoder::isDefaultSodiumAlgorithm()) {
- $this->markTestSkipped('Argon2id algorithm not available.');
- }
-
- $encoder = new Argon2iPasswordEncoder();
- $result = $encoder->encodePassword(self::PASSWORD, null);
- $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null));
- $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
- }
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2idPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php
similarity index 64%
rename from src/Symfony/Component/Security/Core/Tests/Encoder/Argon2idPasswordEncoderTest.php
rename to src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php
index 460777c124f5f..fe9e5db0eb4cb 100644
--- a/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2idPasswordEncoderTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Encoder/SodiumPasswordEncoderTest.php
@@ -12,28 +12,20 @@
namespace Symfony\Component\Security\Core\Tests\Encoder;
use PHPUnit\Framework\TestCase;
-use Symfony\Component\Security\Core\Encoder\Argon2idPasswordEncoder;
+use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder;
-class Argon2idPasswordEncoderTest extends TestCase
+class SodiumPasswordEncoderTest extends TestCase
{
protected function setUp()
{
- if (!Argon2idPasswordEncoder::isSupported()) {
- $this->markTestSkipped('Argon2i algorithm is not supported.');
+ if (!SodiumPasswordEncoder::isSupported()) {
+ $this->markTestSkipped('Libsodium is not available.');
}
}
- public function testValidationWithConfig()
- {
- $encoder = new Argon2idPasswordEncoder(8, 4, 1);
- $result = $encoder->encodePassword('password', null);
- $this->assertTrue($encoder->isPasswordValid($result, 'password', null));
- $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
- }
-
public function testValidation()
{
- $encoder = new Argon2idPasswordEncoder();
+ $encoder = new SodiumPasswordEncoder();
$result = $encoder->encodePassword('password', null);
$this->assertTrue($encoder->isPasswordValid($result, 'password', null));
$this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null));
@@ -44,13 +36,13 @@ public function testValidation()
*/
public function testEncodePasswordLength()
{
- $encoder = new Argon2idPasswordEncoder();
+ $encoder = new SodiumPasswordEncoder();
$encoder->encodePassword(str_repeat('a', 4097), 'salt');
}
public function testCheckPasswordLength()
{
- $encoder = new Argon2idPasswordEncoder();
+ $encoder = new SodiumPasswordEncoder();
$result = $encoder->encodePassword(str_repeat('a', 4096), null);
$this->assertFalse($encoder->isPasswordValid($result, str_repeat('a', 4097), null));
$this->assertTrue($encoder->isPasswordValid($result, str_repeat('a', 4096), null));
@@ -58,7 +50,7 @@ public function testCheckPasswordLength()
public function testUserProvidedSaltIsNotUsed()
{
- $encoder = new Argon2idPasswordEncoder();
+ $encoder = new SodiumPasswordEncoder();
$result = $encoder->encodePassword('password', 'salt');
$this->assertTrue($encoder->isPasswordValid($result, 'password', 'anotherSalt'));
}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy