function testValues()
 {
     $aclPlugin = new Plugin();
     $this->assertEquals('acl', $aclPlugin->getPluginName());
     $this->assertEquals(array('access-control', 'calendarserver-principal-property-search'), $aclPlugin->getFeatures());
     $this->assertEquals(array('{DAV:}expand-property', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set'), $aclPlugin->getSupportedReportSet(''));
     $this->assertEquals(array('ACL'), $aclPlugin->getMethods(''));
 }
Exemplo n.º 2
0
 function getServer()
 {
     $tree = [new DAV\Mock\PropertiesCollection('node1', [], ['{http://sabredav.org/ns}simple' => 'foo', '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'), '{DAV:}displayname' => 'Node 1']), new DAV\Mock\PropertiesCollection('node2', [], ['{http://sabredav.org/ns}simple' => 'simple', '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1', 'node3']), '{DAV:}displayname' => 'Node 2']), new DAV\Mock\PropertiesCollection('node3', [], ['{http://sabredav.org/ns}simple' => 'simple', '{DAV:}displayname' => 'Node 3'])];
     $fakeServer = new DAV\Server($tree);
     $fakeServer->sapi = new HTTP\SapiMock();
     $fakeServer->debugExceptions = true;
     $fakeServer->httpResponse = new HTTP\ResponseMock();
     $plugin = new Plugin();
     $plugin->allowUnauthenticatedAccess = false;
     // Anyone can do anything
     $plugin->setDefaultACL([['principal' => '{DAV:}all', 'privilege' => '{DAV:}all']]);
     $this->assertTrue($plugin instanceof Plugin);
     $fakeServer->addPlugin($plugin);
     $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
     return $fakeServer;
 }
Exemplo n.º 3
0
 function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $throwExceptions = true)
 {
     $access = parent::checkPrivileges($uri, $privileges, $recursion, false);
     if ($access === false && $throwExceptions) {
         /** @var INode $node */
         $node = $this->server->tree->getNodeForPath($uri);
         switch (get_class($node)) {
             case 'OCA\\DAV\\CardDAV\\AddressBook':
                 $type = 'Addressbook';
                 break;
             default:
                 $type = 'Node';
                 break;
         }
         throw new NotFound(sprintf("%s with name '%s' could not be found", $type, $node->getName()));
     }
     return $access;
 }
Exemplo n.º 4
0
 /**
  * Returns the list of supported privileges for this node.
  *
  * The returned data structure is a list of nested privileges.
  * See \Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
  * standard structure.
  *
  * If null is returned from this method, the default privilege set is used,
  * which is fine for most common usecases.
  *
  * @return array|null
  */
 function getSupportedPrivilegeSet()
 {
     $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet();
     // We need to inject 'read-free-busy' in the tree, aggregated under
     // {DAV:}read.
     foreach ($default['aggregates'] as &$agg) {
         if ($agg['privilege'] !== '{DAV:}read') {
             continue;
         }
         $agg['aggregates'][] = ['privilege' => '{' . Plugin::NS_CALDAV . '}read-free-busy'];
     }
     return $default;
 }
Exemplo n.º 5
0
 /**
  * Returns the list of supported privileges for this node.
  *
  * The returned data structure is a list of nested privileges.
  * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
  * standard structure.
  *
  * If null is returned from this method, the default privilege set is used,
  * which is fine for most common usecases.
  *
  * @return array|null
  */
 function getSupportedPrivilegeSet()
 {
     $ns = '{' . CalDAV\Plugin::NS_CALDAV . '}';
     $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet();
     $default['aggregates'][] = ['privilege' => $ns . 'schedule-deliver', 'aggregates' => [['privilege' => $ns . 'schedule-deliver-invite'], ['privilege' => $ns . 'schedule-deliver-reply']]];
     return $default;
 }
Exemplo n.º 6
0
 /**
  * Returns the list of supported privileges for this node.
  *
  * The returned data structure is a list of nested privileges.
  * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple
  * standard structure.
  *
  * If null is returned from this method, the default privilege set is used,
  * which is fine for most common usecases.
  *
  * @return array|null
  */
 public function getSupportedPrivilegeSet()
 {
     $default = DAVACL\Plugin::getDefaultSupportedPrivilegeSet();
     $default['aggregates'][] = array('privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-query-freebusy');
     $default['aggregates'][] = array('privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-post-vevent');
     return $default;
 }
Exemplo n.º 7
0
 function testGroupMemberSet()
 {
     $tree = [new DAV\SimpleCollection('principals', [$principal = new MockPrincipal('user', 'principals/user')])];
     $fakeServer = new DAV\Server($tree);
     //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend());
     //$fakeServer->addPlugin($plugin);
     $plugin = new Plugin();
     $plugin->allowUnauthenticatedAccess = false;
     $plugin->setDefaultACL([['principal' => '{DAV:}all', 'privilege' => '{DAV:}all']]);
     $fakeServer->addPlugin($plugin);
     $requestedProperties = ['{DAV:}group-member-set'];
     $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
     $result = $result[0];
     $this->assertTrue(isset($result[200]));
     $this->assertTrue(isset($result[200]['{DAV:}group-member-set']));
     $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-member-set']);
     $this->assertEquals([], $result[200]['{DAV:}group-member-set']->getHrefs());
 }