@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.
- package/.github/workflows/nodejs.yml +26 -0
- package/CHANGELOG.md +75 -0
- package/Dockerfile +21 -0
- package/README.md +1 -0
- package/app.js +316 -0
- package/conf/clients.json +2491 -0
- package/conf/mapping.json +1048 -0
- package/conf/scripts/p1.js +11 -0
- package/conf/scripts/p2.js +1 -0
- package/conf/scripts/p3.js +1 -0
- package/conf/scripts/p4.js +2 -0
- package/conf/scripts/script1.js +2 -0
- package/conf/scripts/script2.js +2 -0
- package/conf/scripts/script3.js +2 -0
- package/controller/cmdbobjectController.js +291 -0
- package/controller/eventLogController.js +78 -0
- package/controller/orgdataController.js +440 -0
- package/controller/relatedObjectsController.js +194 -0
- package/controller/scriptController.js +213 -0
- package/controller/taskController.js +368 -0
- package/controller/templateController.js +97 -0
- package/controller/ticketCIRelationController.js +522 -0
- package/controller/ticketController.js +329 -0
- package/controller/ticketWorkLogController.js +195 -0
- package/docs/.gitattributes +48 -0
- package/docs/404.html +13 -0
- package/docs/CNAME +1 -0
- package/docs/Gemfile +7 -0
- package/docs/Gemfile.lock +249 -0
- package/docs/_config.yml +257 -0
- package/docs/_data/SocialNetworks.yml +92 -0
- package/docs/_data/ui-text.yml +494 -0
- package/docs/_includes/disqus.html +17 -0
- package/docs/_includes/ext-css.html +7 -0
- package/docs/_includes/ext-js.html +7 -0
- package/docs/_includes/fb-comment.html +14 -0
- package/docs/_includes/footer-minimal.html +16 -0
- package/docs/_includes/footer-scripts.html +32 -0
- package/docs/_includes/footer.html +51 -0
- package/docs/_includes/google_analytics.html +14 -0
- package/docs/_includes/gtag.html +11 -0
- package/docs/_includes/gtm_body.html +6 -0
- package/docs/_includes/gtm_head.html +9 -0
- package/docs/_includes/head.html +131 -0
- package/docs/_includes/header.html +76 -0
- package/docs/_includes/just_comments.html +4 -0
- package/docs/_includes/matomo.html +17 -0
- package/docs/_includes/nav.html +57 -0
- package/docs/_includes/social-share.html +42 -0
- package/docs/_includes/staticman-comment.html +22 -0
- package/docs/_includes/staticman-comments.html +81 -0
- package/docs/_layouts/base.html +35 -0
- package/docs/_layouts/default.html +9 -0
- package/docs/_layouts/minimal.html +26 -0
- package/docs/_layouts/page.html +26 -0
- package/docs/_layouts/post.html +82 -0
- package/docs/_posts/2015-02-28-test-markdown.md +77 -0
- package/docs/aboutme.md +18 -0
- package/docs/css/bootstrap-social.css +147 -0
- package/docs/css/bootstrap-theme.css +476 -0
- package/docs/css/bootstrap-theme.css.map +1 -0
- package/docs/css/bootstrap-theme.min.css +5 -0
- package/docs/css/bootstrap.css +6566 -0
- package/docs/css/bootstrap.css.map +1 -0
- package/docs/css/bootstrap.min.css +5 -0
- package/docs/css/main-minimal.css +13 -0
- package/docs/css/main.css +788 -0
- package/docs/css/normalize.css +427 -0
- package/docs/css/pygment_highlights.css +61 -0
- package/docs/css/staticman.css +180 -0
- package/docs/eventlog/events.md +65 -0
- package/docs/feed.xml +24 -0
- package/docs/general/architecture.md +10 -0
- package/docs/general/config.md +192 -0
- package/docs/general/field-management.md +119 -0
- package/docs/general/release-notes.md +9 -0
- package/docs/getting-started.md +19 -0
- package/docs/howto/cmdbobjects.md +339 -0
- package/docs/howto/incident-worklogs.md +186 -0
- package/docs/howto/incidents.md +244 -0
- package/docs/howto/sample-config.md +518 -0
- package/docs/howto/token.md +71 -0
- package/docs/howto/worklog-attachment.md +113 -0
- package/docs/img/404-southpark.jpg +0 -0
- package/docs/img/architecture.jpeg +0 -0
- package/docs/img/attachment-upload.png +0 -0
- package/docs/img/avatar-icon.png +0 -0
- package/docs/img/bgimage.png +0 -0
- package/docs/img/gb-isapi.jpg +0 -0
- package/docs/img/install-steps.gif +0 -0
- package/docs/img/workflow.png +0 -0
- package/docs/index.md +41 -0
- package/docs/installation.md +123 -0
- package/docs/js/bootstrap.js +2306 -0
- package/docs/js/bootstrap.min.js +7 -0
- package/docs/js/jquery-1.11.2.min.js +4 -0
- package/docs/js/main.js +140 -0
- package/docs/js/staticman.js +54 -0
- package/docs/openapi.json +15097 -0
- package/docs/postinstall.md +169 -0
- package/docs/preinstall.md +19 -0
- package/docs/spec/index.html +24 -0
- package/docs/staticman.yml +110 -0
- package/docs/tags.html +34 -0
- package/docs/workflow.md +127 -0
- package/nodemon.json +3 -0
- package/package.json +46 -0
- package/routes/appConfigRoutes.js +352 -0
- package/routes/ciRelationRoutes.js +38 -0
- package/routes/cmdbObjectRoutes.js +154 -0
- package/routes/organisationRoutes.js +121 -0
- package/routes/peopleRelationRoutes.js +38 -0
- package/routes/personRoutes.js +131 -0
- package/routes/supportgroupRoutes.js +122 -0
- package/routes/taskRoutes.js +306 -0
- package/routes/templateRoutes.js +67 -0
- package/routes/ticketRoutes.js +181 -0
- package/routes/ticketWorkLogRoutes.js +185 -0
- package/screwdriver.yaml +52 -0
- package/test/appTest.js +3 -0
- package/test/changeTest.js +541 -0
- package/test/cmdbobjectTest.js +167 -0
- package/test/files/logo.png +0 -0
- package/test/incidentTest.js +539 -0
- package/test/orgdataTest.js +156 -0
- package/test/problemTest.js +512 -0
- package/test/templateTest.js +80 -0
- package/test/testUtils.js +21 -0
- package/test/workorderTest.js +544 -0
- package/util/arquery.js +416 -0
- package/util/auth.js +37 -0
- package/util/cache.service.js +52 -0
- package/util/config.js +361 -0
- package/util/constants.js +73 -0
- package/util/mappingUtil.js +96 -0
- package/util/paramHelper.js +43 -0
- package/util/relationUtil.js +63 -0
- package/util/responsehandler.js +92 -0
- package/util/schemas/clientConfigSchema.js +180 -0
- package/util/schemas/fieldMappingSchema.js +211 -0
- 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
|
+
})
|