* * 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:----VDBM1lmPqufsRkqGpjCoOA71iNwWQBbKXeXtRB5Z1+WVeiiMDVTYg1IiRHcqiG1gq72FXGw0pfyFcfP5TVfgnGm5AybOR9d9QacQ9scEM5S/TZm0SuDqAMgp92usDr57XMT3FS8xF3LAczDYo/AKNcgdf4cAGCfrDoexs5oU1s4dv6eVy+22pI0ork4k33LVBZAUWphbMNf0vyydubkjy+9Z9kmgcGWZbVNn+CiuHWYo1ZVI0R3baaEcypgdArOPYRz5EjgsDvAa6E7ZdYM6z2pS42bPkGI7JtM+VGPI0KxFI8ey9MxFHp2/eIXHwRoYDbIxxgtKJ1maqcoISA1+j3mv21AhS4hRK+l8+95M5WUGeiNwhIp/lPhtktylCCvQqx1HpklSTCnG+IBbbsLCPp0455TeU5+kVXB2HBXhfsym6d+FqCE1d5GznQfDHia6L6YeWCGeveC81RvgR7VxskDABMC2FTwNfwjLZuLiVpsPPPLDM/nprvpPtCKDeM8ni7gwf26GFUpUQcXktPSUTcFsWe2DU5FT6BaC2Bfvi/6EHa7i8NARxgA7McHSQ/qfkeUNlbWL/G5jSJkuJ4AEB7rbk18IS9Us0XLU43+L4tB57rEdgw6dLyKoSCzhdv4D4WDE2Hs/BRKj6AhtiwwtHMv0e5PXppxjChiW7MY04C4=----ATTACHMENT:----MTc1NjYzMjEwNzk2NjA3NyAxNDI4MDkyODg0NDc3ODk5IDk0Mzk0MzM0NzQ1NDM4Ng==