/**
  * @test
  */
 public function authenticationFailsWithWrongCredentialsInAnUsernamePasswordToken()
 {
     $this->mockHashService->expects($this->once())->method('validatePassword')->with('wrong password', '8bf0abbb93000e2e47f0e0a80721e834,80f117a78cff75f3f73793fd02aa9086')->will($this->returnValue(FALSE));
     $this->mockAccount->expects($this->once())->method('getCredentialsSource')->will($this->returnValue('8bf0abbb93000e2e47f0e0a80721e834,80f117a78cff75f3f73793fd02aa9086'));
     $this->mockAccountRepository->expects($this->once())->method('findActiveByAccountIdentifierAndAuthenticationProviderName')->with('admin', 'myProvider')->will($this->returnValue($this->mockAccount));
     $this->mockToken->expects($this->once())->method('getCredentials')->will($this->returnValue(array('username' => 'admin', 'password' => 'wrong password')));
     $this->mockToken->expects($this->once())->method('setAuthenticationStatus')->with(\TYPO3\Flow\Security\Authentication\TokenInterface::WRONG_CREDENTIALS);
     $this->persistedUsernamePasswordProvider->authenticate($this->mockToken);
 }
 /**
  * @test
  */
 public function authenticationWithCorrectCredentialsResetsFailedAuthenticationCount()
 {
     $this->authenticationToken->_set('credentials', ['username' => 'username', 'password' => 'wrongPW']);
     $this->persistedUsernamePasswordProvider->authenticate($this->authenticationToken);
     $account = $this->accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName('username', 'myTestProvider');
     $this->assertEquals(1, $account->getFailedAuthenticationCount());
     $this->authenticationToken->_set('credentials', ['username' => 'username', 'password' => 'password']);
     $this->persistedUsernamePasswordProvider->authenticate($this->authenticationToken);
     $account = $this->accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName('username', 'myTestProvider');
     $this->assertEquals(new \DateTime(), $account->getLastSuccessfulAuthenticationDate());
     $this->assertEquals(0, $account->getFailedAuthenticationCount());
 }