/** * @test * @expectedException \TYPO3\Flow\Security\Exception\AuthenticationRequiredException */ public function authenticateThrowsAnExceptionIfAuthenticateAllTokensIsTrueButATokenCouldNotBeAuthenticated() { $token1 = $this->createMock(\TYPO3\Flow\Security\Authentication\TokenInterface::class); $token2 = $this->createMock(\TYPO3\Flow\Security\Authentication\TokenInterface::class); $token1->expects($this->atLeastOnce())->method('isAuthenticated')->will($this->returnValue(true)); $token2->expects($this->atLeastOnce())->method('isAuthenticated')->will($this->returnValue(false)); $this->mockSecurityContext->expects($this->atLeastOnce())->method('getAuthenticationTokens')->will($this->returnValue(array($token1, $token2))); $this->mockSecurityContext->expects($this->atLeastOnce())->method('getAuthenticationStrategy')->will($this->returnValue(Context::AUTHENTICATE_ALL_TOKENS)); $this->inject($this->authenticationProviderManager, 'providers', array()); $this->authenticationProviderManager->authenticate(); }
/** * @test * @expectedException TYPO3\Flow\Security\Exception\AuthenticationRequiredException */ public function authenticateThrowsAnExceptionIfAuthenticateAllTokensIsTrueButATokenCouldNotBeAuthenticated() { $securityContext = $this->getMock('TYPO3\\Flow\\Security\\Context', array(), array(), '', FALSE); $token1 = $this->getMock('TYPO3\\Flow\\Security\\Authentication\\TokenInterface'); $token2 = $this->getMock('TYPO3\\Flow\\Security\\Authentication\\TokenInterface'); $token1->expects($this->atLeastOnce())->method('isAuthenticated')->will($this->returnValue(TRUE)); $token2->expects($this->atLeastOnce())->method('isAuthenticated')->will($this->returnValue(FALSE)); $securityContext->expects($this->atLeastOnce())->method('getAuthenticationTokens')->will($this->returnValue(array($token1, $token2))); $securityContext->expects($this->atLeastOnce())->method('getAuthenticationStrategy')->will($this->returnValue(\TYPO3\Flow\Security\Context::AUTHENTICATE_ALL_TOKENS)); $this->authenticationProviderManager->_set('providers', array()); $this->authenticationProviderManager->_set('securityContext', $securityContext); $this->authenticationProviderManager->authenticate(); }