@reportportal/client-javascript 5.0.5 → 5.0.6
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/CHANGELOG.md +6 -0
- package/README.md +3 -0
- package/VERSION +1 -1
- package/analytics/analytics.js +7 -7
- package/analytics/constants.js +1 -1
- package/analytics/events.js +7 -7
- package/lib/constants/events.js +7 -7
- package/lib/constants/statuses.js +8 -8
- package/lib/helpers.js +61 -61
- package/lib/publicReportingAPI.js +28 -28
- package/lib/report-portal-client.js +486 -481
- package/lib/rest.js +82 -81
- package/package.json +17 -12
- package/.eslintrc +0 -17
- package/.istanbul.yml +0 -3
- package/spec/analytics.spec.js +0 -46
- package/spec/helper.spec.js +0 -142
- package/spec/publicReportingAPI.spec.js +0 -75
- package/spec/report-portal-client.spec.js +0 -744
- package/spec/rest.spec.js +0 -315
- package/spec/support/jasmine.json +0 -11
- package/version_fragment +0 -1
package/spec/rest.spec.js
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
const nock = require('nock');
|
|
2
|
-
const isEqual = require('lodash/isEqual');
|
|
3
|
-
const http = require('http');
|
|
4
|
-
const RestClient = require('../lib/rest');
|
|
5
|
-
|
|
6
|
-
describe('RestClient', () => {
|
|
7
|
-
const options = {
|
|
8
|
-
baseURL: 'http://report-portal-host:8080/api/v1',
|
|
9
|
-
headers: {
|
|
10
|
-
Authorization: 'bearer 00000000-0000-0000-0000-000000000000',
|
|
11
|
-
'User-Agent': 'NodeJS',
|
|
12
|
-
},
|
|
13
|
-
restClientConfig: {
|
|
14
|
-
agent: {
|
|
15
|
-
rejectUnauthorized: false,
|
|
16
|
-
},
|
|
17
|
-
timeout: 0,
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
const noOptions = {};
|
|
21
|
-
const restClient = new RestClient(options);
|
|
22
|
-
|
|
23
|
-
const unathorizedError = {
|
|
24
|
-
error: 'unauthorized',
|
|
25
|
-
error_description: 'Full authentication is required to access this resource',
|
|
26
|
-
};
|
|
27
|
-
const unauthorizedErrorMessage = 'Request failed with status code 403: '
|
|
28
|
-
+ '{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}';
|
|
29
|
-
const netErrConnectionResetError = { code: 'ECONNABORTED', message: 'connection reset' };
|
|
30
|
-
|
|
31
|
-
describe('constructor', () => {
|
|
32
|
-
it('creates object with correct properties', () => {
|
|
33
|
-
expect(restClient.baseURL).toBe(options.baseURL);
|
|
34
|
-
expect(restClient.headers).toEqual(options.headers);
|
|
35
|
-
expect(restClient.restClientConfig).toEqual(options.restClientConfig);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('buildPath', () => {
|
|
40
|
-
it('compose path basing on base', () => {
|
|
41
|
-
expect(restClient.buildPath('users')).toBe(`${options.baseURL}/users`);
|
|
42
|
-
expect(restClient.buildPath('users/123')).toBe(`${options.baseURL}/users/123`);
|
|
43
|
-
expect(restClient.buildPath()).toBe(`${options.baseURL}/`);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('getRestConfig', () => {
|
|
48
|
-
it('return {} in case agent property is doesn\'t exist', () => {
|
|
49
|
-
restClient.restClientConfig = {};
|
|
50
|
-
expect(restClient.getRestConfig()).toEqual({});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('creates object with correct properties with http(s) agent', () => {
|
|
54
|
-
restClient.restClientConfig = {
|
|
55
|
-
agent: {
|
|
56
|
-
rejectUnauthorized: false,
|
|
57
|
-
},
|
|
58
|
-
timeout: 10000,
|
|
59
|
-
};
|
|
60
|
-
expect(restClient.getRestConfig().httpAgent).toBeDefined();
|
|
61
|
-
expect(restClient.getRestConfig().httpAgent).toBeInstanceOf(http.Agent);
|
|
62
|
-
expect(restClient.getRestConfig().timeout).toBe(10000);
|
|
63
|
-
expect(restClient.getRestConfig().agent).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe('retrieve', () => {
|
|
68
|
-
it('performs GET request for resource', (done) => {
|
|
69
|
-
const listOfUsers = [
|
|
70
|
-
{ id: 1 },
|
|
71
|
-
{ id: 2 },
|
|
72
|
-
{ id: 3 },
|
|
73
|
-
];
|
|
74
|
-
|
|
75
|
-
const scope = nock(options.baseURL)
|
|
76
|
-
.get('/users')
|
|
77
|
-
.reply(200, listOfUsers);
|
|
78
|
-
|
|
79
|
-
restClient.retrieve('users').then((result) => {
|
|
80
|
-
expect(result).toEqual(listOfUsers);
|
|
81
|
-
expect(scope.isDone()).toBeTruthy();
|
|
82
|
-
|
|
83
|
-
done();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('catches NETWORK errors', (done) => {
|
|
88
|
-
const scope = nock(options.baseURL)
|
|
89
|
-
.get('/users')
|
|
90
|
-
.replyWithError(netErrConnectionResetError);
|
|
91
|
-
|
|
92
|
-
restClient.retrieve('users', noOptions).catch((error) => {
|
|
93
|
-
expect(error instanceof Error).toBeTruthy();
|
|
94
|
-
expect(error.message).toMatch(netErrConnectionResetError.message);
|
|
95
|
-
expect(scope.isDone()).toBeTruthy();
|
|
96
|
-
|
|
97
|
-
done();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('catches API errors', (done) => {
|
|
102
|
-
const scope = nock(options.baseURL)
|
|
103
|
-
.get('/users')
|
|
104
|
-
.reply(403, unathorizedError);
|
|
105
|
-
|
|
106
|
-
restClient.retrieve('users', noOptions).catch((error) => {
|
|
107
|
-
expect(error instanceof Error).toBeTruthy();
|
|
108
|
-
expect(error.message).toMatch(unauthorizedErrorMessage);
|
|
109
|
-
expect(scope.isDone()).toBeTruthy();
|
|
110
|
-
|
|
111
|
-
done();
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe('create', () => {
|
|
117
|
-
it('performs POST request to resource', (done) => {
|
|
118
|
-
const newUser = { username: 'John' };
|
|
119
|
-
const userCreated = { id: 1 };
|
|
120
|
-
|
|
121
|
-
const scope = nock(options.baseURL)
|
|
122
|
-
.post('/users', body => isEqual(body, newUser))
|
|
123
|
-
.reply(201, userCreated);
|
|
124
|
-
|
|
125
|
-
restClient.create('users', newUser).then((result) => {
|
|
126
|
-
expect(result).toEqual(userCreated);
|
|
127
|
-
expect(scope.isDone()).toBeTruthy();
|
|
128
|
-
|
|
129
|
-
done();
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('catches NETWORK errors', (done) => {
|
|
134
|
-
const newUser = { username: 'John' };
|
|
135
|
-
|
|
136
|
-
const scope = nock(options.baseURL)
|
|
137
|
-
.post('/users', body => isEqual(body, newUser))
|
|
138
|
-
.replyWithError(netErrConnectionResetError);
|
|
139
|
-
|
|
140
|
-
restClient.create('users', newUser, noOptions).catch((error) => {
|
|
141
|
-
expect(error instanceof Error).toBeTruthy();
|
|
142
|
-
expect(error.message).toMatch(netErrConnectionResetError.message);
|
|
143
|
-
expect(scope.isDone()).toBeTruthy();
|
|
144
|
-
|
|
145
|
-
done();
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('catches API errors', (done) => {
|
|
150
|
-
const newUser = { username: 'John' };
|
|
151
|
-
|
|
152
|
-
const scope = nock(options.baseURL)
|
|
153
|
-
.post('/users', body => isEqual(body, newUser))
|
|
154
|
-
.reply(403, unathorizedError);
|
|
155
|
-
|
|
156
|
-
restClient.create('users', newUser, noOptions).catch((error) => {
|
|
157
|
-
expect(error instanceof Error).toBeTruthy();
|
|
158
|
-
expect(error.message).toMatch(unauthorizedErrorMessage);
|
|
159
|
-
expect(scope.isDone()).toBeTruthy();
|
|
160
|
-
|
|
161
|
-
done();
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
describe('update', () => {
|
|
167
|
-
it('performs PUT request to resource', (done) => {
|
|
168
|
-
const newUserInfo = { username: 'Mike' };
|
|
169
|
-
const userUpdated = { id: 1 };
|
|
170
|
-
|
|
171
|
-
const scope = nock(options.baseURL)
|
|
172
|
-
.put('/users/1', body => isEqual(body, newUserInfo))
|
|
173
|
-
.reply(200, userUpdated);
|
|
174
|
-
|
|
175
|
-
restClient.update('users/1', newUserInfo).then((result) => {
|
|
176
|
-
expect(result).toEqual(userUpdated);
|
|
177
|
-
expect(scope.isDone()).toBeTruthy();
|
|
178
|
-
|
|
179
|
-
done();
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('catches NETWORK errors', (done) => {
|
|
184
|
-
const newUserInfo = { username: 'Mike' };
|
|
185
|
-
|
|
186
|
-
const scope = nock(options.baseURL)
|
|
187
|
-
.put('/users/1', body => isEqual(body, newUserInfo))
|
|
188
|
-
.replyWithError(netErrConnectionResetError);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
restClient.update('users/1', newUserInfo, noOptions).catch((error) => {
|
|
192
|
-
expect(error instanceof Error).toBeTruthy();
|
|
193
|
-
expect(error.message).toMatch(netErrConnectionResetError.message);
|
|
194
|
-
expect(scope.isDone()).toBeTruthy();
|
|
195
|
-
|
|
196
|
-
done();
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it('catches API errors', (done) => {
|
|
201
|
-
const newUserInfo = { username: 'Mike' };
|
|
202
|
-
|
|
203
|
-
const scope = nock(options.baseURL)
|
|
204
|
-
.put('/users/1', body => isEqual(body, newUserInfo))
|
|
205
|
-
.reply(403, unathorizedError);
|
|
206
|
-
|
|
207
|
-
restClient.update('users/1', newUserInfo, noOptions).catch((error) => {
|
|
208
|
-
expect(error instanceof Error).toBeTruthy();
|
|
209
|
-
expect(error.message).toMatch(unauthorizedErrorMessage);
|
|
210
|
-
expect(scope.isDone()).toBeTruthy();
|
|
211
|
-
|
|
212
|
-
done();
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
describe('delete', () => {
|
|
218
|
-
it('performs DELETE request to resource', (done) => {
|
|
219
|
-
const emptyBody = {};
|
|
220
|
-
const userDeleted = {};
|
|
221
|
-
|
|
222
|
-
const scope = nock(options.baseURL)
|
|
223
|
-
.delete('/users/1')
|
|
224
|
-
.reply(200, userDeleted);
|
|
225
|
-
|
|
226
|
-
restClient.delete('users/1', emptyBody).then((result) => {
|
|
227
|
-
expect(result).toEqual(userDeleted);
|
|
228
|
-
expect(scope.isDone()).toBeTruthy();
|
|
229
|
-
|
|
230
|
-
done();
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('catches NETWORK errors', (done) => {
|
|
235
|
-
const emptyBody = {};
|
|
236
|
-
|
|
237
|
-
const scope = nock(options.baseURL)
|
|
238
|
-
.delete('/users/1')
|
|
239
|
-
.replyWithError(netErrConnectionResetError);
|
|
240
|
-
|
|
241
|
-
restClient.delete('users/1', emptyBody, noOptions).catch((error) => {
|
|
242
|
-
expect(error instanceof Error).toBeTruthy();
|
|
243
|
-
expect(error.message).toMatch(netErrConnectionResetError.message);
|
|
244
|
-
expect(scope.isDone()).toBeTruthy();
|
|
245
|
-
|
|
246
|
-
done();
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it('catches API errors', (done) => {
|
|
251
|
-
const emptyBody = {};
|
|
252
|
-
|
|
253
|
-
const scope = nock(options.baseURL)
|
|
254
|
-
.delete('/users/1')
|
|
255
|
-
.reply(403, unathorizedError);
|
|
256
|
-
|
|
257
|
-
restClient.delete('users/1', emptyBody, noOptions).catch((error) => {
|
|
258
|
-
expect(error instanceof Error).toBeTruthy();
|
|
259
|
-
expect(error.message).toMatch(unauthorizedErrorMessage);
|
|
260
|
-
expect(scope.isDone()).toBeTruthy();
|
|
261
|
-
|
|
262
|
-
done();
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
describe('retrieveSyncAPI', () => {
|
|
268
|
-
it('should retrieve SyncAPI', (done) => {
|
|
269
|
-
const listOfUsers = [
|
|
270
|
-
{ id: 1 },
|
|
271
|
-
{ id: 2 },
|
|
272
|
-
{ id: 3 },
|
|
273
|
-
];
|
|
274
|
-
|
|
275
|
-
const scope = nock(options.baseURL)
|
|
276
|
-
.get('/users')
|
|
277
|
-
.reply(200, listOfUsers);
|
|
278
|
-
|
|
279
|
-
restClient.retrieveSyncAPI('users').then((result) => {
|
|
280
|
-
expect(result).toEqual(listOfUsers);
|
|
281
|
-
expect(scope.isDone()).toBeTruthy();
|
|
282
|
-
|
|
283
|
-
done();
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it('catches NETWORK errors', (done) => {
|
|
288
|
-
const scope = nock(options.baseURL)
|
|
289
|
-
.get('/users')
|
|
290
|
-
.replyWithError(netErrConnectionResetError);
|
|
291
|
-
|
|
292
|
-
restClient.retrieveSyncAPI('users', noOptions).catch((error) => {
|
|
293
|
-
expect(error instanceof Error).toBeTruthy();
|
|
294
|
-
expect(error.message).toMatch(netErrConnectionResetError.message);
|
|
295
|
-
expect(scope.isDone()).toBeTruthy();
|
|
296
|
-
|
|
297
|
-
done();
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it('catches API errors', (done) => {
|
|
302
|
-
const scope = nock(options.baseURL)
|
|
303
|
-
.get('/users')
|
|
304
|
-
.reply(403, unathorizedError);
|
|
305
|
-
|
|
306
|
-
restClient.retrieveSyncAPI('users', noOptions).catch((error) => {
|
|
307
|
-
expect(error instanceof Error).toBeTruthy();
|
|
308
|
-
expect(error.message).toMatch(unauthorizedErrorMessage);
|
|
309
|
-
expect(scope.isDone()).toBeTruthy();
|
|
310
|
-
|
|
311
|
-
done();
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
});
|
|
315
|
-
});
|
package/version_fragment
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
patch
|