xref: /plugin/davcal/vendor/sabre/dav/tests/Sabre/CalDAV/SharingPluginTest.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\CalDAV;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse Sabre\DAV;
6*a1a3b679SAndreas Boehleruse Sabre\HTTP;
7*a1a3b679SAndreas Boehler
8*a1a3b679SAndreas Boehlerclass SharingPluginTest extends \Sabre\DAVServerTest {
9*a1a3b679SAndreas Boehler
10*a1a3b679SAndreas Boehler    protected $setupCalDAV = true;
11*a1a3b679SAndreas Boehler    protected $setupCalDAVSharing = true;
12*a1a3b679SAndreas Boehler    protected $setupACL = true;
13*a1a3b679SAndreas Boehler    protected $autoLogin = 'user1';
14*a1a3b679SAndreas Boehler
15*a1a3b679SAndreas Boehler    function setUp() {
16*a1a3b679SAndreas Boehler
17*a1a3b679SAndreas Boehler        $this->caldavCalendars = array(
18*a1a3b679SAndreas Boehler            array(
19*a1a3b679SAndreas Boehler                'principaluri' => 'principals/user1',
20*a1a3b679SAndreas Boehler                'id' => 1,
21*a1a3b679SAndreas Boehler                'uri' => 'cal1',
22*a1a3b679SAndreas Boehler            ),
23*a1a3b679SAndreas Boehler            array(
24*a1a3b679SAndreas Boehler                'principaluri' => 'principals/user1',
25*a1a3b679SAndreas Boehler                'id' => 2,
26*a1a3b679SAndreas Boehler                'uri' => 'cal2',
27*a1a3b679SAndreas Boehler                '{' . Plugin::NS_CALENDARSERVER . '}shared-url' => 'calendars/user1/cal2',
28*a1a3b679SAndreas Boehler                '{http://sabredav.org/ns}owner-principal' => 'principals/user2',
29*a1a3b679SAndreas Boehler                '{http://sabredav.org/ns}read-only' => 'true',
30*a1a3b679SAndreas Boehler            ),
31*a1a3b679SAndreas Boehler            array(
32*a1a3b679SAndreas Boehler                'principaluri' => 'principals/user1',
33*a1a3b679SAndreas Boehler                'id' => 3,
34*a1a3b679SAndreas Boehler                'uri' => 'cal3',
35*a1a3b679SAndreas Boehler            ),
36*a1a3b679SAndreas Boehler        );
37*a1a3b679SAndreas Boehler
38*a1a3b679SAndreas Boehler        parent::setUp();
39*a1a3b679SAndreas Boehler
40*a1a3b679SAndreas Boehler        // Making the logged in user an admin, for full access:
41*a1a3b679SAndreas Boehler        $this->aclPlugin->adminPrincipals[] = 'principals/user1';
42*a1a3b679SAndreas Boehler        $this->aclPlugin->adminPrincipals[] = 'principals/user2';
43*a1a3b679SAndreas Boehler
44*a1a3b679SAndreas Boehler    }
45*a1a3b679SAndreas Boehler
46*a1a3b679SAndreas Boehler    function testSimple() {
47*a1a3b679SAndreas Boehler
48*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\CalDAV\\SharingPlugin', $this->server->getPlugin('caldav-sharing'));
49*a1a3b679SAndreas Boehler        $this->assertEquals(
50*a1a3b679SAndreas Boehler            'caldav-sharing',
51*a1a3b679SAndreas Boehler            $this->caldavSharingPlugin->getPluginInfo()['name']
52*a1a3b679SAndreas Boehler        );
53*a1a3b679SAndreas Boehler
54*a1a3b679SAndreas Boehler    }
55*a1a3b679SAndreas Boehler
56*a1a3b679SAndreas Boehler    function testGetFeatures() {
57*a1a3b679SAndreas Boehler
58*a1a3b679SAndreas Boehler        $this->assertEquals(array('calendarserver-sharing'), $this->caldavSharingPlugin->getFeatures());
59*a1a3b679SAndreas Boehler
60*a1a3b679SAndreas Boehler    }
61*a1a3b679SAndreas Boehler
62*a1a3b679SAndreas Boehler    function testBeforeGetShareableCalendar() {
63*a1a3b679SAndreas Boehler
64*a1a3b679SAndreas Boehler        // Forcing the server to authenticate:
65*a1a3b679SAndreas Boehler        $this->authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
66*a1a3b679SAndreas Boehler        $props = $this->server->getProperties('calendars/user1/cal1', array(
67*a1a3b679SAndreas Boehler            '{' . Plugin::NS_CALENDARSERVER . '}invite',
68*a1a3b679SAndreas Boehler            '{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes',
69*a1a3b679SAndreas Boehler        ));
70*a1a3b679SAndreas Boehler
71*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
72*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes']);
73*a1a3b679SAndreas Boehler
74*a1a3b679SAndreas Boehler    }
75*a1a3b679SAndreas Boehler
76*a1a3b679SAndreas Boehler    function testBeforeGetSharedCalendar() {
77*a1a3b679SAndreas Boehler
78*a1a3b679SAndreas Boehler        $props = $this->server->getProperties('calendars/user1/cal2', array(
79*a1a3b679SAndreas Boehler            '{' . Plugin::NS_CALENDARSERVER . '}shared-url',
80*a1a3b679SAndreas Boehler            '{' . Plugin::NS_CALENDARSERVER . '}invite',
81*a1a3b679SAndreas Boehler        ));
82*a1a3b679SAndreas Boehler
83*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
84*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']);
85*a1a3b679SAndreas Boehler
86*a1a3b679SAndreas Boehler    }
87*a1a3b679SAndreas Boehler
88*a1a3b679SAndreas Boehler    function testUpdateProperties() {
89*a1a3b679SAndreas Boehler
90*a1a3b679SAndreas Boehler        $this->caldavBackend->updateShares(1,
91*a1a3b679SAndreas Boehler            array(
92*a1a3b679SAndreas Boehler                array(
93*a1a3b679SAndreas Boehler                    'href' => 'mailto:joe@example.org',
94*a1a3b679SAndreas Boehler                ),
95*a1a3b679SAndreas Boehler            ),
96*a1a3b679SAndreas Boehler            array()
97*a1a3b679SAndreas Boehler        );
98*a1a3b679SAndreas Boehler        $result = $this->server->updateProperties('calendars/user1/cal1', array(
99*a1a3b679SAndreas Boehler            '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection'])
100*a1a3b679SAndreas Boehler        ));
101*a1a3b679SAndreas Boehler
102*a1a3b679SAndreas Boehler        $this->assertEquals([
103*a1a3b679SAndreas Boehler            '{DAV:}resourcetype' => 200
104*a1a3b679SAndreas Boehler        ], $result);
105*a1a3b679SAndreas Boehler
106*a1a3b679SAndreas Boehler        $this->assertEquals(0, count($this->caldavBackend->getShares(1)));
107*a1a3b679SAndreas Boehler
108*a1a3b679SAndreas Boehler    }
109*a1a3b679SAndreas Boehler
110*a1a3b679SAndreas Boehler    function testUpdatePropertiesPassThru() {
111*a1a3b679SAndreas Boehler
112*a1a3b679SAndreas Boehler        $result = $this->server->updateProperties('calendars/user1/cal3', array(
113*a1a3b679SAndreas Boehler            '{DAV:}foo' => 'bar',
114*a1a3b679SAndreas Boehler        ));
115*a1a3b679SAndreas Boehler
116*a1a3b679SAndreas Boehler        $this->assertEquals(array(
117*a1a3b679SAndreas Boehler            '{DAV:}foo' => 403,
118*a1a3b679SAndreas Boehler        ), $result);
119*a1a3b679SAndreas Boehler
120*a1a3b679SAndreas Boehler    }
121*a1a3b679SAndreas Boehler
122*a1a3b679SAndreas Boehler    function testUnknownMethodNoPOST() {
123*a1a3b679SAndreas Boehler
124*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
125*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'PATCH',
126*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/',
127*a1a3b679SAndreas Boehler        ));
128*a1a3b679SAndreas Boehler
129*a1a3b679SAndreas Boehler        $response = $this->request($request);
130*a1a3b679SAndreas Boehler
131*a1a3b679SAndreas Boehler        $this->assertEquals(501, $response->status, $response->body);
132*a1a3b679SAndreas Boehler
133*a1a3b679SAndreas Boehler    }
134*a1a3b679SAndreas Boehler
135*a1a3b679SAndreas Boehler    function testUnknownMethodNoXML() {
136*a1a3b679SAndreas Boehler
137*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
138*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
139*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/',
140*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/plain',
141*a1a3b679SAndreas Boehler        ));
142*a1a3b679SAndreas Boehler
143*a1a3b679SAndreas Boehler        $response = $this->request($request);
144*a1a3b679SAndreas Boehler
145*a1a3b679SAndreas Boehler        $this->assertEquals(501, $response->status, $response->body);
146*a1a3b679SAndreas Boehler
147*a1a3b679SAndreas Boehler    }
148*a1a3b679SAndreas Boehler
149*a1a3b679SAndreas Boehler    function testUnknownMethodNoNode() {
150*a1a3b679SAndreas Boehler
151*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
152*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
153*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/foo',
154*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
155*a1a3b679SAndreas Boehler        ));
156*a1a3b679SAndreas Boehler
157*a1a3b679SAndreas Boehler        $response = $this->request($request);
158*a1a3b679SAndreas Boehler
159*a1a3b679SAndreas Boehler        $this->assertEquals(501, $response->status, $response->body);
160*a1a3b679SAndreas Boehler
161*a1a3b679SAndreas Boehler    }
162*a1a3b679SAndreas Boehler
163*a1a3b679SAndreas Boehler    function testShareRequest() {
164*a1a3b679SAndreas Boehler
165*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
166*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
167*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1/cal1',
168*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
169*a1a3b679SAndreas Boehler        ));
170*a1a3b679SAndreas Boehler
171*a1a3b679SAndreas Boehler        $xml = <<<RRR
172*a1a3b679SAndreas Boehler<?xml version="1.0"?>
173*a1a3b679SAndreas Boehler<cs:share xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:">
174*a1a3b679SAndreas Boehler    <cs:set>
175*a1a3b679SAndreas Boehler        <d:href>mailto:joe@example.org</d:href>
176*a1a3b679SAndreas Boehler        <cs:common-name>Joe Shmoe</cs:common-name>
177*a1a3b679SAndreas Boehler        <cs:read-write />
178*a1a3b679SAndreas Boehler    </cs:set>
179*a1a3b679SAndreas Boehler    <cs:remove>
180*a1a3b679SAndreas Boehler        <d:href>mailto:nancy@example.org</d:href>
181*a1a3b679SAndreas Boehler    </cs:remove>
182*a1a3b679SAndreas Boehler</cs:share>
183*a1a3b679SAndreas BoehlerRRR;
184*a1a3b679SAndreas Boehler
185*a1a3b679SAndreas Boehler        $request->setBody($xml);
186*a1a3b679SAndreas Boehler
187*a1a3b679SAndreas Boehler        $response = $this->request($request);
188*a1a3b679SAndreas Boehler        $this->assertEquals(200, $response->status, $response->body);
189*a1a3b679SAndreas Boehler
190*a1a3b679SAndreas Boehler        $this->assertEquals(array(array(
191*a1a3b679SAndreas Boehler            'href' => 'mailto:joe@example.org',
192*a1a3b679SAndreas Boehler            'commonName' => 'Joe Shmoe',
193*a1a3b679SAndreas Boehler            'readOnly' => false,
194*a1a3b679SAndreas Boehler            'status' => SharingPlugin::STATUS_NORESPONSE,
195*a1a3b679SAndreas Boehler            'summary' => '',
196*a1a3b679SAndreas Boehler        )), $this->caldavBackend->getShares(1));
197*a1a3b679SAndreas Boehler
198*a1a3b679SAndreas Boehler        // Verifying that the calendar is now marked shared.
199*a1a3b679SAndreas Boehler        $props = $this->server->getProperties('calendars/user1/cal1', array('{DAV:}resourcetype'));
200*a1a3b679SAndreas Boehler        $this->assertTrue(
201*a1a3b679SAndreas Boehler            $props['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared-owner')
202*a1a3b679SAndreas Boehler        );
203*a1a3b679SAndreas Boehler
204*a1a3b679SAndreas Boehler    }
205*a1a3b679SAndreas Boehler
206*a1a3b679SAndreas Boehler    function testShareRequestNoShareableCalendar() {
207*a1a3b679SAndreas Boehler
208*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
209*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
210*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1/cal2',
211*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
212*a1a3b679SAndreas Boehler        ));
213*a1a3b679SAndreas Boehler
214*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
215*a1a3b679SAndreas Boehler<cs:share xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
216*a1a3b679SAndreas Boehler    <cs:set>
217*a1a3b679SAndreas Boehler        <d:href>mailto:joe@example.org</d:href>
218*a1a3b679SAndreas Boehler        <cs:common-name>Joe Shmoe</cs:common-name>
219*a1a3b679SAndreas Boehler        <cs:read-write />
220*a1a3b679SAndreas Boehler    </cs:set>
221*a1a3b679SAndreas Boehler    <cs:remove>
222*a1a3b679SAndreas Boehler        <d:href>mailto:nancy@example.org</d:href>
223*a1a3b679SAndreas Boehler    </cs:remove>
224*a1a3b679SAndreas Boehler</cs:share>
225*a1a3b679SAndreas Boehler';
226*a1a3b679SAndreas Boehler
227*a1a3b679SAndreas Boehler        $request->setBody($xml);
228*a1a3b679SAndreas Boehler
229*a1a3b679SAndreas Boehler        $response = $this->request($request);
230*a1a3b679SAndreas Boehler        $this->assertEquals(501, $response->status, $response->body);
231*a1a3b679SAndreas Boehler
232*a1a3b679SAndreas Boehler    }
233*a1a3b679SAndreas Boehler
234*a1a3b679SAndreas Boehler    function testInviteReply() {
235*a1a3b679SAndreas Boehler
236*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
237*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
238*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1',
239*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
240*a1a3b679SAndreas Boehler        ));
241*a1a3b679SAndreas Boehler
242*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
243*a1a3b679SAndreas Boehler<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
244*a1a3b679SAndreas Boehler    <cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl>
245*a1a3b679SAndreas Boehler    <cs:invite-accepted />
246*a1a3b679SAndreas Boehler</cs:invite-reply>
247*a1a3b679SAndreas Boehler';
248*a1a3b679SAndreas Boehler
249*a1a3b679SAndreas Boehler        $request->setBody($xml);
250*a1a3b679SAndreas Boehler        $response = $this->request($request);
251*a1a3b679SAndreas Boehler        $this->assertEquals(200, $response->status, $response->body);
252*a1a3b679SAndreas Boehler
253*a1a3b679SAndreas Boehler    }
254*a1a3b679SAndreas Boehler
255*a1a3b679SAndreas Boehler    function testInviteBadXML() {
256*a1a3b679SAndreas Boehler
257*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
258*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
259*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1',
260*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
261*a1a3b679SAndreas Boehler        ));
262*a1a3b679SAndreas Boehler
263*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
264*a1a3b679SAndreas Boehler<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
265*a1a3b679SAndreas Boehler</cs:invite-reply>
266*a1a3b679SAndreas Boehler';
267*a1a3b679SAndreas Boehler        $request->setBody($xml);
268*a1a3b679SAndreas Boehler        $response = $this->request($request);
269*a1a3b679SAndreas Boehler        $this->assertEquals(400, $response->status, $response->body);
270*a1a3b679SAndreas Boehler
271*a1a3b679SAndreas Boehler    }
272*a1a3b679SAndreas Boehler
273*a1a3b679SAndreas Boehler    function testInviteWrongUrl() {
274*a1a3b679SAndreas Boehler
275*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
276*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
277*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1/cal1',
278*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
279*a1a3b679SAndreas Boehler        ));
280*a1a3b679SAndreas Boehler
281*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
282*a1a3b679SAndreas Boehler<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
283*a1a3b679SAndreas Boehler    <cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl>
284*a1a3b679SAndreas Boehler</cs:invite-reply>
285*a1a3b679SAndreas Boehler';
286*a1a3b679SAndreas Boehler        $request->setBody($xml);
287*a1a3b679SAndreas Boehler        $response = $this->request($request);
288*a1a3b679SAndreas Boehler        $this->assertEquals(501, $response->status, $response->body);
289*a1a3b679SAndreas Boehler
290*a1a3b679SAndreas Boehler        // If the plugin did not handle this request, it must ensure that the
291*a1a3b679SAndreas Boehler        // body is still accessible by other plugins.
292*a1a3b679SAndreas Boehler        $this->assertEquals($xml, $request->getBody(true));
293*a1a3b679SAndreas Boehler
294*a1a3b679SAndreas Boehler    }
295*a1a3b679SAndreas Boehler
296*a1a3b679SAndreas Boehler    function testPublish() {
297*a1a3b679SAndreas Boehler
298*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
299*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
300*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1/cal1',
301*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
302*a1a3b679SAndreas Boehler        ));
303*a1a3b679SAndreas Boehler
304*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
305*a1a3b679SAndreas Boehler<cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
306*a1a3b679SAndreas Boehler';
307*a1a3b679SAndreas Boehler
308*a1a3b679SAndreas Boehler        $request->setBody($xml);
309*a1a3b679SAndreas Boehler
310*a1a3b679SAndreas Boehler        $response = $this->request($request);
311*a1a3b679SAndreas Boehler        $this->assertEquals(202, $response->status, $response->body);
312*a1a3b679SAndreas Boehler
313*a1a3b679SAndreas Boehler    }
314*a1a3b679SAndreas Boehler
315*a1a3b679SAndreas Boehler    function testUnpublish() {
316*a1a3b679SAndreas Boehler
317*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
318*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
319*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1/cal1',
320*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
321*a1a3b679SAndreas Boehler        ));
322*a1a3b679SAndreas Boehler
323*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
324*a1a3b679SAndreas Boehler<cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
325*a1a3b679SAndreas Boehler';
326*a1a3b679SAndreas Boehler
327*a1a3b679SAndreas Boehler        $request->setBody($xml);
328*a1a3b679SAndreas Boehler
329*a1a3b679SAndreas Boehler        $response = $this->request($request);
330*a1a3b679SAndreas Boehler        $this->assertEquals(200, $response->status, $response->body);
331*a1a3b679SAndreas Boehler
332*a1a3b679SAndreas Boehler    }
333*a1a3b679SAndreas Boehler
334*a1a3b679SAndreas Boehler    function testPublishWrongUrl() {
335*a1a3b679SAndreas Boehler
336*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
337*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
338*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1/cal2',
339*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
340*a1a3b679SAndreas Boehler        ));
341*a1a3b679SAndreas Boehler
342*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
343*a1a3b679SAndreas Boehler<cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
344*a1a3b679SAndreas Boehler';
345*a1a3b679SAndreas Boehler
346*a1a3b679SAndreas Boehler        $request->setBody($xml);
347*a1a3b679SAndreas Boehler
348*a1a3b679SAndreas Boehler        $response = $this->request($request);
349*a1a3b679SAndreas Boehler        $this->assertEquals(501, $response->status, $response->body);
350*a1a3b679SAndreas Boehler
351*a1a3b679SAndreas Boehler    }
352*a1a3b679SAndreas Boehler
353*a1a3b679SAndreas Boehler    function testUnpublishWrongUrl() {
354*a1a3b679SAndreas Boehler
355*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
356*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
357*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1/cal2',
358*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
359*a1a3b679SAndreas Boehler        ));
360*a1a3b679SAndreas Boehler
361*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
362*a1a3b679SAndreas Boehler<cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
363*a1a3b679SAndreas Boehler';
364*a1a3b679SAndreas Boehler
365*a1a3b679SAndreas Boehler        $request->setBody($xml);
366*a1a3b679SAndreas Boehler
367*a1a3b679SAndreas Boehler        $response = $this->request($request);
368*a1a3b679SAndreas Boehler        $this->assertEquals(501, $response->status, $response->body);
369*a1a3b679SAndreas Boehler
370*a1a3b679SAndreas Boehler    }
371*a1a3b679SAndreas Boehler
372*a1a3b679SAndreas Boehler    function testUnknownXmlDoc() {
373*a1a3b679SAndreas Boehler
374*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray(array(
375*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'POST',
376*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/calendars/user1/cal2',
377*a1a3b679SAndreas Boehler            'CONTENT_TYPE'   => 'text/xml',
378*a1a3b679SAndreas Boehler        ));
379*a1a3b679SAndreas Boehler
380*a1a3b679SAndreas Boehler        $xml = '<?xml version="1.0"?>
381*a1a3b679SAndreas Boehler<cs:foo-bar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />';
382*a1a3b679SAndreas Boehler
383*a1a3b679SAndreas Boehler        $request->setBody($xml);
384*a1a3b679SAndreas Boehler
385*a1a3b679SAndreas Boehler        $response = $this->request($request);
386*a1a3b679SAndreas Boehler        $this->assertEquals(501, $response->status, $response->body);
387*a1a3b679SAndreas Boehler
388*a1a3b679SAndreas Boehler    }
389*a1a3b679SAndreas Boehler}
390