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