public function testEncodePasswordPbkdf2()
 {
     $this->passwordEncoderCommandTester->execute(array('command' => 'security:encode-password', 'password' => 'password', 'user-class' => 'Custom\\Class\\Pbkdf2\\User'), array('interactive' => false));
     $output = $this->passwordEncoderCommandTester->getDisplay();
     $this->assertContains('Password encoding succeeded', $output);
     $encoder = new Pbkdf2PasswordEncoder('sha512', true, 1000);
     preg_match('# Encoded password\\s{1,}([\\w+\\/]+={0,2})\\s+#', $output, $matches);
     $hash = $matches[1];
     preg_match('# Generated salt\\s{1,}([\\w+\\/]+={0,2})\\s+#', $output, $matches);
     $salt = $matches[1];
     $this->assertTrue($encoder->isPasswordValid($hash, 'password', $salt));
 }
コード例 #2
0
 public function testCheckPasswordLength()
 {
     $encoder = new Pbkdf2PasswordEncoder('foobar');
     $this->assertFalse($encoder->isPasswordValid('encoded', str_repeat('a', 5000), 'salt'));
 }
コード例 #3
0
 public function testIsPasswordValid()
 {
     $encoder = new Pbkdf2PasswordEncoder('sha256', false, 1, 40);
     $this->assertTrue($encoder->isPasswordValid('c1232f10f62715fda06ae7c0a2037ca19b33cf103b727ba56d870c11f290a2ab106974c75607c8a3', 'password', ''));
 }