@itentialopensource/adapter-gcp_compute 1.8.6 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +1 -0
- package/AUTH.md +4 -4
- package/BROKER.md +4 -4
- package/CALLS.md +9 -9
- package/ENHANCE.md +3 -3
- package/PROPERTIES.md +24 -9
- package/README.md +24 -23
- package/SUMMARY.md +2 -2
- package/SYSTEMINFO.md +1 -1
- package/TAB1.md +2 -2
- package/TAB2.md +9 -5
- package/TROUBLESHOOT.md +10 -1
- package/UTILITIES.md +473 -0
- package/adapter.js +5 -5
- package/adapterBase.js +52 -16
- package/package.json +25 -29
- package/pronghorn.json +15 -13
- package/propertiesSchema.json +68 -7
- package/report/adapterInfo.json +7 -7
- package/report/updateReport1748555599881.json +120 -0
- package/sampleProperties.json +4 -0
- package/test/integration/adapterTestBasicGet.js +88 -54
- package/test/integration/adapterTestConnectivity.js +15 -16
- package/test/integration/adapterTestIntegration.js +12 -45
- package/test/unit/adapterBaseTestUnit.js +641 -39
- package/test/unit/adapterTestUnit.js +28 -61
- package/utils/adapterInfo.js +114 -164
- package/utils/argParser.js +44 -0
- package/utils/checkMigrate.js +77 -38
- package/utils/entitiesToDB.js +53 -42
- package/utils/logger.js +26 -0
- package/utils/modify.js +56 -55
- package/utils/mongoDbConnection.js +79 -0
- package/utils/mongoUtils.js +162 -0
- package/utils/taskMover.js +31 -32
- package/utils/tbScript.js +36 -172
- package/utils/tbUtils.js +84 -226
- package/utils/troubleshootingAdapter.js +68 -84
- package/utils/updateAdapterConfig.js +158 -0
- package/utils/addAuth.js +0 -94
- package/utils/artifactize.js +0 -146
- package/utils/basicGet.js +0 -50
- package/utils/packModificationScript.js +0 -35
- package/utils/patches2bundledDeps.js +0 -90
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itentialopensource/adapter-gcp_compute",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "This adapter integrates with system described as: computeEngineApi.",
|
|
5
5
|
"main": "adapter.js",
|
|
6
6
|
"systemName": "Google Cloud Platform Compute",
|
|
7
7
|
"wizardVersion": "2.44.7",
|
|
8
|
-
"engineVersion": "1.
|
|
8
|
+
"engineVersion": "1.69.14",
|
|
9
9
|
"adapterType": "http",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"artifactize": "npm i && node utils/packModificationScript.js",
|
|
12
11
|
"preinstall": "node utils/setup.js",
|
|
13
12
|
"deinstall": "node utils/removeHooks.js",
|
|
14
13
|
"lint": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js",
|
|
@@ -17,7 +16,6 @@
|
|
|
17
16
|
"test:unit": "mocha test/unit/adapterTestUnit.js --LOG=error",
|
|
18
17
|
"test:integration": "mocha test/integration/adapterTestIntegration.js --LOG=error",
|
|
19
18
|
"test": "npm run test:baseunit && npm run test:unit && npm run test:integration",
|
|
20
|
-
"adapter:install": "npm i && node utils/tbScript.js install",
|
|
21
19
|
"adapter:checkMigrate": "node utils/checkMigrate.js",
|
|
22
20
|
"adapter:findPath": "node utils/findPath.js",
|
|
23
21
|
"adapter:migrate": "node utils/modify.js -m",
|
|
@@ -32,10 +30,9 @@
|
|
|
32
30
|
},
|
|
33
31
|
"keywords": [
|
|
34
32
|
"Itential",
|
|
35
|
-
"
|
|
33
|
+
"Itential Platform",
|
|
36
34
|
"Automation",
|
|
37
35
|
"Integration",
|
|
38
|
-
"App-Artifacts",
|
|
39
36
|
"Adapter",
|
|
40
37
|
"Cloud",
|
|
41
38
|
"Google",
|
|
@@ -55,31 +52,30 @@
|
|
|
55
52
|
"author": "Itential",
|
|
56
53
|
"homepage": "https://gitlab.com/itentialopensource/adapters/adapter-gcp_compute#readme",
|
|
57
54
|
"dependencies": {
|
|
58
|
-
"@itentialopensource/adapter-utils": "
|
|
59
|
-
"acorn": "
|
|
60
|
-
"ajv": "
|
|
61
|
-
"axios": "
|
|
62
|
-
"commander": "
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"mocha": "
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"winston": "^3.17.0"
|
|
55
|
+
"@itentialopensource/adapter-utils": "5.10.16",
|
|
56
|
+
"acorn": "8.14.1",
|
|
57
|
+
"ajv": "8.17.1",
|
|
58
|
+
"axios": "1.9.0",
|
|
59
|
+
"commander": "11.1.0",
|
|
60
|
+
"fs-extra": "11.3.0",
|
|
61
|
+
"gtoken": "5.3.2",
|
|
62
|
+
"json-query": "2.2.2",
|
|
63
|
+
"mocha": "10.8.2",
|
|
64
|
+
"mocha-param": "2.0.1",
|
|
65
|
+
"mongodb": "4.17.2",
|
|
66
|
+
"ping": "0.4.4",
|
|
67
|
+
"prompts": "2.4.2",
|
|
68
|
+
"readline-sync": "1.4.10",
|
|
69
|
+
"semver": "7.7.2",
|
|
70
|
+
"winston": "3.17.0"
|
|
75
71
|
},
|
|
76
72
|
"devDependencies": {
|
|
77
|
-
"chai": "
|
|
78
|
-
"eslint": "
|
|
79
|
-
"eslint-config-airbnb-base": "
|
|
80
|
-
"eslint-plugin-import": "
|
|
81
|
-
"eslint-plugin-json": "
|
|
82
|
-
"testdouble": "
|
|
73
|
+
"chai": "4.5.0",
|
|
74
|
+
"eslint": "8.57.0",
|
|
75
|
+
"eslint-config-airbnb-base": "15.0.0",
|
|
76
|
+
"eslint-plugin-import": "2.31.0",
|
|
77
|
+
"eslint-plugin-json": "3.1.0",
|
|
78
|
+
"testdouble": "3.18.0"
|
|
83
79
|
},
|
|
84
80
|
"private": false
|
|
85
81
|
}
|
package/pronghorn.json
CHANGED
|
@@ -226,16 +226,6 @@
|
|
|
226
226
|
"title": "props",
|
|
227
227
|
"type": "object"
|
|
228
228
|
}
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
"name": "persistFlag",
|
|
232
|
-
"type": "boolean",
|
|
233
|
-
"info": "Whether the input properties should be saved",
|
|
234
|
-
"required": true,
|
|
235
|
-
"schema": {
|
|
236
|
-
"title": "persistFlag",
|
|
237
|
-
"type": "boolean"
|
|
238
|
-
}
|
|
239
229
|
}
|
|
240
230
|
],
|
|
241
231
|
"output": {
|
|
@@ -306,7 +296,19 @@
|
|
|
306
296
|
"name": "iapRunAdapterBasicGet",
|
|
307
297
|
"summary": "Runs basicGet script for adapter",
|
|
308
298
|
"description": "Runs basicGet script for adapter",
|
|
309
|
-
"input": [
|
|
299
|
+
"input": [
|
|
300
|
+
{
|
|
301
|
+
"name": "maxCalls",
|
|
302
|
+
"required": false,
|
|
303
|
+
"type": "number",
|
|
304
|
+
"info": "How many GET endpoints to test (defaults to 5)",
|
|
305
|
+
"schema": {
|
|
306
|
+
"title": "maxCalls",
|
|
307
|
+
"type": "number",
|
|
308
|
+
"default": 5
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
],
|
|
310
312
|
"output": {
|
|
311
313
|
"name": "result",
|
|
312
314
|
"type": "object",
|
|
@@ -327,8 +329,8 @@
|
|
|
327
329
|
},
|
|
328
330
|
{
|
|
329
331
|
"name": "iapMoveAdapterEntitiesToDB",
|
|
330
|
-
"summary": "Moves entities from an adapter into the
|
|
331
|
-
"description": "Moves entities from an adapter into the
|
|
332
|
+
"summary": "Moves entities from an adapter into the Itential Platform database",
|
|
333
|
+
"description": "Moves entities from an adapter into the Itential Platform database",
|
|
332
334
|
"input": [],
|
|
333
335
|
"output": {
|
|
334
336
|
"name": "res",
|
package/propertiesSchema.json
CHANGED
|
@@ -810,6 +810,14 @@
|
|
|
810
810
|
"security/ca.pem"
|
|
811
811
|
]
|
|
812
812
|
},
|
|
813
|
+
"ca_file_content": {
|
|
814
|
+
"type": "string",
|
|
815
|
+
"description": "The content of the CA file used for SSL",
|
|
816
|
+
"default": "",
|
|
817
|
+
"examples": [
|
|
818
|
+
"-----BEGIN CERTIFICATE-----"
|
|
819
|
+
]
|
|
820
|
+
},
|
|
813
821
|
"key_file": {
|
|
814
822
|
"type": "string",
|
|
815
823
|
"description": "The fully qualified path name to the key file used for SSL",
|
|
@@ -899,32 +907,48 @@
|
|
|
899
907
|
"mongo": {
|
|
900
908
|
"type": "object",
|
|
901
909
|
"properties": {
|
|
910
|
+
"url": {
|
|
911
|
+
"type": "string",
|
|
912
|
+
"description": "Mongo's complete connection URL. This property overrides host, port, database, username, password and replSet settings.",
|
|
913
|
+
"examples": [
|
|
914
|
+
"mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]",
|
|
915
|
+
"mongodb+srv://[username:password@]cluster0.xxxxx.mongodb.net/[defaultauthdb][?options]",
|
|
916
|
+
"mongodb+srv://cluster0.xxxxx.mongodb.net/[defaultauthdb][?options]"
|
|
917
|
+
]
|
|
918
|
+
},
|
|
902
919
|
"host": {
|
|
903
920
|
"type": "string",
|
|
904
|
-
"description": "
|
|
921
|
+
"description": "Host information for the Mongo server",
|
|
905
922
|
"default": "",
|
|
906
923
|
"examples": [
|
|
907
|
-
"localhost"
|
|
924
|
+
"localhost",
|
|
925
|
+
"cluster0.xxxxx.mongodb.net",
|
|
926
|
+
"my-cluster.example.com"
|
|
908
927
|
]
|
|
909
928
|
},
|
|
910
929
|
"port": {
|
|
911
930
|
"type": "integer",
|
|
912
|
-
"description": "
|
|
931
|
+
"description": "Port information for the Mongo server. Not used when using mongodb+srv:// protocol",
|
|
913
932
|
"default": 443,
|
|
914
933
|
"minimum": 0,
|
|
915
934
|
"maximum": 65535
|
|
916
935
|
},
|
|
917
936
|
"database": {
|
|
918
937
|
"type": "string",
|
|
919
|
-
"description": "The
|
|
938
|
+
"description": "The database for the adapter to use for its data.",
|
|
920
939
|
"default": "",
|
|
921
940
|
"examples": [
|
|
922
941
|
"adapter-xyz"
|
|
923
942
|
]
|
|
924
943
|
},
|
|
944
|
+
"dbAuth": {
|
|
945
|
+
"type": "boolean",
|
|
946
|
+
"description": "Whether to use authentication for MongoDB connection. Default is false.",
|
|
947
|
+
"default": false
|
|
948
|
+
},
|
|
925
949
|
"username": {
|
|
926
950
|
"type": "string",
|
|
927
|
-
"description": "
|
|
951
|
+
"description": "If credentials are required to access Mongo, this is the user to login as.",
|
|
928
952
|
"default": "",
|
|
929
953
|
"examples": [
|
|
930
954
|
"username"
|
|
@@ -932,7 +956,7 @@
|
|
|
932
956
|
},
|
|
933
957
|
"password": {
|
|
934
958
|
"type": "string",
|
|
935
|
-
"description": "
|
|
959
|
+
"description": "If credentials are required to access Mongo, this is the password to login with.",
|
|
936
960
|
"default": "",
|
|
937
961
|
"examples": [
|
|
938
962
|
"password"
|
|
@@ -940,12 +964,17 @@
|
|
|
940
964
|
},
|
|
941
965
|
"replSet": {
|
|
942
966
|
"type": "string",
|
|
943
|
-
"description": "
|
|
967
|
+
"description": "If the database is set up to use replica sets, define it here so it can be added to the database connection. Not used when using mongodb+srv:// protocol",
|
|
944
968
|
"default": "",
|
|
945
969
|
"examples": [
|
|
946
970
|
"my_repolica_set"
|
|
947
971
|
]
|
|
948
972
|
},
|
|
973
|
+
"addSrv": {
|
|
974
|
+
"type": "boolean",
|
|
975
|
+
"description": "Whether the connection requires the mongodb+srv:// protocol. If true, uses mongodb+srv:// protocol. Note: mongodb+srv:// can also be used for non-Atlas deployments that support DNS SRV records",
|
|
976
|
+
"default": false
|
|
977
|
+
},
|
|
949
978
|
"db_ssl": {
|
|
950
979
|
"type": "object",
|
|
951
980
|
"description": "SSL for mongo database connection",
|
|
@@ -986,6 +1015,38 @@
|
|
|
986
1015
|
}
|
|
987
1016
|
}
|
|
988
1017
|
}
|
|
1018
|
+
},
|
|
1019
|
+
"dependencies": {
|
|
1020
|
+
"dbAuth": {
|
|
1021
|
+
"oneOf": [
|
|
1022
|
+
{
|
|
1023
|
+
"properties": {
|
|
1024
|
+
"dbAuth": {
|
|
1025
|
+
"const": false
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
"properties": {
|
|
1031
|
+
"dbAuth": {
|
|
1032
|
+
"const": true
|
|
1033
|
+
},
|
|
1034
|
+
"username": {
|
|
1035
|
+
"type": "string",
|
|
1036
|
+
"minLength": 1
|
|
1037
|
+
},
|
|
1038
|
+
"password": {
|
|
1039
|
+
"type": "string",
|
|
1040
|
+
"minLength": 1
|
|
1041
|
+
}
|
|
1042
|
+
},
|
|
1043
|
+
"required": [
|
|
1044
|
+
"username",
|
|
1045
|
+
"password"
|
|
1046
|
+
]
|
|
1047
|
+
}
|
|
1048
|
+
]
|
|
1049
|
+
}
|
|
989
1050
|
}
|
|
990
1051
|
},
|
|
991
1052
|
"devicebroker": {
|
package/report/adapterInfo.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.8.
|
|
3
|
-
"configLines":
|
|
4
|
-
"scriptLines":
|
|
5
|
-
"codeLines":
|
|
6
|
-
"testLines":
|
|
7
|
-
"testCases":
|
|
8
|
-
"totalCodeLines":
|
|
2
|
+
"version": "1.8.6",
|
|
3
|
+
"configLines": 92449,
|
|
4
|
+
"scriptLines": 2498,
|
|
5
|
+
"codeLines": 57427,
|
|
6
|
+
"testLines": 62273,
|
|
7
|
+
"testCases": 2522,
|
|
8
|
+
"totalCodeLines": 122198,
|
|
9
9
|
"wfTasks": 583
|
|
10
10
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
"errors": [],
|
|
3
|
+
"statistics": [
|
|
4
|
+
{
|
|
5
|
+
"owner": "errorJson",
|
|
6
|
+
"description": "New adapter errors available for use",
|
|
7
|
+
"value": 0
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"owner": "errorJson",
|
|
11
|
+
"description": "Adapter errors no longer available for use",
|
|
12
|
+
"value": 0
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"owner": "errorJson",
|
|
16
|
+
"description": "Adapter errors that have been updated (e.g. recommendation changes)",
|
|
17
|
+
"value": 31
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"owner": "packageJson",
|
|
21
|
+
"description": "Number of production dependencies",
|
|
22
|
+
"value": 15
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"owner": "packageJson",
|
|
26
|
+
"description": "Number of development dependencies",
|
|
27
|
+
"value": 6
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"owner": "packageJson",
|
|
31
|
+
"description": "Number of npm scripts",
|
|
32
|
+
"value": 19
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"owner": "packageJson",
|
|
36
|
+
"description": "Runtime Library dependency",
|
|
37
|
+
"value": "5.10.16"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"owner": "propertiesSchemaJson",
|
|
41
|
+
"description": "Adapter properties defined in the propertiesSchema file",
|
|
42
|
+
"value": 80
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"owner": "markdown",
|
|
46
|
+
"description": "Number of lines in the README.md",
|
|
47
|
+
"value": 345
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"owner": "markdown",
|
|
51
|
+
"description": "Number of lines in the SUMMARY.md",
|
|
52
|
+
"value": 9
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"owner": "markdown",
|
|
56
|
+
"description": "Number of lines in the PROPERTIES.md",
|
|
57
|
+
"value": 662
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"owner": "markdown",
|
|
61
|
+
"description": "Number of lines in the TROUBLESHOOT.md",
|
|
62
|
+
"value": 57
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"owner": "markdown",
|
|
66
|
+
"description": "Number of lines in the ENHANCE.md",
|
|
67
|
+
"value": 70
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"owner": "markdown",
|
|
71
|
+
"description": "Number of lines in the BROKER.md",
|
|
72
|
+
"value": 70
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"owner": "unitTestJS",
|
|
76
|
+
"description": "Number of lines of code in unit tests",
|
|
77
|
+
"value": 29137
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"owner": "unitTestJS",
|
|
81
|
+
"description": "Number of unit tests",
|
|
82
|
+
"value": 1865
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"owner": "integrationTestJS",
|
|
86
|
+
"description": "Number of lines of code in integration tests",
|
|
87
|
+
"value": 31273
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"owner": "integrationTestJS",
|
|
91
|
+
"description": "Number of integration tests",
|
|
92
|
+
"value": 567
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"owner": "staticFile",
|
|
96
|
+
"description": "Number of lines of code in adapterBase.js",
|
|
97
|
+
"value": 1489
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"owner": "staticFile",
|
|
101
|
+
"description": "Number of static files added",
|
|
102
|
+
"value": 37
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"owner": "Overall",
|
|
106
|
+
"description": "Total lines of Code",
|
|
107
|
+
"value": 61899
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"owner": "Overall",
|
|
111
|
+
"description": "Total Tests",
|
|
112
|
+
"value": 2432
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"owner": "Overall",
|
|
116
|
+
"description": "Total Files",
|
|
117
|
+
"value": 6
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
package/sampleProperties.json
CHANGED
|
@@ -104,18 +104,22 @@
|
|
|
104
104
|
"enabled": false,
|
|
105
105
|
"accept_invalid_cert": false,
|
|
106
106
|
"ca_file": "",
|
|
107
|
+
"ca_file_content": "",
|
|
107
108
|
"key_file": "",
|
|
108
109
|
"cert_file": "",
|
|
109
110
|
"secure_protocol": "",
|
|
110
111
|
"ciphers": ""
|
|
111
112
|
},
|
|
112
113
|
"mongo": {
|
|
114
|
+
"url": "",
|
|
113
115
|
"host": "",
|
|
114
116
|
"port": 0,
|
|
115
117
|
"database": "",
|
|
118
|
+
"dbAuth": false,
|
|
116
119
|
"username": "",
|
|
117
120
|
"password": "",
|
|
118
121
|
"replSet": "",
|
|
122
|
+
"addSrv": false,
|
|
119
123
|
"db_ssl": {
|
|
120
124
|
"enabled": false,
|
|
121
125
|
"accept_invalid_cert": false,
|
|
@@ -1,83 +1,117 @@
|
|
|
1
1
|
/* @copyright Itential, LLC 2020 */
|
|
2
2
|
|
|
3
|
-
/* global describe
|
|
3
|
+
/* global describe it log before after */
|
|
4
4
|
/* eslint global-require: warn */
|
|
5
5
|
/* eslint no-unused-vars: warn */
|
|
6
6
|
/* eslint import/no-extraneous-dependencies: warn */
|
|
7
7
|
/* eslint import/no-dynamic-require: warn */
|
|
8
8
|
/* eslint import/no-unresolved: warn */
|
|
9
|
+
/* eslint no-loop-func: warn */
|
|
10
|
+
|
|
11
|
+
/* This performs a number of GET calls (defaults to 5 calls) which do not reuire an input, to test connectivity and functionality.
|
|
12
|
+
The number of calls can be modified if running from CLI. */
|
|
9
13
|
|
|
10
|
-
const path = require('path');
|
|
11
14
|
const assert = require('assert');
|
|
12
|
-
const mocha = require('mocha');
|
|
13
|
-
const itParam = require('mocha-param');
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const { name } = require('../../package.json');
|
|
16
|
+
const log = require('../../utils/logger');
|
|
17
|
+
const { id } = require('../../package.json');
|
|
18
18
|
const { methods } = require('../../pronghorn.json');
|
|
19
|
+
const { parseArgs } = require('../../utils/argParser');
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
properties, maxCalls
|
|
23
|
+
} = parseArgs();
|
|
24
|
+
|
|
25
|
+
// require the adapter that we are going to be using
|
|
26
|
+
const TestAdapter = require('../../adapter');
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const pronghornProps = utils.decryptProperties(rawProps, iapDir);
|
|
25
|
-
console.log('Found properties.\n');
|
|
26
|
-
return pronghornProps;
|
|
27
|
-
};
|
|
28
|
+
if (!properties) {
|
|
29
|
+
log.warn('No properties provided. Exiting process.');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
28
32
|
|
|
29
|
-
let
|
|
33
|
+
let successCount = 0;
|
|
34
|
+
let calls = 0;
|
|
35
|
+
let attemptTimeout = 60000;
|
|
36
|
+
if (properties.request && properties.request.attempt_timeout) {
|
|
37
|
+
attemptTimeout = properties.request.attempt_timeout;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// turn off stub mode - basic get should not be run in stub mode
|
|
41
|
+
properties.stub = false;
|
|
30
42
|
|
|
31
43
|
describe('[integration] Adapter BasicGET Test', () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
describe('Class Tests', () => {
|
|
45
|
+
const testAdapter = new TestAdapter(
|
|
46
|
+
id,
|
|
47
|
+
properties
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
after((done) => {
|
|
51
|
+
if (successCount === calls) {
|
|
52
|
+
log.info('\x1b[32m%s\x1b[0m', `\n\nSUCCESS: ${successCount} test(s) passed of ${calls} executed!`);
|
|
53
|
+
} else if (successCount > 0) {
|
|
54
|
+
log.error('\x1b[32m%s\x1b[0m', `\n\nPARTIAL SUCCESS: ${successCount} test(s) passed of ${calls} executed!`);
|
|
39
55
|
} else {
|
|
40
|
-
|
|
41
|
-
console.log('Connecting to Database...');
|
|
42
|
-
const database = await basicGet.connect(pronghornProps);
|
|
43
|
-
console.log('Connection established.');
|
|
44
|
-
const adapter = await database.collection(utils.SERVICE_CONFIGS_COLLECTION).findOne(
|
|
45
|
-
{ model: name }
|
|
46
|
-
);
|
|
47
|
-
a = basicGet.getAdapterInstance(adapter);
|
|
56
|
+
log.error('\x1b[31m%s\x1b[0m', '\n\nFAILURE: All tests failed.');
|
|
48
57
|
}
|
|
58
|
+
done();
|
|
49
59
|
});
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
const basicGets = methods.filter((method) => {
|
|
62
|
+
// ignore iapMetadata as the input since its optional and all functions will have it
|
|
63
|
+
const inputKeys = (method.input || [])
|
|
64
|
+
.map((param) => param.name)
|
|
65
|
+
.filter((name) => name !== 'iapMetadata');
|
|
66
|
+
return method.route.verb === 'GET' && inputKeys.length === 0 && !method.name.startsWith('iap');
|
|
53
67
|
});
|
|
54
68
|
|
|
55
|
-
const basicGets = methods.filter((method) => (method.route.verb === 'GET' && method.input.length === 0));
|
|
56
69
|
if (basicGets.length === 0) {
|
|
57
|
-
|
|
58
|
-
process.
|
|
70
|
+
log.warn('No non-parameter GET calls found.');
|
|
71
|
+
process.exitCode = 0;
|
|
72
|
+
return;
|
|
59
73
|
}
|
|
74
|
+
|
|
60
75
|
const functionNames = basicGets.map((g) => g.name);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
calls = functionNames.length;
|
|
77
|
+
if (calls > maxCalls) {
|
|
78
|
+
calls = maxCalls;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// test up to the first 5 get calls without parameters
|
|
82
|
+
for (let f = 0; f < calls; f += 1) {
|
|
83
|
+
const fnName = functionNames[f];
|
|
84
|
+
const method = basicGets.find((m) => m.name === fnName);
|
|
85
|
+
const hasIapMetadata = Array.isArray(method.input) && method.input.some((param) => param.name === 'iapMetadata');
|
|
86
|
+
describe(`#${functionNames[f]}`, () => {
|
|
87
|
+
it('should return valid response without error', (done) => {
|
|
88
|
+
const callback = (data, error) => {
|
|
89
|
+
try {
|
|
90
|
+
assert.equal(undefined, error);
|
|
91
|
+
assert.notEqual(undefined, data);
|
|
92
|
+
assert.notEqual(null, data);
|
|
93
|
+
assert.notEqual(undefined, data.response);
|
|
94
|
+
assert.notEqual(null, data.response);
|
|
95
|
+
successCount += 1;
|
|
96
|
+
done();
|
|
97
|
+
} catch (err) {
|
|
98
|
+
log.error(`Test Failure in ${fnName}: ${err}`);
|
|
99
|
+
done(err);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
if (hasIapMetadata) {
|
|
105
|
+
testAdapter[fnName](null, callback);
|
|
106
|
+
} else {
|
|
107
|
+
testAdapter[fnName](callback);
|
|
67
108
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
reject(new Error(`${f} failed`));
|
|
109
|
+
} catch (err) {
|
|
110
|
+
log.error(`Unexpected error in test for ${fnName}: ${err}`);
|
|
111
|
+
done(err);
|
|
72
112
|
}
|
|
73
|
-
};
|
|
74
|
-
ad[f](getRespCode, console.log);
|
|
113
|
+
}).timeout(attemptTimeout);
|
|
75
114
|
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
itParam('GET call should return 200', functionNames, (fname) => {
|
|
79
|
-
console.log(`\t ${fname}`);
|
|
80
|
-
return request(fname, a).then((result) => assert.equal(result, 200));
|
|
81
|
-
});
|
|
115
|
+
}
|
|
82
116
|
});
|
|
83
117
|
});
|