@bigid/apps-infrastructure-node-js 1.218.1 → 1.220.1
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.
|
@@ -8,7 +8,7 @@ export declare enum RequestMethod {
|
|
|
8
8
|
DELETE = "delete"
|
|
9
9
|
}
|
|
10
10
|
export declare const getTenantRegistrations: (bigidToken: string) => Promise<TenantRegistration[]>;
|
|
11
|
-
export declare const doCallToUrl: (bigidToken: string, requestMethod: RequestMethod, endpoint: string, bodyJson?: Record<string, any>) => Promise<any>;
|
|
11
|
+
export declare const doCallToUrl: (bigidToken: string, requestMethod: RequestMethod, endpoint: string, bodyJson?: Record<string, any>, additionalHeaderFields?: Record<string, any>) => Promise<any>;
|
|
12
12
|
/**
|
|
13
13
|
* This method receives a message object to update BigID regarding the current state of the action execution
|
|
14
14
|
* (should be used in case of an async actions)
|
|
@@ -22,20 +22,20 @@ export declare const updateActionStatusToBigID: (executionContext: ExecutionCont
|
|
|
22
22
|
* @param endpoint - the endpoint in BigID, used for GET request. e.g - {BigIDBaseUrl}/ds_connections
|
|
23
23
|
* @return - String containing the response from BigID
|
|
24
24
|
*/
|
|
25
|
-
export declare const executeHttpGet: (executionContext: ExecutionContext, endpoint: string) => Promise<any>;
|
|
25
|
+
export declare const executeHttpGet: (executionContext: ExecutionContext, endpoint: string, additionalHeaderFields?: Record<string, any>) => Promise<any>;
|
|
26
26
|
/**
|
|
27
27
|
* the endpoint in BigID, used for POST requests. e.g - {BigIDBaseUrl}/scan
|
|
28
28
|
*/
|
|
29
|
-
export declare const executeHttpPost: (executionContext: ExecutionContext, endpoint: string, obj: any) => Promise<any>;
|
|
29
|
+
export declare const executeHttpPost: (executionContext: ExecutionContext, endpoint: string, obj: any, additionalHeaderFields?: Record<string, any>) => Promise<any>;
|
|
30
30
|
/**
|
|
31
31
|
* the endpoint in BigID, used for POST requests. e.g - {BigIDBaseUrl}/scan
|
|
32
32
|
*/
|
|
33
|
-
export declare const executeHttpPut: (executionContext: ExecutionContext, endpoint: string, obj: any) => Promise<any>;
|
|
33
|
+
export declare const executeHttpPut: (executionContext: ExecutionContext, endpoint: string, obj: any, additionalHeaderFields?: Record<string, any>) => Promise<any>;
|
|
34
34
|
/**
|
|
35
35
|
* the endpoint in BigID, used for DELETE requests.
|
|
36
36
|
*/
|
|
37
|
-
export declare const executeHttpDelete: (executionContext: ExecutionContext, endpoint: string) => Promise<any>;
|
|
38
|
-
export declare const executePost: (requestMethod: RequestMethod, baseUrl: string | undefined, bodyJson: Record<string, any>) => Promise<any>;
|
|
37
|
+
export declare const executeHttpDelete: (executionContext: ExecutionContext, endpoint: string, additionalHeaderFields?: Record<string, any>) => Promise<any>;
|
|
38
|
+
export declare const executePost: (requestMethod: RequestMethod, baseUrl: string | undefined, bodyJson: Record<string, any>, additionalHeaderFields?: Record<string, any>) => Promise<any>;
|
|
39
39
|
export declare const uploadAttachment: (executionContext: ExecutionContext, filePathToUpload: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
40
40
|
export declare const getAppStorage: (executionContext: ExecutionContext) => Promise<any>;
|
|
41
41
|
export declare const getValueFromAppStorage: (executionContext: ExecutionContext, key: string) => Promise<string>;
|
|
@@ -31,14 +31,10 @@ const getTenantRegistrations = (bigidToken) => __awaiter(void 0, void 0, void 0,
|
|
|
31
31
|
return tenants;
|
|
32
32
|
});
|
|
33
33
|
exports.getTenantRegistrations = getTenantRegistrations;
|
|
34
|
-
const doCallToUrl = (bigidToken, requestMethod, endpoint, bodyJson) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const doCallToUrl = (bigidToken, requestMethod, endpoint, bodyJson, additionalHeaderFields) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
35
|
(0, utils_1.logInfo)(`--> bigid-proxy::callBigIdApi: [${requestMethod}] endpoint: ${endpoint}`);
|
|
36
36
|
try {
|
|
37
|
-
const headers = {
|
|
38
|
-
Accept: 'application/json, text/plain, */*',
|
|
39
|
-
'Content-Type': 'application/json',
|
|
40
|
-
Authorization: bigidToken,
|
|
41
|
-
};
|
|
37
|
+
const headers = Object.assign({ Accept: 'application/json, text/plain, */*', 'Content-Type': 'application/json', Authorization: bigidToken }, (additionalHeaderFields || {}));
|
|
42
38
|
const parsedUrl = new URL(endpoint);
|
|
43
39
|
parsedUrl.pathname = parsedUrl.pathname.replace(/\/+/g, '/');
|
|
44
40
|
const requestObj = {
|
|
@@ -63,10 +59,10 @@ const doCallToUrl = (bigidToken, requestMethod, endpoint, bodyJson) => __awaiter
|
|
|
63
59
|
}
|
|
64
60
|
});
|
|
65
61
|
exports.doCallToUrl = doCallToUrl;
|
|
66
|
-
function callBigIdApi(executionContext, requestMethod, endpoint,
|
|
62
|
+
function callBigIdApi(executionContext, requestMethod, endpoint, options) {
|
|
67
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const url = useEndpointWithoutBigIdBasePath ? endpoint : executionContext.bigidBaseUrl + endpoint;
|
|
69
|
-
return yield (0, exports.doCallToUrl)(executionContext.bigidToken, requestMethod, url, bodyJson);
|
|
64
|
+
const url = (options === null || options === void 0 ? void 0 : options.useEndpointWithoutBigIdBasePath) ? endpoint : executionContext.bigidBaseUrl + endpoint;
|
|
65
|
+
return yield (0, exports.doCallToUrl)(executionContext.bigidToken, requestMethod, url, options === null || options === void 0 ? void 0 : options.bodyJson, options === null || options === void 0 ? void 0 : options.additionalHeaderFields);
|
|
70
66
|
});
|
|
71
67
|
}
|
|
72
68
|
/**
|
|
@@ -76,7 +72,10 @@ function callBigIdApi(executionContext, requestMethod, endpoint, bodyJson, useEn
|
|
|
76
72
|
* @param actionResponseDetails
|
|
77
73
|
*/
|
|
78
74
|
const updateActionStatusToBigID = (executionContext, actionResponseDetails) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
return yield callBigIdApi(executionContext, RequestMethod.PUT, executionContext.updateResultCallback,
|
|
75
|
+
return yield callBigIdApi(executionContext, RequestMethod.PUT, executionContext.updateResultCallback, {
|
|
76
|
+
bodyJson: actionResponseDetails,
|
|
77
|
+
useEndpointWithoutBigIdBasePath: true
|
|
78
|
+
});
|
|
80
79
|
});
|
|
81
80
|
exports.updateActionStatusToBigID = updateActionStatusToBigID;
|
|
82
81
|
/**
|
|
@@ -85,31 +84,28 @@ exports.updateActionStatusToBigID = updateActionStatusToBigID;
|
|
|
85
84
|
* @param endpoint - the endpoint in BigID, used for GET request. e.g - {BigIDBaseUrl}/ds_connections
|
|
86
85
|
* @return - String containing the response from BigID
|
|
87
86
|
*/
|
|
88
|
-
const executeHttpGet = (executionContext, endpoint) => __awaiter(void 0, void 0, void 0, function* () { return yield callBigIdApi(executionContext, RequestMethod.GET, endpoint); });
|
|
87
|
+
const executeHttpGet = (executionContext, endpoint, additionalHeaderFields) => __awaiter(void 0, void 0, void 0, function* () { return yield callBigIdApi(executionContext, RequestMethod.GET, endpoint, { additionalHeaderFields }); });
|
|
89
88
|
exports.executeHttpGet = executeHttpGet;
|
|
90
89
|
/**
|
|
91
90
|
* the endpoint in BigID, used for POST requests. e.g - {BigIDBaseUrl}/scan
|
|
92
91
|
*/
|
|
93
|
-
const executeHttpPost = (executionContext, endpoint, obj) => __awaiter(void 0, void 0, void 0, function* () { return yield callBigIdApi(executionContext, RequestMethod.POST, endpoint, obj); });
|
|
92
|
+
const executeHttpPost = (executionContext, endpoint, obj, additionalHeaderFields) => __awaiter(void 0, void 0, void 0, function* () { return yield callBigIdApi(executionContext, RequestMethod.POST, endpoint, { bodyJson: obj, additionalHeaderFields }); });
|
|
94
93
|
exports.executeHttpPost = executeHttpPost;
|
|
95
94
|
/**
|
|
96
95
|
* the endpoint in BigID, used for POST requests. e.g - {BigIDBaseUrl}/scan
|
|
97
96
|
*/
|
|
98
|
-
const executeHttpPut = (executionContext, endpoint, obj) => __awaiter(void 0, void 0, void 0, function* () { return yield callBigIdApi(executionContext, RequestMethod.PUT, endpoint, obj); });
|
|
97
|
+
const executeHttpPut = (executionContext, endpoint, obj, additionalHeaderFields) => __awaiter(void 0, void 0, void 0, function* () { return yield callBigIdApi(executionContext, RequestMethod.PUT, endpoint, { bodyJson: obj, additionalHeaderFields }); });
|
|
99
98
|
exports.executeHttpPut = executeHttpPut;
|
|
100
99
|
/**
|
|
101
100
|
* the endpoint in BigID, used for DELETE requests.
|
|
102
101
|
*/
|
|
103
|
-
const executeHttpDelete = (executionContext, endpoint) => __awaiter(void 0, void 0, void 0, function* () { return yield callBigIdApi(executionContext, RequestMethod.DELETE, endpoint); });
|
|
102
|
+
const executeHttpDelete = (executionContext, endpoint, additionalHeaderFields) => __awaiter(void 0, void 0, void 0, function* () { return yield callBigIdApi(executionContext, RequestMethod.DELETE, endpoint, { additionalHeaderFields }); });
|
|
104
103
|
exports.executeHttpDelete = executeHttpDelete;
|
|
105
|
-
const executePost = (requestMethod, baseUrl, bodyJson) => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
+
const executePost = (requestMethod, baseUrl, bodyJson, additionalHeaderFields) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
105
|
var _a, _b, _c, _d, _e, _f;
|
|
107
106
|
try {
|
|
108
107
|
const url = baseUrl + 'api/v1/sessions';
|
|
109
|
-
const headers = {
|
|
110
|
-
Accept: 'application/json',
|
|
111
|
-
'Content-type': 'application/json',
|
|
112
|
-
};
|
|
108
|
+
const headers = Object.assign({ Accept: 'application/json', 'Content-type': 'application/json' }, (additionalHeaderFields || {}));
|
|
113
109
|
const requestObj = {
|
|
114
110
|
method: requestMethod,
|
|
115
111
|
url: url,
|
package/log/app.log
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
[2025-01-23T09:45:58.982] [INFO] default - --> bigid-proxy::callBigIdApi: [get] endpoint: https://bigid-ui:9090/api/v1/id_connections
|
|
2
|
+
[2025-01-23T09:45:58.995] [INFO] default - <-- bigid-proxy::callBigIdApi: https://bigid-ui:9090/api/v1/id_connections success
|
|
3
|
+
[2025-01-23T09:45:58.998] [INFO] default - --> bigid-proxy::callBigIdApi: [post] endpoint: https://bigid-ui:9090/api/v1/id_connections
|
|
4
|
+
[2025-01-23T09:45:59.002] [INFO] default - <-- bigid-proxy::callBigIdApi: https://bigid-ui:9090/api/v1/id_connections success
|
|
5
|
+
[2025-01-23T09:45:59.003] [INFO] default - --> bigid-proxy::callBigIdApi: [put] endpoint: https://bigid-ui:9090/api/v1/id_connections
|
|
6
|
+
[2025-01-23T09:45:59.006] [INFO] default - <-- bigid-proxy::callBigIdApi: https://bigid-ui:9090/api/v1/id_connections success
|
|
7
|
+
[2025-01-23T09:45:59.007] [INFO] default - --> bigid-proxy::callBigIdApi: [delete] endpoint: https://bigid-ui:9090/api/v1/id_connections
|
|
8
|
+
[2025-01-23T09:45:59.011] [INFO] default - <-- bigid-proxy::callBigIdApi: https://bigid-ui:9090/api/v1/id_connections success
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigid/apps-infrastructure-node-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.220.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"docs": "npx tsc && ./node_modules/.bin/jsdoc -c jsdoc.json",
|
|
8
|
-
"test": "mocha 'test/**/*.ts'"
|
|
8
|
+
"test": "mocha --require ts-node/register --require source-map-support/register 'test/**/*.ts'"
|
|
9
9
|
},
|
|
10
10
|
"types": "lib/index.d.ts",
|
|
11
11
|
"repository": {
|
|
@@ -15,18 +15,22 @@
|
|
|
15
15
|
"author": "Shay Sheli",
|
|
16
16
|
"homepage": "https://github.com/bigexchange/apps-infrastructure-node-js#readme",
|
|
17
17
|
"devDependencies": {
|
|
18
|
+
"@types/chai": "^4.3.20",
|
|
18
19
|
"@types/express": "^4.17.13",
|
|
19
20
|
"@types/http-errors": "^1.8.1",
|
|
20
21
|
"@types/mocha": "10.0.3",
|
|
22
|
+
"@types/nock": "^11.1.0",
|
|
21
23
|
"@types/node": "^16.11.10",
|
|
22
24
|
"@types/node-schedule": "^2.1.0",
|
|
23
25
|
"@typescript-eslint/eslint-plugin": "4.6.1",
|
|
24
26
|
"@typescript-eslint/parser": "4.6.1",
|
|
27
|
+
"chai": "4.5.0",
|
|
25
28
|
"eslint": "7.12.1",
|
|
26
29
|
"eslint-config-prettier": "^6.15.0",
|
|
27
30
|
"eslint-plugin-no-only-tests": "2.4.0",
|
|
28
31
|
"eslint-plugin-prettier": "^3.1.4",
|
|
29
32
|
"jsdoc": "4.0.2",
|
|
33
|
+
"nock": "^13.5.6",
|
|
30
34
|
"prettier": "^2.4.1",
|
|
31
35
|
"typescript": "^4.5.2"
|
|
32
36
|
},
|
|
@@ -15,6 +15,12 @@ export enum RequestMethod {
|
|
|
15
15
|
DELETE = 'delete',
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
interface BigIdApiRequestOptions {
|
|
19
|
+
bodyJson?: ActionResponseDetails;
|
|
20
|
+
useEndpointWithoutBigIdBasePath?: boolean;
|
|
21
|
+
additionalHeaderFields?: Record<string, any>;
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
export const getTenantRegistrations = async (bigidToken: string): Promise<TenantRegistration[]> => {
|
|
19
25
|
const {
|
|
20
26
|
data: {
|
|
@@ -32,6 +38,7 @@ export const doCallToUrl = async (
|
|
|
32
38
|
requestMethod: RequestMethod,
|
|
33
39
|
endpoint: string,
|
|
34
40
|
bodyJson?: Record<string, any>,
|
|
41
|
+
additionalHeaderFields?: Record<string, any>,
|
|
35
42
|
) => {
|
|
36
43
|
logInfo(`--> bigid-proxy::callBigIdApi: [${requestMethod}] endpoint: ${endpoint}`);
|
|
37
44
|
try {
|
|
@@ -39,6 +46,7 @@ export const doCallToUrl = async (
|
|
|
39
46
|
Accept: 'application/json, text/plain, */*',
|
|
40
47
|
'Content-Type': 'application/json',
|
|
41
48
|
Authorization: bigidToken,
|
|
49
|
+
...(additionalHeaderFields || {}),
|
|
42
50
|
};
|
|
43
51
|
const parsedUrl = new URL(endpoint);
|
|
44
52
|
parsedUrl.pathname = parsedUrl.pathname.replace(/\/+/g, '/');
|
|
@@ -71,11 +79,10 @@ async function callBigIdApi(
|
|
|
71
79
|
executionContext: ExecutionContext,
|
|
72
80
|
requestMethod: RequestMethod,
|
|
73
81
|
endpoint: string,
|
|
74
|
-
|
|
75
|
-
useEndpointWithoutBigIdBasePath?: boolean,
|
|
82
|
+
options: BigIdApiRequestOptions,
|
|
76
83
|
) {
|
|
77
|
-
const url = useEndpointWithoutBigIdBasePath ? endpoint : executionContext.bigidBaseUrl + endpoint;
|
|
78
|
-
return await doCallToUrl(executionContext.bigidToken, requestMethod, url, bodyJson);
|
|
84
|
+
const url = options?.useEndpointWithoutBigIdBasePath ? endpoint : executionContext.bigidBaseUrl + endpoint;
|
|
85
|
+
return await doCallToUrl(executionContext.bigidToken, requestMethod, url, options?.bodyJson, options?.additionalHeaderFields);
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
/**
|
|
@@ -92,8 +99,10 @@ export const updateActionStatusToBigID = async (
|
|
|
92
99
|
executionContext,
|
|
93
100
|
RequestMethod.PUT,
|
|
94
101
|
executionContext.updateResultCallback,
|
|
95
|
-
|
|
96
|
-
|
|
102
|
+
{
|
|
103
|
+
bodyJson: actionResponseDetails,
|
|
104
|
+
useEndpointWithoutBigIdBasePath: true
|
|
105
|
+
}
|
|
97
106
|
);
|
|
98
107
|
|
|
99
108
|
/**
|
|
@@ -102,37 +111,39 @@ export const updateActionStatusToBigID = async (
|
|
|
102
111
|
* @param endpoint - the endpoint in BigID, used for GET request. e.g - {BigIDBaseUrl}/ds_connections
|
|
103
112
|
* @return - String containing the response from BigID
|
|
104
113
|
*/
|
|
105
|
-
export const executeHttpGet = async (executionContext: ExecutionContext, endpoint: string) =>
|
|
106
|
-
await callBigIdApi(executionContext, RequestMethod.GET, endpoint);
|
|
114
|
+
export const executeHttpGet = async (executionContext: ExecutionContext, endpoint: string, additionalHeaderFields?: Record<string, any>) =>
|
|
115
|
+
await callBigIdApi(executionContext, RequestMethod.GET, endpoint, { additionalHeaderFields });
|
|
107
116
|
|
|
108
117
|
/**
|
|
109
118
|
* the endpoint in BigID, used for POST requests. e.g - {BigIDBaseUrl}/scan
|
|
110
119
|
*/
|
|
111
|
-
export const executeHttpPost = async (executionContext: ExecutionContext, endpoint: string, obj: any) =>
|
|
112
|
-
await callBigIdApi(executionContext, RequestMethod.POST, endpoint, obj);
|
|
120
|
+
export const executeHttpPost = async (executionContext: ExecutionContext, endpoint: string, obj: any, additionalHeaderFields?: Record<string, any>) =>
|
|
121
|
+
await callBigIdApi(executionContext, RequestMethod.POST, endpoint, { bodyJson: obj, additionalHeaderFields });
|
|
113
122
|
|
|
114
123
|
/**
|
|
115
124
|
* the endpoint in BigID, used for POST requests. e.g - {BigIDBaseUrl}/scan
|
|
116
125
|
*/
|
|
117
|
-
export const executeHttpPut = async (executionContext: ExecutionContext, endpoint: string, obj: any) =>
|
|
118
|
-
await callBigIdApi(executionContext, RequestMethod.PUT, endpoint, obj);
|
|
126
|
+
export const executeHttpPut = async (executionContext: ExecutionContext, endpoint: string, obj: any, additionalHeaderFields?: Record<string, any>) =>
|
|
127
|
+
await callBigIdApi(executionContext, RequestMethod.PUT, endpoint, { bodyJson: obj, additionalHeaderFields });
|
|
119
128
|
|
|
120
129
|
/**
|
|
121
130
|
* the endpoint in BigID, used for DELETE requests.
|
|
122
131
|
*/
|
|
123
|
-
export const executeHttpDelete = async (executionContext: ExecutionContext, endpoint: string) =>
|
|
124
|
-
await callBigIdApi(executionContext, RequestMethod.DELETE, endpoint);
|
|
132
|
+
export const executeHttpDelete = async (executionContext: ExecutionContext, endpoint: string, additionalHeaderFields?: Record<string, any>) =>
|
|
133
|
+
await callBigIdApi(executionContext, RequestMethod.DELETE, endpoint, { additionalHeaderFields });
|
|
125
134
|
|
|
126
135
|
export const executePost = async (
|
|
127
136
|
requestMethod: RequestMethod,
|
|
128
137
|
baseUrl: string | undefined,
|
|
129
138
|
bodyJson: Record<string, any>,
|
|
139
|
+
additionalHeaderFields?: Record<string, any>
|
|
130
140
|
) => {
|
|
131
141
|
try {
|
|
132
142
|
const url = baseUrl + 'api/v1/sessions';
|
|
133
143
|
const headers = {
|
|
134
144
|
Accept: 'application/json',
|
|
135
145
|
'Content-type': 'application/json',
|
|
146
|
+
...(additionalHeaderFields || {}),
|
|
136
147
|
};
|
|
137
148
|
const requestObj: Record<string, any> = {
|
|
138
149
|
method: requestMethod,
|
package/test/mock.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const mockExecutionContext = {
|
|
2
|
+
actionName: 'helloWorld',
|
|
3
|
+
executionId: '6787da8066db56a1866ccb82',
|
|
4
|
+
presetId: '6787d2a566db56a1866c8ea7',
|
|
5
|
+
globalParams: [
|
|
6
|
+
{
|
|
7
|
+
paramName: 'username',
|
|
8
|
+
paramValue: 'admin',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
paramName: 'password',
|
|
12
|
+
paramValue: 'admin',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
actionParams: [
|
|
16
|
+
{
|
|
17
|
+
paramName: 'idConnectionName',
|
|
18
|
+
paramValue: 'identity source',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
bigidToken:
|
|
22
|
+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJiaWdpZC13ZWIiLCJpc0FkbWluIjp0cnVlLCJyb2xlSWRzIjpbInN5c3RlbSJdLCJ0eXBlIjoiYWNjZXNzLXRva2VuIiwidGVuYW50SWQiOiJTSU5HTEVfVEVOQU5UIiwiaWF0IjoxNzM2OTU2NTQ0LCJleHAiOjE3Mzc1NjEzNDR9.jlcHlT8uKxHA615NGAxIsM8-Cgvda3aOuy2Lji_u5hk',
|
|
23
|
+
updateResultCallback: 'https://bigid-ui:9090/api/v1/tpa/executions/6787da8066db56a1866ccb82',
|
|
24
|
+
bigidBaseUrl: 'https://bigid-ui:9090/api/v1/',
|
|
25
|
+
tpaId: '6787d2a566db56a1866c8e9d',
|
|
26
|
+
tpaName: 'Basic demo Nodejs app',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const mockBaseUrl = 'https://bigid-ui:9090/api/v1';
|
|
30
|
+
|
|
31
|
+
export const mockDataResponse = { Response: 'ok' };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import nock = require("nock");
|
|
3
|
+
import {
|
|
4
|
+
executeHttpGet,
|
|
5
|
+
executeHttpPost,
|
|
6
|
+
executeHttpPut,
|
|
7
|
+
executeHttpDelete,
|
|
8
|
+
} from '../../../src/services/bigidProxyService';
|
|
9
|
+
import { mockExecutionContext, mockBaseUrl, mockDataResponse } from '../../mock';
|
|
10
|
+
|
|
11
|
+
describe('Main api requests unit tests', () => {
|
|
12
|
+
const apiUrl = 'id_connections';
|
|
13
|
+
const modifiedHeader = { AdditionalFieldName: 'AdditionalFieldValue' };
|
|
14
|
+
const expectedFieldName = 'AdditionalFieldName';
|
|
15
|
+
const expectedFieldValue = 'AdditionalFieldValue';
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
nock.cleanAll();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('Should verify modified header for executeHttpGet request', async () => {
|
|
22
|
+
nock(mockBaseUrl).get(`/${apiUrl}`).matchHeader(expectedFieldName,expectedFieldValue).reply(200, mockDataResponse);
|
|
23
|
+
const response = await executeHttpGet(mockExecutionContext, apiUrl, modifiedHeader);
|
|
24
|
+
expect(response.data).to.deep.equal(mockDataResponse);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('Should verify modified header for executeHttpPost request', async () => {
|
|
28
|
+
nock(mockBaseUrl).post(`/${apiUrl}`).matchHeader(expectedFieldName,expectedFieldValue).reply(200, mockDataResponse);
|
|
29
|
+
const response = await executeHttpPost(mockExecutionContext, apiUrl, undefined, modifiedHeader);
|
|
30
|
+
expect(response.data).to.deep.equal(mockDataResponse);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('Should verify modified header for executeHttpPut request', async () => {
|
|
34
|
+
nock(mockBaseUrl).put(`/${apiUrl}`).matchHeader(expectedFieldName,expectedFieldValue).reply(200, mockDataResponse);
|
|
35
|
+
const response = await executeHttpPut(mockExecutionContext, apiUrl, undefined, modifiedHeader);
|
|
36
|
+
expect(response.data).to.deep.equal(mockDataResponse);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('Should verify modified header for executeHttpDelete request', async () => {
|
|
40
|
+
nock(mockBaseUrl).delete(`/${apiUrl}`).matchHeader(expectedFieldName,expectedFieldValue).reply(200, mockDataResponse);
|
|
41
|
+
const response = await executeHttpDelete(mockExecutionContext, apiUrl, modifiedHeader);
|
|
42
|
+
expect(response.data).to.deep.equal(mockDataResponse);
|
|
43
|
+
});
|
|
44
|
+
});
|