@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,541 @@
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
+ const path = require('path');
9
+ const log = require('@manyos/logger').setupLog('SMILEconnect_' + path.basename(__filename));
10
+
11
+ //Integrations Tests here
12
+
13
+ chai.use(chaiHttp);
14
+
15
+ describe('Integration Tests - Change', function () {
16
+ let change;
17
+
18
+ let authUser = {'id':process.env.TEST_ID, 'secret':process.env.TEST_SECRET};
19
+
20
+ console.log('authuser', authUser);
21
+
22
+ before((done) => {
23
+
24
+ // Authenticate the user to get a token
25
+ TestUtils.authenticateUser(authUser, server)
26
+ .then((accessToken) => {
27
+ // Keep the token on the user so we can use it in the tests
28
+ authUser.access_token = accessToken;
29
+ return done();
30
+ })
31
+ .catch((err) => done(err));
32
+ });
33
+
34
+ describe('POST Changes', function () {
35
+ it ('it should create a spezific change', function (done) {
36
+ this.timeout(15000);
37
+ chai.request(server)
38
+ .post('/v1/changes')
39
+ .set('Authorization', 'Bearer ' + authUser.access_token)
40
+ .send({"data":{"summary":"hurst", "template":"sfddd", "horstbox":"leer", "relatedCIs":["asdad"]}})
41
+ .end(function(err, res) {
42
+ res.should.have.status(200);
43
+ res.body.data.should.be.an('object');
44
+ res.body.data.should.have.property('summary');
45
+ res.body.data.should.have.property('id');
46
+ res.body.data.should.have.property('status');
47
+ change = res.body.data;
48
+ done();
49
+ })
50
+ })
51
+ })
52
+
53
+ describe('GET Changes', function () {
54
+ it ('it should get all changes', function (done) {
55
+ this.timeout(5000);
56
+ chai.request(server)
57
+ .get('/v1/changes')
58
+ .set('Authorization', 'Bearer ' + authUser.access_token)
59
+ .end(function(err, res) {
60
+ res.should.have.status(200);
61
+ res.body.data.should.be.a('array');
62
+ res.body.data.length.should.be.above(0);
63
+ done();
64
+ })
65
+ })
66
+
67
+ it ('it should get a spezific change by id', function (done) {
68
+ this.timeout(5000);
69
+ chai.request(server)
70
+ .get(`/v1/changes/${change.id}`)
71
+ .set('Authorization', 'Bearer ' + authUser.access_token)
72
+ .end(function(err, res) {
73
+ res.should.have.status(200);
74
+ res.body.data.should.be.an('object');
75
+ res.body.data.should.have.property('summary');
76
+ res.body.data.should.have.property('id');
77
+ res.body.data.should.have.property('status');
78
+ done();
79
+ })
80
+ })
81
+
82
+ it ('it should get a spezific change by id and included objects', function (done) {
83
+ this.timeout(5000);
84
+ chai.request(server)
85
+ .get(`/v1/changes/${change.id}?includeObjects=true`)
86
+ .set('Authorization', 'Bearer ' + authUser.access_token)
87
+ .end(function(err, res) {
88
+ res.should.have.status(200);
89
+ res.body.data.should.be.an('object');
90
+ res.body.data.should.have.property('summary');
91
+ res.body.data.should.have.property('id');
92
+ res.body.data.should.have.property('status');
93
+
94
+ res.body.included.should.be.an('object');
95
+ res.body.included.should.have.property('persons');
96
+ res.body.included.persons.should.be.an('array');
97
+ //res.body.included.persons.length.should.be.above(0);
98
+
99
+ res.body.included.should.have.property('organisations');
100
+ res.body.included.organisations.should.be.an('array');
101
+ //res.body.included.organisations.length.should.be.above(0);
102
+
103
+ res.body.included.should.have.property('supportgroups');
104
+ res.body.included.supportgroups.should.be.an('array');
105
+ //res.body.included.supportgroups.length.should.be.above(0);
106
+ done();
107
+ })
108
+ })
109
+
110
+ it ('it should get a spezific change by id and include', function (done) {
111
+ this.timeout(5000);
112
+ chai.request(server)
113
+ .get(`/v1/changes/${change.id}?includeObjects=true`)
114
+ .set('Authorization', 'Bearer ' + authUser.access_token)
115
+ .end(function(err, res) {
116
+ res.should.have.status(200);
117
+ res.body.data.should.be.an('object');
118
+ res.body.data.should.have.property('summary');
119
+ res.body.data.should.have.property('id');
120
+ res.body.data.should.have.property('status');
121
+
122
+ res.body.included.should.be.an('object');
123
+ res.body.included.should.have.property('persons');
124
+ res.body.included.persons.should.be.an('array');
125
+ //res.body.included.persons.length.should.be.above(0);
126
+
127
+ res.body.included.should.have.property('organisations');
128
+ res.body.included.organisations.should.be.an('array');
129
+ //res.body.included.organisations.length.should.be.above(0);
130
+
131
+ res.body.included.should.have.property('supportgroups');
132
+ res.body.included.supportgroups.should.be.an('array');
133
+ //res.body.included.supportgroups.length.should.be.above(0);
134
+ done();
135
+ })
136
+ })
137
+
138
+ it ('it should search for a change with included objects', function (done) {
139
+ this.timeout(50000);
140
+ chai.request(server)
141
+ .post('/v1/changes/search?includeObjects=true')
142
+ .set('Authorization', 'Bearer ' + authUser.access_token)
143
+ .send({
144
+ "searchString":`'id'=\"${change.id}\"`
145
+ })
146
+ .end(function(err, res) {
147
+ res.should.have.status(200);
148
+ res.body.data.should.be.an('array');
149
+ res.body.data.length.should.be.above(0);
150
+
151
+ done();
152
+ })
153
+ })
154
+ })
155
+
156
+ describe ('Change Update', function () {
157
+ it ('it should update a spezific change by id', function (done) {
158
+ this.timeout(5000);
159
+ chai.request(server)
160
+ .put(`/v1/changes/${change.id}`)
161
+ .set('Authorization', 'Bearer ' + authUser.access_token)
162
+ .send({"data":{"summary":"Updated", "status":"Request For Authorization", "scheduledStartDate":new Date(), "scheduledEndDate":new Date(new Date().getTime()+3600000)}})
163
+ .end(function(err, res) {
164
+ res.should.have.status(200);
165
+ res.body.data.should.be.an('object');
166
+ res.body.data.should.have.property('summary');
167
+ res.body.data.should.have.property('id');
168
+ res.body.data.should.have.property('status');
169
+ res.body.data.summary.should.equal("Updated");
170
+ done();
171
+ })
172
+ })
173
+ })
174
+
175
+
176
+ describe ('Change Relations', function() {
177
+ it ('it should link a specific CI to the change', function (done) {
178
+ this.timeout(50000);
179
+ chai.request(server)
180
+ .put(`/v1/changes/${change.id}?include=ciRelations`)
181
+ .set('Authorization', 'Bearer ' + authUser.access_token)
182
+ .send(
183
+ {
184
+ "data": {
185
+ "relations": {
186
+ "ciRelations":
187
+ [{
188
+ "ciId":"OI-a2c843b3e3d14eeaa74dcefd4fdcf808",
189
+ "relationType":"Changes"
190
+ },
191
+ {
192
+ "ciId":"OI-94001f3f08b7415685fe72ec17f98f84",
193
+ "relationType":"Related to"
194
+ }]
195
+ }
196
+ }
197
+ })
198
+ .end(function(err, res) {
199
+ res.should.have.status(200);
200
+ res.body.data.should.be.an('object');
201
+ res.body.data.should.have.property('summary');
202
+ res.body.data.should.have.property('id');
203
+ res.body.data.should.have.property('status');
204
+ res.body.data.should.have.property('relations');
205
+ res.body.data.relations.should.have.property('ciRelations');
206
+ res.body.data.relations.ciRelations.should.be.an('array');
207
+ res.body.data.relations.ciRelations.length.should.be.above(0);
208
+ done();
209
+ })
210
+ })
211
+
212
+ it ('it should link a wrong CI to the change', function (done) {
213
+ this.timeout(50000);
214
+ chai.request(server)
215
+ .put(`/v1/changes/${change.id}?include=ciRelations`)
216
+ .set('Authorization', 'Bearer ' + authUser.access_token)
217
+ .send(
218
+ {
219
+ "data": {
220
+ "relations": {
221
+ "ciRelations":
222
+ [{
223
+ "ciId":"AGGarserver000PMIYWAPL1SMUB5AZxxx",
224
+ "relationType":"Changes"
225
+ }]
226
+ }
227
+ }
228
+ })
229
+ .end(function(err, res) {
230
+ res.should.have.status(500);
231
+ done();
232
+ })
233
+ })
234
+
235
+ it ('it should use a wrong relation type', function (done) {
236
+ this.timeout(50000);
237
+ chai.request(server)
238
+ .put(`/v1/changes/${change.id}?include=ciRelations`)
239
+ .set('Authorization', 'Bearer ' + authUser.access_token)
240
+ .send(
241
+ {
242
+ "data": {
243
+ "relations": {
244
+ "ciRelations":
245
+ [{
246
+ "ciId":"AGGarserver000PMIYWAPL1SMUB5AZ",
247
+ "relationType":"RestoresX"
248
+ }]
249
+ }
250
+ }
251
+ })
252
+ .end(function(err, res) {
253
+ res.should.have.status(500);
254
+ done();
255
+ })
256
+ })
257
+
258
+ it ('it should link to a specific incident', function (done) {
259
+ this.timeout(50000);
260
+ chai.request(server)
261
+ .put(`/v1/changes/${change.id}?include=ticketRelations`)
262
+ .set('Authorization', 'Bearer ' + authUser.access_token)
263
+ .send(
264
+ {
265
+ "data": {
266
+ "relations": {
267
+ "ticketRelations":
268
+ [{
269
+ "ticketId":"INC000000000335",
270
+ "relationType":"Related to",
271
+ "ticketType": "Incident"
272
+ }]
273
+ }
274
+ }
275
+ })
276
+ .end(function(err, res) {
277
+ res.should.have.status(200);
278
+ res.body.data.should.be.an('object');
279
+ res.body.data.should.have.property('summary');
280
+ res.body.data.should.have.property('id');
281
+ res.body.data.should.have.property('status');
282
+ res.body.data.should.have.property('relations');
283
+ res.body.data.relations.should.have.property('ticketRelations');
284
+ res.body.data.relations.ticketRelations.should.be.an('array');
285
+ res.body.data.relations.ticketRelations.length.should.be.above(0);
286
+ done();
287
+ })
288
+ })
289
+
290
+ })
291
+
292
+ describe('Change Worklogs', function () {
293
+ let worklog;
294
+
295
+ let attachmentUrl;
296
+ //const worklogBaseUri = `/v1/incidents/${incident.id}/worklogs`;
297
+
298
+ it('it should create a spezific change worklog', function (done) {
299
+ this.timeout(5000);
300
+ chai.request(server)
301
+ .post(`/v1/changes/${change.id}/worklogs`)
302
+ .set('Authorization', 'Bearer ' + authUser.access_token)
303
+ .send({data: {summary: "Worklog Summary", text: "Worklog Text"}})
304
+ .end(function (err, res) {
305
+ console.log(res.body.data);
306
+ res.should.have.status(200);
307
+ res.body.data.should.be.an('object');
308
+ res.body.data.should.have.property('summary');
309
+ res.body.data.should.have.property('text');
310
+ res.body.data.should.have.property('id');
311
+ worklog = res.body.data;
312
+ res.body.urls.should.be.an('object');
313
+
314
+ res.body.urls.should.have.property('attachmentUrl');
315
+ res.body.urls.should.have.property('self');
316
+ done();
317
+ })
318
+ })
319
+
320
+ it('it should read a spezific change worklog', function (done) {
321
+ this.timeout(5000);
322
+ chai.request(server)
323
+ .get(`/v1/changes/${change.id}/worklogs/${worklog.id}`)
324
+ .set('Authorization', 'Bearer ' + authUser.access_token)
325
+ .end(function (err, res) {
326
+ res.should.have.status(200);
327
+ res.body.data.should.be.an('object');
328
+ res.body.data.should.have.property('summary');
329
+ res.body.data.should.have.property('text');
330
+ res.body.data.should.have.property('id');
331
+
332
+ res.body.data.summary.should.equal(worklog.summary);
333
+ res.body.data.text.should.equal(worklog.text);
334
+
335
+ res.body.urls.should.be.an('object');
336
+
337
+ res.body.urls.should.have.property('attachmentUrl');
338
+ res.body.urls.should.have.property('self');
339
+ attachmentUrl = res.body.urls.attachmentUrl;
340
+ done();
341
+ })
342
+ })
343
+
344
+ it('it should add an attachment to a worklog', function (done) {
345
+ this.timeout(5000);
346
+ chai.request(server)
347
+ .post(attachmentUrl)
348
+ .attach('file', 'test/files/logo.png', 'logo.png')
349
+ .set('Authorization', 'Bearer ' + authUser.access_token)
350
+ .end(function (err, res) {
351
+ res.should.have.status(200);
352
+ done();
353
+ })
354
+ })
355
+
356
+ it('it should read an attachment from a worklog', function (done) {
357
+ this.timeout(5000);
358
+ chai.request(server)
359
+ .get(attachmentUrl)
360
+ .set('Authorization', 'Bearer ' + authUser.access_token)
361
+ .end(function (err, res) {
362
+ res.should.have.status(200);
363
+ res.should.have.header('content-type', 'application/octet-stream');
364
+ res.should.have.header('content-disposition', 'attachment; filename=logo.png');
365
+ console.log(res.headers);
366
+ done();
367
+ })
368
+ })
369
+
370
+ it ('it should get all change worklogs', function (done) {
371
+ this.timeout(5000);
372
+ chai.request(server)
373
+ .get(`/v1/changes/${change.id}/worklogs`)
374
+ .set('Authorization', 'Bearer ' + authUser.access_token)
375
+ .end(function(err, res) {
376
+ res.should.have.status(200);
377
+ res.body.data.should.be.a('array');
378
+ res.body.data.length.should.be.above(0);
379
+ done();
380
+ })
381
+ })
382
+ })
383
+
384
+ describe('Tasks', function () {
385
+ let task;
386
+ it ('it should create a spezific task', function (done) {
387
+ this.timeout(5000);
388
+ chai.request(server)
389
+ .post(`/v1/changes/${change.id}/tasks`)
390
+ .set('Authorization', 'Bearer ' + authUser.access_token)
391
+ .send({"data":{"summary":"task1"}})
392
+ .end(function(err, res) {
393
+ res.should.have.status(200);
394
+ res.body.data.should.be.an('object');
395
+ res.body.data.should.have.property('summary');
396
+ res.body.data.should.have.property('notes');
397
+ res.body.data.should.have.property('id');
398
+ task = res.body.data;
399
+ done();
400
+ })
401
+ })
402
+
403
+ it ('it should create a multiple tasks at once', function (done) {
404
+ this.timeout(5000);
405
+ chai.request(server)
406
+ .post(`/v1/changes/${change.id}/tasks`)
407
+ .set('Authorization', 'Bearer ' + authUser.access_token)
408
+ .send({
409
+ "data": [
410
+ {"summary":"task2"},
411
+ {"summary":"task3"}
412
+ ]
413
+ })
414
+ .end(function(err, res) {
415
+ res.should.have.status(200);
416
+ res.body.data.should.be.an('array');
417
+ res.body.data.length.should.be.eq(2);
418
+ done();
419
+ })
420
+ })
421
+
422
+ it ('it should create a single tasks as array', function (done) {
423
+ this.timeout(5000);
424
+ chai.request(server)
425
+ .post(`/v1/changes/${change.id}/tasks`)
426
+ .set('Authorization', 'Bearer ' + authUser.access_token)
427
+ .send({
428
+ "data": [
429
+ {"summary":"task2"}
430
+ ]
431
+ })
432
+ .end(function(err, res) {
433
+ res.should.have.status(200);
434
+ res.body.data.should.be.an('array');
435
+ res.body.data.length.should.be.eq(1);
436
+ done();
437
+ })
438
+ })
439
+
440
+ it ('it should get all tasks', function (done) {
441
+ this.timeout(5000);
442
+ chai.request(server)
443
+ .get(`/v1/changes/${change.id}/tasks`)
444
+ .set('Authorization', 'Bearer ' + authUser.access_token)
445
+ .end(function(err, res) {
446
+ res.should.have.status(200);
447
+ res.body.data.should.be.a('array');
448
+ res.body.data.length.should.be.eq(4);
449
+ done();
450
+ })
451
+ })
452
+
453
+ it ('it should get a specific task', function (done) {
454
+ this.timeout(5000);
455
+ chai.request(server)
456
+ .get(`/v1/changes/${change.id}/tasks/${task.id}`)
457
+ .set('Authorization', 'Bearer ' + authUser.access_token)
458
+ .end(function(err, res) {
459
+ res.should.have.status(200);
460
+ res.body.data.should.be.an('object');
461
+ res.body.data.should.have.property('summary');
462
+ res.body.data.should.have.property('notes');
463
+ res.body.data.should.have.property('id');
464
+ res.body.data.summary.should.equal(task.summary);
465
+ done();
466
+ })
467
+ })
468
+
469
+ it ('it should update a specific task', function (done) {
470
+ this.timeout(5000);
471
+ chai.request(server)
472
+ .put(`/v1/changes/${change.id}/tasks/${task.id}`)
473
+ .set('Authorization', 'Bearer ' + authUser.access_token)
474
+ .send({"data":{"summary":"Task1.1"}})
475
+ .end(function(err, res) {
476
+ res.should.have.status(200);
477
+ res.body.data.should.be.an('object');
478
+ res.body.data.should.have.property('summary');
479
+ res.body.data.should.have.property('notes');
480
+ res.body.data.should.have.property('id');
481
+ res.body.data.summary.should.equal("Task1.1");
482
+ done();
483
+ })
484
+ })
485
+
486
+ describe('Task Worklogs', function () {
487
+ let taskWorklog;
488
+ //const worklogBaseUri = `/v1/incidents/${incident.id}/worklogs`;
489
+
490
+ it('it should create a spezific task worklog', function (done) {
491
+ this.timeout(5000);
492
+ chai.request(server)
493
+ .post(`/v1/changes/${change.id}/tasks/${task.id}/worklogs`)
494
+ .set('Authorization', 'Bearer ' + authUser.access_token)
495
+ .send({data: {summary: "Worklog Summary", text: "Worklog Text"}})
496
+ .end(function (err, res) {
497
+ res.should.have.status(200);
498
+ res.body.data.should.be.an('object');
499
+ res.body.data.should.have.property('summary');
500
+ res.body.data.should.have.property('text');
501
+ res.body.data.should.have.property('id');
502
+ taskWorklog = res.body.data;
503
+ done();
504
+ })
505
+ })
506
+
507
+ it('it should read a spezific task worklog', function (done) {
508
+ this.timeout(5000);
509
+ chai.request(server)
510
+ .get(`/v1/changes/${change.id}/tasks/${task.id}/worklogs/${taskWorklog.id}`)
511
+ .set('Authorization', 'Bearer ' + authUser.access_token)
512
+ .end(function (err, res) {
513
+ res.should.have.status(200);
514
+ res.body.data.should.be.an('object');
515
+ res.body.data.should.have.property('summary');
516
+ res.body.data.should.have.property('text');
517
+ res.body.data.should.have.property('id');
518
+
519
+ res.body.data.summary.should.equal(taskWorklog.summary);
520
+ res.body.data.text.should.equal(taskWorklog.text);
521
+
522
+ res.body.urls.should.have.nested.property('attachmentUrl');
523
+ done();
524
+ })
525
+ })
526
+
527
+ it ('it should get all task worklogs', function (done) {
528
+ this.timeout(5000);
529
+ chai.request(server)
530
+ .get(`/v1/changes/${change.id}/tasks/${task.id}/worklogs`)
531
+ .set('Authorization', 'Bearer ' + authUser.access_token)
532
+ .end(function(err, res) {
533
+ res.should.have.status(200);
534
+ res.body.data.should.be.a('array');
535
+ res.body.data.length.should.be.above(0);
536
+ done();
537
+ })
538
+ })
539
+ })
540
+ })
541
+ })