function testACLIntegrationNotBlocked() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $cbackend = Sabre_CalDAV_TestUtil::getBackend(); $pbackend = new Sabre_DAVACL_MockPrincipalBackend(); $props = array('uri' => 'UUID-123467', 'principaluri' => 'admin', 'id' => 1); $tree = array(new Sabre_CalDAV_Calendar($pbackend, $cbackend, $props), new Sabre_DAVACL_PrincipalCollection($pbackend)); $p = new Sabre_CalDAV_ICSExportPlugin(); $s = new Sabre_DAV_Server($tree); $s->addPlugin($p); $s->addPlugin(new Sabre_CalDAV_Plugin()); $s->addPlugin(new Sabre_DAVACL_Plugin()); $s->addPlugin(new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'SabreDAV')); // Forcing login $s->getPlugin('acl')->adminPrincipals = array('principals/admin'); $h = new Sabre_HTTP_Request(array('QUERY_STRING' => 'export', 'REQUEST_URI' => '/UUID-123467', 'REQUEST_METHOD' => 'GET')); $s->httpRequest = $h; $s->httpResponse = new Sabre_HTTP_ResponseMock(); $s->exec(); $this->assertEquals('HTTP/1.1 200 OK', $s->httpResponse->status, 'Invalid status received. Response body: ' . $s->httpResponse->body); $this->assertEquals(array('Content-Type' => 'text/calendar'), $s->httpResponse->headers); $obj = Sabre_VObject_Reader::read($s->httpResponse->body); $this->assertEquals(5, count($obj->children())); $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); }
function setup() { $this->caldavBackend = new Sabre_CalDAV_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 Sabre_CalDAV_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 Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT', 'VTODO')))), array(1 => array('UUID-2345' => array('calendardata' => Sabre_CalDAV_TestUtil::getTestCalendarData())))); $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); $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 Sabre_CalDAV_CalendarRootNode($principalBackend, $this->caldavBackend); $principals = new Sabre_CalDAV_Principal_Collection($principalBackend); $root = new Sabre_DAV_SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $objectTree = new Sabre_DAV_ObjectTree($root); $this->server = new Sabre_DAV_Server($objectTree); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Sabre_CalDAV_Plugin(); $this->server->addPlugin($this->plugin); // Adding ACL plugin $this->server->addPlugin(new Sabre_DAVACL_Plugin()); // Adding Auth plugin, and ensuring that we are logged in. $authBackend = new Sabre_DAV_Auth_MockBackend(); $authBackend->defaultUser = '******'; $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'SabreDAV'); $this->server->addPlugin($authPlugin); $authPlugin->beforeMethod('GET', '/'); $this->response = new Sabre_HTTP_ResponseMock(); $this->server->httpResponse = $this->response; }
function setup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $this->pdo = Sabre_CalDAV_TestUtil::getSQLiteDB(); }
function setup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('No PDO SQLite support'); } $this->caldavBackend = Sabre_CalDAV_TestUtil::getBackend(); $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); $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 Sabre_CalDAV_CalendarRootNode($principalBackend, $this->caldavBackend); $principals = new Sabre_CalDAV_Principal_Collection($principalBackend); $root = new Sabre_DAV_SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $objectTree = new Sabre_DAV_ObjectTree($root); $this->server = new Sabre_DAV_Server($objectTree); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Sabre_CalDAV_Plugin(); $this->server->addPlugin($this->plugin); $this->response = new Sabre_HTTP_ResponseMock(); $this->server->httpResponse = $this->response; }
function testBeforeMethod() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $cbackend = Sabre_CalDAV_TestUtil::getBackend(); $pbackend = new Sabre_DAVACL_MockPrincipalBackend(); $props = array('uri' => 'UUID-123467', 'principaluri' => 'admin', 'id' => 1); $tree = array(new Sabre_CalDAV_Calendar($pbackend, $cbackend, $props)); $p = new Sabre_CalDAV_ICSExportPlugin(); $s = new Sabre_DAV_Server($tree); $s->addPlugin($p); $h = new Sabre_HTTP_Request(array('QUERY_STRING' => 'export')); $s->httpRequest = $h; $s->httpResponse = new Sabre_HTTP_ResponseMock(); $this->assertFalse($p->beforeMethod('GET', 'UUID-123467?export')); $this->assertEquals('HTTP/1.1 200 Ok', $s->httpResponse->status); $this->assertEquals(array('Content-Type' => 'text/calendar'), $s->httpResponse->headers); $obj = Sabre_VObject_Reader::read($s->httpResponse->body); $this->assertEquals(5, count($obj->children())); $this->assertEquals(1, count($obj->VERSION)); $this->assertEquals(1, count($obj->CALSCALE)); $this->assertEquals(1, count($obj->PRODID)); $this->assertEquals(1, count($obj->VTIMEZONE)); $this->assertEquals(1, count($obj->VEVENT)); }
/** * @depends testSetup */ function testPut() { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); $newData = Sabre_CalDAV_TestUtil::getTestCalendarData(); $children[0]->put($newData); $this->assertEquals($newData, $children[0]->get()); }
function setup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $this->backend = Sabre_CalDAV_TestUtil::getBackend(); $this->principalBackend = new Sabre_DAVACL_MockPrincipalBackend('realm'); $this->usercalendars = new Sabre_CalDAV_UserCalendars($this->principalBackend, $this->backend, 'principals/user1'); }
/** * @depends testSetup */ function testPutStream() { $children = $this->calendar->getChildren(); $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject); $newData = Sabre_CalDAV_TestUtil::getTestCalendarData(); $stream = fopen('php://temp', 'r+'); fwrite($stream, $newData); rewind($stream); $children[0]->put($stream); $this->assertEquals($newData, $children[0]->get()); }
/** * The CalDAV server is a simple script that just composes a * Sabre_DAV_Server. All we really have to do is check if the setup * is done correctly. */ function testSetup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('SQLite driver is not available'); } $pdo = Sabre_CalDAV_TestUtil::getSQLiteDB(); $server = new Sabre_CalDAV_Server($pdo); $authPlugin = $server->getPlugin('auth'); $this->assertTrue($authPlugin instanceof Sabre_DAV_Auth_Plugin); $caldavPlugin = $server->getPlugin('caldav'); $this->assertTrue($caldavPlugin instanceof Sabre_CalDAV_Plugin); $node = $server->tree->getNodeForPath(''); $this->assertTrue($node instanceof Sabre_DAV_SimpleCollection); $this->assertEquals('root', $node->getName()); }
function setup() { if (!SABRE_HASSQLITE) { $this->markTestSkipped('No PDO SQLite support'); } $this->caldavBackend = Sabre_CalDAV_TestUtil::getBackend(); $principalBackend = new Sabre_DAVACL_MockPrincipalBackend(); $calendars = new Sabre_CalDAV_CalendarRootNode($principalBackend, $this->caldavBackend); $principals = new Sabre_DAVACL_PrincipalCollection($principalBackend); $root = new Sabre_DAV_SimpleDirectory('root'); $root->addChild($calendars); $root->addChild($principals); $objectTree = new Sabre_DAV_ObjectTree($root); $this->server = new Sabre_DAV_Server($objectTree); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Sabre_CalDAV_Plugin(); $this->server->addPlugin($this->plugin); $this->response = new Sabre_HTTP_ResponseMock(); $this->server->httpResponse = $this->response; }
function testCreateFile() { $file = fopen('php://memory', 'r+'); fwrite($file, Sabre_CalDAV_TestUtil::getTestCalendarData()); rewind($file); $this->calendar->createFile('hello', $file); $file = $this->calendar->getChild('hello'); $this->assertTrue($file instanceof Sabre_CalDAV_CalendarObject); }
function testCreateFileNoSupportedComponents() { $file = fopen('php://memory', 'r+'); fwrite($file, Sabre_CalDAV_TestUtil::getTestCalendarData()); rewind($file); $calendar = new Sabre_CalDAV_Calendar($this->principalBackend, $this->backend, $this->calendars[1]); $calendar->createFile('hello', $file); $file = $calendar->getChild('hello'); $this->assertTrue($file instanceof Sabre_CalDAV_CalendarObject); }
/** * @depends testParamFilter */ function testUndefinedNegation() { $calendarPlugin = new Sabre_CalDAV_Plugin(Sabre_CalDAV_Util::getBackend()); $filters = array('/c:iCalendar/c:vcalendar' => array(), '/c:iCalendar/c:vcalendar/c:vtodo' => array(), '/c:iCalendar/c:vcalendar/c:vtodo/c:completed' => array('is-not-defined' => true), '/c:iCalendar/c:vcalendar/c:vtodo/c:status' => array('text-match' => array('collation' => 'i;ascii-casemap', 'negate-condition' => true, 'value' => 'CANCELLED'))); $this->assertFalse($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestCalendarData(), $filters)); $this->assertTrue($calendarPlugin->validateFilters(Sabre_CalDAV_TestUtil::getTestTodo(), $filters)); }