@itentialopensource/adapter-bluecat_ipam 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 +39 -0
- package/BROKER.md +211 -0
- package/CALLS.md +3069 -0
- package/CHANGELOG.md +9 -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 +681 -0
- package/README.md +344 -0
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +25 -0
- package/TAB1.md +15 -0
- package/TAB2.md +318 -0
- package/TROUBLESHOOT.md +56 -0
- package/UTILITIES.md +473 -0
- package/adapter.js +47832 -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/ACLResources/action.json +127 -0
- package/entities/ACLResources/schema.json +24 -0
- package/entities/AdminResources/action.json +1954 -0
- package/entities/AdminResources/schema.json +113 -0
- package/entities/ConfigurationResources/action.json +106 -0
- package/entities/ConfigurationResources/schema.json +23 -0
- package/entities/DHCPClientClassResources/action.json +250 -0
- package/entities/DHCPClientClassResources/schema.json +30 -0
- package/entities/DHCPZoneResources/action.json +250 -0
- package/entities/DHCPZoneResources/schema.json +30 -0
- package/entities/DNSSECResources/action.json +147 -0
- package/entities/DNSSECResources/schema.json +25 -0
- package/entities/DeploymentOptionResources/action.json +250 -0
- package/entities/DeploymentOptionResources/schema.json +30 -0
- package/entities/DeploymentRoleResources/action.json +169 -0
- package/entities/DeploymentRoleResources/schema.json +26 -0
- package/entities/DeviceResources/action.json +352 -0
- package/entities/DeviceResources/schema.json +35 -0
- package/entities/FavoriteResources/action.json +65 -0
- package/entities/FavoriteResources/schema.json +21 -0
- package/entities/IPv4AndIPv6Resources/action.json +1964 -0
- package/entities/IPv4AndIPv6Resources/schema.json +113 -0
- package/entities/KerberosResources/action.json +393 -0
- package/entities/KerberosResources/schema.json +37 -0
- package/entities/LocationResources/action.json +209 -0
- package/entities/LocationResources/schema.json +28 -0
- package/entities/MACAddressAndClientIdentifierResources/action.json +395 -0
- package/entities/MACAddressAndClientIdentifierResources/schema.json +37 -0
- package/entities/NamingPolicyResources/action.json +476 -0
- package/entities/NamingPolicyResources/schema.json +41 -0
- package/entities/ResourceRecordResources/action.json +377 -0
- package/entities/ResourceRecordResources/schema.json +36 -0
- package/entities/ServerResources/action.json +784 -0
- package/entities/ServerResources/schema.json +56 -0
- package/entities/TFTPResources/action.json +250 -0
- package/entities/TFTPResources/schema.json +30 -0
- package/entities/TagResources/action.json +495 -0
- package/entities/TagResources/schema.json +42 -0
- package/entities/TaskResources/action.json +106 -0
- package/entities/TaskResources/schema.json +23 -0
- package/entities/VendorProfileResources/action.json +106 -0
- package/entities/VendorProfileResources/schema.json +23 -0
- package/entities/ViewAndZoneResources/action.json +660 -0
- package/entities/ViewAndZoneResources/schema.json +50 -0
- package/error.json +190 -0
- package/metadata.json +84 -0
- package/package.json +75 -0
- package/pronghorn.json +34480 -0
- package/propertiesDecorators.json +18 -0
- package/propertiesSchema.json +1777 -0
- package/report/Bluecat IPAM 9.5 v2 API.yml-OpenApi3Json.json +114720 -0
- package/report/adapterInfo.json +10 -0
- package/report/auto-adapter-openapi.json +28663 -0
- package/report/creationReport.json +2910 -0
- package/sampleProperties.json +264 -0
- package/test/integration/adapterTestBasicGet.js +117 -0
- package/test/integration/adapterTestConnectivity.js +117 -0
- package/test/integration/adapterTestIntegration.js +12568 -0
- package/test/unit/adapterBaseTestUnit.js +1628 -0
- package/test/unit/adapterTestUnit.js +16058 -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 +298 -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,264 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "Adapter-bluecat_ipam",
|
|
3
|
+
"type": "BluecatIpam",
|
|
4
|
+
"properties": {
|
|
5
|
+
"host": "localhost",
|
|
6
|
+
"port": 80,
|
|
7
|
+
"choosepath": "",
|
|
8
|
+
"base_path": "/",
|
|
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": "request_token",
|
|
18
|
+
"username": "username",
|
|
19
|
+
"password": "password",
|
|
20
|
+
"token": "token",
|
|
21
|
+
"token_timeout": 1800000,
|
|
22
|
+
"token_cache": "local",
|
|
23
|
+
"invalid_token_error": 401,
|
|
24
|
+
"auth_field": "header.headers.Authorization",
|
|
25
|
+
"auth_field_format": "Basic {token}",
|
|
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
|
+
"keep_alive_interval": 0
|
|
88
|
+
},
|
|
89
|
+
"proxy": {
|
|
90
|
+
"enabled": false,
|
|
91
|
+
"host": "",
|
|
92
|
+
"port": 1,
|
|
93
|
+
"protocol": "http",
|
|
94
|
+
"username": "",
|
|
95
|
+
"password": ""
|
|
96
|
+
},
|
|
97
|
+
"ssl": {
|
|
98
|
+
"ecdhCurve": "",
|
|
99
|
+
"enabled": false,
|
|
100
|
+
"accept_invalid_cert": false,
|
|
101
|
+
"ca_file": "",
|
|
102
|
+
"key_file": "",
|
|
103
|
+
"cert_file": "",
|
|
104
|
+
"secure_protocol": "",
|
|
105
|
+
"ciphers": ""
|
|
106
|
+
},
|
|
107
|
+
"mongo": {
|
|
108
|
+
"url": "",
|
|
109
|
+
"host": "",
|
|
110
|
+
"port": 0,
|
|
111
|
+
"database": "",
|
|
112
|
+
"dbAuth": false,
|
|
113
|
+
"username": "",
|
|
114
|
+
"password": "",
|
|
115
|
+
"replSet": "",
|
|
116
|
+
"addSrv": false,
|
|
117
|
+
"db_ssl": {
|
|
118
|
+
"enabled": false,
|
|
119
|
+
"accept_invalid_cert": false,
|
|
120
|
+
"ca_file": "",
|
|
121
|
+
"key_file": "",
|
|
122
|
+
"cert_file": ""
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"devicebroker": {
|
|
126
|
+
"enabled": false,
|
|
127
|
+
"getDevice": [
|
|
128
|
+
{
|
|
129
|
+
"path": "/get/devices/{id}",
|
|
130
|
+
"method": "GET",
|
|
131
|
+
"query": {},
|
|
132
|
+
"body": {},
|
|
133
|
+
"headers": {},
|
|
134
|
+
"handleFailure": "fail",
|
|
135
|
+
"requestFields": {
|
|
136
|
+
"id": "name"
|
|
137
|
+
},
|
|
138
|
+
"responseDatakey": "",
|
|
139
|
+
"responseFields": {
|
|
140
|
+
"name": "host",
|
|
141
|
+
"ostype": "os",
|
|
142
|
+
"ostypePrefix": "system-",
|
|
143
|
+
"ipaddress": "attributes.ipaddr",
|
|
144
|
+
"port": "443"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"getDevicesFiltered": [
|
|
149
|
+
{
|
|
150
|
+
"path": "/get/devices",
|
|
151
|
+
"method": "GET",
|
|
152
|
+
"pagination": {
|
|
153
|
+
"offsetVar": "",
|
|
154
|
+
"limitVar": "",
|
|
155
|
+
"incrementBy": "limit",
|
|
156
|
+
"requestLocation": "query"
|
|
157
|
+
},
|
|
158
|
+
"query": {},
|
|
159
|
+
"body": {},
|
|
160
|
+
"headers": {},
|
|
161
|
+
"handleFailure": "fail",
|
|
162
|
+
"requestFields": {},
|
|
163
|
+
"responseDatakey": "",
|
|
164
|
+
"responseFields": {
|
|
165
|
+
"name": "host",
|
|
166
|
+
"ostype": "os",
|
|
167
|
+
"ostypePrefix": "system-",
|
|
168
|
+
"ipaddress": "attributes.ipaddr",
|
|
169
|
+
"port": "443"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
],
|
|
173
|
+
"isAlive": [
|
|
174
|
+
{
|
|
175
|
+
"path": "/get/devices/{id}/status",
|
|
176
|
+
"method": "GET",
|
|
177
|
+
"query": {},
|
|
178
|
+
"body": {},
|
|
179
|
+
"headers": {},
|
|
180
|
+
"handleFailure": "fail",
|
|
181
|
+
"requestFields": {
|
|
182
|
+
"id": "name"
|
|
183
|
+
},
|
|
184
|
+
"responseDatakey": "",
|
|
185
|
+
"responseFields": {
|
|
186
|
+
"status": "status",
|
|
187
|
+
"statusValue": "online"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"getConfig": [
|
|
192
|
+
{
|
|
193
|
+
"path": "/get/devices/{id}/configPart1",
|
|
194
|
+
"method": "GET",
|
|
195
|
+
"query": {},
|
|
196
|
+
"body": {},
|
|
197
|
+
"headers": {},
|
|
198
|
+
"handleFailure": "fail",
|
|
199
|
+
"requestFields": {
|
|
200
|
+
"id": "name"
|
|
201
|
+
},
|
|
202
|
+
"responseDatakey": "",
|
|
203
|
+
"responseFields": {}
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"getCount": [
|
|
207
|
+
{
|
|
208
|
+
"path": "/get/devices",
|
|
209
|
+
"method": "GET",
|
|
210
|
+
"query": {},
|
|
211
|
+
"body": {},
|
|
212
|
+
"headers": {},
|
|
213
|
+
"handleFailure": "fail",
|
|
214
|
+
"requestFields": {},
|
|
215
|
+
"responseDatakey": "",
|
|
216
|
+
"responseFields": {}
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
"cache": {
|
|
221
|
+
"enabled": false,
|
|
222
|
+
"entities": [
|
|
223
|
+
{
|
|
224
|
+
"entityType": "",
|
|
225
|
+
"frequency": 1440,
|
|
226
|
+
"flushOnFail": false,
|
|
227
|
+
"limit": 1000,
|
|
228
|
+
"retryAttempts": 5,
|
|
229
|
+
"sort": true,
|
|
230
|
+
"populate": [
|
|
231
|
+
{
|
|
232
|
+
"path": "",
|
|
233
|
+
"method": "GET",
|
|
234
|
+
"pagination": {
|
|
235
|
+
"offsetVar": "",
|
|
236
|
+
"limitVar": "",
|
|
237
|
+
"incrementBy": "limit",
|
|
238
|
+
"requestLocation": "query"
|
|
239
|
+
},
|
|
240
|
+
"query": {},
|
|
241
|
+
"body": {},
|
|
242
|
+
"headers": {},
|
|
243
|
+
"handleFailure": "ignore",
|
|
244
|
+
"requestFields": {},
|
|
245
|
+
"responseDatakey": "",
|
|
246
|
+
"responseFields": {}
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
"cachedTasks": [
|
|
250
|
+
{
|
|
251
|
+
"name": "",
|
|
252
|
+
"filterField": "",
|
|
253
|
+
"filterLoc": ""
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
"groups": [],
|
|
261
|
+
"brokers": [],
|
|
262
|
+
"logLevel": "none",
|
|
263
|
+
"timeout": 120000
|
|
264
|
+
}
|
|
@@ -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
|
+
});
|