function testCurrentUserPrincipal()
 {
     $fakeServer = new Sabre_DAV_Server();
     $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'realm');
     $fakeServer->addPlugin($plugin);
     $plugin = new Sabre_DAVACL_Plugin();
     $fakeServer->addPlugin($plugin);
     $requestedProperties = array('{DAV:}current-user-principal');
     $returnedProperties = array(200 => array(), 404 => array());
     $this->assertNull($plugin->beforeGetProperties('', new Sabre_DAV_SimpleCollection('root'), $requestedProperties, $returnedProperties));
     $this->assertEquals(1, count($returnedProperties[200]));
     $this->assertArrayHasKey('{DAV:}current-user-principal', $returnedProperties[200]);
     $this->assertInstanceOf('Sabre_DAVACL_Property_Principal', $returnedProperties[200]['{DAV:}current-user-principal']);
     $this->assertEquals(Sabre_DAVACL_Property_Principal::UNAUTHENTICATED, $returnedProperties[200]['{DAV:}current-user-principal']->getType());
     // This will force the login
     $fakeServer->broadCastEvent('beforeMethod', array('GET', ''));
     $requestedProperties = array('{DAV:}current-user-principal');
     $returnedProperties = array(200 => array(), 404 => array());
     $this->assertNull($plugin->beforeGetProperties('', new Sabre_DAV_SimpleCollection('root'), $requestedProperties, $returnedProperties));
     $this->assertEquals(1, count($returnedProperties[200]));
     $this->assertArrayHasKey('{DAV:}current-user-principal', $returnedProperties[200]);
     $this->assertInstanceOf('Sabre_DAVACL_Property_Principal', $returnedProperties[200]['{DAV:}current-user-principal']);
     $this->assertEquals(Sabre_DAVACL_Property_Principal::HREF, $returnedProperties[200]['{DAV:}current-user-principal']->getType());
     $this->assertEquals('principals/admin/', $returnedProperties[200]['{DAV:}current-user-principal']->getHref());
 }
Beispiel #2
0
 /**
  * @depends testInit
  * @expectedException Sabre_DAV_Exception_NotAuthenticated
  */
 function testAuthenticateFail()
 {
     $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')));
     $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'failme');
     $fakeServer->addPlugin($plugin);
     $fakeServer->broadCastEvent('beforeMethod', array('GET', '/'));
 }
Beispiel #3
0
 /**
  * @depends testInit
  */
 function testGetCurrentUserPrincipal()
 {
     $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')));
     $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'realm');
     $fakeServer->addPlugin($plugin);
     $fakeServer->broadCastEvent('beforeMethod', array('GET', '/'));
     $this->assertEquals('admin', $plugin->getCurrentUser());
 }