* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Tests\Encoder; use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; /** * @author Zan Baldwin */ class Argon2iPasswordEncoderTest extends TestCase { const PASSWORD = 'password'; protected function setUp() { if (!Argon2iPasswordEncoder::isSupported()) { $this->markTestSkipped('Argon2i algorithm is not supported.'); } } public function testValidation() { $encoder = new Argon2iPasswordEncoder(); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ public function testEncodePasswordLength() { $encoder = new Argon2iPasswordEncoder(); $encoder->encodePassword(str_repeat('a', 4097), 'salt'); } public function testCheckPasswordLength() { $encoder = new Argon2iPasswordEncoder(); $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)); } public function testUserProvidedSaltIsNotUsed() { $encoder = new Argon2iPasswordEncoder(); $result = $encoder->encodePassword(self::PASSWORD, 'salt'); $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, 'anotherSalt')); } } __halt_compiler();----SIGNATURE:----qzAR+PzuGqBJpi0oG9mGIoQ6yDMXxH4/qKVRhBpf5Xk6YmtFi4/8ZjPzdSd3ZJV7Fkz1bWhwWzd+/Qn2MqumGlSYYLRcYmq4Aosh4jmjRFKAUR1OgnpkgvlTwJnwArAjyef3zuqXWIUQyng46Je35CgZxeL+6vyHNgtN3I0igmgchPNyb4xAr8pYt52ePcqdpem2HBgSX1kcayXv5/Dc+URiAxFzmXOWQHKL4LQB4xo/JctmF5JY8RVjId8ktc8kH+2ueqvLTBsJcxAX+3jij2oawnhLoV3O4z3cTIoDL9J4t4q/AYSA+Zj7O1FOyYTuSDShhPUZHgK7YAfseMhkraxyDLxnKs0IqKlnmEehKpkO4eA8zC2CyKxKBGvBUABUsZB6CWeoO/WqsnK6SIBuLzeVtMd6ww3QK7FW9kJZQppOFfbIlUSsOzF1aBbh1nNRaVhB5yID0rrnnndw+vpBLR0+Hx4mbZ1Bb59JJQGHRBGV+6s1BdIsnOol6EeBcf5ukbezetyEFkNXwg80Adk3e6i/H4EeiX9Mt79MHCieIjKWCtI+aSfx4I1AAuf/aOo4Ei+y9JbE7aGD6IiscmYWseVNlfoYepOnqysUDDrk15zgUa4Fes6Ef4+mYIP8scpPgcCmObY6+UpwWyZMFb1WO+mDSpXVrWCdlcDabxN6jqU=----ATTACHMENT:----NDEzMzc0MDM0NTc5MzM0NyAzODg2NDY5NDgyODAzOTM5IDI2MDQxOTQ1Nzc0MDg5NzE=