@sap_oss/wdio-qmate-service 1.5.1 → 1.5.2

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/docs/doc.md CHANGED
@@ -4970,10 +4970,11 @@ Global namespace for service modules.
4970
4970
  * [.readPdfFromDirectUrl(url, [username], [password], [isSaml])](#service.odata.readPdfFromDirectUrl)
4971
4971
  * [.rest](#service.rest)
4972
4972
  * [.init([customConfig])](#service.rest.init) ⇒ <code>Object</code>
4973
- * [.get(uri, [options])](#service.rest.get) ⇒ <code>Object</code>
4974
- * [.post(uri, payload)](#service.rest.post) ⇒ <code>Object</code>
4975
- * [.delete(uri, options)](#service.rest.delete) ⇒ <code>Object</code>
4976
- * [.patch(uri, options)](#service.rest.patch) ⇒ <code>Object</code>
4973
+ * [.get(uri, [config])](#service.rest.get) ⇒ <code>Object</code>
4974
+ * [.post(uri, payload, [config])](#service.rest.post) ⇒ <code>Object</code>
4975
+ * [.delete(uri, [config])](#service.rest.delete) ⇒ <code>Object</code>
4976
+ * [.patch(uri, payload, [config])](#service.rest.patch) ⇒ <code>Object</code>
4977
+ * [.put(uri, payload, [config])](#service.rest.put) ⇒ <code>Object</code>
4977
4978
 
4978
4979
  <a name="service.odata"></a>
4979
4980
 
@@ -5231,10 +5232,11 @@ const pdfStream = await service.odata.readPdfFromDirectUrl(url, "username", "Pas
5231
5232
 
5232
5233
  * [.rest](#service.rest)
5233
5234
  * [.init([customConfig])](#service.rest.init) ⇒ <code>Object</code>
5234
- * [.get(uri, [options])](#service.rest.get) ⇒ <code>Object</code>
5235
- * [.post(uri, payload)](#service.rest.post) ⇒ <code>Object</code>
5236
- * [.delete(uri, options)](#service.rest.delete) ⇒ <code>Object</code>
5237
- * [.patch(uri, options)](#service.rest.patch) ⇒ <code>Object</code>
5235
+ * [.get(uri, [config])](#service.rest.get) ⇒ <code>Object</code>
5236
+ * [.post(uri, payload, [config])](#service.rest.post) ⇒ <code>Object</code>
5237
+ * [.delete(uri, [config])](#service.rest.delete) ⇒ <code>Object</code>
5238
+ * [.patch(uri, payload, [config])](#service.rest.patch) ⇒ <code>Object</code>
5239
+ * [.put(uri, payload, [config])](#service.rest.put) ⇒ <code>Object</code>
5238
5240
 
5239
5241
  <a name="service.rest.init"></a>
5240
5242
 
@@ -5260,25 +5262,26 @@ const axios = service.rest.init(customConfig);
5260
5262
  ```
5261
5263
  <a name="service.rest.get"></a>
5262
5264
 
5263
- #### rest.get(uri, [options]) ⇒ <code>Object</code>
5265
+ #### rest.get(uri, [config]) ⇒ <code>Object</code>
5264
5266
  makes a GET request.
5265
5267
 
5266
5268
  **Kind**: static method of [<code>rest</code>](#service.rest)
5267
5269
  **Returns**: <code>Object</code> - The response of the GET request.
5268
5270
 
5269
- | Param | Type | Default | Description |
5270
- | --- | --- | --- | --- |
5271
- | uri | <code>String</code> | | The uri to the data source you want to GET. |
5272
- | [options] | <code>Object</code> | <code>{}</code> | The options you want to specify for GET. |
5271
+ | Param | Type | Description |
5272
+ | --- | --- | --- |
5273
+ | uri | <code>String</code> | The uri to the data source you want to GET. |
5274
+ | [config] | <code>Object</code> | The config options for the request. |
5273
5275
 
5274
5276
  **Example**
5275
5277
  ```js
5276
5278
  const uri = https://api.predic8.de/shop/products/";
5277
5279
  let res = await service.rest.get(uri);
5280
+ common.assertion.expectEqual(res.data.title, "qmate-service");
5278
5281
  ```
5279
5282
  <a name="service.rest.post"></a>
5280
5283
 
5281
- #### rest.post(uri, payload) ⇒ <code>Object</code>
5284
+ #### rest.post(uri, payload, [config]) ⇒ <code>Object</code>
5282
5285
  makes a POST request.
5283
5286
 
5284
5287
  **Kind**: static method of [<code>rest</code>](#service.rest)
@@ -5288,14 +5291,27 @@ makes a POST request.
5288
5291
  | --- | --- | --- |
5289
5292
  | uri | <code>String</code> | The uri to the data source you want to POST against. |
5290
5293
  | payload | <code>Object</code> | The data you want to POST against your entity set. |
5294
+ | [config] | <code>Object</code> | The config options for the request. |
5291
5295
 
5292
5296
  **Example**
5293
5297
  ```js
5294
- let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`);
5298
+ const payload = {
5299
+ id: 99,
5300
+ title: "qmate-service",
5301
+ author: "marvin"
5302
+ };
5303
+ const config = {
5304
+ headers: {
5305
+ "X-CSRF-TOKEN": "<CSRF TOKEN>",
5306
+ "Cookie": "<COOKIE>",
5307
+ "Content-Type": "application/json"
5308
+ }
5309
+ };
5310
+ let res = await service.rest.post(`${browser.config.baseUrl}/posts/99`, payload, config);
5295
5311
  ```
5296
5312
  <a name="service.rest.delete"></a>
5297
5313
 
5298
- #### rest.delete(uri, options) ⇒ <code>Object</code>
5314
+ #### rest.delete(uri, [config]) ⇒ <code>Object</code>
5299
5315
  makes a DELETE request.
5300
5316
 
5301
5317
  **Kind**: static method of [<code>rest</code>](#service.rest)
@@ -5304,15 +5320,21 @@ makes a DELETE request.
5304
5320
  | Param | Type | Description |
5305
5321
  | --- | --- | --- |
5306
5322
  | uri | <code>String</code> | The uri to the data source you want to DELETE. |
5307
- | options | <code>Object</code> | The options you want to specify for DELETE. |
5323
+ | [config] | <code>Object</code> | The config options for the request. |
5308
5324
 
5309
5325
  **Example**
5310
5326
  ```js
5311
- let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`);
5327
+ const config = {
5328
+ auth: {
5329
+ "username": "<username>",
5330
+ "password": "<password>"
5331
+ }
5332
+ };
5333
+ let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`, config);
5312
5334
  ```
5313
5335
  <a name="service.rest.patch"></a>
5314
5336
 
5315
- #### rest.patch(uri, options) ⇒ <code>Object</code>
5337
+ #### rest.patch(uri, payload, [config]) ⇒ <code>Object</code>
5316
5338
  makes a PATCH request.
5317
5339
 
5318
5340
  **Kind**: static method of [<code>rest</code>](#service.rest)
@@ -5321,9 +5343,49 @@ makes a PATCH request.
5321
5343
  | Param | Type | Description |
5322
5344
  | --- | --- | --- |
5323
5345
  | uri | <code>String</code> | The uri to the data source you want to PATCH. |
5324
- | options | <code>Object</code> | The options you want to specify for PATCH. |
5346
+ | payload | <code>Object</code> | The data to be used for updating the entity. |
5347
+ | [config] | <code>Object</code> | The config options for the request. |
5325
5348
 
5326
5349
  **Example**
5327
5350
  ```js
5328
- let res = await service.rest.patch(`${browser.config.baseUrl}/posts/99`);
5351
+ const config = {
5352
+ auth: {
5353
+ "username": "<username>",
5354
+ "password": "<password>"
5355
+ }
5356
+ };
5357
+ const payload = {
5358
+ "title": "patched-qmate-service",
5359
+ "author": "qmate-tester"
5360
+ },
5361
+ let res = await service.rest.patch(`${browser.config.baseUrl}/posts/99`, payload, config);
5362
+ ```
5363
+ <a name="service.rest.put"></a>
5364
+
5365
+ #### rest.put(uri, payload, [config]) ⇒ <code>Object</code>
5366
+ makes a PUT request.
5367
+
5368
+ **Kind**: static method of [<code>rest</code>](#service.rest)
5369
+ **Returns**: <code>Object</code> - The response of the PUT request.
5370
+
5371
+ | Param | Type | Description |
5372
+ | --- | --- | --- |
5373
+ | uri | <code>String</code> | The uri to the data source you want to PUT. |
5374
+ | payload | <code>Object</code> | The data to be used for updating the entity. |
5375
+ | [config] | <code>Object</code> | The config options for the request. |
5376
+
5377
+ **Example**
5378
+ ```js
5379
+ const config = {
5380
+ auth: {
5381
+ "username": "<username>",
5382
+ "password": "<password>"
5383
+ }
5384
+ }
5385
+ const payload = {
5386
+ "id": 99,
5387
+ "title": "put-qmate-service",
5388
+ "author": "qmate-tester"
5389
+ },
5390
+ let res = await service.rest.put(`${browser.config.baseUrl}/posts/99`, payload, config);
5329
5391
  ```
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  // functions
7
- const runner_1 = require("./modules/runner");
7
+ const runner_1 = require("./runner/runner");
8
8
  // modules
9
9
  const Util_1 = __importDefault(require("./modules/util/Util"));
10
10
  const Common_1 = __importDefault(require("./modules/common/Common"));
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","s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AC/B,UAAU,EAAE,aAAQ,CAAC,UAAU;YAC/B,aAAa,EAAE,aAAQ,CAAC,aAAa;YACrC,OAAO,EAAE,aAAQ,CAAC,OAAO;YACzB,KAAK,EAAE,aAAQ,CAAC,KAAK;YACrB,eAAe,EAAE,aAAQ,CAAC,eAAe;YACzC,KAAK,EAAE,aAAQ,CAAC,KAAK;YACrB,OAAO;YACP,cAAc,EAAd,6BAAc;SACf,CAAC;QACF,MAAM,CAAC,GAAG,GAAG;YACX,GAAG,GAAG;YACN,GAAG,MAAM,CAAC,GAAG;SACd,CAAC;QAEF;;;WAGG;QACH,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,gBAAW,CAAC,SAAS;YAChC,OAAO,EAAE,gBAAW,CAAC,OAAO;YAC5B,UAAU,EAAE,gBAAW,CAAC,UAAU;YAClC,eAAe,EAAE,gBAAW,CAAC,eAAe;YAC5C,OAAO,EAAE,gBAAW,CAAC,OAAO;SAC7B,CAAC;QACF,MAAM,CAAC,MAAM,GAAG;YACd,GAAG,MAAM;YACT,GAAG,MAAM,CAAC,MAAM;SACjB,CAAC;QAEF;;;WAGG;QACH,MAAM,OAAO,GAAG;YACd,KAAK,EAAE,iBAAY,CAAC,KAAK;YACzB,IAAI,EAAE,iBAAY,CAAC,IAAI;SACxB,CAAC;QACF,MAAM,CAAC,OAAO,GAAG;YACf,GAAG,OAAO;YACV,GAAG,MAAM,CAAC,OAAO;SAClB,CAAC;IACJ,CAAC;CACF;AAED,kBAAe,IAAI,YAAY,EAAE,CAAC"}
@@ -25,42 +25,98 @@ export declare class Rest {
25
25
  * @memberOf service.rest
26
26
  * @description makes a GET request.
27
27
  * @param {String} uri - The uri to the data source you want to GET.
28
- * @param {Object} [options={}] - The options you want to specify for GET.
28
+ * @param {Object} [config] - The config options for the request.
29
29
  * @returns {Object} The response of the GET request.
30
30
  * @example const uri = https://api.predic8.de/shop/products/";
31
31
  * let res = await service.rest.get(uri);
32
+ * common.assertion.expectEqual(res.data.title, "qmate-service");
32
33
  */
33
- get(uri: string, options?: AxiosRequestConfig<any> | undefined): Promise<AxiosResponse<any, any>>;
34
+ get(uri: string, config?: AxiosRequestConfig<any>): Promise<AxiosResponse<any, any>>;
34
35
  /**
35
36
  * @function post
36
37
  * @memberOf service.rest
37
38
  * @description makes a POST request.
38
39
  * @param {String} uri - The uri to the data source you want to POST against.
39
40
  * @param {Object} payload - The data you want to POST against your entity set.
41
+ * @param {Object} [config] - The config options for the request.
40
42
  * @returns {Object} The response of the POST request.
41
- * @example let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`);
43
+ * @example const payload = {
44
+ id: 99,
45
+ title: "qmate-service",
46
+ author: "marvin"
47
+ };
48
+ const config = {
49
+ headers: {
50
+ "X-CSRF-TOKEN": "<CSRF TOKEN>",
51
+ "Cookie": "<COOKIE>",
52
+ "Content-Type": "application/json"
53
+ }
54
+ };
55
+ let res = await service.rest.post(`${browser.config.baseUrl}/posts/99`, payload, config);
42
56
  */
43
- post(uri: string, payload: any): Promise<AxiosResponse<any, any>>;
57
+ post(uri: string, payload: any, config?: AxiosRequestConfig<any>): Promise<AxiosResponse<any, any>>;
44
58
  /**
45
59
  * @function delete
46
60
  * @memberOf service.rest
47
61
  * @description makes a DELETE request.
48
62
  * @param {String} uri - The uri to the data source you want to DELETE.
49
- * @param {Object} options - The options you want to specify for DELETE.
63
+ * @param {Object} [config] - The config options for the request.
50
64
  * @returns {Object} The response of the DELETE request.
51
- * @example let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`);
65
+ * @example
66
+ * const config = {
67
+ auth: {
68
+ "username": "<username>",
69
+ "password": "<password>"
70
+ }
71
+ };
72
+ let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`, config);
52
73
  */
53
- delete(uri: string, options: AxiosRequestConfig<any> | undefined): Promise<AxiosResponse<any, any>>;
74
+ delete(uri: string, config?: AxiosRequestConfig<any>): Promise<AxiosResponse<any, any>>;
54
75
  /**
55
76
  * @function patch
56
77
  * @memberOf service.rest
57
78
  * @description makes a PATCH request.
58
79
  * @param {String} uri - The uri to the data source you want to PATCH.
59
- * @param {Object} options - The options you want to specify for PATCH.
80
+ * @param {Object} payload - The data to be used for updating the entity.
81
+ * @param {Object} [config] - The config options for the request.
60
82
  * @returns {Object} The response of the PATCH request.
61
- * @example let res = await service.rest.patch(`${browser.config.baseUrl}/posts/99`);
83
+ * @example
84
+ * const config = {
85
+ auth: {
86
+ "username": "<username>",
87
+ "password": "<password>"
88
+ }
89
+ };
90
+ const payload = {
91
+ "title": "patched-qmate-service",
92
+ "author": "qmate-tester"
93
+ },
94
+ let res = await service.rest.patch(`${browser.config.baseUrl}/posts/99`, payload, config);
62
95
  */
63
- patch(uri: string, options: AxiosRequestConfig<any> | undefined): Promise<AxiosResponse<any, any>>;
96
+ patch(uri: string, payload: any, config?: AxiosRequestConfig<any>): Promise<AxiosResponse<any, any>>;
97
+ /**
98
+ * @function put
99
+ * @memberOf service.rest
100
+ * @description makes a PUT request.
101
+ * @param {String} uri - The uri to the data source you want to PUT.
102
+ * @param {Object} payload - The data to be used for updating the entity.
103
+ * @param {Object} [config] - The config options for the request.
104
+ * @returns {Object} The response of the PUT request.
105
+ * @example
106
+ * const config = {
107
+ auth: {
108
+ "username": "<username>",
109
+ "password": "<password>"
110
+ }
111
+ }
112
+ const payload = {
113
+ "id": 99,
114
+ "title": "put-qmate-service",
115
+ "author": "qmate-tester"
116
+ },
117
+ let res = await service.rest.put(`${browser.config.baseUrl}/posts/99`, payload, config);
118
+ */
119
+ put(uri: string, payload: any, config?: AxiosRequestConfig<any> | undefined): Promise<AxiosResponse<any, any>>;
64
120
  }
65
121
  declare const _default: Rest;
66
122
  export default _default;
@@ -31,28 +31,28 @@ class Rest {
31
31
  * @memberOf service.rest
32
32
  * @description makes a GET request.
33
33
  * @param {String} uri - The uri to the data source you want to GET.
34
- * @param {Object} [options={}] - The options you want to specify for GET.
34
+ * @param {Object} [config] - The config options for the request.
35
35
  * @returns {Object} The response of the GET request.
36
36
  * @example const uri = https://api.predic8.de/shop/products/";
37
37
  * let res = await service.rest.get(uri);
38
+ * common.assertion.expectEqual(res.data.title, "qmate-service");
38
39
  */
39
- async get(uri, options = {}) {
40
+ async get(uri, config) {
40
41
  try {
41
- return await this.axios.get(uri, options);
42
+ return await this.axios.get(uri, config);
42
43
  }
43
44
  catch (error) {
45
+ let message = error.message;
44
46
  if (error.message) {
45
47
  if (error.response && error.response.statusText) {
46
- throw new Error(`${error.response.statusText} - ${error.message}`);
48
+ message = `${error.response.statusText} - ${error.message}`;
47
49
  }
48
- throw new Error(`${error.message}`);
49
50
  }
50
51
  else if (error.response) {
51
- throw new Error(`Status Code ${error.response.status}, - ${error.response.data}`);
52
- }
53
- else {
54
- throw new Error(error.request);
52
+ message = `Status Code ${error.response.status}, - ${error.response.data}`;
55
53
  }
54
+ const newError = new Error(message);
55
+ throw Object.assign(error, { message, stack: newError.stack });
56
56
  }
57
57
  }
58
58
  /**
@@ -61,26 +61,38 @@ class Rest {
61
61
  * @description makes a POST request.
62
62
  * @param {String} uri - The uri to the data source you want to POST against.
63
63
  * @param {Object} payload - The data you want to POST against your entity set.
64
+ * @param {Object} [config] - The config options for the request.
64
65
  * @returns {Object} The response of the POST request.
65
- * @example let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`);
66
+ * @example const payload = {
67
+ id: 99,
68
+ title: "qmate-service",
69
+ author: "marvin"
70
+ };
71
+ const config = {
72
+ headers: {
73
+ "X-CSRF-TOKEN": "<CSRF TOKEN>",
74
+ "Cookie": "<COOKIE>",
75
+ "Content-Type": "application/json"
76
+ }
77
+ };
78
+ let res = await service.rest.post(`${browser.config.baseUrl}/posts/99`, payload, config);
66
79
  */
67
- async post(uri, payload) {
80
+ async post(uri, payload, config) {
68
81
  try {
69
- return await this.axios.post(uri, payload);
82
+ return await this.axios.post(uri, payload, config);
70
83
  }
71
84
  catch (error) {
85
+ let message = error.message;
72
86
  if (error.message) {
73
87
  if (error.response && error.response.statusText) {
74
- throw new Error(`${error.response.statusText} - ${error.message}`);
88
+ message = `${error.response.statusText} - ${error.message}`;
75
89
  }
76
- throw new Error(`${error.message}`);
77
90
  }
78
91
  else if (error.response) {
79
- throw new Error(`Status Code ${error.response.status}, - ${error.response.data}`);
80
- }
81
- else {
82
- throw new Error(error.request);
92
+ message = `Status Code ${error.response.status}, - ${error.response.data}`;
83
93
  }
94
+ const newError = new Error(message);
95
+ throw Object.assign(error, { message, stack: newError.stack });
84
96
  }
85
97
  }
86
98
  /**
@@ -88,27 +100,33 @@ class Rest {
88
100
  * @memberOf service.rest
89
101
  * @description makes a DELETE request.
90
102
  * @param {String} uri - The uri to the data source you want to DELETE.
91
- * @param {Object} options - The options you want to specify for DELETE.
103
+ * @param {Object} [config] - The config options for the request.
92
104
  * @returns {Object} The response of the DELETE request.
93
- * @example let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`);
105
+ * @example
106
+ * const config = {
107
+ auth: {
108
+ "username": "<username>",
109
+ "password": "<password>"
110
+ }
111
+ };
112
+ let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`, config);
94
113
  */
95
- async delete(uri, options) {
114
+ async delete(uri, config) {
96
115
  try {
97
- return await this.axios.delete(uri, options);
116
+ return await this.axios.delete(uri, config);
98
117
  }
99
118
  catch (error) {
119
+ let message = error.message;
100
120
  if (error.message) {
101
121
  if (error.response && error.response.statusText) {
102
- throw new Error(`${error.response.statusText} - ${error.message}`);
122
+ message = `${error.response.statusText} - ${error.message}`;
103
123
  }
104
- throw new Error(`${error.message}`);
105
124
  }
106
125
  else if (error.response) {
107
- throw new Error(`Status Code ${error.response.status}, - ${error.response.data}`);
108
- }
109
- else {
110
- throw new Error(error.request);
126
+ message = `Status Code ${error.response.status}, - ${error.response.data}`;
111
127
  }
128
+ const newError = new Error(message);
129
+ throw Object.assign(error, { message, stack: newError.stack });
112
130
  }
113
131
  }
114
132
  /**
@@ -116,27 +134,78 @@ class Rest {
116
134
  * @memberOf service.rest
117
135
  * @description makes a PATCH request.
118
136
  * @param {String} uri - The uri to the data source you want to PATCH.
119
- * @param {Object} options - The options you want to specify for PATCH.
137
+ * @param {Object} payload - The data to be used for updating the entity.
138
+ * @param {Object} [config] - The config options for the request.
120
139
  * @returns {Object} The response of the PATCH request.
121
- * @example let res = await service.rest.patch(`${browser.config.baseUrl}/posts/99`);
140
+ * @example
141
+ * const config = {
142
+ auth: {
143
+ "username": "<username>",
144
+ "password": "<password>"
145
+ }
146
+ };
147
+ const payload = {
148
+ "title": "patched-qmate-service",
149
+ "author": "qmate-tester"
150
+ },
151
+ let res = await service.rest.patch(`${browser.config.baseUrl}/posts/99`, payload, config);
122
152
  */
123
- async patch(uri, options) {
153
+ async patch(uri, payload, config) {
124
154
  try {
125
- return await this.axios.patch(uri, options);
155
+ return await this.axios.patch(uri, payload, config);
126
156
  }
127
157
  catch (error) {
158
+ let message = error.message;
128
159
  if (error.message) {
129
160
  if (error.response && error.response.statusText) {
130
- throw new Error(`${error.response.statusText} - ${error.message}`);
161
+ message = `${error.response.statusText} - ${error.message}`;
131
162
  }
132
- throw new Error(`${error.message}`);
133
163
  }
134
164
  else if (error.response) {
135
- throw new Error(`Status Code ${error.response.status}, - ${error.response.data}`);
165
+ message = `Status Code ${error.response.status}, - ${error.response.data}`;
136
166
  }
137
- else {
138
- throw new Error(error.request);
167
+ const newError = new Error(message);
168
+ throw Object.assign(error, { message, stack: newError.stack });
169
+ }
170
+ }
171
+ /**
172
+ * @function put
173
+ * @memberOf service.rest
174
+ * @description makes a PUT request.
175
+ * @param {String} uri - The uri to the data source you want to PUT.
176
+ * @param {Object} payload - The data to be used for updating the entity.
177
+ * @param {Object} [config] - The config options for the request.
178
+ * @returns {Object} The response of the PUT request.
179
+ * @example
180
+ * const config = {
181
+ auth: {
182
+ "username": "<username>",
183
+ "password": "<password>"
184
+ }
185
+ }
186
+ const payload = {
187
+ "id": 99,
188
+ "title": "put-qmate-service",
189
+ "author": "qmate-tester"
190
+ },
191
+ let res = await service.rest.put(`${browser.config.baseUrl}/posts/99`, payload, config);
192
+ */
193
+ async put(uri, payload, config) {
194
+ try {
195
+ return await this.axios.put(uri, payload, config);
196
+ }
197
+ catch (error) {
198
+ let message = error.message;
199
+ if (error.message) {
200
+ if (error.response && error.response.statusText) {
201
+ message = `${error.response.statusText} - ${error.message}`;
202
+ }
203
+ }
204
+ else if (error.response) {
205
+ message = `Status Code ${error.response.status}, - ${error.response.data}`;
139
206
  }
207
+ const newError = new Error(message);
208
+ throw Object.assign(error, { message, stack: newError.stack });
140
209
  }
141
210
  }
142
211
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rest.js","sourceRoot":"","sources":["../../../../src/reuse/modules/service/rest.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb;;;GAGG;AACH,MAAa,IAAI;IAAjB;QACU,UAAK,GAAgB,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;IA6HxD,CAAC;IA3HC;;;;;;;;;;;;;OAaG;IAEH,IAAI,CAAC,eAAoD,EAAE;QACzD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,UAA+C,EAAE;QACtE,IAAI;YACF,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;SAC3C;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,KAAK,CAAC,OAAO,EAAE;gBACjB,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE;oBAC/C,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;iBACpE;gBACD,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;aACrC;iBAAM,IAAI,KAAK,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AAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAC,CAAC,CAAC;SAC9D;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACD,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,OAAY,EAAE,MAA4C;QAC/E,IAAI;YACA,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;SACrD;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;YAC5B,IAAI,KAAK,CAAC,OAAO,EAAE;gBACjB,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE;oBAC/C,OAAO,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,UAAU,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;iBAC7D;aACF;iBAAM,IAAI,KAAK,CAAC,QAAQ,EAAE;gBACzB,OAAO,GAAG,eAAe,KAAK,CAAC,QAAQ,CAAC,MAAM,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;aAC5E;YACD,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YACpC,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAC,CAAC,CAAC;SAC9D;IACH,CAAC;CACJ;AAtMD,oBAsMC;AACD,kBAAe,IAAI,IAAI,EAAE,CAAC"}
@@ -105,7 +105,6 @@ class File {
105
105
  }
106
106
  // =================================== HELPER ===================================
107
107
  async _renderPage(pageData) {
108
- const vl = this.vlf.initLog(this._renderPage);
109
108
  // should be in scope of render page due to library specific implementation
110
109
  const _parseText = function (textContent) {
111
110
  if (textContent === undefined || textContent === null || !textContent.items || !Array.isArray(textContent.items)) {
@@ -1 +1 @@
1
- {"version":3,"file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AAC,CAAC,CAAC;iBAC3B;aACF;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEF,MAAM,cAAc,GAAG;YACrB,oGAAoG;YACpG,mBAAmB,EAAE,KAAK;YAC1B,gFAAgF;YAChF,uBAAuB,EAAE,KAAK;SAC/B,CAAC;QACF,OAAO,QAAQ,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClE,CAAC;CACF;AArID,oBAqIC;AACD,kBAAe,IAAI,IAAI,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/reuse/runner/runner.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,6EAA6E;AACtE,KAAK,UAAU,GAAG,CAAC,QAAgB,EAAE,EAAgB;IAC1D,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC7D,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;KACvB;SAAM;QACL,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;KAClB;AACH,CAAC;AAND,kBAMC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap_oss/wdio-qmate-service",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "author": "SAP SE",
5
5
  "types": "./@types/index.d.ts",
6
6
  "main": "./lib/index.js",
@@ -94,15 +94,17 @@
94
94
  "test:reuse:util:console": "npx wdio ./test/reuse/util/console/test.console.conf.js",
95
95
  "test:reuse:util:system": "npx wdio ./test/reuse/util/system/test.system.conf.js",
96
96
  "test:reuse:util:formatter": "npx wdio ./test/reuse/util/formatter/test.formatter.conf.js",
97
- "test:reuse:util": "npm run test:reuse:util:browser && npm run test:reuse:util:data && npm run test:reuse:util:file && npm run test:reuse:util:formatter && npm run test:reuse:util:system && npm run test:reuse:util:console",
97
+ "test:reuse:util": "npm run test:reuse:util:browser && npm run test:reuse:util:data && npm run test:reuse:util:file && npm run test:reuse:util:formatter && npm run test:reuse:util:system && npm run test:reuse:util:console && npm run test:reuse:util:component",
98
98
  "test:reuse:common:assertion": "npx wdio ./test/reuse/common/assertion/test.assertion.conf.js",
99
99
  "test:reuse:common:navigation": "npx wdio ./test/reuse/common/navigation/test.navigation.conf.js",
100
100
  "test:reuse:common:date": "npx wdio ./test/reuse/common/date/test.date.conf.js",
101
101
  "test:reuse:common:userInteraction": "npx wdio ./test/reuse/common/userInteraction/test.userInteraction.conf.js",
102
102
  "test:reuse:common": "npm run test:reuse:common:assertion && npm run test:reuse:common:navigation && npm run test:reuse:common:date && npm run test:reuse:common:userInteraction",
103
- "test:reuse:service:rest:startJsonServer": "cd test/reuse/service/rest && json-server --watch db.json",
104
- "test:reuse:service:rest": "npx wdio test/reuse/service/rest/test.rest.conf.js",
103
+ "test:reuse:service:rest:startJsonServer": "cd test/reuse/service/rest && node rest-server.js",
104
+ "test:reuse:service:restTests": "npx wdio test/reuse/service/rest/test.rest.conf.js",
105
+ "test:reuse:service:rest": "concurrently \"npm run test:reuse:service:rest:startJsonServer\" \"npm run test:reuse:service:restTests\"",
105
106
  "test:reuse:service:odata": "npx wdio test/reuse/service/odata/test.odata.conf.js",
107
+ "test:reuse:service": "npm run test:reuse:service:rest && npm run test:reuse:service:odata",
106
108
  "test:reuse": "npm run test:reuse:common && npm run test:reuse:nonUi5 && npm run test:reuse:ui5 && npm run test:reuse:util && npm run test:reuse:service:odata",
107
109
  "test": "npm run test:authenticator:staticLogin && npm run test:core && npm run test:reuse"
108
110
  },
@@ -123,7 +125,7 @@
123
125
  "license": "Apache-2.0",
124
126
  "dependencies": {
125
127
  "@sap_oss/odata-library": "^1.0.6",
126
- "axios": "^0.24.0",
128
+ "axios": "^1.3.4",
127
129
  "curl": "^0.1.4",
128
130
  "fs-extra": "^10.0.0",
129
131
  "path": "^0.12.7",
@@ -142,7 +144,8 @@
142
144
  "@wdio/spec-reporter": "^7.20.8",
143
145
  "@wdio/static-server-service": "^7.10.1",
144
146
  "chai": "^4.3.4",
145
- "chromedriver": "^109.0.0",
147
+ "chromedriver": "^111.0.0",
148
+ "concurrently": "^7.6.0",
146
149
  "deepmerge": "^4.2.2",
147
150
  "eslint": "^6.8.0",
148
151
  "eslint-plugin-wdio": "^6.0.12",
@@ -1,5 +1,25 @@
1
1
  {
2
2
  "posts": [
3
+ {
4
+ "id": 99,
5
+ "title": "qmate-service",
6
+ "author": "marvin"
7
+ },
8
+ {
9
+ "id": 111,
10
+ "title": "qmate-service-patch",
11
+ "author": "m4rv1n"
12
+ },
13
+ {
14
+ "id": 222,
15
+ "title": "qmate-service-put",
16
+ "author": "m4rv1n"
17
+ },
18
+ {
19
+ "id": 444,
20
+ "title": "qmate-service-delete",
21
+ "author": "marvin"
22
+ }
3
23
  ],
4
24
  "comments": [],
5
25
  "profile": {
@@ -1,20 +1,53 @@
1
1
  "use strict";
2
+ const config = {
3
+ auth: {
4
+ username: "restuser",
5
+ password: "restpassword"
6
+ }
7
+ };
8
+ const invalidConfig = {
9
+ auth: {
10
+ username: "restuser-invalid",
11
+ password: "restpassword-invalid"
12
+ }
13
+ };
14
+ const postId = 444;
2
15
 
3
- describe("service.rest.delete - expect to DELETE 99 as response", function () {
16
+ describe("service.rest.delete - expect to DELETE 444 as response", function () {
17
+ let originalPost;
18
+
19
+ it("Preparation", async function () {
20
+ const res = await service.rest.get(`${browser.config.baseUrl}/posts/${postId}`);
21
+ originalPost = res.data;
22
+ });
4
23
 
5
24
  it("Execution & Validation", async function () {
6
- const res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`);
25
+ const res = await service.rest.delete(`${browser.config.baseUrl}/posts/${postId}`, config);
7
26
  await common.assertion.expectEqual(res.status, 200);
8
27
  await common.assertion.expectEqual(res.statusText, "OK");
9
28
  await common.assertion.expectEqual(res.data, {});
10
29
  });
30
+
31
+ it("Cleanup", async function () {
32
+ await service.rest.post(`${browser.config.baseUrl}/posts`, originalPost, config);
33
+ });
34
+
11
35
  });
12
36
 
13
37
  describe("service.rest.delete - expect DELETE request to fail with status code '404'", function () {
38
+
39
+ it("Execution & Validation", async function () {
40
+ await expect(service.rest.delete(`${browser.config.baseUrl}/posts/00`, config))
41
+ .rejects.toThrow("Not Found - Request failed with status code 404");
42
+ });
43
+
44
+ });
14
45
 
46
+ describe("service.rest.delete - Expect DELETE request to fail with 'Unauthorized - Request failed with status code 401'", function () {
47
+
15
48
  it("Execution & Validation", async function () {
16
- await expect(service.rest.delete(`${browser.config.baseUrl}/posts/00`))
17
- .rejects.toThrow(/Request failed with status code 404/);
49
+ await expect(service.rest.delete(`${browser.config.baseUrl}/posts/${postId}`, invalidConfig))
50
+ .rejects.toThrow("Unauthorized - Request failed with status code 401");
18
51
  });
19
52
 
20
53
  });
@@ -13,7 +13,19 @@ describe("service.rest.get - expect to GET request to fail with status code '404
13
13
 
14
14
  it("Execution & Validation", async function () {
15
15
  await expect(service.rest.get(`${browser.config.baseUrl}/posts/00`))
16
- .rejects.toThrow(/Request failed with status code 404/);
16
+ .rejects.toThrow("Not Found - Request failed with status code 404");
17
+ });
18
+
19
+ });
20
+
21
+ describe("service.rest.get - expect error stacktrace to contain spec name", function () {
22
+
23
+ it("Execution & Validation", async function () {
24
+ try {
25
+ await service.rest.get(`${browser.config.baseUrl}/posts/00`);
26
+ } catch (error) {
27
+ await expect(error.stack).toMatch(/get\.spec\.js/);
28
+ }
17
29
  });
18
30
 
19
31
  });
@@ -1,8 +1,15 @@
1
1
  "use strict";
2
- describe("service.rest.init - expect to do GET request with default axios instance", function () {
2
+ const config = {
3
+ auth: {
4
+ username: "restuser",
5
+ password: "restpassword"
6
+ }
7
+ };
3
8
 
9
+ describe("service.rest.init - expect to do GET request with default axios instance", function () {
4
10
  let axios;
5
- it("Preperation", async function () {
11
+
12
+ it("Preparation", async function () {
6
13
  axios = await service.rest.init();
7
14
  });
8
15
 
@@ -14,22 +21,27 @@ describe("service.rest.init - expect to do GET request with default axios instan
14
21
  });
15
22
 
16
23
  describe("service.rest.init - expect to do POST request with default axios instance", function () {
17
-
18
24
  let axios;
19
25
  let payload;
20
- it("Preperation", async function () {
26
+
27
+ it("Preparation", async function () {
21
28
  axios = await service.rest.init();
22
29
  payload = {
23
- "id": 999,
24
- "title": "axios-instance",
25
- "author": "marvin"
30
+ id: 999,
31
+ title: "axios-instance",
32
+ author: "marvin"
26
33
  };
27
34
  });
35
+
28
36
  it("Execution & Validation", async function () {
29
- const res = await axios.post(`${browser.config.baseUrl}/posts`, payload);
37
+ const res = await axios.post(`${browser.config.baseUrl}/posts`, payload, config);
30
38
  common.assertion.expectEqual(res.status, 201);
31
39
  common.assertion.expectEqual(res.statusText, "Created");
32
- common.assertion.expectEqual(res.data.id, 999);
40
+ common.assertion.expectEqual(res.data.id, payload.id);
41
+ });
42
+
43
+ it("Cleanup", async function () {
44
+ await axios.delete(`${browser.config.baseUrl}/posts/${payload.id}`, config);
33
45
  });
34
46
 
35
- });
47
+ });
@@ -1,29 +1,59 @@
1
1
  "use strict";
2
- const qs = require("querystring");
3
- let payload;
2
+
3
+ const payload = {
4
+ id: 111,
5
+ title: "patched",
6
+ author: "m4rv1n"
7
+ };
8
+ const config = {
9
+ auth: {
10
+ username: "restuser",
11
+ password: "restpassword"
12
+ }
13
+ };
14
+ const invalidConfig = {
15
+ auth: {
16
+ username: "restuser-invalid",
17
+ password: "restpassword-invalid"
18
+ }
19
+ };
4
20
 
5
21
  describe("service.rest.patch - PATCH 'title' and 'author'", function () {
6
- it("Preperation", async function () {
7
- payload = {
8
- "id": 99,
9
- "title": "patched",
10
- "author": "m4rv1n"
11
- };
22
+ let originalPost;
23
+
24
+ it("Preparation", async function () {
25
+ const res = await service.rest.get(`${browser.config.baseUrl}/posts/${payload.id}`);
26
+ originalPost = res.data;
12
27
  });
13
-
28
+
14
29
  it("Execution & Validation", async function () {
15
- const res = await service.rest.patch(`${browser.config.baseUrl}/posts/99`, payload);
30
+ const res = await service.rest.patch(`${browser.config.baseUrl}/posts/${payload.id}`, payload, config);
16
31
  common.assertion.expectEqual(res.status, 200);
17
32
  common.assertion.expectEqual(res.statusText, "OK");
18
- common.assertion.expectEqual(res.data.title, "patched");
19
- common.assertion.expectEqual(res.data.author, "m4rv1n");
33
+ common.assertion.expectEqual(res.data.title, payload.title);
34
+ common.assertion.expectEqual(res.data.author, payload.author);
35
+ });
36
+
37
+ it("Cleanup", async function () {
38
+ await service.rest.patch(`${browser.config.baseUrl}/posts/${payload.id}`, originalPost, config);
20
39
  });
21
40
 
22
41
  });
23
42
 
24
43
  describe("service.rest.patch - PATCH against not existing entitySet", function () {
44
+
25
45
  it("Execution & Validation", async function () {
26
- await expect(service.rest.patch(`${browser.config.baseUrl}/notExistingEntitySet`, {}))
46
+ await expect(service.rest.patch(`${browser.config.baseUrl}/notExistingEntitySet`, {}, config))
27
47
  .rejects.toThrow("Not Found - Request failed with status code 404");
28
48
  });
29
- });
49
+
50
+ });
51
+
52
+ describe("service.rest.patch - Expect PATCH request to fail with 'Unauthorized - Request failed with status code 401'", function () {
53
+
54
+ it("Execution & Validation", async function () {
55
+ await expect(service.rest.patch(`${browser.config.baseUrl}/posts/${payload.id}`, payload, invalidConfig))
56
+ .rejects.toThrow("Unauthorized - Request failed with status code 401");
57
+ });
58
+
59
+ });
@@ -1,37 +1,69 @@
1
1
  "use strict";
2
- const qs = require("querystring");
3
- let payload;
4
2
 
5
- describe("service.rest.post - POST 'qmate-service' as a new entry", function () {
6
- it("Preperation", async function () {
7
- payload = {
8
- "id": 99,
9
- "title": "qmate-service",
10
- "author": "marvin"
11
- };
12
- });
3
+ const payload = {
4
+ id: 199,
5
+ title: "qmate-service",
6
+ author: "marvin"
7
+ };
8
+ const config = {
9
+ auth: {
10
+ username: "restuser",
11
+ password: "restpassword"
12
+ }
13
+ };
14
+ const invalidConfig = {
15
+ auth: {
16
+ username: "restuser-invalid",
17
+ password: "restpassword-invalid"
18
+ }
19
+ };
13
20
 
21
+ describe("service.rest.post - POST 'qmate-service' as a new entry", function () {
22
+
14
23
  it("Execution & Validation", async function () {
15
- const res = await service.rest.post(`${browser.config.baseUrl}/posts`, payload);
24
+ const res = await service.rest.post(`${browser.config.baseUrl}/posts`, payload, config);
16
25
  common.assertion.expectEqual(res.status, 201);
17
26
  common.assertion.expectEqual(res.statusText, "Created");
18
- common.assertion.expectEqual(res.data.id, 99);
27
+ common.assertion.expectEqual(res.data.id, payload.id);
28
+ });
29
+
30
+ it("Cleanup", async function () {
31
+ await service.rest.delete(`${browser.config.baseUrl}/posts/${payload.id}`, config);
19
32
  });
20
33
 
21
34
  });
22
35
 
23
36
  describe("service.rest.post - Expect POST request to fail with '500' due to duplicate id", function () {
37
+
38
+ it("Preparation", async function () {
39
+ await service.rest.post(`${browser.config.baseUrl}/posts`, payload, config);
40
+ });
41
+
24
42
  it("Execution & Validation", async function () {
25
- await expect(service.rest.post(`${browser.config.baseUrl}/posts`, payload))
43
+ await expect(service.rest.post(`${browser.config.baseUrl}/posts`, payload, config))
26
44
  .rejects.toThrow("Internal Server Error - Request failed with status code 500");
27
45
  });
46
+
47
+ it("Cleanup", async function () {
48
+ await service.rest.delete(`${browser.config.baseUrl}/posts/${payload.id}`, config);
49
+ });
28
50
 
29
51
  });
30
52
 
31
53
  describe("service.rest.post - POST against not existing entitySet", function () {
54
+
32
55
  it("Execution & Validation", async function () {
33
- await expect(service.rest.post(`${browser.config.baseUrl}/notExistingEntitySet`, {}))
56
+ await expect(service.rest.post(`${browser.config.baseUrl}/notExistingEntitySet`, {}, config))
34
57
  .rejects.toThrow("Not Found - Request failed with status code 404");
35
58
  });
36
59
 
37
- });
60
+ });
61
+
62
+ describe("service.rest.post - Expect POST request to fail with 'Unauthorized - Request failed with status code 401'", function () {
63
+
64
+ it("Execution & Validation", async function () {
65
+ await expect(service.rest.post(`${browser.config.baseUrl}/posts`, payload, invalidConfig))
66
+ .rejects.toThrow("Unauthorized - Request failed with status code 401");
67
+ });
68
+
69
+ });
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ const config = {
3
+ auth: {
4
+ username: "restuser",
5
+ password: "restpassword"
6
+ }
7
+ };
8
+ const invalidConfig = {
9
+ auth: {
10
+ username: "restuser-invalid",
11
+ password: "restpassword-invalid"
12
+ }
13
+ };
14
+ const payload = {
15
+ "id": 222,
16
+ "title": "qmate-service-updated-by-put",
17
+ "author": "m4rv1n"
18
+ };
19
+
20
+ describe("service.rest.put", function () {
21
+ let originalPost;
22
+
23
+ it("Preparation", async function () {
24
+ const res = await service.rest.get(`${browser.config.baseUrl}/posts/${payload.id}`);
25
+ originalPost = res.data;
26
+ });
27
+
28
+ it("Execution & Validation", async function () {
29
+ const res = await service.rest.put(`${browser.config.baseUrl}/posts/${payload.id}`, payload, config);
30
+ common.assertion.expectEqual(res.status, 200);
31
+ common.assertion.expectEqual(res.statusText, "OK");
32
+ common.assertion.expectEqual(res.data.title, payload.title);
33
+ common.assertion.expectEqual(res.data.author, payload.author);
34
+ });
35
+
36
+ it("Cleanup", async function () {
37
+ await service.rest.patch(`${browser.config.baseUrl}/posts/${payload.id}`, originalPost, config);
38
+ });
39
+
40
+ });
41
+
42
+ describe("service.rest.put - PUT against not existing entitySet", function () {
43
+
44
+ it("Execution & Validation", async function () {
45
+ await expect(service.rest.put(`${browser.config.baseUrl}/notExistingEntitySet`, {}, config))
46
+ .rejects.toThrow("Not Found - Request failed with status code 404");
47
+ });
48
+
49
+ });
50
+
51
+ describe("service.rest.put - Expect PUT request to fail with 'Unauthorized - Request failed with status code 401'", function () {
52
+
53
+ it("Execution & Validation", async function () {
54
+ await expect(service.rest.put(`${browser.config.baseUrl}/posts/${payload.id}`, payload, invalidConfig))
55
+ .rejects.toThrow("Unauthorized - Request failed with status code 401");
56
+ });
57
+
58
+ });
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Rest server used to test service.rest API
3
+ * GET calls don't require authentication
4
+ * All other calls accept basic authentication
5
+ * Server shuts down automatically if idle for 60 seconds
6
+ */
7
+ const jsonServer = require("json-server");
8
+ const server = jsonServer.create();
9
+ const router = jsonServer.router("db.json");
10
+ const middlewares = jsonServer.defaults();
11
+ const process = require("node:process");
12
+ const defaultUser = "restuser";
13
+ const defaultPassword = "restpassword";
14
+
15
+ function handle(signal) {
16
+ console.log(`Received ${signal}`);
17
+ process.exit();
18
+ }
19
+
20
+ let lastRequestTime = (new Date()).getTime();
21
+
22
+ setInterval(() => {
23
+ // if there are no requests for 60 seconds, shutdown gracefully
24
+ const currentTime = (new Date()).getTime();
25
+ if ((currentTime - lastRequestTime) > 60000 && server.listenerCount() == 0) {
26
+ process.exit();
27
+ }
28
+ }, 1000);
29
+
30
+ process.on("SIGINT", handle);
31
+ process.on("SIGTERM", handle);
32
+
33
+ function isAuthorized(req, res) {
34
+ if (req.method === "GET") {
35
+ return true;
36
+ } else {
37
+ return checkAuthHeader(req, res);
38
+ }
39
+ }
40
+ function checkAuthHeader(req, res) {
41
+ const { authorization } = req.headers;
42
+
43
+ if (!authorization) {
44
+ res.status(401).jsonp("Missing authorization header");
45
+ return false;
46
+ }
47
+
48
+ const [scheme, token] = authorization.split(" ");
49
+
50
+ if (scheme !== "Basic") {
51
+ res.status(401).jsonp("Incorrect authorization scheme");
52
+ return false;
53
+ }
54
+
55
+ if (!token) {
56
+ res.status(401).jsonp("Missing token");
57
+ return false;
58
+ }
59
+ const [username, password] = Buffer.from(token, "base64").toString().split(":");
60
+ if (username !== defaultUser && password !== defaultPassword) {
61
+ res.status(401).jsonp("Invalid login credentials, please try again");
62
+ return false;
63
+ }
64
+ return true;
65
+ }
66
+ server.use(middlewares);
67
+ server.use((req, res, next) => {
68
+ lastRequestTime = (new Date()).getTime();
69
+ if (isAuthorized(req, res)) {
70
+ next(); // continue to JSON Server router
71
+ }
72
+ });
73
+ server.use(router);
74
+ server.listen(3000, () => {
75
+ console.log("JSON Server is running at port 3000");
76
+ });
@@ -3,7 +3,7 @@ const merge = require("deepmerge");
3
3
  const profile = require("../../../helper/configurations/chrome.headless.conf");
4
4
 
5
5
  exports.config = merge(profile.config, {
6
- maxInstances: 6,
6
+ maxInstances: 3,
7
7
  specFileRetries: 2,
8
8
 
9
9
  baseUrl: "http://localhost:3000",
@@ -13,6 +13,7 @@ exports.config = merge(profile.config, {
13
13
  path.resolve(__dirname, "get.spec.js"),
14
14
  path.resolve(__dirname, "init.spec.js"),
15
15
  path.resolve(__dirname, "patch.spec.js"),
16
+ path.resolve(__dirname, "put.spec.js"),
16
17
  path.resolve(__dirname, "delete.spec.js")
17
18
  ]
18
19
  });
@@ -1,9 +1,10 @@
1
1
  const fs = require("fs");
2
2
  const path = require("path");
3
+ const os = require("os");
3
4
 
4
5
  describe("component - loadEntryPoint", function () {
5
6
  const filename = "loadEntryPoint.entrypoint.json";
6
- const folderPath = path.resolve(__dirname, "entrypoints");
7
+ const folderPath = "entrypoints";
7
8
  const data = { purchaseOrder: "123456" };
8
9
  let entryPointData;
9
10
 
@@ -23,13 +24,13 @@ describe("component - loadEntryPoint", function () {
23
24
  });
24
25
 
25
26
  it("Cleanup", async function () {
26
- fs.unlinkSync(path.resolve(folderPath, filename));
27
+ await fs.promises.rm(folderPath, {recursive: true, force: true});
27
28
  });
28
29
  });
29
30
 
30
31
  describe("component - loadEntryPoint - custom folder path", function () {
31
32
  const filename = "loadEntryPoint.entrypoint.json";
32
- const folderPath = path.resolve(__dirname, "myEntrypoints");
33
+ const folderPath = path.resolve(os.tmpdir(), "entrypointsLoad");
33
34
  const data = { purchaseOrder: "123456" };
34
35
  let entryPointData;
35
36
 
@@ -49,27 +50,15 @@ describe("component - loadEntryPoint - custom folder path", function () {
49
50
  });
50
51
 
51
52
  it("Cleanup", async function () {
52
- fs.unlinkSync(path.resolve(folderPath, filename));
53
+ await fs.promises.rm(folderPath, {recursive: true, force: true});
53
54
  });
54
55
  });
55
56
 
56
57
  describe("component - loadEntryPoint - error case", function () {
57
- const filename = "loadEntryPoint.no-such-entrypoint.json";
58
- const folderPath = path.resolve(__dirname, "entrypoints");
59
- const data = { purchaseOrder: "123456" };
60
-
61
- it("Preparation", async function () {
62
- if (!fs.existsSync(folderPath)) {
63
- fs.mkdirSync(folderPath);
64
- }
65
- fs.writeFileSync(path.resolve(folderPath, filename), JSON.stringify(data));
66
- });
58
+ const folderPath = path.resolve(os.tmpdir(), "entrypointsLoad");
67
59
 
68
60
  it("Execution & Verification", async function () {
69
- await expect(util.component.loadEntryPoint()).rejects.toThrow("Function 'readDataFromFile' failed:");
61
+ await expect(util.component.loadEntryPoint(folderPath)).rejects.toThrow("Function 'readDataFromFile' failed:");
70
62
  });
71
63
 
72
- it("Cleanup", async function () {
73
- fs.unlinkSync(path.resolve(folderPath, filename));
74
- });
75
64
  });
@@ -1,13 +1,14 @@
1
1
  const fs = require("fs");
2
2
  const path = require("path");
3
+ const os = require("os");
3
4
 
4
- describe("component - storeEntryPoint", function () {
5
+ describe("component - storeEntryPoint - custom folder path", function () {
5
6
  const filename = "storeEntryPoint.entrypoint.json";
6
- const folderPath = path.resolve(__dirname, "entrypoints");
7
+ const folderPath = path.resolve(os.tmpdir(), "entrypointsStore");
7
8
  const data = { purchaseOrder: "123456" };
8
9
 
9
10
  it("Execution", async function () {
10
- await util.component.storeEntryPoint(data);
11
+ await util.component.storeEntryPoint(data, folderPath);
11
12
  });
12
13
 
13
14
  it("Verification", async function () {
@@ -16,18 +17,36 @@ describe("component - storeEntryPoint", function () {
16
17
  });
17
18
 
18
19
  it("Cleanup", async function () {
19
- fs.unlinkSync(path.resolve(folderPath, filename));
20
+ await fs.promises.rm(folderPath, {recursive: true, force: true});
20
21
  });
21
22
 
22
23
  });
23
24
 
24
- describe("component - storeEntryPoint - custom folder path", function () {
25
+ describe("component - storeEntryPoint - error case", function () {
26
+ const folderPath = path.resolve(os.tmpdir(), "entrypointsStore");
27
+
28
+ it("Execution & Verification", async function () {
29
+ await expect(util.component.storeEntryPoint(undefined, folderPath))
30
+ .rejects.toThrow("Function 'writeDataToFile' failed:");
31
+ });
32
+
33
+ it("Cleanup", async function () {
34
+ await fs.promises.rm(folderPath, {recursive: true, force: true});
35
+ });
36
+
37
+ });
38
+
39
+ // this test has been moved down, and sleep added to
40
+ // avoid race condition with loadEntryPoint tests
41
+ // since both use the same folder
42
+ describe("component - storeEntryPoint", function () {
25
43
  const filename = "storeEntryPoint.entrypoint.json";
26
- const folderPath = path.resolve(__dirname, "myEntrypoints");
44
+ const folderPath = "entrypoints";
27
45
  const data = { purchaseOrder: "123456" };
28
46
 
29
47
  it("Execution", async function () {
30
- await util.component.storeEntryPoint(data, folderPath);
48
+ await util.browser.sleep(1000);
49
+ await util.component.storeEntryPoint(data);
31
50
  });
32
51
 
33
52
  it("Verification", async function () {
@@ -36,16 +55,7 @@ describe("component - storeEntryPoint - custom folder path", function () {
36
55
  });
37
56
 
38
57
  it("Cleanup", async function () {
39
- fs.unlinkSync(path.resolve(folderPath, filename));
40
- });
41
-
42
- });
43
-
44
- describe("component - storeEntryPoint - error case", function () {
45
-
46
- it("Execution & Verification", async function () {
47
- await expect(util.component.storeEntryPoint())
48
- .rejects.toThrow("Function 'writeDataToFile' failed:");
58
+ await fs.promises.rm(folderPath, {recursive: true, force: true});
49
59
  });
50
60
 
51
61
  });
@@ -10,6 +10,6 @@ exports.config = merge(profile.config, {
10
10
 
11
11
  specs: [
12
12
  path.resolve(__dirname, "file.spec.js"),
13
- // path.resolve(__dirname, "pdfParser.spec.js")
13
+ path.resolve(__dirname, "pdfParser.spec.js")
14
14
  ]
15
15
  });
@@ -1 +0,0 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/reuse/modules/runner.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAIb,6EAA6E;AACtE,KAAK,UAAU,GAAG,CAAC,QAAgB,EAAE,EAAgB;IAC1D,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC7D,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;KACvB;SAAM;QACL,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;KAClB;AACH,CAAC;AAND,kBAMC"}
File without changes
File without changes