Issues (588)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/js/unit/factory/calendarFactorySpec.js (51 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
/**
2
 * Calendar App
3
 *
4
 * @author Georg Ehrke
5
 * @copyright 2016 Georg Ehrke <[email protected]>
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
9
 * License as published by the Free Software Foundation; either
10
 * version 3 of the License, or any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public
18
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
22
describe('CalendarFactory', function () {
23
	'use strict';
24
25
	let CalendarFactory;
0 ignored issues
show
Backwards Compatibility introduced by
'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
26
	let $window, DavClient, Calendar, WebCal, constants;
0 ignored issues
show
Backwards Compatibility introduced by
'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
27
	let davService;
0 ignored issues
show
Backwards Compatibility introduced by
'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
28
	let privateCalendarServiceAPI;
0 ignored issues
show
Backwards Compatibility introduced by
'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
29
30
	const calendar_default = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
31
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
32
 <d:response>
33
  <d:href>/remote.php/dav/calendars/admin/privat/</d:href>
34
  <d:propstat>
35
   <d:prop>
36
    <d:displayname>Privat</d:displayname>
37
    <d:resourcetype>
38
     <d:collection/>
39
     <cal:calendar/>
40
    </d:resourcetype>
41
    <cal:calendar-description/>
42
    <cal:calendar-timezone/>
43
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
44
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/">#78e774</x1:calendar-color>
45
    <cal:supported-calendar-component-set>
46
     <cal:comp name="VEVENT"/>
47
     <cal:comp name="VTODO"/>
48
    </cal:supported-calendar-component-set>
49
    <cs:allowed-sharing-modes>
50
     <cs:can-be-shared/>
51
     <cs:can-be-published/>
52
    </cs:allowed-sharing-modes>
53
    <oc:calendar-enabled>1</oc:calendar-enabled>
54
    <d:acl>
55
     <d:ace>
56
      <d:principal>
57
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
58
      </d:principal>
59
      <d:grant>
60
       <d:privilege>
61
        <d:read/>
62
       </d:privilege>
63
      </d:grant>
64
      <d:protected/>
65
     </d:ace>
66
     <d:ace>
67
      <d:principal>
68
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
69
      </d:principal>
70
      <d:grant>
71
       <d:privilege>
72
        <d:write/>
73
       </d:privilege>
74
      </d:grant>
75
      <d:protected/>
76
     </d:ace>
77
    </d:acl>
78
    <d:owner>
79
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
80
    </d:owner>
81
    <oc:invite/>
82
   </d:prop>
83
   <d:status>HTTP/1.1 200 OK</d:status>
84
  </d:propstat>
85
  <d:propstat>
86
   <d:prop>
87
    <cs:publish-url/>
88
    <cs:source/>
89
   </d:prop>
90
   <d:status>HTTP/1.1 404 Not Found</d:status>
91
  </d:propstat>
92
 </d:response>
93
</d:multistatus>`;
94
95
	const calendar_nocolor = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
96
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
97
 <d:response>
98
  <d:href>/remote.php/dav/calendars/admin/privat/</d:href>
99
  <d:propstat>
100
   <d:prop>
101
    <d:displayname>Privat</d:displayname>
102
    <d:resourcetype>
103
     <d:collection/>
104
     <cal:calendar/>
105
    </d:resourcetype>
106
    <cal:calendar-description/>
107
    <cal:calendar-timezone/>
108
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
109
    <cal:supported-calendar-component-set>
110
     <cal:comp name="VEVENT"/>
111
     <cal:comp name="VTODO"/>
112
    </cal:supported-calendar-component-set>
113
    <cs:allowed-sharing-modes>
114
     <cs:can-be-shared/>
115
     <cs:can-be-published/>
116
    </cs:allowed-sharing-modes>
117
    <oc:calendar-enabled>1</oc:calendar-enabled>
118
    <d:acl>
119
     <d:ace>
120
      <d:principal>
121
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
122
      </d:principal>
123
      <d:grant>
124
       <d:privilege>
125
        <d:read/>
126
       </d:privilege>
127
      </d:grant>
128
      <d:protected/>
129
     </d:ace>
130
     <d:ace>
131
      <d:principal>
132
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
133
      </d:principal>
134
      <d:grant>
135
       <d:privilege>
136
        <d:write/>
137
       </d:privilege>
138
      </d:grant>
139
      <d:protected/>
140
     </d:ace>
141
    </d:acl>
142
    <d:owner>
143
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
144
    </d:owner>
145
    <oc:invite/>
146
   </d:prop>
147
   <d:status>HTTP/1.1 200 OK</d:status>
148
  </d:propstat>
149
  <d:propstat>
150
   <d:prop>
151
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/"/>
152
    <cs:publish-url/>
153
    <cs:source/>
154
   </d:prop>
155
   <d:status>HTTP/1.1 404 Not Found</d:status>
156
  </d:propstat>
157
 </d:response>
158
</d:multistatus>`;
159
160
	const calendar_noenabled = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
161
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
162
 <d:response>
163
  <d:href>/remote.php/dav/calendars/admin/privat/</d:href>
164
  <d:propstat>
165
   <d:prop>
166
    <d:displayname>Privat</d:displayname>
167
    <d:resourcetype>
168
     <d:collection/>
169
     <cal:calendar/>
170
    </d:resourcetype>
171
    <cal:calendar-description/>
172
    <cal:calendar-timezone/>
173
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
174
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/">#78e774</x1:calendar-color>
175
    <cal:supported-calendar-component-set>
176
     <cal:comp name="VEVENT"/>
177
     <cal:comp name="VTODO"/>
178
    </cal:supported-calendar-component-set>
179
    <cs:allowed-sharing-modes>
180
     <cs:can-be-shared/>
181
     <cs:can-be-published/>
182
    </cs:allowed-sharing-modes>
183
    <d:acl>
184
     <d:ace>
185
      <d:principal>
186
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
187
      </d:principal>
188
      <d:grant>
189
       <d:privilege>
190
        <d:read/>
191
       </d:privilege>
192
      </d:grant>
193
      <d:protected/>
194
     </d:ace>
195
     <d:ace>
196
      <d:principal>
197
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
198
      </d:principal>
199
      <d:grant>
200
       <d:privilege>
201
        <d:write/>
202
       </d:privilege>
203
      </d:grant>
204
      <d:protected/>
205
     </d:ace>
206
    </d:acl>
207
    <d:owner>
208
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
209
    </d:owner>
210
    <oc:invite/>
211
   </d:prop>
212
   <d:status>HTTP/1.1 200 OK</d:status>
213
  </d:propstat>
214
  <d:propstat>
215
   <d:prop>
216
    <cs:publish-url/>
217
    <oc:calendar-enabled/>
218
    <cs:source/>
219
   </d:prop>
220
   <d:status>HTTP/1.1 404 Not Found</d:status>
221
  </d:propstat>
222
 </d:response>
223
</d:multistatus>`;
224
225
	const calendar_published = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
226
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
227
 <d:response>
228
  <d:href>/remote.php/dav/calendars/admin/privat/</d:href>
229
  <d:propstat>
230
   <d:prop>
231
    <d:displayname>Privat</d:displayname>
232
    <d:resourcetype>
233
     <d:collection/>
234
     <cal:calendar/>
235
    </d:resourcetype>
236
    <cal:calendar-description/>
237
    <cal:calendar-timezone/>
238
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
239
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/">#78e774</x1:calendar-color>
240
    <cal:supported-calendar-component-set>
241
     <cal:comp name="VEVENT"/>
242
     <cal:comp name="VTODO"/>
243
    </cal:supported-calendar-component-set>
244
    <cs:publish-url>
245
     <d:href>http://nextcloud.dev/remote.php/dav/public-calendars/NW1DRAC4J4UDCH4M</d:href>
246
    </cs:publish-url>
247
    <cs:allowed-sharing-modes>
248
     <cs:can-be-shared/>
249
     <cs:can-be-published/>
250
    </cs:allowed-sharing-modes>
251
    <oc:calendar-enabled>1</oc:calendar-enabled>
252
    <d:acl>
253
     <d:ace>
254
      <d:principal>
255
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
256
      </d:principal>
257
      <d:grant>
258
       <d:privilege>
259
        <d:read/>
260
       </d:privilege>
261
      </d:grant>
262
      <d:protected/>
263
     </d:ace>
264
     <d:ace>
265
      <d:principal>
266
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
267
      </d:principal>
268
      <d:grant>
269
       <d:privilege>
270
        <d:write/>
271
       </d:privilege>
272
      </d:grant>
273
      <d:protected/>
274
     </d:ace>
275
     <d:ace>
276
      <d:principal>
277
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
278
      </d:principal>
279
      <d:grant>
280
       <d:privilege>
281
        <d:read/>
282
       </d:privilege>
283
      </d:grant>
284
      <d:protected/>
285
     </d:ace>
286
     <d:ace>
287
      <d:principal>
288
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
289
      </d:principal>
290
      <d:grant>
291
       <d:privilege>
292
        <d:write/>
293
       </d:privilege>
294
      </d:grant>
295
      <d:protected/>
296
     </d:ace>
297
    </d:acl>
298
    <d:owner>
299
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
300
    </d:owner>
301
    <oc:invite>
302
     <oc:user>
303
      <d:href>principal:principals/users/admin</d:href>
304
      <oc:common-name>admin</oc:common-name>
305
      <oc:invite-accepted/>
306
      <oc:access>
307
       <oc:read-write/>
308
      </oc:access>
309
     </oc:user>
310
    </oc:invite>
311
   </d:prop>
312
   <d:status>HTTP/1.1 200 OK</d:status>
313
  </d:propstat>
314
  <d:propstat>
315
   <d:prop>
316
    <cs:source/>
317
   </d:prop>
318
   <d:status>HTTP/1.1 404 Not Found</d:status>
319
  </d:propstat>
320
 </d:response>
321
</d:multistatus>`;
322
323
	const calendar_shared = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
324
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
325
 <d:response>
326
  <d:href>/remote.php/dav/calendars/admin/privat/</d:href>
327
  <d:propstat>
328
   <d:prop>
329
    <d:displayname>Privat</d:displayname>
330
    <d:resourcetype>
331
     <d:collection/>
332
     <cal:calendar/>
333
    </d:resourcetype>
334
    <cal:calendar-description/>
335
    <cal:calendar-timezone/>
336
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
337
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/">#78e774</x1:calendar-color>
338
    <cal:supported-calendar-component-set>
339
     <cal:comp name="VEVENT"/>
340
     <cal:comp name="VTODO"/>
341
    </cal:supported-calendar-component-set>
342
    <cs:allowed-sharing-modes>
343
     <cs:can-be-shared/>
344
     <cs:can-be-published/>
345
    </cs:allowed-sharing-modes>
346
    <oc:calendar-enabled>1</oc:calendar-enabled>
347
    <d:acl>
348
     <d:ace>
349
      <d:principal>
350
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
351
      </d:principal>
352
      <d:grant>
353
       <d:privilege>
354
        <d:read/>
355
       </d:privilege>
356
      </d:grant>
357
      <d:protected/>
358
     </d:ace>
359
     <d:ace>
360
      <d:principal>
361
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
362
      </d:principal>
363
      <d:grant>
364
       <d:privilege>
365
        <d:write/>
366
       </d:privilege>
367
      </d:grant>
368
      <d:protected/>
369
     </d:ace>
370
     <d:ace>
371
      <d:principal>
372
       <d:href>/remote.php/dav/principals/groups/test/</d:href>
373
      </d:principal>
374
      <d:grant>
375
       <d:privilege>
376
        <d:read/>
377
       </d:privilege>
378
      </d:grant>
379
      <d:protected/>
380
     </d:ace>
381
     <d:ace>
382
      <d:principal>
383
       <d:href>/remote.php/dav/principals/groups/test/</d:href>
384
      </d:principal>
385
      <d:grant>
386
       <d:privilege>
387
        <d:write-properties/>
388
       </d:privilege>
389
      </d:grant>
390
      <d:protected/>
391
     </d:ace>
392
     <d:ace>
393
      <d:principal>
394
       <d:href>/remote.php/dav/principals/users/user1/</d:href>
395
      </d:principal>
396
      <d:grant>
397
       <d:privilege>
398
        <d:read/>
399
       </d:privilege>
400
      </d:grant>
401
      <d:protected/>
402
     </d:ace>
403
     <d:ace>
404
      <d:principal>
405
       <d:href>/remote.php/dav/principals/users/user1/</d:href>
406
      </d:principal>
407
      <d:grant>
408
       <d:privilege>
409
        <d:write-properties/>
410
       </d:privilege>
411
      </d:grant>
412
      <d:protected/>
413
     </d:ace>
414
     <d:ace>
415
      <d:principal>
416
       <d:href>/remote.php/dav/principals/users/user2/</d:href>
417
      </d:principal>
418
      <d:grant>
419
       <d:privilege>
420
        <d:read/>
421
       </d:privilege>
422
      </d:grant>
423
      <d:protected/>
424
     </d:ace>
425
     <d:ace>
426
      <d:principal>
427
       <d:href>/remote.php/dav/principals/users/user2/</d:href>
428
      </d:principal>
429
      <d:grant>
430
       <d:privilege>
431
        <d:write/>
432
       </d:privilege>
433
      </d:grant>
434
      <d:protected/>
435
     </d:ace>
436
    </d:acl>
437
    <d:owner>
438
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
439
    </d:owner>
440
    <oc:invite>
441
     <oc:user>
442
      <d:href>principal:principals/groups/test</d:href>
443
      <oc:invite-accepted/>
444
      <oc:access>
445
       <oc:read/>
446
      </oc:access>
447
     </oc:user>
448
     <oc:user>
449
      <d:href>principal:principals/users/user1</d:href>
450
      <oc:common-name>User 1</oc:common-name>
451
      <oc:invite-accepted/>
452
      <oc:access>
453
       <oc:read/>
454
      </oc:access>
455
     </oc:user>
456
     <oc:user>
457
      <d:href>principal:principals/users/user2</d:href>
458
      <oc:common-name>User 2</oc:common-name>
459
      <oc:invite-accepted/>
460
      <oc:access>
461
       <oc:read-write/>
462
      </oc:access>
463
     </oc:user>
464
    </oc:invite>
465
   </d:prop>
466
   <d:status>HTTP/1.1 200 OK</d:status>
467
  </d:propstat>
468
  <d:propstat>
469
   <d:prop>
470
    <cs:publish-url/>
471
    <cs:source/>
472
   </d:prop>
473
   <d:status>HTTP/1.1 404 Not Found</d:status>
474
  </d:propstat>
475
 </d:response>
476
</d:multistatus>`;
477
478
	const calendar_shared_owner_displayname = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
479
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
480
 <d:response>
481
  <d:href>/remote.php/dav/calendars/admin/privat/</d:href>
482
  <d:propstat>
483
   <d:prop>
484
    <d:displayname>Privat</d:displayname>
485
    <d:resourcetype>
486
     <d:collection/>
487
     <cal:calendar/>
488
    </d:resourcetype>
489
    <cal:calendar-description/>
490
    <cal:calendar-timezone/>
491
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
492
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/">#78e774</x1:calendar-color>
493
    <cal:supported-calendar-component-set>
494
     <cal:comp name="VEVENT"/>
495
     <cal:comp name="VTODO"/>
496
    </cal:supported-calendar-component-set>
497
    <cs:allowed-sharing-modes>
498
     <cs:can-be-shared/>
499
     <cs:can-be-published/>
500
    </cs:allowed-sharing-modes>
501
    <oc:calendar-enabled>1</oc:calendar-enabled>
502
    <d:acl>
503
     <d:ace>
504
      <d:principal>
505
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
506
      </d:principal>
507
      <d:grant>
508
       <d:privilege>
509
        <d:read/>
510
       </d:privilege>
511
      </d:grant>
512
      <d:protected/>
513
     </d:ace>
514
     <d:ace>
515
      <d:principal>
516
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
517
      </d:principal>
518
      <d:grant>
519
       <d:privilege>
520
        <d:write/>
521
       </d:privilege>
522
      </d:grant>
523
      <d:protected/>
524
     </d:ace>
525
     <d:ace>
526
      <d:principal>
527
       <d:href>/remote.php/dav/principals/groups/test/</d:href>
528
      </d:principal>
529
      <d:grant>
530
       <d:privilege>
531
        <d:read/>
532
       </d:privilege>
533
      </d:grant>
534
      <d:protected/>
535
     </d:ace>
536
     <d:ace>
537
      <d:principal>
538
       <d:href>/remote.php/dav/principals/groups/test/</d:href>
539
      </d:principal>
540
      <d:grant>
541
       <d:privilege>
542
        <d:write-properties/>
543
       </d:privilege>
544
      </d:grant>
545
      <d:protected/>
546
     </d:ace>
547
     <d:ace>
548
      <d:principal>
549
       <d:href>/remote.php/dav/principals/users/user1/</d:href>
550
      </d:principal>
551
      <d:grant>
552
       <d:privilege>
553
        <d:read/>
554
       </d:privilege>
555
      </d:grant>
556
      <d:protected/>
557
     </d:ace>
558
     <d:ace>
559
      <d:principal>
560
       <d:href>/remote.php/dav/principals/users/user1/</d:href>
561
      </d:principal>
562
      <d:grant>
563
       <d:privilege>
564
        <d:write-properties/>
565
       </d:privilege>
566
      </d:grant>
567
      <d:protected/>
568
     </d:ace>
569
     <d:ace>
570
      <d:principal>
571
       <d:href>/remote.php/dav/principals/users/user2/</d:href>
572
      </d:principal>
573
      <d:grant>
574
       <d:privilege>
575
        <d:read/>
576
       </d:privilege>
577
      </d:grant>
578
      <d:protected/>
579
     </d:ace>
580
     <d:ace>
581
      <d:principal>
582
       <d:href>/remote.php/dav/principals/users/user2/</d:href>
583
      </d:principal>
584
      <d:grant>
585
       <d:privilege>
586
        <d:write/>
587
       </d:privilege>
588
      </d:grant>
589
      <d:protected/>
590
     </d:ace>
591
    </d:acl>
592
    <d:owner>
593
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
594
    </d:owner>
595
    <nc:owner-displayname>Administrator</nc:owner-displayname>
596
    <oc:invite>
597
     <oc:user>
598
      <d:href>principal:principals/groups/test</d:href>
599
      <oc:invite-accepted/>
600
      <oc:access>
601
       <oc:read/>
602
      </oc:access>
603
     </oc:user>
604
     <oc:user>
605
      <d:href>principal:principals/users/user1</d:href>
606
      <oc:common-name>User 1</oc:common-name>
607
      <oc:invite-accepted/>
608
      <oc:access>
609
       <oc:read/>
610
      </oc:access>
611
     </oc:user>
612
     <oc:user>
613
      <d:href>principal:principals/users/user2</d:href>
614
      <oc:common-name>User 2</oc:common-name>
615
      <oc:invite-accepted/>
616
      <oc:access>
617
       <oc:read-write/>
618
      </oc:access>
619
     </oc:user>
620
    </oc:invite>
621
   </d:prop>
622
   <d:status>HTTP/1.1 200 OK</d:status>
623
  </d:propstat>
624
  <d:propstat>
625
   <d:prop>
626
    <cs:publish-url/>
627
    <cs:source/>
628
   </d:prop>
629
   <d:status>HTTP/1.1 404 Not Found</d:status>
630
  </d:propstat>
631
 </d:response>
632
</d:multistatus>`;
633
634
	const calendar_vevent_vjournal = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
635
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
636
 <d:response>
637
  <d:href>/remote.php/dav/calendars/admin/privat/</d:href>
638
  <d:propstat>
639
   <d:prop>
640
    <d:displayname>Privat</d:displayname>
641
    <d:resourcetype>
642
     <d:collection/>
643
     <cal:calendar/>
644
    </d:resourcetype>
645
    <cal:calendar-description/>
646
    <cal:calendar-timezone/>
647
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
648
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/">#78e774</x1:calendar-color>
649
    <cal:supported-calendar-component-set>
650
     <cal:comp name="VEVENT"/>
651
     <cal:comp name="VTODO"/>
652
     <cal:comp name="VJOURNAL"/>
653
    </cal:supported-calendar-component-set>
654
    <cs:allowed-sharing-modes>
655
     <cs:can-be-shared/>
656
     <cs:can-be-published/>
657
    </cs:allowed-sharing-modes>
658
    <oc:calendar-enabled>1</oc:calendar-enabled>
659
    <d:acl>
660
     <d:ace>
661
      <d:principal>
662
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
663
      </d:principal>
664
      <d:grant>
665
       <d:privilege>
666
        <d:read/>
667
       </d:privilege>
668
      </d:grant>
669
      <d:protected/>
670
     </d:ace>
671
     <d:ace>
672
      <d:principal>
673
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
674
      </d:principal>
675
      <d:grant>
676
       <d:privilege>
677
        <d:write/>
678
       </d:privilege>
679
      </d:grant>
680
      <d:protected/>
681
     </d:ace>
682
    </d:acl>
683
    <d:owner>
684
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
685
    </d:owner>
686
    <oc:invite/>
687
   </d:prop>
688
   <d:status>HTTP/1.1 200 OK</d:status>
689
  </d:propstat>
690
  <d:propstat>
691
   <d:prop>
692
    <cs:publish-url/>
693
    <cs:source/>
694
   </d:prop>
695
   <d:status>HTTP/1.1 404 Not Found</d:status>
696
  </d:propstat>
697
 </d:response>
698
</d:multistatus>`;
699
700
	const calendar_no_sharingmodes_fallback = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
701
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns">
702
 <d:response>
703
  <d:href>/remote.php/dav/calendars/admin/123/</d:href>
704
  <d:propstat>
705
   <d:prop>
706
    <d:displayname>123</d:displayname>
707
    <d:resourcetype>
708
     <d:collection/>
709
     <cal:calendar/>
710
    </d:resourcetype>
711
    <cal:calendar-description/>
712
    <cal:calendar-timezone/>
713
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
714
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/">#FF7A66</x1:calendar-color>
715
    <oc:calendar-enabled>1</oc:calendar-enabled>
716
    <cal:supported-calendar-component-set>
717
     <cal:comp name="VEVENT"/>
718
     <cal:comp name="VTODO"/>
719
    </cal:supported-calendar-component-set>
720
    <d:acl>
721
     <d:ace>
722
      <d:principal>
723
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
724
      </d:principal>
725
      <d:grant>
726
       <d:privilege>
727
        <d:read/>
728
       </d:privilege>
729
      </d:grant>
730
      <d:protected/>
731
     </d:ace>
732
     <d:ace>
733
      <d:principal>
734
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
735
      </d:principal>
736
      <d:grant>
737
       <d:privilege>
738
        <d:write/>
739
       </d:privilege>
740
      </d:grant>
741
      <d:protected/>
742
     </d:ace>
743
    </d:acl>
744
    <d:owner>
745
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
746
    </d:owner>
747
    <oc:invite/>
748
   </d:prop>
749
   <d:status>HTTP/1.1 200 OK</d:status>
750
  </d:propstat>
751
  <d:propstat>
752
   <d:prop>
753
    <cs:publish-url/>
754
    <cs:allowed-sharing-modes/>
755
    <cs:source/>
756
   </d:prop>
757
   <d:status>HTTP/1.1 404 Not Found</d:status>
758
  </d:propstat>
759
 </d:response>
760
</d:multistatus>`;
761
762
	const webcal_default = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
763
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
764
 <d:response>
765
  <d:href>/remote.php/dav/calendars/admin/some-webcal-abo/</d:href>
766
  <d:propstat>
767
   <d:prop>
768
    <d:displayname>http://some-fancy-webcal.com/foo.ics</d:displayname>
769
    <d:resourcetype>
770
     <d:collection/>
771
     <cs:subscribed/>
772
    </d:resourcetype>
773
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
774
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/">#e774b5</x1:calendar-color>
775
    <cal:supported-calendar-component-set>
776
     <cal:comp name="VTODO"/>
777
     <cal:comp name="VEVENT"/>
778
    </cal:supported-calendar-component-set>
779
    <oc:calendar-enabled>1</oc:calendar-enabled>
780
    <d:acl>
781
     <d:ace>
782
      <d:principal>
783
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
784
      </d:principal>
785
      <d:grant>
786
       <d:privilege>
787
        <d:read/>
788
       </d:privilege>
789
      </d:grant>
790
      <d:protected/>
791
     </d:ace>
792
     <d:ace>
793
      <d:principal>
794
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
795
      </d:principal>
796
      <d:grant>
797
       <d:privilege>
798
        <d:write/>
799
       </d:privilege>
800
      </d:grant>
801
      <d:protected/>
802
     </d:ace>
803
     <d:ace>
804
      <d:principal>
805
       <d:href>/remote.php/dav/principals/users/admin/calendar-proxy-write/</d:href>
806
      </d:principal>
807
      <d:grant>
808
       <d:privilege>
809
        <d:read/>
810
       </d:privilege>
811
      </d:grant>
812
      <d:protected/>
813
     </d:ace>
814
     <d:ace>
815
      <d:principal>
816
       <d:href>/remote.php/dav/principals/users/admin/calendar-proxy-write/</d:href>
817
      </d:principal>
818
      <d:grant>
819
       <d:privilege>
820
        <d:write/>
821
       </d:privilege>
822
      </d:grant>
823
      <d:protected/>
824
     </d:ace>
825
     <d:ace>
826
      <d:principal>
827
       <d:href>/remote.php/dav/principals/users/admin/calendar-proxy-read/</d:href>
828
      </d:principal>
829
      <d:grant>
830
       <d:privilege>
831
        <d:read/>
832
       </d:privilege>
833
      </d:grant>
834
      <d:protected/>
835
     </d:ace>
836
    </d:acl>
837
    <d:owner>
838
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
839
    </d:owner>
840
    <cs:source>
841
     <d:href>http://some-fancy-webcal.com/foo.ics</d:href>
842
    </cs:source>
843
   </d:prop>
844
   <d:status>HTTP/1.1 200 OK</d:status>
845
  </d:propstat>
846
  <d:propstat>
847
   <d:prop>
848
    <cal:calendar-description/>
849
    <cal:calendar-timezone/>
850
    <cs:publish-url/>
851
    <cs:allowed-sharing-modes/>
852
    <oc:invite/>
853
   </d:prop>
854
   <d:status>HTTP/1.1 404 Not Found</d:status>
855
  </d:propstat>
856
 </d:response>
857
</d:multistatus>`;
858
859
	const public_calendar = `<?xml version="1.0"?>
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
'template literal syntax' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
860
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.com/ns">
861
 <d:response>
862
  <d:href>/remote.php/dav/public-calendars/KCMY4V5JZ22ODGFW/</d:href>
863
  <d:propstat>
864
   <d:prop>
865
    <d:displayname>Personal (admin)</d:displayname>
866
    <d:resourcetype>
867
     <d:collection/>
868
     <cal:calendar/>
869
    </d:resourcetype>
870
    <cal:calendar-description/>
871
    <cal:calendar-timezone/>
872
    <x1:calendar-order xmlns:x1="http://apple.com/ns/ical/">0</x1:calendar-order>
873
    <x1:calendar-color xmlns:x1="http://apple.com/ns/ical/"/>
874
    <cal:supported-calendar-component-set>
875
     <cal:comp name="VEVENT"/>
876
     <cal:comp name="VTODO"/>
877
    </cal:supported-calendar-component-set>
878
    <cs:publish-url>
879
     <d:href>http://nextcloud.dev/remote.php/dav/public-calendars/KCMY4V5JZ22ODGFW</d:href>
880
    </cs:publish-url>
881
    <cs:allowed-sharing-modes>
882
     <cs:can-be-shared/>
883
     <cs:can-be-published/>
884
    </cs:allowed-sharing-modes>
885
    <d:acl>
886
     <d:ace>
887
      <d:principal>
888
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
889
      </d:principal>
890
      <d:grant>
891
       <d:privilege>
892
        <d:read/>
893
       </d:privilege>
894
      </d:grant>
895
      <d:protected/>
896
     </d:ace>
897
     <d:ace>
898
      <d:principal>
899
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
900
      </d:principal>
901
      <d:grant>
902
       <d:privilege>
903
        <d:write/>
904
       </d:privilege>
905
      </d:grant>
906
      <d:protected/>
907
     </d:ace>
908
     <d:ace>
909
      <d:principal>
910
       <d:href>/remote.php/dav/principals/system/public/</d:href>
911
      </d:principal>
912
      <d:grant>
913
       <d:privilege>
914
        <d:read/>
915
       </d:privilege>
916
      </d:grant>
917
      <d:protected/>
918
     </d:ace>
919
     <d:ace>
920
      <d:principal>
921
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
922
      </d:principal>
923
      <d:grant>
924
       <d:privilege>
925
        <d:read/>
926
       </d:privilege>
927
      </d:grant>
928
      <d:protected/>
929
     </d:ace>
930
     <d:ace>
931
      <d:principal>
932
       <d:href>/remote.php/dav/principals/users/admin/</d:href>
933
      </d:principal>
934
      <d:grant>
935
       <d:privilege>
936
        <d:write/>
937
       </d:privilege>
938
      </d:grant>
939
      <d:protected/>
940
     </d:ace>
941
    </d:acl>
942
    <d:owner>
943
     <d:href>/remote.php/dav/principals/users/admin/</d:href>
944
    </d:owner>
945
    <oc:invite>
946
     <oc:user>
947
      <d:href>principal:principals/users/admin</d:href>
948
      <oc:common-name>admin</oc:common-name>
949
      <oc:invite-accepted/>
950
      <oc:access>
951
       <oc:read-write/>
952
      </oc:access>
953
     </oc:user>
954
    </oc:invite>
955
   </d:prop>
956
   <d:status>HTTP/1.1 200 OK</d:status>
957
  </d:propstat>
958
  <d:propstat>
959
   <d:prop>
960
    <oc:calendar-enabled/>
961
    <cs:source/>
962
   </d:prop>
963
   <d:status>HTTP/1.1 404 Not Found</d:status>
964
  </d:propstat>
965
 </d:response>
966
</d:multistatus>`;
967
968
	beforeEach(function() {
969
		davService = new dav.Client({
970
			xmlNamespaces: {
971
				'DAV:': 'd',
972
				'urn:ietf:params:xml:ns:cal dav': 'c',
973
				'http://apple.com/ns/ical/': 'aapl',
974
				'http://owncloud.org/ns': 'oc',
975
				'http://nextcloud.com/ns': 'nc',
976
				'http://calendarserver.org/ns/': 'cs'
977
			}
978
		});
979
	});
980
981
	beforeEach(module('Calendar', function($provide) {
982
		$window = {};
983
984
		DavClient = {};
985
		DavClient.NS_DAV = 'DAV:';
986
		DavClient.NS_IETF = 'urn:ietf:params:xml:ns:caldav';
987
		DavClient.NS_APPLE = 'http://apple.com/ns/ical/';
988
		DavClient.NS_OWNCLOUD = 'http://owncloud.org/ns';
989
		DavClient.NS_NEXTCLOUD = 'http://nextcloud.com/ns';
990
		DavClient.NS_CALENDARSERVER = 'http://calendarserver.org/ns/';
991
		DavClient.getNodesFullName = jasmine.createSpy().and.callFake((node) => '{' + node.namespaceURI + '}' + node.localName);
0 ignored issues
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').

Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.

Further Reading:

Loading history...
992
993
		Calendar = jasmine.createSpy().and.callFake(function() {return Array.from(arguments);});
994
		WebCal = jasmine.createSpy().and.callFake(function() {return Array.from(arguments);});
995
996
		privateCalendarServiceAPI = {};
997
998
		constants = {
999
			fallbackColor: '#fefefe',
1000
			shareeCanEditCalendarProperties: true,
1001
			shareeCanEditShares: false
1002
		};
1003
1004
		$provide.value('$window', $window);
1005
		$provide.value('DavClient', DavClient);
1006
		$provide.value('Calendar', Calendar);
1007
		$provide.value('WebCal', WebCal);
1008
		$provide.value('constants', constants);
1009
	}));
1010
1011
	beforeEach(inject(function (_CalendarFactory_) {
1012
		CalendarFactory = _CalendarFactory_;
1013
	}));
1014
1015
	it('create a calendar object', function() {
1016
		const calendarProperties = davService.parseMultiStatus(calendar_default);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1017
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1018
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1019
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1020
			order: 0, writable: true, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: null,
1021
			shareable: true, publishable: true, published: false, publicToken: null,
1022
			writableProperties: true}]);
1023
	});
1024
1025
	it('create a webcal object', function() {
1026
		const webcalProperties = davService.parseMultiStatus(webcal_default);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1027
		const webcal = CalendarFactory.webcal(privateCalendarServiceAPI, webcalProperties[0], '/remote.php/dav/principals/users/admin/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1028
		expect(webcal).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/some-webcal-abo/', {
1029
			color: '#e774b5', displayname: 'http://some-fancy-webcal.com/foo.ics',
1030
			components: {vevent: true, vjournal: false, vtodo: true}, order: 0, writable: false, owner: 'admin',
1031
			enabled: true, shares: {users: [ ], groups: [  ]}, ownerDisplayname: null, shareable: false, publishable: false, published: false,
1032
			publicToken: null, writableProperties: true,
1033
			href: 'http://some-fancy-webcal.com/foo.ics'
1034
		}]);
1035
	});
1036
1037
	it('fallback to the instance color if no color is given', function() {
1038
		const calendarProperties = davService.parseMultiStatus(calendar_nocolor);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1039
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1040
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1041
			color: '#fefefe', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1042
			order: 0, writable: true, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: null,
1043
			shareable: true, publishable: true, published: false, publicToken: null,
1044
			writableProperties: true}]);
1045
	});
1046
1047
	it('enable the calendar when it\'s owned by the user and enabled is not set', function() {
1048
		const calendarProperties = davService.parseMultiStatus(calendar_noenabled);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1049
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1050
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1051
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1052
			order: 0, writable: true, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: null,
1053
			shareable: true, publishable: true, published: false, publicToken: null,
1054
			writableProperties: true}]);
1055
	});
1056
1057
	it('disable the calendar when it\'s not owned by the user and enabled is not set', function() {
1058
		const calendarProperties = davService.parseMultiStatus(calendar_noenabled);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1059
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/hans_dieter/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1060
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1061
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1062
			order: 0, writable: false, owner: 'admin', enabled: false, shares: {users: [], groups: []}, ownerDisplayname: null,
1063
			shareable: false, publishable: false, published: false, publicToken: null,
1064
			writableProperties: true}]);
1065
	});
1066
1067
	it('handle published calendars', function() {
1068
		$window.location = 'http://nextcloud.dev/index.php/apps/calendar/';
1069
1070
		const calendarProperties = davService.parseMultiStatus(calendar_published);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1071
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1072
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1073
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1074
			order: 0, writable: true, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: 'admin',
1075
			shareable: true, publishable: true, published: true, publicToken: 'NW1DRAC4J4UDCH4M',
1076
			writableProperties: true}]);
1077
	});
1078
1079
	it('handle published calendars when current url ends with #', function() {
1080
		$window.location = 'http://nextcloud.dev/index.php/apps/calendar/#';
1081
1082
		const calendarProperties = davService.parseMultiStatus(calendar_published);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1083
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1084
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1085
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1086
			order: 0, writable: true, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: 'admin',
1087
			shareable: true, publishable: true, published: true, publicToken: 'NW1DRAC4J4UDCH4M',
1088
			writableProperties: true}]);
1089
	});
1090
1091
	it('handle shared calendars for owner - 11 and below', function() {
1092
		const calendarProperties = davService.parseMultiStatus(calendar_shared);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1093
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1094
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1095
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1096
			order: 0, writable: true, owner: 'admin', enabled: true,
1097
			shares: {
1098
				users: [
1099
					{id: 'user1', displayname: 'User 1', writable: false},
1100
					{id: 'user2', displayname: 'User 2', writable: true}
1101
				],
1102
				groups: [
1103
					{id: 'test', displayname: 'test', writable: false}
1104
				]
1105
			}, ownerDisplayname: null, shareable: true, publishable: true, published: false, publicToken: null, writableProperties: true}
1106
		]);
1107
	});
1108
1109
	it('handle shared calendars for owner - 12+', function() {
1110
		const calendarProperties = davService.parseMultiStatus(calendar_shared_owner_displayname);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1111
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1112
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1113
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1114
			order: 0, writable: true, owner: 'admin', enabled: true,
1115
			shares: {
1116
				users: [
1117
					{id: 'user1', displayname: 'User 1', writable: false},
1118
					{id: 'user2', displayname: 'User 2', writable: true}
1119
				],
1120
				groups: [
1121
					{id: 'test', displayname: 'test', writable: false}
1122
				]
1123
			}, ownerDisplayname: 'Administrator', shareable: true, publishable: true, published: false, publicToken: null, writableProperties: true}
1124
		]);
1125
	});
1126
1127
	it('handle shared calendars for ro sharee - 12+', function() {
1128
		const calendarProperties = davService.parseMultiStatus(calendar_shared);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1129
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/user1/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1130
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1131
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1132
			order: 0, writable: false, owner: 'admin', enabled: true,
1133
			shares: {
1134
				users: [
1135
					{id: 'user1', displayname: 'User 1', writable: false},
1136
					{id: 'user2', displayname: 'User 2', writable: true}
1137
				],
1138
				groups: [
1139
					{id: 'test', displayname: 'test', writable: false}
1140
				]
1141
			}, ownerDisplayname: null, shareable: false, publishable: false, published: false, publicToken: null, writableProperties: true}
1142
		]);
1143
	});
1144
1145
	it('handle shared calendars for ro sharee - 11 and below', function() {
1146
		constants.shareeCanEditCalendarProperties = false;
1147
		constants.shareeCanEditShares = true;
1148
1149
		const calendarProperties = davService.parseMultiStatus(calendar_shared);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1150
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/user1/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1151
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1152
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1153
			order: 0, writable: false, owner: 'admin', enabled: true,
1154
			shares: {
1155
				users: [
1156
					{id: 'user1', displayname: 'User 1', writable: false},
1157
					{id: 'user2', displayname: 'User 2', writable: true}
1158
				],
1159
				groups: [
1160
					{id: 'test', displayname: 'test', writable: false}
1161
				]
1162
			}, ownerDisplayname: null, shareable: false, publishable: false, published: false, publicToken: null, writableProperties: false}
1163
		]);
1164
	});
1165
1166
	it('handle shared calendars for rw sharee - 12+', function() {
1167
		const calendarProperties = davService.parseMultiStatus(calendar_shared);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1168
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/user2/', false);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
1169
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1170
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1171
			order: 0, writable: true, owner: 'admin', enabled: true,
1172
			shares: {
1173
				users: [
1174
					{id: 'user1', displayname: 'User 1', writable: false},
1175
					{id: 'user2', displayname: 'User 2', writable: true}
1176
				],
1177
				groups: [
1178
					{id: 'test', displayname: 'test', writable: false}
1179
				]
1180
			}, ownerDisplayname: null, shareable: false, publishable: false, published: false, publicToken: null, writableProperties: true}
1181
		]);
1182
	});
1183
1184
	it('handle shared calendars for rw sharee - 11 and below', function() {
1185
		constants.shareeCanEditCalendarProperties = false;
1186
		constants.shareeCanEditShares = true;
1187
1188
		const calendarProperties = davService.parseMultiStatus(calendar_shared);
0 ignored issues
show
Backwards Compatibility introduced by
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
Loading history...
There were too many errors found in this file; checking aborted after 95%.

If JSHint finds too many errors in a file, it aborts checking altogether because it suspects a configuration issue.

Further Reading:

Loading history...
1189
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/user2/', false);
1190
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1191
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: false, vtodo: true},
1192
			order: 0, writable: true, owner: 'admin', enabled: true,
1193
			shares: {
1194
				users: [
1195
					{id: 'user1', displayname: 'User 1', writable: false},
1196
					{id: 'user2', displayname: 'User 2', writable: true}
1197
				],
1198
				groups: [
1199
					{id: 'test', displayname: 'test', writable: false}
1200
				]
1201
			}, ownerDisplayname: null, shareable: true, publishable: true, published: false, publicToken: null, writableProperties: false}
1202
		]);
1203
	});
1204
1205
	it('handle vjournal as a component', function() {
1206
		const calendarProperties = davService.parseMultiStatus(calendar_vevent_vjournal);
1207
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
1208
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/privat/', {
1209
			color: '#78e774', displayname: 'Privat', components: {vevent: true, vjournal: true, vtodo: true},
1210
			order: 0, writable: true, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: null,
1211
			shareable: true, publishable: true, published: false, publicToken: null,
1212
			writableProperties: true}]);
1213
	});
1214
1215
	it('correctly determine sharing options when sharing-modes is not available - owner', function() {
1216
		const calendarProperties = davService.parseMultiStatus(calendar_no_sharingmodes_fallback);
1217
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/admin/', false);
1218
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/123/', {
1219
			color: '#FF7A66', displayname: '123', components: {vevent: true, vjournal: false, vtodo: true},
1220
			order: 0, writable: true, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: null,
1221
			shareable: true, publishable: false, published: false, publicToken: null,
1222
			writableProperties: true}]);
1223
	});
1224
1225
	it('correctly determine sharing options when sharing-modes is not available - not owner', function() {
1226
		const calendarProperties = davService.parseMultiStatus(calendar_no_sharingmodes_fallback);
1227
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '/remote.php/dav/principals/users/foobar/', false);
1228
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/calendars/admin/123/', {
1229
			color: '#FF7A66', displayname: '123', components: {vevent: true, vjournal: false, vtodo: true},
1230
			order: 0, writable: false, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: null,
1231
			shareable: false, publishable: false, published: false, publicToken: null,
1232
			writableProperties: true}]);
1233
	});
1234
1235
	it('create a calendar object from a public calendar', function() {
1236
		$window.location = 'http://nextcloud.dev/index.php/apps/calendar/public/KCMY4V5JZ22ODGFW';
1237
1238
		const calendarProperties = davService.parseMultiStatus(public_calendar);
1239
		const calendar = CalendarFactory.calendar(privateCalendarServiceAPI, calendarProperties[0], '', true);
1240
		expect(calendar).toEqual([privateCalendarServiceAPI, '/remote.php/dav/public-calendars/KCMY4V5JZ22ODGFW/', {
1241
			color: '#fefefe', displayname: 'Personal (admin)', components: {vevent: true, vjournal: false, vtodo: true},
1242
			order: 0, writable: false, owner: 'admin', enabled: true, shares: {users: [], groups: []}, ownerDisplayname: 'admin', shareable: false,
1243
			publishable: false, published: true, publicToken: 'KCMY4V5JZ22ODGFW', writableProperties: false}
1244
		]);
1245
	});
1246
});
1247