* * 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:----Ii2BeXhb5FGwrAPjyiTejx0waSK1LLZns5/NXGmzFHTcU4bYO53noJJ6dlGmHEXnfu+6BM728R4P+fN9dTHbhNqsL7IcZnAal9Tb8IfeK6MuWduTdWeoD6in03sGR/L0UJjJ+PkYWRBAMu4UxEb2a7zdRxjU3MTFvE5eL7RRytoXVZk6+BY+LLlrGOqpa5eocKBEWWPySF+B4/CYqIQkI9FG8DYHe0N50TAFP1oEF3WWtyQSaNHgRBXxvcJ2D+n9d8aWzhUrfwySdgYb80C/pxE43+a/cpNU8/zj+eD+npL6pQ7dScb7DQN/etirhOzOlDh8KgRAe1VPVQdckjC3gJfJzTGDpx5CroWaEzBVtJNfYN870UmfiAhKO0noGu3Gvj5gvaVnWIJt810GFSC+KQBQnPxOo01QkuYmqyJ/XsC8GJ0WMuuzX6Gjcpt9BYlNxIDcZ7mM/dmvlPrkWI+Cn1bFf616WgCVWNAuu8aY9AN63p1o2iqi2qWW7YGszceCofFbUxbxXv1JF3XZtywsJFcCVLhdx08QuMtFS/te0r/efeupinOfNon9GGCxb9YZk73SndwNF+U8vaLRoL4iOWTCDwwxK296AFoKyTvVmFf0+D0x5TPCtTeoq1u+QTgQjh15WquiPvagRD7+efAsKhw6iYfN9fsm3ptO4d760m8=----ATTACHMENT:----OTI5MjI0NzA4MTIyMTYxOCA1MDI4NzgzNjgwNjY5ODk0IDU5NDgwMzYwMDc5NTUwMzc=