Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 function getInstance()
 {
     $backend = new DAVACL\PrincipalBackend\Mock();
     $backend->addPrincipal(array('uri' => 'principals/user/calendar-proxy-read'));
     $backend->addPrincipal(array('uri' => 'principals/user/calendar-proxy-write'));
     $backend->addPrincipal(array('uri' => 'principals/user/random'));
     return new User($backend, array('uri' => 'principals/user'));
 }