function setUp()
    {
        $calendars = array(array('principaluri' => 'principals/user2', 'id' => 1, 'uri' => 'calendar1', '{' . CalDAV\Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR"), array('principaluri' => 'principals/user2', 'id' => 2, 'uri' => 'calendar2', '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp(ScheduleCalendarTransp::TRANSPARENT)));
        $calendarobjects = array(1 => array('1.ics' => array('uri' => '1.ics', 'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T130000
DURATION:PT1H
END:VEVENT
END:VCALENDAR', 'calendarid' => 1)), 2 => array('2.ics' => array('uri' => '2.ics', 'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T080000
DURATION:PT1H
END:VEVENT
END:VCALENDAR', 'calendarid' => 2)));
        $principalBackend = new DAVACL\PrincipalBackend\Mock();
        $this->caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects);
        $tree = array(new DAVACL\PrincipalCollection($principalBackend), new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend));
        $this->request = HTTP\Sapi::createFromServerArray(['CONTENT_TYPE' => 'text/calendar']);
        $this->response = new HTTP\ResponseMock();
        $this->server = new DAV\Server($tree);
        $this->server->httpRequest = $this->request;
        $this->server->httpResponse = $this->response;
        $this->aclPlugin = new DAVACL\Plugin();
        $this->server->addPlugin($this->aclPlugin);
        $authBackend = new DAV\Auth\Backend\Mock();
        $authBackend->setCurrentUser('user1');
        $this->authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
        $this->server->addPlugin($this->authPlugin);
        // CalDAV plugin
        $this->plugin = new CalDAV\Plugin();
        $this->server->addPlugin($this->plugin);
        // Scheduling plugin
        $this->plugin = new Plugin();
        $this->server->addPlugin($this->plugin);
    }
Example #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;
 }
Example #3
0
    function setUp()
    {
        $calendars = array(array('principaluri' => 'principals/user2', 'id' => 1, 'uri' => 'calendar1'));
        $calendarobjects = array(1 => array('1.ics' => array('uri' => '1.ics', 'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T130000
DURATION:PT1H
END:VEVENT
END:VCALENDAR', 'calendarid' => 1)));
        $principalBackend = new DAVACL\PrincipalBackend\Mock();
        $caldavBackend = new Backend\Mock($calendars, $calendarobjects);
        $tree = array(new DAVACL\PrincipalCollection($principalBackend), new CalendarRootNode($principalBackend, $caldavBackend));
        $this->request = new HTTP\Request(array('CONTENT_TYPE' => 'text/calendar'));
        $this->response = new HTTP\ResponseMock();
        $this->server = new DAV\Server($tree);
        $this->server->httpRequest = $this->request;
        $this->server->httpResponse = $this->response;
        $this->aclPlugin = new DAVACL\Plugin();
        $this->server->addPlugin($this->aclPlugin);
        $authBackend = new DAV\Auth\Backend\Mock();
        $authBackend->setCurrentUser('user1');
        $this->authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
        $this->server->addPlugin($this->authPlugin);
        $this->plugin = new Plugin();
        $this->server->addPlugin($this->plugin);
    }
    function setUp()
    {
        $caldavNS = '{' . CalDAV\Plugin::NS_CALDAV . '}';
        $calendars = [['principaluri' => 'principals/user2', 'id' => 1, 'uri' => 'calendar1', $caldavNS . 'calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR"], ['principaluri' => 'principals/user2', 'id' => 2, 'uri' => 'calendar2', $caldavNS . 'schedule-calendar-transp' => new ScheduleCalendarTransp(ScheduleCalendarTransp::TRANSPARENT)]];
        $calendarobjects = [1 => ['1.ics' => ['uri' => '1.ics', 'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T130000
DURATION:PT1H
END:VEVENT
END:VCALENDAR', 'calendarid' => 1]], 2 => ['2.ics' => ['uri' => '2.ics', 'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T080000
DURATION:PT1H
END:VEVENT
END:VCALENDAR', 'calendarid' => 2]]];
        $principalBackend = new DAVACL\PrincipalBackend\Mock();
        $this->caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects);
        $tree = [new DAVACL\PrincipalCollection($principalBackend), new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend)];
        $this->request = HTTP\Sapi::createFromServerArray(['CONTENT_TYPE' => 'text/calendar']);
        $this->response = new HTTP\ResponseMock();
        $this->server = new DAV\Server($tree);
        $this->server->httpRequest = $this->request;
        $this->server->httpResponse = $this->response;
        $this->aclPlugin = new DAVACL\Plugin();
        $this->aclPlugin->allowUnauthenticatedAccess = false;
        $this->server->addPlugin($this->aclPlugin);
        $authBackend = new DAV\Auth\Backend\Mock();
        $authBackend->setPrincipal('principals/user1');
        $this->authPlugin = new DAV\Auth\Plugin($authBackend);
        // Forcing authentication to work.
        $this->authPlugin->beforeMethod($this->request, $this->response);
        $this->server->addPlugin($this->authPlugin);
        // CalDAV plugin
        $this->plugin = new CalDAV\Plugin();
        $this->server->addPlugin($this->plugin);
        // Scheduling plugin
        $this->plugin = new Plugin();
        $this->server->addPlugin($this->plugin);
    }
Example #5
0
 function setUp()
 {
     $this->setUpBackends();
     $this->setUpTree();
     $this->server = new DAV\Server($this->tree);
     $this->server->sapi = new HTTP\SapiMock();
     $this->server->debugExceptions = true;
     if ($this->setupCalDAV) {
         $this->caldavPlugin = new CalDAV\Plugin();
         $this->server->addPlugin($this->caldavPlugin);
     }
     if ($this->setupCalDAVSharing) {
         $this->caldavSharingPlugin = new CalDAV\SharingPlugin();
         $this->server->addPlugin($this->caldavSharingPlugin);
     }
     if ($this->setupCalDAVScheduling) {
         $this->caldavSchedulePlugin = new CalDAV\Schedule\Plugin();
         $this->server->addPlugin($this->caldavSchedulePlugin);
     }
     if ($this->setupCalDAVSubscriptions) {
         $this->server->addPlugin(new CalDAV\Subscriptions\Plugin());
     }
     if ($this->setupCalDAVICSExport) {
         $this->caldavICSExportPlugin = new CalDAV\ICSExportPlugin();
         $this->server->addPlugin($this->caldavICSExportPlugin);
     }
     if ($this->setupCardDAV) {
         $this->carddavPlugin = new CardDAV\Plugin();
         $this->server->addPlugin($this->carddavPlugin);
     }
     if ($this->setupACL) {
         $this->aclPlugin = new DAVACL\Plugin();
         $this->server->addPlugin($this->aclPlugin);
     }
     if ($this->setupLocks) {
         $this->locksPlugin = new DAV\Locks\Plugin($this->locksBackend);
         $this->server->addPlugin($this->locksPlugin);
     }
     if ($this->autoLogin) {
         $authBackend = new DAV\Auth\Backend\Mock();
         $authBackend->setPrincipal('principals/' . $this->autoLogin);
         $this->authPlugin = new DAV\Auth\Plugin($authBackend);
         $this->server->addPlugin($this->authPlugin);
         // This will trigger the actual login procedure
         $this->authPlugin->beforeMethod(new Request(), new Response());
     }
 }
Example #6
0
 /**
  * This function takes a username and sets the server in a state where
  * this user is logged in, and no longer requires an authentication check.
  *
  * @param string $userName
  */
 function autoLogin($userName)
 {
     $authBackend = new DAV\Auth\Backend\Mock();
     $authBackend->setPrincipal('principals/' . $userName);
     $this->authPlugin = new DAV\Auth\Plugin($authBackend);
     // If the auth plugin already exists, we're removing its hooks:
     if ($oldAuth = $this->server->getPlugin('auth')) {
         $this->server->removeListener('beforeMethod', [$oldAuth, 'beforeMethod']);
     }
     $this->server->addPlugin($this->authPlugin);
     // This will trigger the actual login procedure
     $this->authPlugin->beforeMethod(new Request(), new Response());
 }