@itentialopensource/adapter-calix_smx 0.1.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.
- package/.eslintignore +5 -0
- package/.eslintrc.js +19 -0
- package/.jshintrc +3 -0
- package/AUTH.md +42 -0
- package/BROKER.md +211 -0
- package/CALLS.md +207 -0
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +13 -0
- package/ENHANCE.md +69 -0
- package/LICENSE +201 -0
- package/PROPERTIES.md +676 -0
- package/README.md +344 -0
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +35 -0
- package/TROUBLESHOOT.md +56 -0
- package/UTILITIES.md +473 -0
- package/adapter.js +189915 -0
- package/adapterBase.js +1526 -0
- package/entities/.generic/action.json +214 -0
- package/entities/.generic/schema.json +28 -0
- package/entities/.system/action.json +50 -0
- package/entities/.system/mockdatafiles/getToken-default.json +3 -0
- package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
- package/entities/.system/schema.json +19 -0
- package/entities/.system/schemaTokenReq.json +53 -0
- package/entities/.system/schemaTokenResp.json +53 -0
- package/entities/Config/action.json +861 -0
- package/entities/Config/schema.json +136 -0
- package/entities/ConfigDevice/action.json +12813 -0
- package/entities/ConfigDevice/schema.json +1281 -0
- package/entities/ConfigProfile/action.json +2608 -0
- package/entities/ConfigProfile/schema.json +164 -0
- package/entities/ConfigTemplate/action.json +841 -0
- package/entities/ConfigTemplate/schema.json +147 -0
- package/entities/EMS/action.json +1565 -0
- package/entities/EMS/schema.json +182 -0
- package/entities/EMSProfile/action.json +14871 -0
- package/entities/EMSProfile/schema.json +1001 -0
- package/entities/EMSRegion/action.json +127 -0
- package/entities/EMSRegion/schema.json +24 -0
- package/entities/EMSService/action.json +855 -0
- package/entities/EMSService/schema.json +269 -0
- package/entities/EMSSubscriber/action.json +190 -0
- package/entities/EMSSubscriber/schema.json +104 -0
- package/entities/Fault/action.json +209 -0
- package/entities/Fault/schema.json +61 -0
- package/entities/Log/action.json +25 -0
- package/entities/Log/schema.json +19 -0
- package/entities/PerformanceMonitoring/action.json +1114 -0
- package/entities/PerformanceMonitoring/schema.json +302 -0
- package/entities/Port/action.json +24 -0
- package/entities/Port/schema.json +30 -0
- package/error.json +190 -0
- package/metadata.json +81 -0
- package/package.json +76 -0
- package/pronghorn.json +119022 -0
- package/propertiesDecorators.json +18 -0
- package/propertiesSchema.json +1765 -0
- package/report/creationReport.json +9189 -0
- package/report/smx_modified_rename.json +97860 -0
- package/report/updateReport1766175812348.json +120 -0
- package/sampleProperties.json +263 -0
- package/test/integration/adapterTestBasicGet.js +117 -0
- package/test/integration/adapterTestConnectivity.js +117 -0
- package/test/integration/adapterTestIntegration.js +45491 -0
- package/test/unit/adapterBaseTestUnit.js +1628 -0
- package/test/unit/adapterTestUnit.js +66088 -0
- package/utils/adapterInfo.js +156 -0
- package/utils/argParser.js +44 -0
- package/utils/checkMigrate.js +102 -0
- package/utils/entitiesToDB.js +190 -0
- package/utils/findPath.js +74 -0
- package/utils/logger.js +26 -0
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +153 -0
- package/utils/mongoDbConnection.js +79 -0
- package/utils/mongoUtils.js +162 -0
- package/utils/pre-commit.sh +32 -0
- package/utils/removeHooks.js +20 -0
- package/utils/setup.js +33 -0
- package/utils/taskMover.js +308 -0
- package/utils/tbScript.js +103 -0
- package/utils/tbUtils.js +347 -0
- package/utils/testRunner.js +298 -0
- package/utils/troubleshootingAdapter.js +177 -0
- package/utils/updateAdapterConfig.js +158 -0
|
@@ -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": 17
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"owner": "packageJson",
|
|
36
|
+
"description": "Runtime Library dependency",
|
|
37
|
+
"value": "6.0.3"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"owner": "propertiesSchemaJson",
|
|
41
|
+
"description": "Adapter properties defined in the propertiesSchema file",
|
|
42
|
+
"value": 82
|
|
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": 677
|
|
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": 66089
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"owner": "unitTestJS",
|
|
81
|
+
"description": "Number of unit tests",
|
|
82
|
+
"value": 4386
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"owner": "integrationTestJS",
|
|
86
|
+
"description": "Number of lines of code in integration tests",
|
|
87
|
+
"value": 45493
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"owner": "integrationTestJS",
|
|
91
|
+
"description": "Number of integration tests",
|
|
92
|
+
"value": 1768
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"owner": "staticFile",
|
|
96
|
+
"description": "Number of lines of code in adapterBase.js",
|
|
97
|
+
"value": 1527
|
|
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": 113109
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"owner": "Overall",
|
|
111
|
+
"description": "Total Tests",
|
|
112
|
+
"value": 6154
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"owner": "Overall",
|
|
116
|
+
"description": "Total Files",
|
|
117
|
+
"value": 6
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "Adapter-calix_smx",
|
|
3
|
+
"type": "Calixsmx",
|
|
4
|
+
"properties": {
|
|
5
|
+
"host": "localhost",
|
|
6
|
+
"port": 80,
|
|
7
|
+
"choosepath": "",
|
|
8
|
+
"base_path": "/rest/v1",
|
|
9
|
+
"version": "",
|
|
10
|
+
"cache_location": "none",
|
|
11
|
+
"encode_pathvars": true,
|
|
12
|
+
"encode_queryvars": true,
|
|
13
|
+
"save_metric": false,
|
|
14
|
+
"stub": true,
|
|
15
|
+
"protocol": "http",
|
|
16
|
+
"authentication": {
|
|
17
|
+
"auth_method": "basic user_password",
|
|
18
|
+
"username": "username",
|
|
19
|
+
"password": "password",
|
|
20
|
+
"token": "token",
|
|
21
|
+
"token_timeout": 600000,
|
|
22
|
+
"token_cache": "local",
|
|
23
|
+
"invalid_token_error": 401,
|
|
24
|
+
"auth_field": "header.headers.Authorization",
|
|
25
|
+
"auth_field_format": "Basic {b64}{username}:{password}{/b64}",
|
|
26
|
+
"auth_logging": false,
|
|
27
|
+
"client_id": "",
|
|
28
|
+
"client_secret": "",
|
|
29
|
+
"grant_type": "",
|
|
30
|
+
"auth_request_datatype": "",
|
|
31
|
+
"auth_response_datatype": "",
|
|
32
|
+
"token_response_placement": "",
|
|
33
|
+
"sensitive": [],
|
|
34
|
+
"multiStepAuthCalls": [
|
|
35
|
+
{
|
|
36
|
+
"name": "",
|
|
37
|
+
"requestFields": {},
|
|
38
|
+
"responseFields": {},
|
|
39
|
+
"successfullResponseCode": 200
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"sso": {
|
|
43
|
+
"protocol": "",
|
|
44
|
+
"host": "",
|
|
45
|
+
"port": 0
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"healthcheck": {
|
|
49
|
+
"type": "none",
|
|
50
|
+
"frequency": 60000,
|
|
51
|
+
"query_object": {},
|
|
52
|
+
"addlHeaders": {}
|
|
53
|
+
},
|
|
54
|
+
"throttle": {
|
|
55
|
+
"throttle_enabled": false,
|
|
56
|
+
"number_pronghorns": 1,
|
|
57
|
+
"sync_async": "sync",
|
|
58
|
+
"max_in_queue": 1000,
|
|
59
|
+
"concurrent_max": 1,
|
|
60
|
+
"expire_timeout": 0,
|
|
61
|
+
"avg_runtime": 200,
|
|
62
|
+
"priorities": [
|
|
63
|
+
{
|
|
64
|
+
"value": 0,
|
|
65
|
+
"percent": 100
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"request": {
|
|
70
|
+
"number_redirects": 0,
|
|
71
|
+
"number_retries": 3,
|
|
72
|
+
"limit_retry_error": [
|
|
73
|
+
0
|
|
74
|
+
],
|
|
75
|
+
"failover_codes": [],
|
|
76
|
+
"attempt_timeout": 5000,
|
|
77
|
+
"global_request": {
|
|
78
|
+
"payload": {},
|
|
79
|
+
"uriOptions": {},
|
|
80
|
+
"addlHeaders": {},
|
|
81
|
+
"authData": {}
|
|
82
|
+
},
|
|
83
|
+
"healthcheck_on_timeout": true,
|
|
84
|
+
"return_raw": false,
|
|
85
|
+
"archiving": false,
|
|
86
|
+
"return_request": false
|
|
87
|
+
},
|
|
88
|
+
"proxy": {
|
|
89
|
+
"enabled": false,
|
|
90
|
+
"host": "",
|
|
91
|
+
"port": 1,
|
|
92
|
+
"protocol": "http",
|
|
93
|
+
"username": "",
|
|
94
|
+
"password": ""
|
|
95
|
+
},
|
|
96
|
+
"ssl": {
|
|
97
|
+
"ecdhCurve": "",
|
|
98
|
+
"enabled": false,
|
|
99
|
+
"accept_invalid_cert": false,
|
|
100
|
+
"ca_file": "",
|
|
101
|
+
"key_file": "",
|
|
102
|
+
"cert_file": "",
|
|
103
|
+
"secure_protocol": "",
|
|
104
|
+
"ciphers": ""
|
|
105
|
+
},
|
|
106
|
+
"mongo": {
|
|
107
|
+
"url": "",
|
|
108
|
+
"host": "",
|
|
109
|
+
"port": 0,
|
|
110
|
+
"database": "",
|
|
111
|
+
"dbAuth": false,
|
|
112
|
+
"username": "",
|
|
113
|
+
"password": "",
|
|
114
|
+
"replSet": "",
|
|
115
|
+
"addSrv": false,
|
|
116
|
+
"db_ssl": {
|
|
117
|
+
"enabled": false,
|
|
118
|
+
"accept_invalid_cert": false,
|
|
119
|
+
"ca_file": "",
|
|
120
|
+
"key_file": "",
|
|
121
|
+
"cert_file": ""
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"devicebroker": {
|
|
125
|
+
"enabled": false,
|
|
126
|
+
"getDevice": [
|
|
127
|
+
{
|
|
128
|
+
"path": "/get/devices/{id}",
|
|
129
|
+
"method": "GET",
|
|
130
|
+
"query": {},
|
|
131
|
+
"body": {},
|
|
132
|
+
"headers": {},
|
|
133
|
+
"handleFailure": "fail",
|
|
134
|
+
"requestFields": {
|
|
135
|
+
"id": "name"
|
|
136
|
+
},
|
|
137
|
+
"responseDatakey": "",
|
|
138
|
+
"responseFields": {
|
|
139
|
+
"name": "host",
|
|
140
|
+
"ostype": "os",
|
|
141
|
+
"ostypePrefix": "system-",
|
|
142
|
+
"ipaddress": "attributes.ipaddr",
|
|
143
|
+
"port": "443"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"getDevicesFiltered": [
|
|
148
|
+
{
|
|
149
|
+
"path": "/get/devices",
|
|
150
|
+
"method": "GET",
|
|
151
|
+
"pagination": {
|
|
152
|
+
"offsetVar": "",
|
|
153
|
+
"limitVar": "",
|
|
154
|
+
"incrementBy": "limit",
|
|
155
|
+
"requestLocation": "query"
|
|
156
|
+
},
|
|
157
|
+
"query": {},
|
|
158
|
+
"body": {},
|
|
159
|
+
"headers": {},
|
|
160
|
+
"handleFailure": "fail",
|
|
161
|
+
"requestFields": {},
|
|
162
|
+
"responseDatakey": "",
|
|
163
|
+
"responseFields": {
|
|
164
|
+
"name": "host",
|
|
165
|
+
"ostype": "os",
|
|
166
|
+
"ostypePrefix": "system-",
|
|
167
|
+
"ipaddress": "attributes.ipaddr",
|
|
168
|
+
"port": "443"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
"isAlive": [
|
|
173
|
+
{
|
|
174
|
+
"path": "/get/devices/{id}/status",
|
|
175
|
+
"method": "GET",
|
|
176
|
+
"query": {},
|
|
177
|
+
"body": {},
|
|
178
|
+
"headers": {},
|
|
179
|
+
"handleFailure": "fail",
|
|
180
|
+
"requestFields": {
|
|
181
|
+
"id": "name"
|
|
182
|
+
},
|
|
183
|
+
"responseDatakey": "",
|
|
184
|
+
"responseFields": {
|
|
185
|
+
"status": "status",
|
|
186
|
+
"statusValue": "online"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"getConfig": [
|
|
191
|
+
{
|
|
192
|
+
"path": "/get/devices/{id}/configPart1",
|
|
193
|
+
"method": "GET",
|
|
194
|
+
"query": {},
|
|
195
|
+
"body": {},
|
|
196
|
+
"headers": {},
|
|
197
|
+
"handleFailure": "fail",
|
|
198
|
+
"requestFields": {
|
|
199
|
+
"id": "name"
|
|
200
|
+
},
|
|
201
|
+
"responseDatakey": "",
|
|
202
|
+
"responseFields": {}
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
"getCount": [
|
|
206
|
+
{
|
|
207
|
+
"path": "/get/devices",
|
|
208
|
+
"method": "GET",
|
|
209
|
+
"query": {},
|
|
210
|
+
"body": {},
|
|
211
|
+
"headers": {},
|
|
212
|
+
"handleFailure": "fail",
|
|
213
|
+
"requestFields": {},
|
|
214
|
+
"responseDatakey": "",
|
|
215
|
+
"responseFields": {}
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
},
|
|
219
|
+
"cache": {
|
|
220
|
+
"enabled": false,
|
|
221
|
+
"entities": [
|
|
222
|
+
{
|
|
223
|
+
"entityType": "",
|
|
224
|
+
"frequency": 1440,
|
|
225
|
+
"flushOnFail": false,
|
|
226
|
+
"limit": 1000,
|
|
227
|
+
"retryAttempts": 5,
|
|
228
|
+
"sort": true,
|
|
229
|
+
"populate": [
|
|
230
|
+
{
|
|
231
|
+
"path": "",
|
|
232
|
+
"method": "GET",
|
|
233
|
+
"pagination": {
|
|
234
|
+
"offsetVar": "",
|
|
235
|
+
"limitVar": "",
|
|
236
|
+
"incrementBy": "limit",
|
|
237
|
+
"requestLocation": "query"
|
|
238
|
+
},
|
|
239
|
+
"query": {},
|
|
240
|
+
"body": {},
|
|
241
|
+
"headers": {},
|
|
242
|
+
"handleFailure": "ignore",
|
|
243
|
+
"requestFields": {},
|
|
244
|
+
"responseDatakey": "",
|
|
245
|
+
"responseFields": {}
|
|
246
|
+
}
|
|
247
|
+
],
|
|
248
|
+
"cachedTasks": [
|
|
249
|
+
{
|
|
250
|
+
"name": "",
|
|
251
|
+
"filterField": "",
|
|
252
|
+
"filterLoc": ""
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
"groups": [],
|
|
260
|
+
"brokers": [],
|
|
261
|
+
"logLevel": "none",
|
|
262
|
+
"timeout": 120000
|
|
263
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* @copyright Itential, LLC 2020 */
|
|
2
|
+
|
|
3
|
+
/* global describe it log before after */
|
|
4
|
+
/* eslint global-require: warn */
|
|
5
|
+
/* eslint no-unused-vars: warn */
|
|
6
|
+
/* eslint import/no-extraneous-dependencies: warn */
|
|
7
|
+
/* eslint import/no-dynamic-require: warn */
|
|
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. */
|
|
13
|
+
|
|
14
|
+
const assert = require('assert');
|
|
15
|
+
|
|
16
|
+
const log = require('../../utils/logger');
|
|
17
|
+
const { id } = require('../../package.json');
|
|
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');
|
|
27
|
+
|
|
28
|
+
if (!properties) {
|
|
29
|
+
log.warn('No properties provided. Exiting process.');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
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;
|
|
42
|
+
|
|
43
|
+
describe('[integration] Adapter BasicGET Test', () => {
|
|
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!`);
|
|
55
|
+
} else {
|
|
56
|
+
log.error('\x1b[31m%s\x1b[0m', '\n\nFAILURE: All tests failed.');
|
|
57
|
+
}
|
|
58
|
+
done();
|
|
59
|
+
});
|
|
60
|
+
|
|
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');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (basicGets.length === 0) {
|
|
70
|
+
log.warn('No non-parameter GET calls found.');
|
|
71
|
+
process.exitCode = 0;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const functionNames = basicGets.map((g) => g.name);
|
|
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);
|
|
108
|
+
}
|
|
109
|
+
} catch (err) {
|
|
110
|
+
log.error(`Unexpected error in test for ${fnName}: ${err}`);
|
|
111
|
+
done(err);
|
|
112
|
+
}
|
|
113
|
+
}).timeout(attemptTimeout);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* @copyright Itential, LLC 2020 */
|
|
2
|
+
|
|
3
|
+
/* global describe it context before after */
|
|
4
|
+
/* eslint no-unused-vars: warn */
|
|
5
|
+
|
|
6
|
+
const assert = require('assert');
|
|
7
|
+
const https = require('https');
|
|
8
|
+
const mocha = require('mocha');
|
|
9
|
+
const ping = require('ping');
|
|
10
|
+
const dns = require('dns');
|
|
11
|
+
const { parseArgs } = require('../../utils/argParser');
|
|
12
|
+
|
|
13
|
+
const dnsPromises = dns.promises;
|
|
14
|
+
const { host } = parseArgs();
|
|
15
|
+
|
|
16
|
+
describe('[integration] Adapter Test', () => {
|
|
17
|
+
context(`Testing network connection on ${host}`, () => {
|
|
18
|
+
after((done) => {
|
|
19
|
+
done();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('DNS resolve', (done) => {
|
|
23
|
+
dnsPromises.lookup(host, { all: true })
|
|
24
|
+
.then((result) => {
|
|
25
|
+
try {
|
|
26
|
+
assert.ok(result.length > 0);
|
|
27
|
+
done();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
done(error);
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
.catch((err) => {
|
|
33
|
+
done(err);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('Responds to ping', (done) => {
|
|
38
|
+
ping.promise.probe(host)
|
|
39
|
+
.then((result) => {
|
|
40
|
+
try {
|
|
41
|
+
assert.ok(result.alive);
|
|
42
|
+
done();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
done(error);
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.catch((err) => {
|
|
48
|
+
done(err);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('Support HTTPS on port 443', (done) => {
|
|
53
|
+
const requestOptions = {
|
|
54
|
+
host,
|
|
55
|
+
port: 443,
|
|
56
|
+
method: 'HEAD'
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const req = https.request(requestOptions, (res) => {
|
|
60
|
+
try {
|
|
61
|
+
assert.ok(res.statusCode >= 200 && res.statusCode < 400);
|
|
62
|
+
done();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
done(error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
req.on('error', (err) => {
|
|
69
|
+
done(err);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
req.end();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('Support IPv4', (done) => {
|
|
76
|
+
const options = {
|
|
77
|
+
family: 4,
|
|
78
|
+
hints: dns.ADDRCONFIG
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
dnsPromises.lookup(host, options)
|
|
82
|
+
.then((result) => {
|
|
83
|
+
try {
|
|
84
|
+
const { address, family } = result;
|
|
85
|
+
assert.ok(address !== null && family === 4);
|
|
86
|
+
done();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
done(error);
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
.catch((err) => {
|
|
92
|
+
done(err);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('Support IPv6', (done) => {
|
|
97
|
+
const options = {
|
|
98
|
+
family: 6,
|
|
99
|
+
hints: dns.ADDRCONFIG
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
dnsPromises.lookup(host, options)
|
|
103
|
+
.then((result) => {
|
|
104
|
+
try {
|
|
105
|
+
const { address, family } = result;
|
|
106
|
+
assert.ok(address !== null && family === 6);
|
|
107
|
+
done();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
done(error);
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
.catch((err) => {
|
|
113
|
+
done(err);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|