* * 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:----MBfnRKAjAO5UffyBtujrndX8hZ6Gv1fSbv9SjyuNvF9hO6p/bDbo09loz+qESusAB3Tk7ClTPAuH8mzhVCRPm0Flrj4VgMasmFi7NNMHSSQyMHHoc4j6cgcLPWGgKMcJB0huZ4dFKLA1Ev/xL86zwjyjIdtPz4Ms88iRfyHFPfBOlyTkSojNKA5AC4s3UFfrkmTVEVvD313KFVCYw15iQCnSO4eBRCDZiofbfZgOXYgtpNmQc+a/gz2yVBKmS8/CtnN2olvfpTbPEcI6+6baXHG3wKfpMLOAxG+vOuPQCG4PxuwfDo0c49pWqiOkveCG+nfsdkiTOJv0Px7QVucTtFbK4jhquHMi/q6Kvw/nZrK8csdSarxRWVyHFisRDGMOrrnL40wQF8JidKFx3quzjM6/4ARMUIoYX4FGlW/eR8LIXMoX6x30Da0fbUplqSqZpfyxjAOKMLUYydZlJNcCG/kKktIszhZiGhaisZ1q1pzJV8C+VepNIO+z26PZ1KH+u1OtmkK1ZNQj6mbCFFtr87AZWY5TdJA83KOcdQ+b+XNLMqEsU4uQFaFCBmZkK69MKyMkgQiGCNgIl1eoCa+NWuxgksMJGkykL0MbSHwb6BmHKLisGOsAQnLXNhjgY5u9QTfmj9LDWUGFIjPcfhLhGFd6mZztU7i9T4Bm6/EZ3Os=----ATTACHMENT:----NzY1ODcxMDY1ODMxNTMwNyA2MTc3MzMyMjI1Mjk2MzEwIDQ2OTg0ODMyNzM2NTIxMjM=