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