/**
  * @test
  */
 public function startAuthenticationSetsTheCorrectValuesInTheResponseObject()
 {
     $mockHttpRequest = $this->getMockBuilder('TYPO3\\Flow\\Http\\Request')->disableOriginalConstructor()->getMock();
     $mockResponse = $this->getMockBuilder('TYPO3\\Flow\\Http\\Response')->getMock();
     $entryPoint = new HttpBasic();
     $entryPoint->setOptions(array('realm' => 'realm string'));
     $mockResponse->expects($this->once())->method('setStatus')->with(401);
     $mockResponse->expects($this->once())->method('setHeader')->with('WWW-Authenticate', 'Basic realm="realm string"');
     $mockResponse->expects($this->once())->method('setContent')->with('Authorization required');
     $entryPoint->startAuthentication($mockHttpRequest, $mockResponse);
     $this->assertEquals(array('realm' => 'realm string'), $entryPoint->getOptions());
 }
示例#2
0
 /**
  * @test
  */
 public function startAuthenticationSetsTheCorrectValuesInTheResponseObject()
 {
     $request = Request::create(new Uri('http://robertlemke.com/admin'))->createActionRequest();
     $response = new Response();
     $entryPoint = new HttpBasic();
     $entryPoint->setOptions(array('realm' => 'realm string'));
     $entryPoint->startAuthentication($request->getHttpRequest(), $response);
     $this->assertEquals('401', substr($response->getStatus(), 0, 3));
     $this->assertEquals('Basic realm="realm string"', $response->getHeader('WWW-Authenticate'));
     $this->assertEquals('Authorization required', $response->getContent());
     $this->assertEquals(array('realm' => 'realm string'), $entryPoint->getOptions());
 }