@itentialopensource/adapter-meraki 0.8.1 → 0.8.4

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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": "0.8.3",
3
+ "configLines": 18012,
4
+ "scriptLines": 1707,
5
+ "codeLines": 28175,
6
+ "testLines": 23912,
7
+ "testCases": 1243,
8
+ "totalCodeLines": 53794,
9
+ "wfTasks": 346
10
+ }
@@ -0,0 +1,115 @@
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": 13
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 7
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 23
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.45.4"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 69
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 258
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": 248
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the TROUBLESHOOT.md",
62
+ "value": 47
63
+ },
64
+ {
65
+ "owner": "markdown",
66
+ "description": "Number of lines in the ENHANCE.md",
67
+ "value": 70
68
+ },
69
+ {
70
+ "owner": "unitTestJS",
71
+ "description": "Number of lines of code in unit tests",
72
+ "value": 13280
73
+ },
74
+ {
75
+ "owner": "unitTestJS",
76
+ "description": "Number of unit tests",
77
+ "value": 852
78
+ },
79
+ {
80
+ "owner": "integrationTestJS",
81
+ "description": "Number of lines of code in integration tests",
82
+ "value": 9678
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of integration tests",
87
+ "value": 334
88
+ },
89
+ {
90
+ "owner": "staticFile",
91
+ "description": "Number of lines of code in adapterBase.js",
92
+ "value": 1294
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of static files added",
97
+ "value": 35
98
+ },
99
+ {
100
+ "owner": "Overall",
101
+ "description": "Total lines of Code",
102
+ "value": 24252
103
+ },
104
+ {
105
+ "owner": "Overall",
106
+ "description": "Total Tests",
107
+ "value": 1186
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Files",
112
+ "value": 6
113
+ }
114
+ ]
115
+ }
@@ -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": 14
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 7
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 22
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.45.4"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 70
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 338
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": 642
58
+ },
59
+ {
60
+ "owner": "markdown",
61
+ "description": "Number of lines in the TROUBLESHOOT.md",
62
+ "value": 48
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": 13187
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 851
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 9595
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 334
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of lines of code in adapterBase.js",
97
+ "value": 1783
98
+ },
99
+ {
100
+ "owner": "staticFile",
101
+ "description": "Number of static files added",
102
+ "value": 36
103
+ },
104
+ {
105
+ "owner": "Overall",
106
+ "description": "Total lines of Code",
107
+ "value": 24565
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 1185
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -3,12 +3,13 @@
3
3
  "type": "Meraki",
4
4
  "properties": {
5
5
  "host": "api.meraki.com",
6
- "port": 80,
6
+ "port": 443,
7
7
  "base_path": "/api",
8
- "version": "v0",
8
+ "version": "v1",
9
9
  "cache_location": "none",
10
10
  "encode_pathvars": true,
11
- "save_metric": true,
11
+ "encode_queryvars": true,
12
+ "save_metric": false,
12
13
  "stub": true,
13
14
  "protocol": "https",
14
15
  "authentication": {
@@ -95,6 +96,134 @@
95
96
  "key_file": "",
96
97
  "cert_file": ""
97
98
  }
99
+ },
100
+ "devicebroker": {
101
+ "getDevice": [
102
+ {
103
+ "path": "/organizations/{orgID}/devices",
104
+ "method": "GET",
105
+ "query": {},
106
+ "body": {},
107
+ "headers": {},
108
+ "handleFailure": "ignore",
109
+ "requestFields": {
110
+ "networkID": "port",
111
+ "serial": "name",
112
+ "orgID": "orgID"
113
+ },
114
+ "responseDatakey": "",
115
+ "responseFields": {
116
+ "name": "serial",
117
+ "ostype": "model",
118
+ "ostypePrefix": "meraki-",
119
+ "port": "networkId",
120
+ "ipaddress": "mac"
121
+ }
122
+ }
123
+ ],
124
+ "getDevicesFiltered": [
125
+ {
126
+ "path": "/organizations/{orgID}/devices",
127
+ "method": "GET",
128
+ "query": {},
129
+ "body": {},
130
+ "headers": {},
131
+ "handleFailure": "ignore",
132
+ "requestFields": {
133
+ "orgID": "549236"
134
+ },
135
+ "responseDatakey": "",
136
+ "responseFields": {
137
+ "name": "serial",
138
+ "ostype": "model",
139
+ "ostypePrefix": "meraki-",
140
+ "port": "networkId",
141
+ "ipaddress": "mac",
142
+ "orgID": "549236"
143
+ }
144
+ },
145
+ {
146
+ "path": "/organizations/{orgID}/devices",
147
+ "method": "GET",
148
+ "query": {},
149
+ "body": {},
150
+ "headers": {},
151
+ "handleFailure": "ignore",
152
+ "requestFields": {
153
+ "orgID": "681155"
154
+ },
155
+ "responseDatakey": "",
156
+ "responseFields": {
157
+ "name": "serial",
158
+ "ostype": "model",
159
+ "ostypePrefix": "meraki-",
160
+ "port": "networkId",
161
+ "ipaddress": "mac",
162
+ "orgID": "681155"
163
+ }
164
+ }
165
+ ],
166
+ "isAlive": [
167
+ {
168
+ "path": "/organizations/{orgID}/networks/{networkID}/devices/{serial}",
169
+ "method": "GET",
170
+ "query": {},
171
+ "body": {},
172
+ "headers": {},
173
+ "handleFailure": "ignore",
174
+ "requestFields": {
175
+ "networkID": "port",
176
+ "serial": "name",
177
+ "orgID": "orgID"
178
+ },
179
+ "responseDatakey": "",
180
+ "responseFields": {
181
+ "status": "return2xx",
182
+ "statusValue": "AD.200"
183
+ }
184
+ }
185
+ ],
186
+ "getConfig": [
187
+ {
188
+ "path": "/organizations/{orgID}/networks/{networkID}/devices/{serial}",
189
+ "method": "GET",
190
+ "query": {},
191
+ "body": {},
192
+ "headers": {},
193
+ "handleFailure": "ignore",
194
+ "requestFields": {
195
+ "networkID": "port",
196
+ "serial": "name",
197
+ "orgID": "orgID"
198
+ },
199
+ "responseDatakey": "",
200
+ "responseFields": {}
201
+ }
202
+ ],
203
+ "getCount": [
204
+ {
205
+ "path": "/organizations/549236/devices",
206
+ "method": "GET",
207
+ "query": {},
208
+ "body": {},
209
+ "headers": {},
210
+ "handleFailure": "ignore",
211
+ "requestFields": {},
212
+ "responseDatakey": "",
213
+ "responseFields": {}
214
+ },
215
+ {
216
+ "path": "/organizations/681155/devices",
217
+ "method": "GET",
218
+ "query": {},
219
+ "body": {},
220
+ "headers": {},
221
+ "handleFailure": "ignore",
222
+ "requestFields": {},
223
+ "responseDatakey": "",
224
+ "responseFields": {}
225
+ }
226
+ ]
98
227
  }
99
228
  },
100
229
  "groups": [],
@@ -34,7 +34,7 @@ describe('[integration] Adapter BasicGET Test', () => {
34
34
  context('Testing GET calls without query parameters', () => {
35
35
  before(async () => {
36
36
  const iapDir = path.join(__dirname, '../../../../../');
37
- if (!utils.withinIAP(iapDir)) {
37
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
38
38
  const sampleProperties = require('../../sampleProperties.json');
39
39
  const adapter = { properties: sampleProperties };
40
40
  a = basicGet.getAdapterInstance(adapter);
@@ -4,6 +4,7 @@
4
4
  /* global describe it log pronghornProps */
5
5
  /* eslint no-unused-vars: warn */
6
6
  /* eslint no-underscore-dangle: warn */
7
+ /* eslint import/no-dynamic-require:warn */
7
8
 
8
9
  // include required items for testing & logging
9
10
  const assert = require('assert');
@@ -15,27 +16,38 @@ const { expect } = require('chai');
15
16
  const { use } = require('chai');
16
17
  const td = require('testdouble');
17
18
  const util = require('util');
18
- const pronghorn = require('../../pronghorn.json');
19
19
 
20
- pronghorn.methodsByName = pronghorn.methods.reduce((result, meth) => ({ ...result, [meth.name]: meth }), {});
21
20
  const anything = td.matchers.anything();
22
21
 
23
22
  // stub and attemptTimeout are used throughout the code so set them here
24
23
  let logLevel = 'none';
25
- const stub = true;
26
24
  const isRapidFail = false;
27
25
  const isSaveMockData = false;
28
- const attemptTimeout = 5000;
26
+
27
+ // read in the properties from the sampleProperties files
28
+ let adaptdir = __dirname;
29
+ if (adaptdir.endsWith('/test/integration')) {
30
+ adaptdir = adaptdir.substring(0, adaptdir.length - 17);
31
+ } else if (adaptdir.endsWith('/test/unit')) {
32
+ adaptdir = adaptdir.substring(0, adaptdir.length - 10);
33
+ }
34
+ const samProps = require(`${adaptdir}/sampleProperties.json`).properties;
29
35
 
30
36
  // these variables can be changed to run in integrated mode so easier to set them here
31
37
  // always check these in with bogus data!!!
32
- const host = 'replace.hostorip.here';
33
- const username = 'username';
34
- const password = 'password';
35
- const protocol = 'http';
36
- const port = 80;
37
- const sslenable = false;
38
- const sslinvalid = false;
38
+ samProps.stub = true;
39
+ samProps.host = 'replace.hostorip.here';
40
+ samProps.authentication.username = 'username';
41
+ samProps.authentication.password = 'password';
42
+ samProps.protocol = 'http';
43
+ samProps.port = 80;
44
+ samProps.ssl.enabled = false;
45
+ samProps.ssl.accept_invalid_cert = false;
46
+ if (samProps.request.attempt_timeout < 30000) {
47
+ samProps.request.attempt_timeout = 30000;
48
+ }
49
+ const attemptTimeout = samProps.request.attempt_timeout;
50
+ const { stub } = samProps;
39
51
 
40
52
  // these are the adapter properties. You generally should not need to alter
41
53
  // any of these after they are initially set up
@@ -47,102 +59,7 @@ global.pronghornProps = {
47
59
  adapters: [{
48
60
  id: 'Test-meraki',
49
61
  type: 'Meraki',
50
- properties: {
51
- host,
52
- port,
53
- base_path: '//api',
54
- version: 'v0',
55
- cache_location: 'none',
56
- encode_pathvars: true,
57
- save_metric: false,
58
- protocol,
59
- stub,
60
- authentication: {
61
- auth_method: 'basic user_password',
62
- username,
63
- password,
64
- token: '',
65
- token_timeout: -1,
66
- token_cache: 'local',
67
- invalid_token_error: 401,
68
- auth_field: 'header.headers.Authorization',
69
- auth_field_format: 'Basic {b64}{username}:{password}{/b64}',
70
- auth_logging: false,
71
- client_id: '',
72
- client_secret: '',
73
- grant_type: ''
74
- },
75
- healthcheck: {
76
- type: 'none',
77
- frequency: 60000,
78
- query_object: {}
79
- },
80
- throttle: {
81
- throttle_enabled: false,
82
- number_pronghorns: 1,
83
- sync_async: 'sync',
84
- max_in_queue: 1000,
85
- concurrent_max: 1,
86
- expire_timeout: 0,
87
- avg_runtime: 200,
88
- priorities: [
89
- {
90
- value: 0,
91
- percent: 100
92
- }
93
- ]
94
- },
95
- request: {
96
- number_redirects: 0,
97
- number_retries: 3,
98
- limit_retry_error: 0,
99
- failover_codes: [],
100
- attempt_timeout: attemptTimeout,
101
- global_request: {
102
- payload: {},
103
- uriOptions: {},
104
- addlHeaders: {},
105
- authData: {}
106
- },
107
- healthcheck_on_timeout: true,
108
- return_raw: true,
109
- archiving: false,
110
- return_request: false
111
- },
112
- proxy: {
113
- enabled: false,
114
- host: '',
115
- port: 1,
116
- protocol: 'http',
117
- username: '',
118
- password: ''
119
- },
120
- ssl: {
121
- ecdhCurve: '',
122
- enabled: sslenable,
123
- accept_invalid_cert: sslinvalid,
124
- ca_file: '',
125
- key_file: '',
126
- cert_file: '',
127
- secure_protocol: '',
128
- ciphers: ''
129
- },
130
- mongo: {
131
- host: '',
132
- port: 0,
133
- database: '',
134
- username,
135
- password: '',
136
- replSet: '',
137
- db_ssl: {
138
- enabled: false,
139
- accept_invalid_cert: false,
140
- ca_file: '',
141
- key_file: '',
142
- cert_file: ''
143
- }
144
- }
145
- }
62
+ properties: samProps
146
63
  }]
147
64
  }
148
65
  };
@@ -317,8 +317,10 @@ describe('[unit] Adapter Base Test', () => {
317
317
  });
318
318
  it('should return a list of functions', (done) => {
319
319
  const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
320
- 'entityInList', 'getAllCapabilities', 'getAllFunctions', 'healthCheck', 'iapFindAdapterPath', 'iapGetAdapterQueue', 'iapGetAdapterWorkflowFunctions', 'iapMoveAdapterEntitiesToDB',
321
- 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapSuspendAdapter', 'iapTroubleshootAdapter', 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'refreshProperties', 'addListener',
320
+ 'entityInList', 'getAllCapabilities', 'getAllFunctions', 'getConfig', 'getDevice', 'getDevicesFiltered', 'hasDevices', 'hasEntities',
321
+ 'healthCheck', 'iapFindAdapterPath', 'iapGetAdapterQueue', 'iapGetAdapterWorkflowFunctions', 'iapGetDeviceCount', 'iapMakeBrokerCall',
322
+ 'iapMoveAdapterEntitiesToDB', 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapSuspendAdapter',
323
+ 'iapTroubleshootAdapter', 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'isAlive', 'refreshProperties', 'addListener',
322
324
  'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
323
325
  'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
324
326
  try {
@@ -817,12 +819,17 @@ describe('[unit] Adapter Base Test', () => {
817
819
  try {
818
820
  assert.notEqual(0, expectedCapabilities.length);
819
821
  assert.equal('.generic', expectedCapabilities[0].entity);
820
- assert.equal(5, expectedCapabilities[0].actions.length);
822
+ assert.equal(10, expectedCapabilities[0].actions.length);
821
823
  assert.equal('getGenerics', expectedCapabilities[0].actions[0]);
822
824
  assert.equal('createGeneric', expectedCapabilities[0].actions[1]);
823
825
  assert.equal('updateGeneric', expectedCapabilities[0].actions[2]);
824
826
  assert.equal('patchGeneric', expectedCapabilities[0].actions[3]);
825
827
  assert.equal('deleteGeneric', expectedCapabilities[0].actions[4]);
828
+ assert.equal('getGenericsNoBase', expectedCapabilities[0].actions[5]);
829
+ assert.equal('createGenericNoBase', expectedCapabilities[0].actions[6]);
830
+ assert.equal('updateGenericNoBase', expectedCapabilities[0].actions[7]);
831
+ assert.equal('patchGenericNoBase', expectedCapabilities[0].actions[8]);
832
+ assert.equal('deleteGenericNoBase', expectedCapabilities[0].actions[9]);
826
833
  assert.equal('.system', expectedCapabilities[1].entity);
827
834
  assert.equal(2, expectedCapabilities[1].actions.length);
828
835
  assert.equal('getToken', expectedCapabilities[1].actions[0]);