/** * @test */ public function isAuthenticatedReturnsTrueIfOneTokenIsAuthenticatedWithStrategyAnyToken() { $token1 = $this->createMock(\TYPO3\Flow\Security\Authentication\TokenInterface::class); $token1->expects($this->once())->method('isAuthenticated')->will($this->returnValue(false)); $token2 = $this->createMock(\TYPO3\Flow\Security\Authentication\TokenInterface::class); $token2->expects($this->once())->method('isAuthenticated')->will($this->returnValue(true)); $authenticationTokens = array($token1, $token2); $this->mockSecurityContext->expects($this->any())->method('getAuthenticationStrategy')->will($this->returnValue(Context::AUTHENTICATE_ANY_TOKEN)); $this->mockSecurityContext->expects($this->atLeastOnce())->method('getAuthenticationTokens')->will($this->returnValue($authenticationTokens)); $this->assertTrue($this->authenticationProviderManager->isAuthenticated()); }
/** * @test */ public function isAuthenticatedReturnsTrueIfOneTokenIsAuthenticatedWithStrategyAnyToken() { $token1 = $this->getMock('TYPO3\\Flow\\Security\\Authentication\\TokenInterface', array(), array(), '', FALSE); $token1->expects($this->once())->method('isAuthenticated')->will($this->returnValue(FALSE)); $token2 = $this->getMock('TYPO3\\Flow\\Security\\Authentication\\TokenInterface', array(), array(), '', FALSE); $token2->expects($this->once())->method('isAuthenticated')->will($this->returnValue(TRUE)); $authenticationTokens = array($token1, $token2); $mockContext = $this->getMock('TYPO3\\Flow\\Security\\Context', array(), array(), '', FALSE); $mockContext->expects($this->any())->method('getAuthenticationStrategy')->will($this->returnValue(\TYPO3\Flow\Security\Context::AUTHENTICATE_ANY_TOKEN)); $mockContext->expects($this->atLeastOnce())->method('getAuthenticationTokens')->will($this->returnValue($authenticationTokens)); $this->authenticationProviderManager->setSecurityContext($mockContext); $this->assertTrue($this->authenticationProviderManager->isAuthenticated()); }