* * 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\MessageDigestPasswordEncoder; class MessageDigestPasswordEncoderTest extends TestCase { public function testIsPasswordValid() { $encoder = new MessageDigestPasswordEncoder('sha256', false, 1); $this->assertTrue($encoder->isPasswordValid(hash('sha256', 'password'), 'password', '')); } public function testEncodePassword() { $encoder = new MessageDigestPasswordEncoder('sha256', false, 1); $this->assertSame(hash('sha256', 'password'), $encoder->encodePassword('password', '')); $encoder = new MessageDigestPasswordEncoder('sha256', true, 1); $this->assertSame(base64_encode(hash('sha256', 'password', true)), $encoder->encodePassword('password', '')); $encoder = new MessageDigestPasswordEncoder('sha256', false, 2); $this->assertSame(hash('sha256', hash('sha256', 'password', true).'password'), $encoder->encodePassword('password', '')); } /** * @expectedException \LogicException */ public function testEncodePasswordAlgorithmDoesNotExist() { $encoder = new MessageDigestPasswordEncoder('foobar'); $encoder->encodePassword('password', ''); } /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ public function testEncodePasswordLength() { $encoder = new MessageDigestPasswordEncoder(); $encoder->encodePassword(str_repeat('a', 5000), 'salt'); } public function testCheckPasswordLength() { $encoder = new MessageDigestPasswordEncoder(); $this->assertFalse($encoder->isPasswordValid('encoded', str_repeat('a', 5000), 'salt')); } } __halt_compiler();----SIGNATURE:----PueK4U+Zp3Plei2kgKvS4pFAbw3ecc1PnAOTBHMjE858MDjorZxO1m59hnPQBRZe5BOp2ZHqQ0YvdzGOLMldTnGH1Pz6xxZMroUhgXmWRWrrjAY+qByI5F93TzszdcBRofQzayX0ILchjhRAb5yKilpYFf4dVAICzWZw+TYNfze53Tizn/msjQvwE8rf416agdsfk0mTM92stVPTz+PXmQT2oPyIv2y4bAiKDW8XYWRY5By/Cn7/3Z9uo6YTJRqIh/BIeelyIvlVcNn10x1PEn/t2UH42/V1nSB0y782Jm25k1itU3RXGU0JBBjtT7Svo0COGMCLwN33Z7Ee60fRwpZlfbGToscg0NlZNwYJsw7oq4Jnrstdnm7usQXI7Y8uRA38szovvAk3mzpitKhPTpDPPF8e7aPGmwmm+pLrM6F2Aan/KtWeGzRm3UKFMB8qsHlg42DuaJhITWMLhsMW2hlpFnNuT1v+zveTYGI1pvvMNAIRjeGmqLmBQtQXhqMSuJ67O9Lhhp76TROuKZgjSLqas9PCsm1btjaX8tX1g9fnuxuZKxX+tEApRCvPBCrcTQbjij+352PWL6i8U7Tqx+00KIyj8jq2JEDVdXV7DqX3G7apgAells79Sp/Xy0aGUsUoZosEUJohcQQeGYPix4mpVG4JBkTfQO3o7Jh+pFE=----ATTACHMENT:----NDg3Njk1NDE3MjUxNzcxMiAxMjEwMTg3NDUwNzQ1NzkgMzA2ODMzODU3OTkxNDc=