@eclipse-che/che-e2e 7.42.0-dev-8ddee57 → 7.42.1-dev-4b37b25
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.
|
@@ -29,6 +29,7 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
29
29
|
const TestConstants_1 = require("../../TestConstants");
|
|
30
30
|
const inversify_types_1 = require("../../inversify.types");
|
|
31
31
|
const inversify_1 = require("inversify");
|
|
32
|
+
const Logger_1 = require("../Logger");
|
|
32
33
|
let CheApiRequestHandler = class CheApiRequestHandler {
|
|
33
34
|
constructor(headerHandler) {
|
|
34
35
|
this.headerHandler = headerHandler;
|
|
@@ -37,15 +38,23 @@ let CheApiRequestHandler = class CheApiRequestHandler {
|
|
|
37
38
|
* This method adds a request interceptor into axios request interceptors list and returns an ID of the interceptor
|
|
38
39
|
*/
|
|
39
40
|
static enableRequestInteceptor() {
|
|
40
|
-
|
|
41
|
+
Logger_1.Logger.debug(`CheApiRequestHandler.enableRequestInterceptor`);
|
|
41
42
|
return axios_1.default.interceptors.request.use(request => {
|
|
42
43
|
try {
|
|
43
44
|
let request_censored = JSON.parse(JSON.stringify(request));
|
|
45
|
+
if (request_censored === undefined) {
|
|
46
|
+
Logger_1.Logger.error('JSON.parse returned an undefined object, cannot process request');
|
|
47
|
+
return request;
|
|
48
|
+
}
|
|
49
|
+
if (request_censored.headers === undefined) {
|
|
50
|
+
Logger_1.Logger.warn('Request does not contain any headers object');
|
|
51
|
+
return request;
|
|
52
|
+
}
|
|
44
53
|
request_censored.headers.Authorization = 'CENSORED';
|
|
45
|
-
|
|
54
|
+
Logger_1.Logger.info(`RequestHandler request:\n` + request_censored);
|
|
46
55
|
}
|
|
47
56
|
catch (err) {
|
|
48
|
-
|
|
57
|
+
Logger_1.Logger.error(`RequestHandler request: Failed to deep clone AxiosRequestConfig:` + err);
|
|
49
58
|
}
|
|
50
59
|
return request;
|
|
51
60
|
});
|
|
@@ -54,7 +63,7 @@ let CheApiRequestHandler = class CheApiRequestHandler {
|
|
|
54
63
|
* This method adds a response interceptor into axios response interceptors list and returns an ID of the interceptor
|
|
55
64
|
*/
|
|
56
65
|
static enableResponseInterceptor() {
|
|
57
|
-
|
|
66
|
+
Logger_1.Logger.debug(`CheApiRequestHandler.enableResponseRedirects`);
|
|
58
67
|
return axios_1.default.interceptors.response.use(response => {
|
|
59
68
|
try {
|
|
60
69
|
let response_censored = JSON.parse(JSON.stringify(response, (key, value) => {
|
|
@@ -63,6 +72,18 @@ let CheApiRequestHandler = class CheApiRequestHandler {
|
|
|
63
72
|
default: return value;
|
|
64
73
|
}
|
|
65
74
|
}));
|
|
75
|
+
if (response_censored === undefined) {
|
|
76
|
+
Logger_1.Logger.error('JSON.parse returned an undefined object, cannot process response');
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
if (response_censored.config === undefined) {
|
|
80
|
+
Logger_1.Logger.warn('Response does not contain any config object');
|
|
81
|
+
return response;
|
|
82
|
+
}
|
|
83
|
+
if (response_censored.config.headers === undefined) {
|
|
84
|
+
Logger_1.Logger.warn('Response does not contain any config.headers object');
|
|
85
|
+
return response;
|
|
86
|
+
}
|
|
66
87
|
response_censored.config.headers.Authorization = 'CENSORED';
|
|
67
88
|
if (response_censored.data.access_token != null) {
|
|
68
89
|
response_censored.data.access_token = 'CENSORED';
|
|
@@ -70,10 +91,10 @@ let CheApiRequestHandler = class CheApiRequestHandler {
|
|
|
70
91
|
if (response_censored.data.refresh_token != null) {
|
|
71
92
|
response_censored.data.refresh_token = 'CENSORED';
|
|
72
93
|
}
|
|
73
|
-
|
|
94
|
+
Logger_1.Logger.info(`RequestHandler response:\n` + response_censored);
|
|
74
95
|
}
|
|
75
96
|
catch (err) {
|
|
76
|
-
|
|
97
|
+
Logger_1.Logger.error(`RequestHandler response: Failed to deep clone AxiosResponse:` + err);
|
|
77
98
|
}
|
|
78
99
|
return response;
|
|
79
100
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheApiRequestHandler.js","sourceRoot":"","sources":["../../../utils/requestHandlers/CheApiRequestHandler.ts"],"names":[],"mappings":";AAAA;;;;;;;;wEAQwE;;;;;;;;;;;;;;;;;;AAExE,kDAAiE;AACjE,uDAAoD;AACpD,2DAA8C;AAC9C,yCAA+C;
|
|
1
|
+
{"version":3,"file":"CheApiRequestHandler.js","sourceRoot":"","sources":["../../../utils/requestHandlers/CheApiRequestHandler.ts"],"names":[],"mappings":";AAAA;;;;;;;;wEAQwE;;;;;;;;;;;;;;;;;;AAExE,kDAAiE;AACjE,uDAAoD;AACpD,2DAA8C;AAC9C,yCAA+C;AAE/C,sCAAmC;AAGnC,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAmE7B,YAAwE,aAA0C;QAA1C,kBAAa,GAAb,aAAa,CAA6B;IAAI,CAAC;IAjEvH;;OAEG;IACI,MAAM,CAAC,uBAAuB;QACjC,eAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC9D,OAAO,eAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAE,OAAO,CAAC,EAAE;YACzC,IAAI;gBACA,IAAI,gBAAgB,GAAuB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC/E,IAAI,gBAAgB,KAAK,SAAS,EAAE;oBAChC,eAAM,CAAC,KAAK,CAAC,iEAAiE,CAAC,CAAC;oBAChF,OAAO,OAAO,CAAC;iBAClB;gBACD,IAAI,gBAAgB,CAAC,OAAO,KAAK,SAAS,EAAE;oBACxC,eAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;oBAC3D,OAAO,OAAO,CAAC;iBAClB;gBACD,gBAAgB,CAAC,OAAO,CAAC,aAAa,GAAG,UAAU,CAAC;gBACpD,eAAM,CAAC,IAAI,CAAC,2BAA2B,GAAG,gBAAgB,CAAC,CAAC;aAC/D;YAAC,OAAO,GAAG,EAAE;gBACV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ipse-che/che-e2e",
|
|
3
|
-
"version": "7.42.
|
|
3
|
+
"version": "7.42.1-dev-4b37b25",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@types/node": "11.13.4",
|
|
38
38
|
"@types/rimraf": "2.0.2",
|
|
39
39
|
"@types/selenium-webdriver": "3.0.16",
|
|
40
|
-
"axios": "0.
|
|
40
|
+
"axios": "^0.25.0",
|
|
41
41
|
"chai": "4.2.0",
|
|
42
42
|
"chromedriver": "95.0.0",
|
|
43
43
|
"mocha": "^9.1.3",
|
|
@@ -13,6 +13,7 @@ import { TestConstants } from '../../TestConstants';
|
|
|
13
13
|
import { TYPES } from '../../inversify.types';
|
|
14
14
|
import { inject, injectable } from 'inversify';
|
|
15
15
|
import { IAuthorizationHeaderHandler } from './headers/IAuthorizationHeaderHandler';
|
|
16
|
+
import { Logger } from '../Logger';
|
|
16
17
|
|
|
17
18
|
@injectable()
|
|
18
19
|
export class CheApiRequestHandler {
|
|
@@ -21,14 +22,22 @@ export class CheApiRequestHandler {
|
|
|
21
22
|
* This method adds a request interceptor into axios request interceptors list and returns an ID of the interceptor
|
|
22
23
|
*/
|
|
23
24
|
public static enableRequestInteceptor(): number {
|
|
24
|
-
|
|
25
|
+
Logger.debug(`CheApiRequestHandler.enableRequestInterceptor`);
|
|
25
26
|
return axios.interceptors.request.use( request => {
|
|
26
27
|
try {
|
|
27
28
|
let request_censored: AxiosRequestConfig = JSON.parse(JSON.stringify(request));
|
|
29
|
+
if (request_censored === undefined) {
|
|
30
|
+
Logger.error('JSON.parse returned an undefined object, cannot process request');
|
|
31
|
+
return request;
|
|
32
|
+
}
|
|
33
|
+
if (request_censored.headers === undefined) {
|
|
34
|
+
Logger.warn('Request does not contain any headers object');
|
|
35
|
+
return request;
|
|
36
|
+
}
|
|
28
37
|
request_censored.headers.Authorization = 'CENSORED';
|
|
29
|
-
|
|
38
|
+
Logger.info(`RequestHandler request:\n` + request_censored);
|
|
30
39
|
} catch (err) {
|
|
31
|
-
|
|
40
|
+
Logger.error(`RequestHandler request: Failed to deep clone AxiosRequestConfig:` + err);
|
|
32
41
|
}
|
|
33
42
|
return request;
|
|
34
43
|
});
|
|
@@ -38,7 +47,7 @@ export class CheApiRequestHandler {
|
|
|
38
47
|
* This method adds a response interceptor into axios response interceptors list and returns an ID of the interceptor
|
|
39
48
|
*/
|
|
40
49
|
public static enableResponseInterceptor(): number {
|
|
41
|
-
|
|
50
|
+
Logger.debug(`CheApiRequestHandler.enableResponseRedirects`);
|
|
42
51
|
return axios.interceptors.response.use( response => {
|
|
43
52
|
try {
|
|
44
53
|
let response_censored: AxiosResponse = JSON.parse(JSON.stringify(response, (key, value) => {
|
|
@@ -47,6 +56,18 @@ export class CheApiRequestHandler {
|
|
|
47
56
|
default: return value;
|
|
48
57
|
}
|
|
49
58
|
}));
|
|
59
|
+
if (response_censored === undefined) {
|
|
60
|
+
Logger.error('JSON.parse returned an undefined object, cannot process response');
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
if (response_censored.config === undefined) {
|
|
64
|
+
Logger.warn('Response does not contain any config object');
|
|
65
|
+
return response;
|
|
66
|
+
}
|
|
67
|
+
if (response_censored.config.headers === undefined) {
|
|
68
|
+
Logger.warn('Response does not contain any config.headers object');
|
|
69
|
+
return response;
|
|
70
|
+
}
|
|
50
71
|
response_censored.config.headers.Authorization = 'CENSORED';
|
|
51
72
|
if (response_censored.data.access_token != null) {
|
|
52
73
|
response_censored.data.access_token = 'CENSORED';
|
|
@@ -54,9 +75,9 @@ export class CheApiRequestHandler {
|
|
|
54
75
|
if (response_censored.data.refresh_token != null) {
|
|
55
76
|
response_censored.data.refresh_token = 'CENSORED';
|
|
56
77
|
}
|
|
57
|
-
|
|
78
|
+
Logger.info(`RequestHandler response:\n` + response_censored);
|
|
58
79
|
} catch (err) {
|
|
59
|
-
|
|
80
|
+
Logger.error(`RequestHandler response: Failed to deep clone AxiosResponse:` + err);
|
|
60
81
|
}
|
|
61
82
|
return response;
|
|
62
83
|
});
|