@manyos/smileconnect-api 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/.github/workflows/nodejs.yml +26 -0
  2. package/CHANGELOG.md +75 -0
  3. package/Dockerfile +21 -0
  4. package/README.md +1 -0
  5. package/app.js +316 -0
  6. package/conf/clients.json +2491 -0
  7. package/conf/mapping.json +1048 -0
  8. package/conf/scripts/p1.js +11 -0
  9. package/conf/scripts/p2.js +1 -0
  10. package/conf/scripts/p3.js +1 -0
  11. package/conf/scripts/p4.js +2 -0
  12. package/conf/scripts/script1.js +2 -0
  13. package/conf/scripts/script2.js +2 -0
  14. package/conf/scripts/script3.js +2 -0
  15. package/controller/cmdbobjectController.js +291 -0
  16. package/controller/eventLogController.js +78 -0
  17. package/controller/orgdataController.js +440 -0
  18. package/controller/relatedObjectsController.js +194 -0
  19. package/controller/scriptController.js +213 -0
  20. package/controller/taskController.js +368 -0
  21. package/controller/templateController.js +97 -0
  22. package/controller/ticketCIRelationController.js +522 -0
  23. package/controller/ticketController.js +329 -0
  24. package/controller/ticketWorkLogController.js +195 -0
  25. package/docs/.gitattributes +48 -0
  26. package/docs/404.html +13 -0
  27. package/docs/CNAME +1 -0
  28. package/docs/Gemfile +7 -0
  29. package/docs/Gemfile.lock +249 -0
  30. package/docs/_config.yml +257 -0
  31. package/docs/_data/SocialNetworks.yml +92 -0
  32. package/docs/_data/ui-text.yml +494 -0
  33. package/docs/_includes/disqus.html +17 -0
  34. package/docs/_includes/ext-css.html +7 -0
  35. package/docs/_includes/ext-js.html +7 -0
  36. package/docs/_includes/fb-comment.html +14 -0
  37. package/docs/_includes/footer-minimal.html +16 -0
  38. package/docs/_includes/footer-scripts.html +32 -0
  39. package/docs/_includes/footer.html +51 -0
  40. package/docs/_includes/google_analytics.html +14 -0
  41. package/docs/_includes/gtag.html +11 -0
  42. package/docs/_includes/gtm_body.html +6 -0
  43. package/docs/_includes/gtm_head.html +9 -0
  44. package/docs/_includes/head.html +131 -0
  45. package/docs/_includes/header.html +76 -0
  46. package/docs/_includes/just_comments.html +4 -0
  47. package/docs/_includes/matomo.html +17 -0
  48. package/docs/_includes/nav.html +57 -0
  49. package/docs/_includes/social-share.html +42 -0
  50. package/docs/_includes/staticman-comment.html +22 -0
  51. package/docs/_includes/staticman-comments.html +81 -0
  52. package/docs/_layouts/base.html +35 -0
  53. package/docs/_layouts/default.html +9 -0
  54. package/docs/_layouts/minimal.html +26 -0
  55. package/docs/_layouts/page.html +26 -0
  56. package/docs/_layouts/post.html +82 -0
  57. package/docs/_posts/2015-02-28-test-markdown.md +77 -0
  58. package/docs/aboutme.md +18 -0
  59. package/docs/css/bootstrap-social.css +147 -0
  60. package/docs/css/bootstrap-theme.css +476 -0
  61. package/docs/css/bootstrap-theme.css.map +1 -0
  62. package/docs/css/bootstrap-theme.min.css +5 -0
  63. package/docs/css/bootstrap.css +6566 -0
  64. package/docs/css/bootstrap.css.map +1 -0
  65. package/docs/css/bootstrap.min.css +5 -0
  66. package/docs/css/main-minimal.css +13 -0
  67. package/docs/css/main.css +788 -0
  68. package/docs/css/normalize.css +427 -0
  69. package/docs/css/pygment_highlights.css +61 -0
  70. package/docs/css/staticman.css +180 -0
  71. package/docs/eventlog/events.md +65 -0
  72. package/docs/feed.xml +24 -0
  73. package/docs/general/architecture.md +10 -0
  74. package/docs/general/config.md +192 -0
  75. package/docs/general/field-management.md +119 -0
  76. package/docs/general/release-notes.md +9 -0
  77. package/docs/getting-started.md +19 -0
  78. package/docs/howto/cmdbobjects.md +339 -0
  79. package/docs/howto/incident-worklogs.md +186 -0
  80. package/docs/howto/incidents.md +244 -0
  81. package/docs/howto/sample-config.md +518 -0
  82. package/docs/howto/token.md +71 -0
  83. package/docs/howto/worklog-attachment.md +113 -0
  84. package/docs/img/404-southpark.jpg +0 -0
  85. package/docs/img/architecture.jpeg +0 -0
  86. package/docs/img/attachment-upload.png +0 -0
  87. package/docs/img/avatar-icon.png +0 -0
  88. package/docs/img/bgimage.png +0 -0
  89. package/docs/img/gb-isapi.jpg +0 -0
  90. package/docs/img/install-steps.gif +0 -0
  91. package/docs/img/workflow.png +0 -0
  92. package/docs/index.md +41 -0
  93. package/docs/installation.md +123 -0
  94. package/docs/js/bootstrap.js +2306 -0
  95. package/docs/js/bootstrap.min.js +7 -0
  96. package/docs/js/jquery-1.11.2.min.js +4 -0
  97. package/docs/js/main.js +140 -0
  98. package/docs/js/staticman.js +54 -0
  99. package/docs/openapi.json +15097 -0
  100. package/docs/postinstall.md +169 -0
  101. package/docs/preinstall.md +19 -0
  102. package/docs/spec/index.html +24 -0
  103. package/docs/staticman.yml +110 -0
  104. package/docs/tags.html +34 -0
  105. package/docs/workflow.md +127 -0
  106. package/nodemon.json +3 -0
  107. package/package.json +46 -0
  108. package/routes/appConfigRoutes.js +352 -0
  109. package/routes/ciRelationRoutes.js +38 -0
  110. package/routes/cmdbObjectRoutes.js +154 -0
  111. package/routes/organisationRoutes.js +121 -0
  112. package/routes/peopleRelationRoutes.js +38 -0
  113. package/routes/personRoutes.js +131 -0
  114. package/routes/supportgroupRoutes.js +122 -0
  115. package/routes/taskRoutes.js +306 -0
  116. package/routes/templateRoutes.js +67 -0
  117. package/routes/ticketRoutes.js +181 -0
  118. package/routes/ticketWorkLogRoutes.js +185 -0
  119. package/screwdriver.yaml +52 -0
  120. package/test/appTest.js +3 -0
  121. package/test/changeTest.js +541 -0
  122. package/test/cmdbobjectTest.js +167 -0
  123. package/test/files/logo.png +0 -0
  124. package/test/incidentTest.js +539 -0
  125. package/test/orgdataTest.js +156 -0
  126. package/test/problemTest.js +512 -0
  127. package/test/templateTest.js +80 -0
  128. package/test/testUtils.js +21 -0
  129. package/test/workorderTest.js +544 -0
  130. package/util/arquery.js +416 -0
  131. package/util/auth.js +37 -0
  132. package/util/cache.service.js +52 -0
  133. package/util/config.js +361 -0
  134. package/util/constants.js +73 -0
  135. package/util/mappingUtil.js +96 -0
  136. package/util/paramHelper.js +43 -0
  137. package/util/relationUtil.js +63 -0
  138. package/util/responsehandler.js +92 -0
  139. package/util/schemas/clientConfigSchema.js +180 -0
  140. package/util/schemas/fieldMappingSchema.js +211 -0
  141. package/util/searchUtil.js +148 -0
@@ -0,0 +1,539 @@
1
+ const assert = require('chai').assert;
2
+ let chai = require('chai');
3
+ let chaiHttp = require('chai-http');
4
+ let should = chai.should();
5
+ let server = require('../app');
6
+ const TestUtils = require('./testUtils')
7
+ require('dotenv').config();
8
+
9
+ //Integrations Tests here
10
+
11
+ chai.use(chaiHttp);
12
+
13
+ describe('Integration Tests - Incidents', function () {
14
+ let incident;
15
+
16
+ let authUser = {'id':process.env.TEST_ID, 'secret':process.env.TEST_SECRET};
17
+
18
+ before((done) => {
19
+
20
+ // Authenticate the user to get a token
21
+ TestUtils.authenticateUser(authUser, server)
22
+ .then((accessToken) => {
23
+ // Keep the token on the user so we can use it in the tests
24
+ authUser.access_token = accessToken;
25
+ return done();
26
+ })
27
+ .catch((err) => done(err));
28
+ });
29
+
30
+ describe('Basic Incident Operations', function () {
31
+ it ('it should create a spezific incident', function (done) {
32
+ this.timeout(5000);
33
+ chai.request(server)
34
+ .post('/v1/incidents')
35
+ .set('Authorization', 'Bearer ' + authUser.access_token)
36
+ .send({"data":{"summary":"hurst"}})
37
+ .end(function(err, res) {
38
+ res.should.have.status(200);
39
+ res.body.data.should.be.an('object');
40
+ res.body.data.should.have.property('summary');
41
+ res.body.data.should.have.property('id');
42
+ res.body.data.should.have.property('status');
43
+ incident = res.body.data;
44
+ done();
45
+ })
46
+ })
47
+
48
+ it ('it should get all incidents', function (done) {
49
+ this.timeout(5000);
50
+ chai.request(server)
51
+ .get('/v1/incidents')
52
+ .set('Authorization', 'Bearer ' + authUser.access_token)
53
+ .end(function(err, res) {
54
+ res.should.have.status(200);
55
+ res.body.data.should.be.a('array');
56
+ res.body.data.length.should.be.above(0);
57
+ done();
58
+ })
59
+ })
60
+
61
+ it ('it should get a spezific incident by id', function (done) {
62
+ this.timeout(5000);
63
+ chai.request(server)
64
+ .get(`/v1/incidents/${incident.id}`)
65
+ .set('Authorization', 'Bearer ' + authUser.access_token)
66
+ .end(function(err, res) {
67
+ res.should.have.status(200);
68
+ res.body.data.should.be.an('object');
69
+ res.body.data.should.have.property('summary');
70
+ res.body.data.should.have.property('id');
71
+ res.body.data.should.have.property('status');
72
+ res.body.data.summary.should.equal(incident.summary);
73
+ done();
74
+ })
75
+ })
76
+
77
+ it ('it should search for an incident with included objects', function (done) {
78
+ this.timeout(50000);
79
+ chai.request(server)
80
+ .post('/v1/incidents/search?includeObjects=true')
81
+ .set('Authorization', 'Bearer ' + authUser.access_token)
82
+ .send({
83
+ "searchString":`'id'=\"${incident.id}\"`
84
+ })
85
+ .end(function(err, res) {
86
+ res.should.have.status(200);
87
+ res.body.data.should.be.an('array');
88
+ res.body.data.length.should.be.above(0);
89
+
90
+ done();
91
+ })
92
+ })
93
+
94
+ it ('it should resolve a spezific incident by id', function (done) {
95
+ this.timeout(5000);
96
+ chai.request(server)
97
+ .put(`/v1/incidents/${incident.id}`)
98
+ .set('Authorization', 'Bearer ' + authUser.access_token)
99
+ .send({"data":{"status":"Resolved", "statusReason": "No Further Action Required", "resolution" :"Dieses Ticket wurde im Test geschlossen."}})
100
+ .end(function(err, res) {
101
+ res.should.have.status(200);
102
+ res.body.data.should.be.an('object');
103
+ res.body.data.should.have.property('summary');
104
+ res.body.data.should.have.property('id');
105
+ res.body.data.should.have.property('status');
106
+ res.body.data.status.should.equal("Resolved");
107
+ done();
108
+ })
109
+ })
110
+
111
+ it ('it should link a specific CI to the incident', function (done) {
112
+ this.timeout(50000);
113
+ chai.request(server)
114
+ .put(`/v1/incidents/${incident.id}?include=ciRelations`)
115
+ .set('Authorization', 'Bearer ' + authUser.access_token)
116
+ .send(
117
+ {
118
+ "data": {
119
+ "relations": {
120
+ "ciRelations":
121
+ [{
122
+ "ciId":"OI-a2c843b3e3d14eeaa74dcefd4fdcf808",
123
+ "relationType":"Restores"
124
+ }]
125
+ }
126
+ }
127
+ })
128
+ .end(function(err, res) {
129
+ res.should.have.status(200);
130
+ res.body.data.should.be.an('object');
131
+ res.body.data.should.have.property('summary');
132
+ res.body.data.should.have.property('id');
133
+ res.body.data.should.have.property('status');
134
+ res.body.data.status.should.equal("Resolved");
135
+ res.body.data.should.have.property('relations');
136
+ res.body.data.relations.should.have.property('ciRelations');
137
+ res.body.data.relations.ciRelations.should.be.an('array');
138
+ res.body.data.relations.ciRelations.length.should.be.above(0);
139
+ done();
140
+ })
141
+ })
142
+
143
+ it ('it should link a wrong CI to the incident', function (done) {
144
+ this.timeout(50000);
145
+ chai.request(server)
146
+ .put(`/v1/incidents/${incident.id}?include=ciRelations`)
147
+ .set('Authorization', 'Bearer ' + authUser.access_token)
148
+ .send(
149
+ {
150
+ "data": {
151
+ "relations": {
152
+ "ciRelations":
153
+ [{
154
+ "ciId":"AGGarserver000PMIYWAPL1SMUB5AZxxx",
155
+ "relationType":"Restores"
156
+ }]
157
+ }
158
+ }
159
+ })
160
+ .end(function(err, res) {
161
+ res.should.have.status(500);
162
+ done();
163
+ })
164
+ })
165
+
166
+ it ('it should use a wrong relation type', function (done) {
167
+ this.timeout(50000);
168
+ chai.request(server)
169
+ .put(`/v1/incidents/${incident.id}?include=ciRelations`)
170
+ .set('Authorization', 'Bearer ' + authUser.access_token)
171
+ .send(
172
+ {
173
+ "data": {
174
+ "relations": {
175
+ "ciRelations":
176
+ [{
177
+ "ciId":"AGGarserver000PMIYWAPL1SMUB5AZ",
178
+ "relationType":"RestoresX"
179
+ }]
180
+ }
181
+ }
182
+ })
183
+ .end(function(err, res) {
184
+ res.should.have.status(500);
185
+ done();
186
+ })
187
+ })
188
+
189
+ it ('it should link to a specific incident', function (done) {
190
+ this.timeout(50000);
191
+ chai.request(server)
192
+ .put(`/v1/incidents/${incident.id}?include=ticketRelations`)
193
+ .set('Authorization', 'Bearer ' + authUser.access_token)
194
+ .send(
195
+ {
196
+ "data": {
197
+ "relations": {
198
+ "ticketRelations":
199
+ [{
200
+ "ticketId":"INC000000000335",
201
+ "relationType":"Related to",
202
+ "ticketType": "Incident"
203
+ }]
204
+ }
205
+ }
206
+ })
207
+ .end(function(err, res) {
208
+ res.should.have.status(200);
209
+ res.body.data.should.be.an('object');
210
+ res.body.data.should.have.property('summary');
211
+ res.body.data.should.have.property('id');
212
+ res.body.data.should.have.property('status');
213
+ res.body.data.status.should.equal("Resolved");
214
+ res.body.data.should.have.property('relations');
215
+ res.body.data.relations.should.have.property('ticketRelations');
216
+ res.body.data.relations.ticketRelations.should.be.an('array');
217
+ res.body.data.relations.ticketRelations.length.should.be.above(0);
218
+ done();
219
+ })
220
+ })
221
+
222
+ })
223
+
224
+ describe('Incident Worklogs', function () {
225
+ let worklog;
226
+ let attachmentUrl;
227
+ let attachmentUrl2;
228
+ let attachmentUrl3;
229
+ //const worklogBaseUri = `/v1/incidents/${incident.id}/worklogs`;
230
+
231
+ it('it should create a spezific incident worklog', function (done) {
232
+ this.timeout(5000);
233
+ chai.request(server)
234
+ .post(`/v1/incidents/${incident.id}/worklogs`)
235
+ .set('Authorization', 'Bearer ' + authUser.access_token)
236
+ .send({data: {summary: "Worklog Summary", text: "Worklog Text"}})
237
+ .end(function (err, res) {
238
+ res.should.have.status(200);
239
+ res.body.data.should.be.an('object');
240
+ res.body.data.should.have.property('summary');
241
+ res.body.data.should.have.property('text');
242
+ res.body.data.should.have.property('id');
243
+ worklog = res.body.data;
244
+ res.body.urls.should.be.an('object');
245
+
246
+ res.body.urls.should.have.property('attachmentUrl');
247
+ res.body.urls.should.have.property('self');
248
+
249
+ //res.body.urls.should.have.property('attachmentUrl');
250
+ //res.body.urls.should.have.property('self');
251
+ done();
252
+ })
253
+ })
254
+
255
+ it('it should read a spezific incident worklog', function (done) {
256
+ this.timeout(5000);
257
+ chai.request(server)
258
+ .get(`/v1/incidents/${incident.id}/worklogs/${worklog.id}`)
259
+ .set('Authorization', 'Bearer ' + authUser.access_token)
260
+ .end(function (err, res) {
261
+ res.should.have.status(200);
262
+ res.body.data.should.be.an('object');
263
+ res.body.data.should.have.property('summary');
264
+ res.body.data.should.have.property('text');
265
+ res.body.data.should.have.property('id');
266
+
267
+ res.body.data.summary.should.equal(worklog.summary);
268
+ res.body.data.text.should.equal(worklog.text);
269
+
270
+ res.body.urls.should.be.an('object');
271
+
272
+ res.body.urls.should.have.property('attachmentUrl');
273
+ res.body.urls.should.have.property('self');
274
+
275
+ attachmentUrl = res.body.urls.attachmentUrl;
276
+ attachmentUrl2 = res.body.urls.attachmentUrl2;
277
+ attachmentUrl3 = res.body.urls.attachmentUrl3;
278
+ console.log('attach', attachmentUrl);
279
+
280
+ /*res.body.urls.should.have.members([
281
+ {"attachmentUrl":`/v1/incidents/${incident.id}/worklogs/${worklog.id}/attachment`},
282
+ {"self":`/v1/incidents/${incident.id}/worklogs/${worklog.id}`}]);*/
283
+ done();
284
+ })
285
+ })
286
+
287
+ it('it should add an attachment to a worklog', function (done) {
288
+ this.timeout(5000);
289
+ chai.request(server)
290
+ .post(attachmentUrl)
291
+ .attach('file', 'test/files/logo.png', 'logo.png')
292
+ .set('Authorization', 'Bearer ' + authUser.access_token)
293
+ .end(function (err, res) {
294
+ res.should.have.status(200);
295
+ done();
296
+ })
297
+ })
298
+
299
+ it('it should add a 2nd attachment to a worklog', function (done) {
300
+ this.timeout(5000);
301
+ chai.request(server)
302
+ .post(attachmentUrl2)
303
+ .attach('file', 'test/files/logo.png', 'logo.png')
304
+ .set('Authorization', 'Bearer ' + authUser.access_token)
305
+ .end(function (err, res) {
306
+ res.should.have.status(200);
307
+ done();
308
+ })
309
+ })
310
+
311
+ it('it should add a 3rd attachment to a worklog', function (done) {
312
+ this.timeout(5000);
313
+ chai.request(server)
314
+ .post(attachmentUrl3)
315
+ .attach('file', 'test/files/logo.png', 'logo.png')
316
+ .set('Authorization', 'Bearer ' + authUser.access_token)
317
+ .end(function (err, res) {
318
+ res.should.have.status(200);
319
+ done();
320
+ })
321
+ })
322
+
323
+ it('it should read an attachment from a worklog', function (done) {
324
+ this.timeout(5000);
325
+ chai.request(server)
326
+ .get(attachmentUrl)
327
+ .set('Authorization', 'Bearer ' + authUser.access_token)
328
+ .end(function (err, res) {
329
+ res.should.have.status(200);
330
+ res.should.have.header('content-type', 'application/octet-stream');
331
+ res.should.have.header('content-disposition', 'attachment; filename=logo.png');
332
+ console.log(res.headers);
333
+ done();
334
+ })
335
+ })
336
+
337
+ it('it should read the 2nd attachment from a worklog', function (done) {
338
+ this.timeout(5000);
339
+ chai.request(server)
340
+ .get(attachmentUrl2)
341
+ .set('Authorization', 'Bearer ' + authUser.access_token)
342
+ .end(function (err, res) {
343
+ res.should.have.status(200);
344
+ res.should.have.header('content-type', 'application/octet-stream');
345
+ res.should.have.header('content-disposition', 'attachment; filename=logo.png');
346
+ console.log(res.headers);
347
+ done();
348
+ })
349
+ })
350
+
351
+ it('it should read the 3rd attachment from a worklog', function (done) {
352
+ this.timeout(5000);
353
+ chai.request(server)
354
+ .get(attachmentUrl3)
355
+ .set('Authorization', 'Bearer ' + authUser.access_token)
356
+ .end(function (err, res) {
357
+ res.should.have.status(200);
358
+ res.should.have.header('content-type', 'application/octet-stream');
359
+ res.should.have.header('content-disposition', 'attachment; filename=logo.png');
360
+ console.log(res.headers);
361
+ done();
362
+ })
363
+ })
364
+
365
+
366
+ it ('it should get all incident worklogs', function (done) {
367
+ this.timeout(5000);
368
+ chai.request(server)
369
+ .get(`/v1/incidents/${incident.id}/worklogs`)
370
+ .set('Authorization', 'Bearer ' + authUser.access_token)
371
+ .end(function(err, res) {
372
+ res.should.have.status(200);
373
+ res.body.data.should.be.a('array');
374
+ res.body.data.length.should.be.above(0);
375
+ done();
376
+ })
377
+ })
378
+
379
+ })
380
+
381
+ describe('Incident Tasks', function () {
382
+ let task;
383
+ it ('it should create a spezific incident task', function (done) {
384
+ this.timeout(5000);
385
+ chai.request(server)
386
+ .post(`/v1/incidents/${incident.id}/tasks`)
387
+ .set('Authorization', 'Bearer ' + authUser.access_token)
388
+ .send({"data":{"summary":"task1"}})
389
+ .end(function(err, res) {
390
+ res.should.have.status(200);
391
+ res.body.data.should.be.an('object');
392
+ res.body.data.should.have.property('summary');
393
+ res.body.data.should.have.property('notes');
394
+ res.body.data.should.have.property('id');
395
+ task = res.body.data;
396
+ done();
397
+ })
398
+ })
399
+
400
+ it ('it should create a multiple incident tasks at once', function (done) {
401
+ this.timeout(5000);
402
+ chai.request(server)
403
+ .post(`/v1/incidents/${incident.id}/tasks`)
404
+ .set('Authorization', 'Bearer ' + authUser.access_token)
405
+ .send({
406
+ "data": [
407
+ {"summary":"task2"},
408
+ {"summary":"task3"}
409
+ ]
410
+ })
411
+ .end(function(err, res) {
412
+ res.should.have.status(200);
413
+ res.body.data.should.be.an('array');
414
+ res.body.data.length.should.be.eq(2);
415
+ done();
416
+ })
417
+ })
418
+
419
+ it ('it should create a single incident tasks as array', function (done) {
420
+ this.timeout(5000);
421
+ chai.request(server)
422
+ .post(`/v1/incidents/${incident.id}/tasks`)
423
+ .set('Authorization', 'Bearer ' + authUser.access_token)
424
+ .send({
425
+ "data": [
426
+ {"summary":"task2"}
427
+ ]
428
+ })
429
+ .end(function(err, res) {
430
+ res.should.have.status(200);
431
+ res.body.data.should.be.an('array');
432
+ res.body.data.length.should.be.eq(1);
433
+ done();
434
+ })
435
+ })
436
+
437
+ it ('it should get all incident tasks', function (done) {
438
+ this.timeout(5000);
439
+ chai.request(server)
440
+ .get(`/v1/incidents/${incident.id}/tasks`)
441
+ .set('Authorization', 'Bearer ' + authUser.access_token)
442
+ .end(function(err, res) {
443
+ res.should.have.status(200);
444
+ res.body.data.should.be.a('array');
445
+ res.body.data.length.should.be.eq(4);
446
+ done();
447
+ })
448
+ })
449
+
450
+ it ('it should get a specific incident task', function (done) {
451
+ this.timeout(5000);
452
+ chai.request(server)
453
+ .get(`/v1/incidents/${incident.id}/tasks/${task.id}`)
454
+ .set('Authorization', 'Bearer ' + authUser.access_token)
455
+ .end(function(err, res) {
456
+ res.should.have.status(200);
457
+ res.body.data.should.be.an('object');
458
+ res.body.data.should.have.property('summary');
459
+ res.body.data.should.have.property('notes');
460
+ res.body.data.should.have.property('id');
461
+ res.body.data.summary.should.equal(task.summary);
462
+ done();
463
+ })
464
+ })
465
+
466
+ it ('it should update a specific incident task', function (done) {
467
+ this.timeout(5000);
468
+ chai.request(server)
469
+ .put(`/v1/incidents/${incident.id}/tasks/${task.id}`)
470
+ .set('Authorization', 'Bearer ' + authUser.access_token)
471
+ .send({"data":{"summary":"Task1.1"}})
472
+ .end(function(err, res) {
473
+ res.should.have.status(200);
474
+ res.body.data.should.be.an('object');
475
+ res.body.data.should.have.property('summary');
476
+ res.body.data.should.have.property('notes');
477
+ res.body.data.should.have.property('id');
478
+ res.body.data.summary.should.equal("Task1.1");
479
+ done();
480
+ })
481
+ })
482
+
483
+ describe('Incident Task Worklogs', function () {
484
+ let taskWorklog;
485
+ //const worklogBaseUri = `/v1/incidents/${incident.id}/worklogs`;
486
+
487
+ it('it should create a spezific incident task worklog', function (done) {
488
+ this.timeout(5000);
489
+ chai.request(server)
490
+ .post(`/v1/incidents/${incident.id}/tasks/${task.id}/worklogs`)
491
+ .set('Authorization', 'Bearer ' + authUser.access_token)
492
+ .send({data: {summary: "Worklog Summary", text: "Worklog Text"}})
493
+ .end(function (err, res) {
494
+ res.should.have.status(200);
495
+ res.body.data.should.be.an('object');
496
+ res.body.data.should.have.property('summary');
497
+ res.body.data.should.have.property('text');
498
+ res.body.data.should.have.property('id');
499
+ taskWorklog = res.body.data;
500
+ done();
501
+ })
502
+ })
503
+
504
+ it('it should read a spezific incident task worklog', function (done) {
505
+ this.timeout(5000);
506
+ chai.request(server)
507
+ .get(`/v1/incidents/${incident.id}/tasks/${task.id}/worklogs/${taskWorklog.id}`)
508
+ .set('Authorization', 'Bearer ' + authUser.access_token)
509
+ .end(function (err, res) {
510
+ res.should.have.status(200);
511
+ res.body.data.should.be.an('object');
512
+ res.body.data.should.have.property('summary');
513
+ res.body.data.should.have.property('text');
514
+ res.body.data.should.have.property('id');
515
+
516
+ res.body.data.summary.should.equal(taskWorklog.summary);
517
+ res.body.data.text.should.equal(taskWorklog.text);
518
+
519
+ res.body.urls.should.have.nested.property('attachmentUrl');
520
+ done();
521
+ })
522
+ })
523
+
524
+ it ('it should get all incident task worklogs', function (done) {
525
+ this.timeout(5000);
526
+ chai.request(server)
527
+ .get(`/v1/incidents/${incident.id}/tasks/${task.id}/worklogs`)
528
+ .set('Authorization', 'Bearer ' + authUser.access_token)
529
+ .end(function(err, res) {
530
+ res.should.have.status(200);
531
+ res.body.data.should.be.a('array');
532
+ res.body.data.length.should.be.above(0);
533
+ done();
534
+ })
535
+ })
536
+ })
537
+ })
538
+
539
+ })