From b35122f7a6ad42756c35bb60ba1f06c3dcd45c77 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 21 Oct 2013 15:46:31 -0700 Subject: add sabre (1.8.x) via composer in the !@#$ place it wants to be --- .../dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php | 282 +++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php (limited to 'vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php') diff --git a/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php new file mode 100644 index 000000000..62252e6a1 --- /dev/null +++ b/vendor/sabre/dav/tests/Sabre/CalDAV/FreeBusyRequestTest.php @@ -0,0 +1,282 @@ + '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 testWrongMethod() { + + $this->assertNull( + $this->plugin->unknownMethod('PUT','calendars/user1/outbox') + ); + + } + + function testWrongContentType() { + + $this->server->httpRequest = new HTTP\Request(array( + 'CONTENT_TYPE' => 'text/plain', + )); + + $this->assertNull( + $this->plugin->unknownMethod('POST','calendars/user1/outbox') + ); + + } + + function testNotFound() { + + $this->assertNull( + $this->plugin->unknownMethod('POST','calendars/user1/blabla') + ); + + } + + function testNotOutbox() { + + $this->assertNull( + $this->plugin->unknownMethod('POST','calendars/user1/inbox') + ); + + } + + /** + * @expectedException Sabre\DAV\Exception\BadRequest + */ + function testNoItipMethod() { + + $body = <<request->setBody($body); + $this->plugin->unknownMethod('POST','calendars/user1/outbox'); + + } + + /** + * @expectedException Sabre\DAV\Exception\BadRequest + */ + function testNoVFreeBusy() { + + $body = <<request->setBody($body); + $this->plugin->unknownMethod('POST','calendars/user1/outbox'); + + } + + /** + * @expectedException Sabre\DAV\Exception\Forbidden + */ + function testIncorrectOrganizer() { + + $body = <<request->setBody($body); + $this->plugin->unknownMethod('POST','calendars/user1/outbox'); + + } + + /** + * @expectedException Sabre\DAV\Exception\BadRequest + */ + function testNoAttendees() { + + $body = <<request->setBody($body); + $this->plugin->unknownMethod('POST','calendars/user1/outbox'); + + } + + /** + * @expectedException Sabre\DAV\Exception\BadRequest + */ + function testNoDTStart() { + + $body = <<request->setBody($body); + $this->plugin->unknownMethod('POST','calendars/user1/outbox'); + + } + + function testSucceed() { + + $body = <<aclPlugin->adminPrincipals[] = 'principals/user1'; + + $this->request->setBody($body); + $this->assertFalse($this->plugin->unknownMethod('POST','calendars/user1/outbox')); + + $this->assertEquals('HTTP/1.1 200 OK' , $this->response->status); + $this->assertEquals(array( + 'Content-Type' => 'application/xml', + ), $this->response->headers); + + $strings = array( + 'mailto:user2.sabredav@sabredav.org', + 'mailto:user3.sabredav@sabredav.org', + '2.0;Success', + '3.7;Could not find principal', + 'FREEBUSY;FBTYPE=BUSY:20110101T130000Z/20110101T140000Z', + ); + + foreach($strings as $string) { + $this->assertTrue( + strpos($this->response->body, $string)!==false, + 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body + ); + } + + + } + + function testNoPrivilege() { + + $body = <<request->setBody($body); + $this->assertFalse($this->plugin->unknownMethod('POST','calendars/user1/outbox')); + + $this->assertEquals('HTTP/1.1 200 OK' , $this->response->status); + $this->assertEquals(array( + 'Content-Type' => 'application/xml', + ), $this->response->headers); + + $strings = array( + 'mailto:user2.sabredav@sabredav.org', + '3.7;No calendar-home-set property found', + ); + + foreach($strings as $string) { + $this->assertTrue( + strpos($this->response->body, $string)!==false, + 'The response body did not contain: ' . $string .'Full response: ' . $this->response->body + ); + } + + + } + +} -- cgit v1.2.3