1<?php 2 3namespace Sabre\CalDAV\Schedule; 4 5use Sabre\HTTP; 6use Sabre\VObject; 7use Sabre\DAV; 8 9class OutboxPostTest extends \Sabre\DAVServerTest { 10 11 protected $setupCalDAV = true; 12 protected $setupACL = true; 13 protected $autoLogin = 'user1'; 14 protected $setupCalDAVScheduling = true; 15 16 function testPostPassThruNotFound() { 17 18 $req = HTTP\Sapi::createFromServerArray(array( 19 'REQUEST_METHOD' => 'POST', 20 'REQUEST_URI' => '/notfound', 21 'HTTP_CONTENT_TYPE' => 'text/calendar', 22 )); 23 24 $this->assertHTTPStatus(501, $req); 25 26 } 27 28 function testPostPassThruNotTextCalendar() { 29 30 $req = HTTP\Sapi::createFromServerArray(array( 31 'REQUEST_METHOD' => 'POST', 32 'REQUEST_URI' => '/calendars/user1/outbox', 33 )); 34 35 $this->assertHTTPStatus(501, $req); 36 37 } 38 39 function testPostPassThruNoOutBox() { 40 41 $req = HTTP\Sapi::createFromServerArray(array( 42 'REQUEST_METHOD' => 'POST', 43 'REQUEST_URI' => '/calendars', 44 'HTTP_CONTENT_TYPE' => 'text/calendar', 45 )); 46 47 $this->assertHTTPStatus(501, $req); 48 49 } 50 51 function testInvalidIcalBody() { 52 53 $req = HTTP\Sapi::createFromServerArray(array( 54 'REQUEST_METHOD' => 'POST', 55 'REQUEST_URI' => '/calendars/user1/outbox', 56 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org', 57 'HTTP_RECIPIENT' => 'mailto:user2@example.org', 58 'HTTP_CONTENT_TYPE' => 'text/calendar', 59 )); 60 $req->setBody('foo'); 61 62 $this->assertHTTPStatus(400, $req); 63 64 } 65 66 function testNoVEVENT() { 67 68 $req = HTTP\Sapi::createFromServerArray(array( 69 'REQUEST_METHOD' => 'POST', 70 'REQUEST_URI' => '/calendars/user1/outbox', 71 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org', 72 'HTTP_RECIPIENT' => 'mailto:user2@example.org', 73 'HTTP_CONTENT_TYPE' => 'text/calendar', 74 )); 75 76 $body = array( 77 'BEGIN:VCALENDAR', 78 'BEGIN:VTIMEZONE', 79 'END:VTIMEZONE', 80 'END:VCALENDAR', 81 ); 82 83 $req->setBody(implode("\r\n",$body)); 84 85 $this->assertHTTPStatus(400, $req); 86 87 } 88 89 function testNoMETHOD() { 90 91 $req = HTTP\Sapi::createFromServerArray(array( 92 'REQUEST_METHOD' => 'POST', 93 'REQUEST_URI' => '/calendars/user1/outbox', 94 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org', 95 'HTTP_RECIPIENT' => 'mailto:user2@example.org', 96 'HTTP_CONTENT_TYPE' => 'text/calendar', 97 )); 98 99 $body = array( 100 'BEGIN:VCALENDAR', 101 'BEGIN:VEVENT', 102 'END:VEVENT', 103 'END:VCALENDAR', 104 ); 105 106 $req->setBody(implode("\r\n",$body)); 107 108 $this->assertHTTPStatus(400, $req); 109 110 } 111 112 function testUnsupportedMethod() { 113 114 $req = HTTP\Sapi::createFromServerArray(array( 115 'REQUEST_METHOD' => 'POST', 116 'REQUEST_URI' => '/calendars/user1/outbox', 117 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org', 118 'HTTP_RECIPIENT' => 'mailto:user2@example.org', 119 'HTTP_CONTENT_TYPE' => 'text/calendar', 120 )); 121 122 $body = array( 123 'BEGIN:VCALENDAR', 124 'METHOD:PUBLISH', 125 'BEGIN:VEVENT', 126 'END:VEVENT', 127 'END:VCALENDAR', 128 ); 129 130 $req->setBody(implode("\r\n",$body)); 131 132 $this->assertHTTPStatus(501, $req); 133 134 } 135 136} 137