Exemplo n.º 1
0
 function setup()
 {
     $this->caldavBackend = new CalDAV\Backend\MockSharing();
     $principalBackend = new DAVACL\PrincipalBackend\Mock();
     $calendars = new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend);
     $principals = new CalDAV\Principal\Collection($principalBackend);
     $root = new DAV\SimpleCollection('root');
     $root->addChild($calendars);
     $root->addChild($principals);
     $this->server = new DAV\Server($root);
     $this->server->sapi = new HTTP\SapiMock();
     $this->server->debugExceptions = true;
     $this->server->setBaseUri('/');
     $this->plugin = new Plugin();
     $this->server->addPlugin($this->plugin);
     // Adding ACL plugin
     $this->server->addPlugin(new DAVACL\Plugin());
     // CalDAV is also required.
     $this->server->addPlugin(new CalDAV\Plugin());
     // Adding Auth plugin, and ensuring that we are logged in.
     $authBackend = new DAV\Auth\Backend\Mock();
     $authBackend->defaultUser = '******';
     $authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
     $this->server->addPlugin($authPlugin);
     // This forces a login
     $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
     $this->response = new HTTP\ResponseMock();
     $this->server->httpResponse = $this->response;
 }
Exemplo n.º 2
0
 function setup()
 {
     $this->caldavBackend = new Backend\Mock(array(array('id' => 1, 'uri' => 'UUID-123467', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT', 'VTODO'))), array('id' => 2, 'uri' => 'UUID-123468', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar2', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT', 'VTODO')))), array(1 => array('UUID-2345' => array('calendardata' => TestUtil::getTestCalendarData()))));
     $principalBackend = new DAVACL\PrincipalBackend\Mock();
     $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', array('principals/user1'));
     $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', array('principals/user1'));
     $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-read'));
     $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-write'));
     $calendars = new CalendarRootNode($principalBackend, $this->caldavBackend);
     $principals = new Principal\Collection($principalBackend);
     $root = new DAV\SimpleCollection('root');
     $root->addChild($calendars);
     $root->addChild($principals);
     $objectTree = new DAV\ObjectTree($root);
     $this->server = new DAV\Server($objectTree);
     $this->server->debugExceptions = true;
     $this->server->setBaseUri('/');
     $this->plugin = new Plugin();
     $this->server->addPlugin($this->plugin);
     // Adding ACL plugin
     $this->server->addPlugin(new DAVACL\Plugin());
     // Adding Auth plugin, and ensuring that we are logged in.
     $authBackend = new DAV\Auth\Backend\Mock();
     $authBackend->defaultUser = '******';
     $authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
     $this->server->addPlugin($authPlugin);
     $authPlugin->beforeMethod('GET', '/');
     $this->response = new HTTP\ResponseMock();
     $this->server->httpResponse = $this->response;
 }
Exemplo n.º 3
0
 function setup()
 {
     $caldavNS = '{urn:ietf:params:xml:ns:caldav}';
     $this->caldavBackend = new Backend\Mock([['id' => 1, 'uri' => 'UUID-123467', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar', $caldavNS . 'calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO'])], ['id' => 2, 'uri' => 'UUID-123468', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar2', $caldavNS . 'calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO'])]], [1 => ['UUID-2345' => ['calendardata' => TestUtil::getTestCalendarData()]]]);
     $principalBackend = new DAVACL\PrincipalBackend\Mock();
     $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', ['principals/user1']);
     $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', ['principals/user1']);
     $principalBackend->addPrincipal(['uri' => 'principals/admin/calendar-proxy-read']);
     $principalBackend->addPrincipal(['uri' => 'principals/admin/calendar-proxy-write']);
     $calendars = new CalendarRoot($principalBackend, $this->caldavBackend);
     $principals = new Principal\Collection($principalBackend);
     $root = new DAV\SimpleCollection('root');
     $root->addChild($calendars);
     $root->addChild($principals);
     $this->server = new DAV\Server($root);
     $this->server->sapi = new HTTP\SapiMock();
     $this->server->debugExceptions = true;
     $this->server->setBaseUri('/');
     $this->plugin = new Plugin();
     $this->server->addPlugin($this->plugin);
     // Adding ACL plugin
     $this->server->addPlugin(new DAVACL\Plugin());
     // Adding Auth plugin, and ensuring that we are logged in.
     $authBackend = new DAV\Auth\Backend\Mock();
     $authBackend->setPrincipal('principals/user1');
     $authPlugin = new DAV\Auth\Plugin($authBackend);
     $authPlugin->beforeMethod(new \Sabre\HTTP\Request(), new \Sabre\HTTP\Response());
     $this->server->addPlugin($authPlugin);
     // This forces a login
     $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
     $this->response = new HTTP\ResponseMock();
     $this->server->httpResponse = $this->response;
 }
 function getServer()
 {
     $backend = new PrincipalBackend\Mock();
     $dir = new DAV\SimpleCollection('root');
     $principals = new PrincipalCollection($backend);
     $dir->addChild($principals);
     $fakeServer = new DAV\Server(new DAV\ObjectTree($dir));
     $fakeServer->httpResponse = new HTTP\ResponseMock();
     $plugin = new Plugin($backend, 'realm');
     $this->assertTrue($plugin instanceof Plugin);
     $fakeServer->addPlugin($plugin);
     $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
     return $fakeServer;
 }
Exemplo n.º 5
0
 public function __construct()
 {
     $config = \OC::$server->getConfig();
     $db = \OC::$server->getDatabaseConnection();
     $dispatcher = \OC::$server->getEventDispatcher();
     $userPrincipalBackend = new Principal(\OC::$server->getUserManager(), \OC::$server->getGroupManager());
     $groupPrincipalBackend = new GroupPrincipalBackend(\OC::$server->getGroupManager());
     // as soon as debug mode is enabled we allow listing of principals
     $disableListing = !$config->getSystemValue('debug', false);
     // setup the first level of the dav tree
     $userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
     $userPrincipals->disableListing = $disableListing;
     $groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
     $groupPrincipals->disableListing = $disableListing;
     $systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
     $systemPrincipals->disableListing = $disableListing;
     $filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
     $filesCollection->disableListing = $disableListing;
     $caldavBackend = new CalDavBackend($db, $userPrincipalBackend);
     $calendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users');
     $calendarRoot->disableListing = $disableListing;
     $systemTagCollection = new SystemTag\SystemTagsByIdCollection(\OC::$server->getSystemTagManager(), \OC::$server->getUserSession(), \OC::$server->getGroupManager());
     $systemTagRelationsCollection = new SystemTag\SystemTagsRelationsCollection(\OC::$server->getSystemTagManager(), \OC::$server->getSystemTagObjectMapper(), \OC::$server->getUserSession(), \OC::$server->getGroupManager(), \OC::$server->getRootFolder());
     $commentsCollection = new Comments\RootCollection(\OC::$server->getCommentsManager(), \OC::$server->getUserManager(), \OC::$server->getUserSession(), \OC::$server->getEventDispatcher(), \OC::$server->getLogger());
     $usersCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $dispatcher);
     $usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, 'principals/users');
     $usersAddressBookRoot->disableListing = $disableListing;
     $systemCardDavBackend = new CardDavBackend($db, $userPrincipalBackend, $dispatcher);
     $systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
     $systemAddressBookRoot->disableListing = $disableListing;
     $uploadCollection = new Upload\RootCollection($userPrincipalBackend, 'principals/users');
     $uploadCollection->disableListing = $disableListing;
     $children = [new SimpleCollection('principals', [$userPrincipals, $groupPrincipals, $systemPrincipals]), $filesCollection, $calendarRoot, new SimpleCollection('addressbooks', [$usersAddressBookRoot, $systemAddressBookRoot]), $systemTagCollection, $systemTagRelationsCollection, $commentsCollection, $uploadCollection];
     parent::__construct('root', $children);
 }
 public function __construct()
 {
     $applications = is_object(Tinebase_Core::getUser()) ? Tinebase_Core::getUser()->getApplications() : new Tinebase_Record_RecordSet('Tinebase_Model_Application');
     parent::__construct('root', array(new \Sabre\DAV\SimpleCollection('principals', array(new Tinebase_WebDav_PrincipalCollection(new Tinebase_WebDav_PrincipalBackend(), Tinebase_WebDav_PrincipalBackend::PREFIX_USERS), new Tinebase_WebDav_PrincipalCollection(new Tinebase_WebDav_PrincipalBackend(), Tinebase_WebDav_PrincipalBackend::PREFIX_GROUPS), new Tinebase_WebDav_PrincipalCollection(new Tinebase_WebDav_PrincipalBackend(), Tinebase_WebDav_PrincipalBackend::PREFIX_INTELLIGROUPS)))));
     if ($applications->find('name', 'Calendar')) {
         $this->addChild(new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT, true));
     }
     if ($applications->find('name', 'Tasks')) {
         $this->addChild(new Tasks_Frontend_WebDAV('tasks', true));
     }
     if ($applications->find('name', 'Addressbook')) {
         $this->addChild(new Addressbook_Frontend_WebDAV(\Sabre\CardDAV\Plugin::ADDRESSBOOK_ROOT, true));
     }
     // main entry point for ownCloud
     if ($applications->find('name', 'Filemanager')) {
         $this->addChild(new \Sabre\DAV\SimpleCollection('remote.php', array(new Filemanager_Frontend_WebDAV('webdav'))));
     }
     // webdav tree
     $webDAVCollection = new \Sabre\DAV\SimpleCollection('webdav');
     foreach ($applications as $application) {
         $applicationClass = $application->name . '_Frontend_WebDAV';
         if (@class_exists($applicationClass)) {
             $webDAVCollection->addChild(new $applicationClass($application->name));
         }
     }
     $this->addChild($webDAVCollection);
 }
 function getServer()
 {
     $backend = new PrincipalBackend\Mock();
     $dir = new DAV\SimpleCollection('root');
     $principals = new PrincipalCollection($backend);
     $dir->addChild($principals);
     $fakeServer = new DAV\Server($dir);
     $fakeServer->sapi = new HTTP\SapiMock();
     $fakeServer->httpResponse = new HTTP\ResponseMock();
     $plugin = new Plugin();
     $plugin->allowUnauthenticatedAccess = false;
     $this->assertTrue($plugin instanceof Plugin);
     $fakeServer->addPlugin($plugin);
     $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
     return $fakeServer;
 }
Exemplo n.º 8
0
 public function __construct()
 {
     $config = \OC::$server->getConfig();
     $db = \OC::$server->getDatabaseConnection();
     $principalBackend = new Principal($config, \OC::$server->getUserManager());
     // as soon as debug mode is enabled we allow listing of principals
     $disableListing = !$config->getSystemValue('debug', false);
     // setup the first level of the dav tree
     $userPrincipals = new Collection($principalBackend, 'principals/users');
     $userPrincipals->disableListing = $disableListing;
     $systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
     $systemPrincipals->disableListing = $disableListing;
     $filesCollection = new Files\RootCollection($principalBackend, 'principals/users');
     $filesCollection->disableListing = $disableListing;
     $caldavBackend = new CalDavBackend($db);
     $calendarRoot = new CalendarRoot($principalBackend, $caldavBackend, 'principals/users');
     $calendarRoot->disableListing = $disableListing;
     $usersCardDavBackend = new CardDavBackend($db, $principalBackend);
     $usersAddressBookRoot = new AddressBookRoot($principalBackend, $usersCardDavBackend, 'principals/users');
     $usersAddressBookRoot->disableListing = $disableListing;
     $systemCardDavBackend = new CardDavBackend($db, $principalBackend);
     $systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, 'principals/system');
     $systemAddressBookRoot->disableListing = $disableListing;
     $children = [new SimpleCollection('principals', [$userPrincipals, $systemPrincipals]), $filesCollection, $calendarRoot, new SimpleCollection('addressbooks', [$usersAddressBookRoot, $systemAddressBookRoot])];
     parent::__construct('root', $children);
 }
Exemplo n.º 9
0
 public function setUp()
 {
     parent::setUp();
     /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */
     $authBackend = $this->getMockBuilder('OCA\\DAV\\Connector\\Sabre\\Auth')->disableOriginalConstructor()->getMock();
     $authBackend->method('isDavAuthenticated')->willReturn(true);
     /** @var IRequest $request */
     $request = $this->getMockBuilder('OCP\\IRequest')->disableOriginalConstructor()->getMock();
     $this->plugin = new Plugin($authBackend, $request);
     $root = new SimpleCollection('root');
     $this->server = new \Sabre\DAV\Server($root);
     /** @var SimpleCollection $node */
     $this->book = $this->getMockBuilder('OCA\\DAV\\DAV\\Sharing\\IShareable')->disableOriginalConstructor()->getMock();
     $this->book->method('getName')->willReturn('addressbook1.vcf');
     $root->addChild($this->book);
     $this->plugin->initialize($this->server);
 }
 function getServer()
 {
     $backend = new PrincipalBackend\Mock();
     $dir = new DAV\SimpleCollection('root');
     $principals = new PrincipalCollection($backend);
     $dir->addChild($principals);
     $fakeServer = new DAV\Server($dir);
     $fakeServer->sapi = new HTTP\SapiMock();
     $fakeServer->httpResponse = new HTTP\ResponseMock();
     $fakeServer->debugExceptions = true;
     $plugin = new MockPlugin($backend, 'realm');
     $plugin->allowAccessToNodesWithoutACL = true;
     $this->assertTrue($plugin instanceof Plugin);
     $fakeServer->addPlugin($plugin);
     $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
     return $fakeServer;
 }
Exemplo n.º 11
0
 public function __construct()
 {
     $principalBackend = new Principal(\OC::$server->getConfig(), \OC::$server->getUserManager());
     $principalCollection = new Collection($principalBackend);
     $principalCollection->disableListing = true;
     $filesCollection = new Files\RootCollection($principalBackend);
     $filesCollection->disableListing = true;
     $children = [$principalCollection, $filesCollection];
     parent::__construct('root', $children);
 }
Exemplo n.º 12
0
 public function __construct()
 {
     $config = \OC::$server->getConfig();
     $principalBackend = new Principal($config, \OC::$server->getUserManager());
     // as soon as debug mode is enabled we allow listing of principals
     $disableListing = !$config->getSystemValue('debug', false);
     // setup the first level of the dav tree
     $principalCollection = new Collection($principalBackend);
     $principalCollection->disableListing = $disableListing;
     $filesCollection = new Files\RootCollection($principalBackend);
     $filesCollection->disableListing = $disableListing;
     $children = [$principalCollection, $filesCollection];
     parent::__construct('root', $children);
 }
Exemplo n.º 13
0
 public function __construct()
 {
     $config = \OC::$server->getConfig();
     $db = \OC::$server->getDatabaseConnection();
     $principalBackend = new Principal($config, \OC::$server->getUserManager());
     // as soon as debug mode is enabled we allow listing of principals
     $disableListing = !$config->getSystemValue('debug', false);
     // setup the first level of the dav tree
     $principalCollection = new Collection($principalBackend);
     $principalCollection->disableListing = $disableListing;
     $filesCollection = new Files\RootCollection($principalBackend);
     $filesCollection->disableListing = $disableListing;
     $caldavBackend = new CalDavBackend($db);
     $calendarRoot = new CalendarRoot($principalBackend, $caldavBackend);
     $calendarRoot->disableListing = $disableListing;
     $cardDavBackend = new CardDavBackend(\OC::$server->getDatabaseConnection(), $principalBackend);
     $addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend);
     $addressBookRoot->disableListing = $disableListing;
     $children = [$principalCollection, $filesCollection, $calendarRoot, $addressBookRoot];
     parent::__construct('root', $children);
 }
 /**
  * SystemTagsRelationsCollection constructor.
  *
  * @param ISystemTagManager $tagManager
  * @param ISystemTagObjectMapper $tagMapper
  * @param IUserSession $userSession
  * @param IGroupManager $groupManager
  * @param IRootFolder $fileRoot
  */
 public function __construct(ISystemTagManager $tagManager, ISystemTagObjectMapper $tagMapper, IUserSession $userSession, IGroupManager $groupManager, IRootFolder $fileRoot)
 {
     $children = [new SystemTagsObjectTypeCollection('files', $tagManager, $tagMapper, $userSession, $groupManager, $fileRoot)];
     parent::__construct('root', $children);
 }
Exemplo n.º 15
0
 /**
  * Constructor.
  *
  * @params  array  $children    Children.
  */
 function __construct(array $children)
 {
     parent::__construct(self::NAME, $children);
 }
Exemplo n.º 16
0
 function __construct($type)
 {
     $this->type = $type;
     parent::__construct('root');
 }
Exemplo n.º 17
0
 /**
  * SystemTagsRelationsCollection constructor.
  *
  * @param ISystemTagManager $tagManager
  * @param ISystemTagObjectMapper $tagMapper
  */
 public function __construct($tagManager, $tagMapper)
 {
     $children = [new SystemTagsObjectTypeCollection('files', $tagManager, $tagMapper)];
     parent::__construct('root', $children);
 }