@itentialopensource/adapter-netbox_v33 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 +18 -0
- package/.gitlab/.gitkeep +0 -0
- package/.gitlab/issue_templates/.gitkeep +0 -0
- package/.gitlab/issue_templates/Default.md +17 -0
- package/.gitlab/issue_templates/bugReportTemplate.md +42 -0
- package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
- package/.jshintrc +3 -0
- package/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +170 -0
- package/CHANGELOG.md +9 -0
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +172 -0
- package/ENHANCE.md +69 -0
- package/LICENSE +201 -0
- package/PROPERTIES.md +641 -0
- package/README.md +337 -0
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +74593 -0
- package/adapterBase.js +1787 -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/Circuits/action.json +935 -0
- package/entities/Circuits/mockdatafiles/getCircuitsCircuitTerminations-default.json +414 -0
- package/entities/Circuits/mockdatafiles/getCircuitsCircuitTypes-default.json +171 -0
- package/entities/Circuits/mockdatafiles/getCircuitsCircuits-default.json +475 -0
- package/entities/Circuits/mockdatafiles/getCircuitsProviderNetworks-default.json +349 -0
- package/entities/Circuits/mockdatafiles/getCircuitsProviders-default.json +960 -0
- package/entities/Circuits/schema.json +1780 -0
- package/entities/Dcim/action.json +7515 -0
- package/entities/Dcim/mockdatafiles/getDcimCableTerminations-default.json +77 -0
- package/entities/Dcim/mockdatafiles/getDcimCables-default.json +133 -0
- package/entities/Dcim/mockdatafiles/getDcimConsolePortTemplates-default.json +95 -0
- package/entities/Dcim/mockdatafiles/getDcimConsolePorts-default.json +686 -0
- package/entities/Dcim/mockdatafiles/getDcimConsoleServerPortTemplates-default.json +315 -0
- package/entities/Dcim/mockdatafiles/getDcimConsoleServerPorts-default.json +353 -0
- package/entities/Dcim/mockdatafiles/getDcimDeviceBayTemplates-default.json +215 -0
- package/entities/Dcim/mockdatafiles/getDcimDeviceBays-default.json +324 -0
- package/entities/Dcim/mockdatafiles/getDcimDeviceRoles-default.json +104 -0
- package/entities/Dcim/mockdatafiles/getDcimDeviceTypes-default.json +414 -0
- package/entities/Dcim/mockdatafiles/getDcimDevices-default.json +703 -0
- package/entities/Dcim/mockdatafiles/getDcimFrontPortTemplates-default.json +163 -0
- package/entities/Dcim/mockdatafiles/getDcimFrontPorts-default.json +1008 -0
- package/entities/Dcim/mockdatafiles/getDcimInterfaceTemplates-default.json +60 -0
- package/entities/Dcim/mockdatafiles/getDcimInterfaces-default.json +1224 -0
- package/entities/Dcim/mockdatafiles/getDcimInventoryItemRoles-default.json +480 -0
- package/entities/Dcim/mockdatafiles/getDcimInventoryItemTemplates-default.json +295 -0
- package/entities/Dcim/mockdatafiles/getDcimInventoryItems-default.json +515 -0
- package/entities/Dcim/mockdatafiles/getDcimLocations-default.json +248 -0
- package/entities/Dcim/mockdatafiles/getDcimManufacturers-default.json +407 -0
- package/entities/Dcim/mockdatafiles/getDcimModuleBayTemplates-default.json +115 -0
- package/entities/Dcim/mockdatafiles/getDcimModuleBays-default.json +641 -0
- package/entities/Dcim/mockdatafiles/getDcimModuleTypes-default.json +121 -0
- package/entities/Dcim/mockdatafiles/getDcimModules-default.json +109 -0
- package/entities/Dcim/mockdatafiles/getDcimPlatforms-default.json +381 -0
- package/entities/Dcim/mockdatafiles/getDcimPowerFeeds-default.json +567 -0
- package/entities/Dcim/mockdatafiles/getDcimPowerOutletTemplates-default.json +493 -0
- package/entities/Dcim/mockdatafiles/getDcimPowerOutlets-default.json +207 -0
- package/entities/Dcim/mockdatafiles/getDcimPowerPanels-default.json +111 -0
- package/entities/Dcim/mockdatafiles/getDcimPowerPortTemplates-default.json +283 -0
- package/entities/Dcim/mockdatafiles/getDcimPowerPorts-default.json +89 -0
- package/entities/Dcim/mockdatafiles/getDcimRackReservations-default.json +735 -0
- package/entities/Dcim/mockdatafiles/getDcimRackRoles-default.json +69 -0
- package/entities/Dcim/mockdatafiles/getDcimRacks-default.json +1019 -0
- package/entities/Dcim/mockdatafiles/getDcimRacksIdElevation-default.json +50 -0
- package/entities/Dcim/mockdatafiles/getDcimRearPortTemplates-default.json +53 -0
- package/entities/Dcim/mockdatafiles/getDcimRearPorts-default.json +127 -0
- package/entities/Dcim/mockdatafiles/getDcimRegions-default.json +79 -0
- package/entities/Dcim/mockdatafiles/getDcimSiteGroups-default.json +711 -0
- package/entities/Dcim/mockdatafiles/getDcimSites-default.json +319 -0
- package/entities/Dcim/mockdatafiles/getDcimVirtualChassis-default.json +248 -0
- package/entities/Dcim/schema.json +5339 -0
- package/entities/Extras/action.json +1690 -0
- package/entities/Extras/mockdatafiles/getExtrasConfigContexts-default.json +6348 -0
- package/entities/Extras/mockdatafiles/getExtrasContentTypes-default.json +21 -0
- package/entities/Extras/mockdatafiles/getExtrasCustomFields-default.json +466 -0
- package/entities/Extras/mockdatafiles/getExtrasCustomLinks-default.json +71 -0
- package/entities/Extras/mockdatafiles/getExtrasExportTemplates-default.json +63 -0
- package/entities/Extras/mockdatafiles/getExtrasImageAttachments-default.json +91 -0
- package/entities/Extras/mockdatafiles/getExtrasJobResults-default.json +28 -0
- package/entities/Extras/mockdatafiles/getExtrasJournalEntries-default.json +106 -0
- package/entities/Extras/mockdatafiles/getExtrasObjectChanges-default.json +99 -0
- package/entities/Extras/mockdatafiles/getExtrasTags-default.json +55 -0
- package/entities/Extras/mockdatafiles/getExtrasWebhooks-default.json +64 -0
- package/entities/Extras/schema.json +2939 -0
- package/entities/Ipam/action.json +3262 -0
- package/entities/Ipam/mockdatafiles/getIpamAggregates-default.json +703 -0
- package/entities/Ipam/mockdatafiles/getIpamAsns-default.json +465 -0
- package/entities/Ipam/mockdatafiles/getIpamFhrpGroupAssignments-default.json +43 -0
- package/entities/Ipam/mockdatafiles/getIpamFhrpGroups-default.json +148 -0
- package/entities/Ipam/mockdatafiles/getIpamIpAddresses-default.json +1231 -0
- package/entities/Ipam/mockdatafiles/getIpamIpRanges-default.json +681 -0
- package/entities/Ipam/mockdatafiles/getIpamIpRangesIdAvailableIps-default.json +14 -0
- package/entities/Ipam/mockdatafiles/getIpamL2vpnTerminations-default.json +473 -0
- package/entities/Ipam/mockdatafiles/getIpamL2vpns-default.json +1142 -0
- package/entities/Ipam/mockdatafiles/getIpamPrefixes-default.json +791 -0
- package/entities/Ipam/mockdatafiles/getIpamPrefixesIdAvailableIps-default.json +14 -0
- package/entities/Ipam/mockdatafiles/getIpamPrefixesIdAvailablePrefixes-default.json +26 -0
- package/entities/Ipam/mockdatafiles/getIpamRirs-default.json +211 -0
- package/entities/Ipam/mockdatafiles/getIpamRoles-default.json +367 -0
- package/entities/Ipam/mockdatafiles/getIpamRouteTargets-default.json +197 -0
- package/entities/Ipam/mockdatafiles/getIpamServiceTemplates-default.json +256 -0
- package/entities/Ipam/mockdatafiles/getIpamServices-default.json +670 -0
- package/entities/Ipam/mockdatafiles/getIpamVlanGroups-default.json +618 -0
- package/entities/Ipam/mockdatafiles/getIpamVlanGroupsIdAvailableVlans-default.json +24 -0
- package/entities/Ipam/mockdatafiles/getIpamVlans-default.json +324 -0
- package/entities/Ipam/mockdatafiles/getIpamVrfs-default.json +1122 -0
- package/entities/Ipam/mockdatafiles/postIpamIpRangesIdAvailableIps-default.json +176 -0
- package/entities/Ipam/mockdatafiles/postIpamPrefixesIdAvailableIps-default.json +645 -0
- package/entities/Ipam/mockdatafiles/postIpamPrefixesIdAvailablePrefixes-default.json +292 -0
- package/entities/Ipam/mockdatafiles/postIpamVlanGroupsIdAvailableVlans-default.json +343 -0
- package/entities/Ipam/schema.json +2764 -0
- package/entities/Status/action.json +25 -0
- package/entities/Status/schema.json +19 -0
- package/entities/Tenancy/action.json +1096 -0
- package/entities/Tenancy/mockdatafiles/getTenancyContactAssignments-default.json +223 -0
- package/entities/Tenancy/mockdatafiles/getTenancyContactGroups-default.json +87 -0
- package/entities/Tenancy/mockdatafiles/getTenancyContactRoles-default.json +211 -0
- package/entities/Tenancy/mockdatafiles/getTenancyContacts-default.json +787 -0
- package/entities/Tenancy/mockdatafiles/getTenancyTenantGroups-default.json +191 -0
- package/entities/Tenancy/mockdatafiles/getTenancyTenants-default.json +404 -0
- package/entities/Tenancy/schema.json +1348 -0
- package/entities/Users/action.json +773 -0
- package/entities/Users/mockdatafiles/getUsersGroups-default.json +49 -0
- package/entities/Users/mockdatafiles/getUsersPermissions-default.json +554 -0
- package/entities/Users/mockdatafiles/getUsersTokens-default.json +97 -0
- package/entities/Users/mockdatafiles/getUsersUsers-default.json +451 -0
- package/entities/Users/schema.json +1068 -0
- package/entities/Virtualization/action.json +914 -0
- package/entities/Virtualization/mockdatafiles/getVirtualizationClusterGroups-default.json +161 -0
- package/entities/Virtualization/mockdatafiles/getVirtualizationClusterTypes-default.json +507 -0
- package/entities/Virtualization/mockdatafiles/getVirtualizationClusters-default.json +255 -0
- package/entities/Virtualization/mockdatafiles/getVirtualizationInterfaces-default.json +1367 -0
- package/entities/Virtualization/mockdatafiles/getVirtualizationVirtualMachines-default.json +261 -0
- package/entities/Virtualization/schema.json +1559 -0
- package/entities/Wireless/action.json +550 -0
- package/entities/Wireless/mockdatafiles/getWirelessWirelessLanGroups-default.json +439 -0
- package/entities/Wireless/mockdatafiles/getWirelessWirelessLans-default.json +107 -0
- package/entities/Wireless/mockdatafiles/getWirelessWirelessLinks-default.json +739 -0
- package/entities/Wireless/schema.json +1090 -0
- package/error.json +190 -0
- package/package.json +86 -0
- package/pronghorn.json +176740 -0
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +1248 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/Netbox_v33.json +86073 -0
- package/report/creationReport.json +3963 -0
- package/sampleProperties.json +195 -0
- package/test/integration/adapterTestBasicGet.js +83 -0
- package/test/integration/adapterTestConnectivity.js +93 -0
- package/test/integration/adapterTestIntegration.js +23531 -0
- package/test/unit/adapterBaseTestUnit.js +949 -0
- package/test/unit/adapterTestUnit.js +25231 -0
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +146 -0
- package/utils/basicGet.js +50 -0
- package/utils/checkMigrate.js +63 -0
- package/utils/entitiesToDB.js +178 -0
- package/utils/findPath.js +74 -0
- package/utils/methodDocumentor.js +225 -0
- package/utils/modify.js +154 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +32 -0
- package/utils/removeHooks.js +20 -0
- package/utils/setup.js +33 -0
- package/utils/tbScript.js +246 -0
- package/utils/tbUtils.js +490 -0
- package/utils/testRunner.js +298 -0
- package/utils/troubleshootingAdapter.js +195 -0
- package/workflows/README.md +3 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "Adapter-netbox_v33",
|
|
3
|
+
"type": "NetboxV33",
|
|
4
|
+
"properties": {
|
|
5
|
+
"host": "netbox.core-services.test.leaseplan.systems",
|
|
6
|
+
"port": 443,
|
|
7
|
+
"base_path": "/api",
|
|
8
|
+
"version": "",
|
|
9
|
+
"cache_location": "none",
|
|
10
|
+
"encode_pathvars": true,
|
|
11
|
+
"encode_queryvars": true,
|
|
12
|
+
"save_metric": false,
|
|
13
|
+
"stub": true,
|
|
14
|
+
"protocol": "https",
|
|
15
|
+
"authentication": {
|
|
16
|
+
"auth_method": "no_authentication",
|
|
17
|
+
"username": "username",
|
|
18
|
+
"password": "password",
|
|
19
|
+
"token": "token",
|
|
20
|
+
"token_timeout": 600000,
|
|
21
|
+
"token_cache": "local",
|
|
22
|
+
"invalid_token_error": 401,
|
|
23
|
+
"auth_field": "header.headers.Authorization",
|
|
24
|
+
"auth_field_format": "Basic {b64}{username}:{password}{/b64}",
|
|
25
|
+
"auth_logging": false,
|
|
26
|
+
"client_id": "",
|
|
27
|
+
"client_secret": "",
|
|
28
|
+
"grant_type": ""
|
|
29
|
+
},
|
|
30
|
+
"healthcheck": {
|
|
31
|
+
"type": "none",
|
|
32
|
+
"frequency": 60000,
|
|
33
|
+
"query_object": {}
|
|
34
|
+
},
|
|
35
|
+
"throttle": {
|
|
36
|
+
"throttle_enabled": false,
|
|
37
|
+
"number_pronghorns": 1,
|
|
38
|
+
"sync_async": "sync",
|
|
39
|
+
"max_in_queue": 1000,
|
|
40
|
+
"concurrent_max": 1,
|
|
41
|
+
"expire_timeout": 0,
|
|
42
|
+
"avg_runtime": 200,
|
|
43
|
+
"priorities": [
|
|
44
|
+
{
|
|
45
|
+
"value": 0,
|
|
46
|
+
"percent": 100
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"request": {
|
|
51
|
+
"number_redirects": 0,
|
|
52
|
+
"number_retries": 3,
|
|
53
|
+
"limit_retry_error": [
|
|
54
|
+
0
|
|
55
|
+
],
|
|
56
|
+
"failover_codes": [],
|
|
57
|
+
"attempt_timeout": 5000,
|
|
58
|
+
"global_request": {
|
|
59
|
+
"payload": {},
|
|
60
|
+
"uriOptions": {},
|
|
61
|
+
"addlHeaders": {},
|
|
62
|
+
"authData": {}
|
|
63
|
+
},
|
|
64
|
+
"healthcheck_on_timeout": true,
|
|
65
|
+
"return_raw": false,
|
|
66
|
+
"archiving": false,
|
|
67
|
+
"return_request": false
|
|
68
|
+
},
|
|
69
|
+
"proxy": {
|
|
70
|
+
"enabled": false,
|
|
71
|
+
"host": "",
|
|
72
|
+
"port": 1,
|
|
73
|
+
"protocol": "http",
|
|
74
|
+
"username": "",
|
|
75
|
+
"password": ""
|
|
76
|
+
},
|
|
77
|
+
"ssl": {
|
|
78
|
+
"ecdhCurve": "",
|
|
79
|
+
"enabled": false,
|
|
80
|
+
"accept_invalid_cert": false,
|
|
81
|
+
"ca_file": "",
|
|
82
|
+
"key_file": "",
|
|
83
|
+
"cert_file": "",
|
|
84
|
+
"secure_protocol": "",
|
|
85
|
+
"ciphers": ""
|
|
86
|
+
},
|
|
87
|
+
"mongo": {
|
|
88
|
+
"host": "",
|
|
89
|
+
"port": 0,
|
|
90
|
+
"database": "",
|
|
91
|
+
"username": "",
|
|
92
|
+
"password": "",
|
|
93
|
+
"replSet": "",
|
|
94
|
+
"db_ssl": {
|
|
95
|
+
"enabled": false,
|
|
96
|
+
"accept_invalid_cert": false,
|
|
97
|
+
"ca_file": "",
|
|
98
|
+
"key_file": "",
|
|
99
|
+
"cert_file": ""
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"devicebroker": {
|
|
103
|
+
"getDevice": [
|
|
104
|
+
{
|
|
105
|
+
"path": "/get/devices/{id}",
|
|
106
|
+
"method": "GET",
|
|
107
|
+
"query": {},
|
|
108
|
+
"body": {},
|
|
109
|
+
"headers": {},
|
|
110
|
+
"handleFailure": "ignore",
|
|
111
|
+
"requestFields": {
|
|
112
|
+
"id": "name"
|
|
113
|
+
},
|
|
114
|
+
"responseDatakey": "",
|
|
115
|
+
"responseFields": {
|
|
116
|
+
"name": "host",
|
|
117
|
+
"ostype": "os",
|
|
118
|
+
"ostypePrefix": "system-",
|
|
119
|
+
"ipaddress": "attributes.ipaddr",
|
|
120
|
+
"port": "443"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"getDevicesFiltered": [
|
|
125
|
+
{
|
|
126
|
+
"path": "/get/devices",
|
|
127
|
+
"method": "GET",
|
|
128
|
+
"query": {},
|
|
129
|
+
"body": {},
|
|
130
|
+
"headers": {},
|
|
131
|
+
"handleFailure": "ignore",
|
|
132
|
+
"requestFields": {},
|
|
133
|
+
"responseDatakey": "",
|
|
134
|
+
"responseFields": {
|
|
135
|
+
"name": "host",
|
|
136
|
+
"ostype": "os",
|
|
137
|
+
"ostypePrefix": "system-",
|
|
138
|
+
"ipaddress": "attributes.ipaddr",
|
|
139
|
+
"port": "443"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"isAlive": [
|
|
144
|
+
{
|
|
145
|
+
"path": "/get/devices/{id}/status",
|
|
146
|
+
"method": "GET",
|
|
147
|
+
"query": {},
|
|
148
|
+
"body": {},
|
|
149
|
+
"headers": {},
|
|
150
|
+
"handleFailure": "ignore",
|
|
151
|
+
"requestFields": {
|
|
152
|
+
"id": "name"
|
|
153
|
+
},
|
|
154
|
+
"responseDatakey": "",
|
|
155
|
+
"responseFields": {
|
|
156
|
+
"status": "status",
|
|
157
|
+
"statusValue": "online"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"getConfig": [
|
|
162
|
+
{
|
|
163
|
+
"path": "/get/devices/{id}/configPart1",
|
|
164
|
+
"method": "GET",
|
|
165
|
+
"query": {},
|
|
166
|
+
"body": {},
|
|
167
|
+
"headers": {},
|
|
168
|
+
"handleFailure": "ignore",
|
|
169
|
+
"requestFields": {
|
|
170
|
+
"id": "name"
|
|
171
|
+
},
|
|
172
|
+
"responseDatakey": "",
|
|
173
|
+
"responseFields": {}
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
"getCount": [
|
|
177
|
+
{
|
|
178
|
+
"path": "/get/devices",
|
|
179
|
+
"method": "GET",
|
|
180
|
+
"query": {},
|
|
181
|
+
"body": {},
|
|
182
|
+
"headers": {},
|
|
183
|
+
"handleFailure": "ignore",
|
|
184
|
+
"requestFields": {},
|
|
185
|
+
"responseDatakey": "",
|
|
186
|
+
"responseFields": {}
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"groups": [],
|
|
192
|
+
"brokers": [],
|
|
193
|
+
"logLevel": "none",
|
|
194
|
+
"timeout": 120000
|
|
195
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* @copyright Itential, LLC 2020 */
|
|
2
|
+
|
|
3
|
+
/* global describe context 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
|
+
|
|
10
|
+
const mocha = require('mocha');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const assert = require('assert');
|
|
13
|
+
const itParam = require('mocha-param');
|
|
14
|
+
|
|
15
|
+
const utils = require('../../utils/tbUtils');
|
|
16
|
+
const basicGet = require('../../utils/basicGet');
|
|
17
|
+
const { name } = require('../../package.json');
|
|
18
|
+
const { methods } = require('../../pronghorn.json');
|
|
19
|
+
|
|
20
|
+
const getPronghornProps = (iapDir) => {
|
|
21
|
+
console.log('Retrieving properties.json file...');
|
|
22
|
+
const rawProps = require(path.join(iapDir, 'properties.json'));
|
|
23
|
+
console.log('Decrypting properties...');
|
|
24
|
+
const pronghornProps = utils.decryptProperties(rawProps, iapDir);
|
|
25
|
+
console.log('Found properties.\n');
|
|
26
|
+
return pronghornProps;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
let a;
|
|
30
|
+
|
|
31
|
+
describe('[integration] Adapter BasicGET Test', () => {
|
|
32
|
+
context('Testing GET calls without query parameters', () => {
|
|
33
|
+
before(async () => {
|
|
34
|
+
const iapDir = path.join(__dirname, '../../../../../');
|
|
35
|
+
if (!utils.areWeUnderIAPinstallationDirectory()) {
|
|
36
|
+
const sampleProperties = require('../../sampleProperties.json');
|
|
37
|
+
const adapter = { properties: sampleProperties };
|
|
38
|
+
a = basicGet.getAdapterInstance(adapter);
|
|
39
|
+
} else {
|
|
40
|
+
const pronghornProps = getPronghornProps(iapDir);
|
|
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);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
after((done) => {
|
|
52
|
+
done();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const basicGets = methods.filter((method) => (method.route.verb === 'GET' && method.input.length === 0));
|
|
56
|
+
if (basicGets.length === 0) {
|
|
57
|
+
console.log('No non-parameter GET calls found.');
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
const functionNames = basicGets.map((g) => g.name);
|
|
61
|
+
const request = function request(f, ad) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const getRespCode = (resp) => {
|
|
64
|
+
if (resp) {
|
|
65
|
+
if (resp.metrics.code !== 200) {
|
|
66
|
+
console.log('\x1b[31m', `Testing ${f} \nResponseCode: ${resp.metrics.code}`);
|
|
67
|
+
}
|
|
68
|
+
resolve(resp.metrics.code);
|
|
69
|
+
} else {
|
|
70
|
+
console.log('\x1b[31m', `call ${f} results in failure`);
|
|
71
|
+
reject(new Error(`${f} failed`));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
ad[f](getRespCode, console.log);
|
|
75
|
+
});
|
|
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
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* @copyright Itential, LLC 2020 */
|
|
2
|
+
|
|
3
|
+
/* global describe it context before after */
|
|
4
|
+
/* eslint no-unused-vars: warn */
|
|
5
|
+
|
|
6
|
+
const mocha = require('mocha');
|
|
7
|
+
const assert = require('assert');
|
|
8
|
+
const diagnostics = require('network-diagnostics');
|
|
9
|
+
|
|
10
|
+
let host;
|
|
11
|
+
process.argv.forEach((val) => {
|
|
12
|
+
if (val.indexOf('--HOST') === 0) {
|
|
13
|
+
[, host] = val.split('=');
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('[integration] Adapter Test', () => {
|
|
18
|
+
context(`Testing network connection on ${host}`, () => {
|
|
19
|
+
before(() => {
|
|
20
|
+
diagnostics.setTestURL(host);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
after((done) => {
|
|
24
|
+
done();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('DNS resolve', (done) => {
|
|
28
|
+
diagnostics.haveDNS((result) => {
|
|
29
|
+
try {
|
|
30
|
+
assert.equal(result, true);
|
|
31
|
+
done();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
done(error);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('Responds to ping', (done) => {
|
|
39
|
+
diagnostics.havePing((result) => {
|
|
40
|
+
try {
|
|
41
|
+
assert.equal(result, true);
|
|
42
|
+
done();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
done(error);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('Support HTTP on port 80', (done) => {
|
|
50
|
+
diagnostics.haveHTTP((result) => {
|
|
51
|
+
try {
|
|
52
|
+
assert.equal(result, true);
|
|
53
|
+
done();
|
|
54
|
+
} catch (error) {
|
|
55
|
+
done(error);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('Support HTTPS on port 443', (done) => {
|
|
61
|
+
diagnostics.haveHTTPS((result) => {
|
|
62
|
+
try {
|
|
63
|
+
assert.equal(result, true);
|
|
64
|
+
done();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
done(error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('Support IPv4', (done) => {
|
|
72
|
+
diagnostics.haveIPv4Async((result) => {
|
|
73
|
+
try {
|
|
74
|
+
assert.equal(result, true);
|
|
75
|
+
done();
|
|
76
|
+
} catch (error) {
|
|
77
|
+
done(error);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('Support IPv6', (done) => {
|
|
83
|
+
diagnostics.haveIPv6Async((result) => {
|
|
84
|
+
try {
|
|
85
|
+
assert.equal(result, true);
|
|
86
|
+
done();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
done(error);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|