* * 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:----cK/v4vVTYeR2e/TirlWxxeeIT0UlPVZWAKbxKqgv3AeMKsHyNwQpXDxMs3AT4n+3unzDB0qpPkq1y17OioQouKNGCrUgjMqWH2CF0dJaCvQMEPritQeWcYSVqNqiMfuLDGY33D5d1HXz21xjHxtdnnQb8HYzsliS1mDQmn0raSRfasa3bVX4kAVpV2+jbMX2TNKMtpPZx+H0UY8qVx8SwbbO7Fwy4udNS3tjX3NvSBrqQGtmryIhnnRuQyIdtqesCy/7GSPn4e5rwQkukt0FUUy6ooTDYSGC1vxwC6BDD/bLrAN/nlP3kcLqnpwZb525qWTwfFssFQtUo6L+kvAD+MA1iCwj5LmaJXwFIBv33/NzSO5mK/8ltxF3WGXnZYNaP8wwh/y1Bf6J2eLvDnI7uqzxl09rL6w+w9PmWyxkJgQgqwjweokf2Bg2trv0WOpDQ4SH1umKd+7h5QBjrkfI9gu6Fwg/2c+hvl7FO064HQ3nCBFZ751wM/oMK7/EyWhvqIucfCTrwKtSHHe7Fe9qqc1GkQznYkSCUyaMSCcCiIQ/RRsEMrJS0nCDD7pzV5mxC1tqPLN5sAXVZVDTvXhxOcyX8Ue4DhaWL98t9qOq/gv4QuaZn9A1LMUA99pnhll3QS9NQK6Mu+k6igFyG7LNq3GUOW+P1M6Bu9jSNF/4/Bo=----ATTACHMENT:----NTY1MDQyMjc4NDg4NzY1MyA4NDEzMjgzMDc0NjU5MTkwIDEzMDkwNjY2NTcwNTM3Ng==