Checks the given token for validity and sets the token authentication status
accordingly (success, wrong credentials or no credentials given).
public authenticate ( Neos\Flow\Security\Authentication\TokenInterface $authenticationToken ) : void | ||
$authenticationToken | Neos\Flow\Security\Authentication\TokenInterface | The token to be authenticated |
return | void |
/** * @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())->format(\DateTime::W3C), $account->getLastSuccessfulAuthenticationDate()->format(\DateTime::W3C)); $this->assertEquals(0, $account->getFailedAuthenticationCount()); }
/** * @test * @expectedException \Neos\Flow\Security\Exception\UnsupportedAuthenticationTokenException */ public function authenticatingAnUnsupportedTokenThrowsAnException() { $someNiceToken = $this->createMock(Security\Authentication\TokenInterface::class); $usernamePasswordProvider = new Security\Authentication\Provider\PersistedUsernamePasswordProvider('myProvider', array()); $usernamePasswordProvider->authenticate($someNiceToken); }