ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\Schedule\FreeBusyRequestTest Class Reference
+ Inheritance diagram for Sabre\CalDAV\Schedule\FreeBusyRequestTest:
+ Collaboration diagram for Sabre\CalDAV\Schedule\FreeBusyRequestTest:

Public Member Functions

 setUp ()
 
 testWrongContentType ()
 
 testNotFound ()
 
 testNotOutbox ()
 
 testNoItipMethod ()
 Sabre More...
 
 testNoVFreeBusy ()
 
 testIncorrectOrganizer ()
 Sabre More...
 
 testNoAttendees ()
 Sabre More...
 
 testNoDTStart ()
 Sabre More...
 
 testSucceed ()
 
 testSucceedNoCalendars ()
 Testing if the freebusy request still works, even if there are no calendars in the target users' account. More...
 
 testNoCalendarHomeFound ()
 
 testNoInboxFound ()
 
 testSucceedUseVAVAILABILITY ()
 

Protected Attributes

 $plugin
 
 $server
 
 $aclPlugin
 
 $request
 
 $authPlugin
 
 $caldavBackend
 

Detailed Description

Definition at line 11 of file FreeBusyRequestTest.php.

Member Function Documentation

◆ setUp()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::setUp ( )

Definition at line 20 of file FreeBusyRequestTest.php.

References $authBackend, $principalBackend, Sabre\CalDAV\Schedule\FreeBusyRequestTest\$request, $response, $tree, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\CalDAV\Plugin\NS_CALDAV, and Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp\TRANSPARENT.

20  {
21 
22  $caldavNS = '{' . CalDAV\Plugin::NS_CALDAV . '}';
23  $calendars = [
24  [
25  'principaluri' => 'principals/user2',
26  'id' => 1,
27  'uri' => 'calendar1',
28  $caldavNS . 'calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR",
29  ],
30  [
31  'principaluri' => 'principals/user2',
32  'id' => 2,
33  'uri' => 'calendar2',
34  $caldavNS . 'schedule-calendar-transp' => new ScheduleCalendarTransp(ScheduleCalendarTransp::TRANSPARENT),
35  ],
36  ];
37  $calendarobjects = [
38  1 => ['1.ics' => [
39  'uri' => '1.ics',
40  'calendardata' => 'BEGIN:VCALENDAR
41 BEGIN:VEVENT
42 DTSTART:20110101T130000
43 DURATION:PT1H
44 END:VEVENT
45 END:VCALENDAR',
46  'calendarid' => 1,
47  ]],
48  2 => ['2.ics' => [
49  'uri' => '2.ics',
50  'calendardata' => 'BEGIN:VCALENDAR
51 BEGIN:VEVENT
52 DTSTART:20110101T080000
53 DURATION:PT1H
54 END:VEVENT
55 END:VCALENDAR',
56  'calendarid' => 2,
57  ]]
58 
59  ];
60 
61  $principalBackend = new DAVACL\PrincipalBackend\Mock();
62  $this->caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects);
63 
64  $tree = [
65  new DAVACL\PrincipalCollection($principalBackend),
66  new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend),
67  ];
68 
69  $this->request = HTTP\Sapi::createFromServerArray([
70  'CONTENT_TYPE' => 'text/calendar',
71  ]);
72  $this->response = new HTTP\ResponseMock();
73 
74  $this->server = new DAV\Server($tree);
75  $this->server->httpRequest = $this->request;
76  $this->server->httpResponse = $this->response;
77 
78  $this->aclPlugin = new DAVACL\Plugin();
79  $this->aclPlugin->allowUnauthenticatedAccess = false;
80  $this->server->addPlugin($this->aclPlugin);
81 
82  $authBackend = new DAV\Auth\Backend\Mock();
83  $authBackend->setPrincipal('principals/user1');
84  $this->authPlugin = new DAV\Auth\Plugin($authBackend);
85  // Forcing authentication to work.
86  $this->authPlugin->beforeMethod($this->request, $this->response);
87  $this->server->addPlugin($this->authPlugin);
88 
89  // CalDAV plugin
90  $this->plugin = new CalDAV\Plugin();
91  $this->server->addPlugin($this->plugin);
92 
93  // Scheduling plugin
94  $this->plugin = new Plugin();
95  $this->server->addPlugin($this->plugin);
96 
97  }
$authBackend
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33
$principalBackend
+ Here is the call graph for this function:

◆ testIncorrectOrganizer()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testIncorrectOrganizer ( )

Sabre

Definition at line 191 of file FreeBusyRequestTest.php.

191  {
192 
193  $this->server->httpRequest = new HTTP\Request(
194  'POST',
195  '/calendars/user1/outbox',
196  ['Content-Type' => 'text/calendar']
197  );
198 
199 
200  $body = <<<ICS
201 BEGIN:VCALENDAR
202 METHOD:REQUEST
203 BEGIN:VFREEBUSY
204 ORGANIZER:mailto:john@wayne.org
205 END:VFREEBUSY
206 END:VCALENDAR
207 ICS;
208 
209  $this->server->httpRequest->setBody($body);
210  $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse);
211 
212  }

◆ testNoAttendees()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testNoAttendees ( )

Sabre

Definition at line 217 of file FreeBusyRequestTest.php.

217  {
218 
219  $this->server->httpRequest = new HTTP\Request(
220  'POST',
221  '/calendars/user1/outbox',
222  ['Content-Type' => 'text/calendar']
223  );
224 
225  $body = <<<ICS
226 BEGIN:VCALENDAR
227 METHOD:REQUEST
228 BEGIN:VFREEBUSY
229 ORGANIZER:mailto:user1.sabredav@sabredav.org
230 END:VFREEBUSY
231 END:VCALENDAR
232 ICS;
233 
234  $this->server->httpRequest->setBody($body);
235  $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse);
236 
237  }

◆ testNoCalendarHomeFound()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testNoCalendarHomeFound ( )

Definition at line 378 of file FreeBusyRequestTest.php.

References Sabre\CalDAV\Plugin\NS_CALDAV, and user2.

378  {
379 
380  $this->server->httpRequest = new HTTP\Request(
381  'POST',
382  '/calendars/user1/outbox',
383  ['Content-Type' => 'text/calendar']
384  );
385 
386  $body = <<<ICS
387 BEGIN:VCALENDAR
388 METHOD:REQUEST
389 BEGIN:VFREEBUSY
390 ORGANIZER:mailto:user1.sabredav@sabredav.org
391 ATTENDEE:mailto:user2.sabredav@sabredav.org
392 DTSTART:20110101T080000Z
393 DTEND:20110101T180000Z
394 END:VFREEBUSY
395 END:VCALENDAR
396 ICS;
397 
398  $this->server->httpRequest->setBody($body);
399 
400  // Lazily making the current principal an admin.
401  $this->aclPlugin->adminPrincipals[] = 'principals/user1';
402 
403  // Removing the calendar home
404  $this->server->on('propFind', function(DAV\PropFind $propFind) {
405 
406  $propFind->set('{' . Plugin::NS_CALDAV . '}calendar-home-set', null, 403);
407 
408  });
409 
410  $this->assertFalse(
411  $this->plugin->httpPost($this->server->httpRequest, $this->response)
412  );
413 
414  $this->assertEquals(200, $this->response->status);
415  $this->assertEquals([
416  'Content-Type' => ['application/xml'],
417  ], $this->response->getHeaders());
418 
419  $strings = [
420  '<d:href>mailto:user2.sabredav@sabredav.org</d:href>',
421  '<cal:request-status>3.7;No calendar-home-set property found</cal:request-status>',
422  ];
423 
424  foreach ($strings as $string) {
425  $this->assertTrue(
426  strpos($this->response->body, $string) !== false,
427  'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
428  );
429  }
430 
431  }
user2
Definition: basicauth.php:12
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33

◆ testNoDTStart()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testNoDTStart ( )

Sabre

Definition at line 242 of file FreeBusyRequestTest.php.

References user2.

242  {
243 
244  $this->server->httpRequest = new HTTP\Request(
245  'POST',
246  '/calendars/user1/outbox',
247  ['Content-Type' => 'text/calendar']
248  );
249 
250  $body = <<<ICS
251 BEGIN:VCALENDAR
252 METHOD:REQUEST
253 BEGIN:VFREEBUSY
254 ORGANIZER:mailto:user1.sabredav@sabredav.org
255 ATTENDEE:mailto:user2.sabredav@sabredav.org
256 END:VFREEBUSY
257 END:VCALENDAR
258 ICS;
259 
260  $this->server->httpRequest->setBody($body);
261  $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse);
262 
263  }
user2
Definition: basicauth.php:12

◆ testNoInboxFound()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testNoInboxFound ( )

Definition at line 433 of file FreeBusyRequestTest.php.

References Sabre\CalDAV\Plugin\NS_CALDAV, and user2.

433  {
434 
435  $this->server->httpRequest = new HTTP\Request(
436  'POST',
437  '/calendars/user1/outbox',
438  ['Content-Type' => 'text/calendar']
439  );
440 
441  $body = <<<ICS
442 BEGIN:VCALENDAR
443 METHOD:REQUEST
444 BEGIN:VFREEBUSY
445 ORGANIZER:mailto:user1.sabredav@sabredav.org
446 ATTENDEE:mailto:user2.sabredav@sabredav.org
447 DTSTART:20110101T080000Z
448 DTEND:20110101T180000Z
449 END:VFREEBUSY
450 END:VCALENDAR
451 ICS;
452 
453  $this->server->httpRequest->setBody($body);
454 
455  // Lazily making the current principal an admin.
456  $this->aclPlugin->adminPrincipals[] = 'principals/user1';
457 
458  // Removing the inbox
459  $this->server->on('propFind', function(DAV\PropFind $propFind) {
460 
461  $propFind->set('{' . Plugin::NS_CALDAV . '}schedule-inbox-URL', null, 403);
462 
463  });
464 
465  $this->assertFalse(
466  $this->plugin->httpPost($this->server->httpRequest, $this->response)
467  );
468 
469  $this->assertEquals(200, $this->response->status);
470  $this->assertEquals([
471  'Content-Type' => ['application/xml'],
472  ], $this->response->getHeaders());
473 
474  $strings = [
475  '<d:href>mailto:user2.sabredav@sabredav.org</d:href>',
476  '<cal:request-status>3.7;No schedule-inbox-URL property found</cal:request-status>',
477  ];
478 
479  foreach ($strings as $string) {
480  $this->assertTrue(
481  strpos($this->response->body, $string) !== false,
482  'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
483  );
484  }
485 
486  }
user2
Definition: basicauth.php:12
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33

◆ testNoItipMethod()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testNoItipMethod ( )

Sabre

Definition at line 144 of file FreeBusyRequestTest.php.

144  {
145 
146  $this->server->httpRequest = new HTTP\Request(
147  'POST',
148  '/calendars/user1/outbox',
149  ['Content-Type' => 'text/calendar']
150  );
151 
152  $body = <<<ICS
153 BEGIN:VCALENDAR
154 BEGIN:VFREEBUSY
155 END:VFREEBUSY
156 END:VCALENDAR
157 ICS;
158 
159  $this->server->httpRequest->setBody($body);
160  $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse);
161 
162  }

◆ testNotFound()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testNotFound ( )

Definition at line 113 of file FreeBusyRequestTest.php.

113  {
114 
115  $this->server->httpRequest = new HTTP\Request(
116  'POST',
117  '/calendars/user1/blabla',
118  ['Content-Type' => 'text/calendar']
119  );
120 
121  $this->assertNull(
122  $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse)
123  );
124 
125  }

◆ testNotOutbox()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testNotOutbox ( )

Definition at line 127 of file FreeBusyRequestTest.php.

127  {
128 
129  $this->server->httpRequest = new HTTP\Request(
130  'POST',
131  '/calendars/user1/inbox',
132  ['Content-Type' => 'text/calendar']
133  );
134 
135  $this->assertNull(
136  $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse)
137  );
138 
139  }

◆ testNoVFreeBusy()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testNoVFreeBusy ( )

Definition at line 167 of file FreeBusyRequestTest.php.

167  {
168 
169  $this->server->httpRequest = new HTTP\Request(
170  'POST',
171  '/calendars/user1/outbox',
172  ['Content-Type' => 'text/calendar']
173  );
174 
175  $body = <<<ICS
176 BEGIN:VCALENDAR
177 METHOD:REQUEST
178 BEGIN:VEVENT
179 END:VEVENT
180 END:VCALENDAR
181 ICS;
182 
183  $this->server->httpRequest->setBody($body);
184  $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse);
185 
186  }

◆ testSucceed()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testSucceed ( )

Definition at line 265 of file FreeBusyRequestTest.php.

References user2.

265  {
266 
267  $this->server->httpRequest = new HTTP\Request(
268  'POST',
269  '/calendars/user1/outbox',
270  ['Content-Type' => 'text/calendar']
271  );
272 
273  $body = <<<ICS
274 BEGIN:VCALENDAR
275 METHOD:REQUEST
276 BEGIN:VFREEBUSY
277 ORGANIZER:mailto:user1.sabredav@sabredav.org
278 ATTENDEE:mailto:user2.sabredav@sabredav.org
279 ATTENDEE:mailto:user3.sabredav@sabredav.org
280 DTSTART:20110101T080000Z
281 DTEND:20110101T180000Z
282 END:VFREEBUSY
283 END:VCALENDAR
284 ICS;
285 
286  $this->server->httpRequest->setBody($body);
287 
288  // Lazily making the current principal an admin.
289  $this->aclPlugin->adminPrincipals[] = 'principals/user1';
290 
291  $this->assertFalse(
292  $this->plugin->httpPost($this->server->httpRequest, $this->response)
293  );
294 
295  $this->assertEquals(200, $this->response->status);
296  $this->assertEquals([
297  'Content-Type' => ['application/xml'],
298  ], $this->response->getHeaders());
299 
300  $strings = [
301  '<d:href>mailto:user2.sabredav@sabredav.org</d:href>',
302  '<d:href>mailto:user3.sabredav@sabredav.org</d:href>',
303  '<cal:request-status>2.0;Success</cal:request-status>',
304  '<cal:request-status>3.7;Could not find principal</cal:request-status>',
305  'FREEBUSY:20110101T120000Z/20110101T130000Z',
306  ];
307 
308  foreach ($strings as $string) {
309  $this->assertTrue(
310  strpos($this->response->body, $string) !== false,
311  'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
312  );
313  }
314 
315  $this->assertTrue(
316  strpos($this->response->body, 'FREEBUSY;FBTYPE=BUSY:20110101T080000Z/20110101T090000Z') == false,
317  'The response body did contain free busy info from a transparent calendar.'
318  );
319 
320  }
user2
Definition: basicauth.php:12

◆ testSucceedNoCalendars()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testSucceedNoCalendars ( )

Testing if the freebusy request still works, even if there are no calendars in the target users' account.

Definition at line 326 of file FreeBusyRequestTest.php.

References user2.

326  {
327 
328  // Deleting calendars
329  $this->caldavBackend->deleteCalendar(1);
330  $this->caldavBackend->deleteCalendar(2);
331 
332  $this->server->httpRequest = new HTTP\Request(
333  'POST',
334  '/calendars/user1/outbox',
335  ['Content-Type' => 'text/calendar']
336  );
337 
338  $body = <<<ICS
339 BEGIN:VCALENDAR
340 METHOD:REQUEST
341 BEGIN:VFREEBUSY
342 ORGANIZER:mailto:user1.sabredav@sabredav.org
343 ATTENDEE:mailto:user2.sabredav@sabredav.org
344 DTSTART:20110101T080000Z
345 DTEND:20110101T180000Z
346 END:VFREEBUSY
347 END:VCALENDAR
348 ICS;
349 
350  $this->server->httpRequest->setBody($body);
351 
352  // Lazily making the current principal an admin.
353  $this->aclPlugin->adminPrincipals[] = 'principals/user1';
354 
355  $this->assertFalse(
356  $this->plugin->httpPost($this->server->httpRequest, $this->response)
357  );
358 
359  $this->assertEquals(200, $this->response->status);
360  $this->assertEquals([
361  'Content-Type' => ['application/xml'],
362  ], $this->response->getHeaders());
363 
364  $strings = [
365  '<d:href>mailto:user2.sabredav@sabredav.org</d:href>',
366  '<cal:request-status>2.0;Success</cal:request-status>',
367  ];
368 
369  foreach ($strings as $string) {
370  $this->assertTrue(
371  strpos($this->response->body, $string) !== false,
372  'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
373  );
374  }
375 
376  }
user2
Definition: basicauth.php:12

◆ testSucceedUseVAVAILABILITY()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testSucceedUseVAVAILABILITY ( )

Definition at line 488 of file FreeBusyRequestTest.php.

References Sabre\CalDAV\Plugin\NS_CALDAV, and user2.

488  {
489 
490  $this->server->httpRequest = new HTTP\Request(
491  'POST',
492  '/calendars/user1/outbox',
493  ['Content-Type' => 'text/calendar']
494  );
495 
496  $body = <<<ICS
497 BEGIN:VCALENDAR
498 METHOD:REQUEST
499 BEGIN:VFREEBUSY
500 ORGANIZER:mailto:user1.sabredav@sabredav.org
501 ATTENDEE:mailto:user2.sabredav@sabredav.org
502 DTSTART:20110101T080000Z
503 DTEND:20110101T180000Z
504 END:VFREEBUSY
505 END:VCALENDAR
506 ICS;
507 
508  $this->server->httpRequest->setBody($body);
509 
510  // Lazily making the current principal an admin.
511  $this->aclPlugin->adminPrincipals[] = 'principals/user1';
512 
513  // Adding VAVAILABILITY manually
514  $this->server->on('propFind', function(DAV\PropFind $propFind) {
515 
516  $propFind->handle('{' . Plugin::NS_CALDAV . '}calendar-availability', function() {
517 
518  $avail = <<<ICS
519 BEGIN:VCALENDAR
520 BEGIN:VAVAILABILITY
521 DTSTART:20110101T000000Z
522 DTEND:20110102T000000Z
523 BEGIN:AVAILABLE
524 DTSTART:20110101T090000Z
525 DTEND:20110101T170000Z
526 END:AVAILABLE
527 END:VAVAILABILITY
528 END:VCALENDAR
529 ICS;
530  return $avail;
531 
532  });
533 
534  });
535 
536  $this->assertFalse(
537  $this->plugin->httpPost($this->server->httpRequest, $this->response)
538  );
539 
540  $this->assertEquals(200, $this->response->status);
541  $this->assertEquals([
542  'Content-Type' => ['application/xml'],
543  ], $this->response->getHeaders());
544 
545  $strings = [
546  '<d:href>mailto:user2.sabredav@sabredav.org</d:href>',
547  '<cal:request-status>2.0;Success</cal:request-status>',
548  'FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:20110101T080000Z/20110101T090000Z',
549  'FREEBUSY:20110101T120000Z/20110101T130000Z',
550  'FREEBUSY;FBTYPE=BUSY-UNAVAILABLE:20110101T170000Z/20110101T180000Z',
551  ];
552 
553  foreach ($strings as $string) {
554  $this->assertTrue(
555  strpos($this->response->body, $string) !== false,
556  'The response body did not contain: ' . $string . 'Full response: ' . $this->response->body
557  );
558  }
559 
560  }
user2
Definition: basicauth.php:12
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33

◆ testWrongContentType()

Sabre\CalDAV\Schedule\FreeBusyRequestTest::testWrongContentType ( )

Definition at line 99 of file FreeBusyRequestTest.php.

99  {
100 
101  $this->server->httpRequest = new HTTP\Request(
102  'POST',
103  '/calendars/user1/outbox',
104  ['Content-Type' => 'text/plain']
105  );
106 
107  $this->assertNull(
108  $this->plugin->httpPost($this->server->httpRequest, $this->server->httpResponse)
109  );
110 
111  }

Field Documentation

◆ $aclPlugin

Sabre\CalDAV\Schedule\FreeBusyRequestTest::$aclPlugin
protected

Definition at line 15 of file FreeBusyRequestTest.php.

◆ $authPlugin

Sabre\CalDAV\Schedule\FreeBusyRequestTest::$authPlugin
protected

Definition at line 17 of file FreeBusyRequestTest.php.

◆ $caldavBackend

Sabre\CalDAV\Schedule\FreeBusyRequestTest::$caldavBackend
protected

Definition at line 18 of file FreeBusyRequestTest.php.

◆ $plugin

Sabre\CalDAV\Schedule\FreeBusyRequestTest::$plugin
protected

Definition at line 13 of file FreeBusyRequestTest.php.

◆ $request

Sabre\CalDAV\Schedule\FreeBusyRequestTest::$request
protected

◆ $server

Sabre\CalDAV\Schedule\FreeBusyRequestTest::$server
protected

Definition at line 14 of file FreeBusyRequestTest.php.


The documentation for this class was generated from the following file: