/** * @test */ public function authenticationIsSkippedIfNoCredentialsInAPasswordToken() { $this->mockToken->expects($this->once())->method('getCredentials')->will($this->returnValue([])); $this->mockToken->expects($this->once())->method('setAuthenticationStatus')->with(TokenInterface::NO_CREDENTIALS_GIVEN); $authenticationProvider = new FileBasedSimpleKeyProvider('myProvider', ['keyName' => 'testKey', 'authenticateRoles' => ['Neos.Flow:TestRoleIdentifier']]); $this->inject($authenticationProvider, 'policyService', $this->mockPolicyService); $this->inject($authenticationProvider, 'hashService', $this->mockHashService); $this->inject($authenticationProvider, 'fileBasedSimpleKeyService', $this->mockFileBasedSimpleKeyService); $authenticationProvider->authenticate($this->mockToken); }
/** * @test */ public function updateCredentialsIgnoresAnythingOtherThanPostRequests() { $arguments = []; $arguments['__authentication']['TYPO3']['Flow']['Security']['Authentication']['Token']['PasswordToken']['password'] = '******'; $this->mockHttpRequest->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue('POST')); $this->mockActionRequest->expects($this->atLeastOnce())->method('getInternalArguments')->will($this->returnValue($arguments)); $this->token->updateCredentials($this->mockActionRequest); $this->assertEquals(['password' => 'verysecurepassword'], $this->token->getCredentials()); $secondToken = new PasswordToken(); $secondMockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); $secondMockHttpRequest = $this->getMockBuilder(Http\Request::class)->disableOriginalConstructor()->getMock(); $secondMockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($secondMockHttpRequest)); $secondMockHttpRequest->expects($this->atLeastOnce())->method('getMethod')->will($this->returnValue('GET')); $secondToken->updateCredentials($secondMockActionRequest); $this->assertEquals(['password' => ''], $secondToken->getCredentials()); }