Exemplo n.º 1
0
 /**
  * @test
  */
 public function updateCredentialsIgnoresAnythingOtherThanPostRequests()
 {
     $arguments = array();
     $arguments['__authentication']['TYPO3']['Flow']['Security']['Authentication']['Token']['PasswordToken']['password'] = '******';
     $actionRequest = Request::create(new Uri('http://robertlemke.com/login'), 'POST', $arguments)->createActionRequest();
     $token = new PasswordToken();
     $token->updateCredentials($actionRequest);
     $this->assertEquals(array('password' => 'verysecurepassword'), $token->getCredentials());
     $actionRequest = Request::create(new Uri('http://robertlemke.com/login'), 'GET', $arguments)->createActionRequest();
     $token = new PasswordToken();
     $token->updateCredentials($actionRequest);
     $this->assertEquals(array('password' => ''), $token->getCredentials());
 }
 /**
  * @test
  */
 public function updateCredentialsIgnoresAnythingOtherThanPostRequests()
 {
     $arguments = array();
     $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(array('password' => 'verysecurepassword'), $this->token->getCredentials());
     $secondToken = new PasswordToken();
     $secondMockActionRequest = $this->getMockBuilder(\TYPO3\Flow\Mvc\ActionRequest::class)->disableOriginalConstructor()->getMock();
     $secondMockHttpRequest = $this->getMockBuilder(\TYPO3\Flow\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(array('password' => ''), $secondToken->getCredentials());
 }
 /**
  * @test
  */
 public function authenticationIsSkippedIfNoCredentialsInAPasswordToken()
 {
     $this->mockToken->expects($this->once())->method('getCredentials')->will($this->returnValue(array()));
     $this->mockToken->expects($this->once())->method('setAuthenticationStatus')->with(TokenInterface::NO_CREDENTIALS_GIVEN);
     $authenticationProvider = new FileBasedSimpleKeyProvider('myProvider', array('keyName' => 'testKey', 'authenticateRoles' => array('TYPO3.Flow:TestRoleIdentifier')));
     $this->inject($authenticationProvider, 'policyService', $this->mockPolicyService);
     $this->inject($authenticationProvider, 'hashService', $this->mockHashService);
     $this->inject($authenticationProvider, 'fileBasedSimpleKeyService', $this->mockFileBasedSimpleKeyService);
     $authenticationProvider->authenticate($this->mockToken);
 }