Exemplo n.º 1
0
 function testRequireAuth()
 {
     $request = new HTTP\Request();
     $response = new HTTP\Response();
     $backend = new AbstractBasicMock();
     $backend->setRealm('writing unittests on a saturday night');
     $backend->challenge($request, $response);
     $this->assertEquals('Basic realm="writing unittests on a saturday night"', $response->getHeader('WWW-Authenticate'));
 }
Exemplo n.º 2
0
 public function testAuthenticate()
 {
     $response = new HTTP\ResponseMock();
     $tree = new DAV\ObjectTree(new DAV\SimpleCollection('bla'));
     $server = new DAV\Server($tree);
     $server->httpResponse = $response;
     $request = new HTTP\Request(array('PHP_AUTH_USER' => 'username', 'PHP_AUTH_PW' => 'password'));
     $server->httpRequest = $request;
     $backend = new AbstractBasicMock();
     $this->assertTrue($backend->authenticate($server, 'myRealm'));
     $result = $backend->getCurrentUser();
     $this->assertEquals('username', $result);
 }