@itentialopensource/adapter-meraki 0.7.2 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -93,6 +93,9 @@
93
93
  },
94
94
  "mongo": {
95
95
  "$ref": "#/definitions/mongo"
96
+ },
97
+ "devicebroker": {
98
+ "$ref": "#/definitions/devicebroker"
96
99
  }
97
100
  },
98
101
  "required": [
@@ -232,6 +235,21 @@
232
235
  "type": "boolean",
233
236
  "description": "This property turns on logging of Authentication Information and should only be true when debugging authentication and connectivity",
234
237
  "default": false
238
+ },
239
+ "client_id": {
240
+ "type": "string",
241
+ "description": "The client id for OAuth requests - can also use username depending on schema",
242
+ "default": ""
243
+ },
244
+ "client_secret": {
245
+ "type": "string",
246
+ "description": "The client secret for OAuth requests - can also use password depending on schema",
247
+ "default": ""
248
+ },
249
+ "grant_type": {
250
+ "type": "string",
251
+ "description": "The grant type for OAuth requests - can also provide in schema",
252
+ "default": ""
235
253
  }
236
254
  },
237
255
  "required": [
@@ -820,6 +838,226 @@
820
838
  }
821
839
  }
822
840
  }
841
+ },
842
+ "devicebroker": {
843
+ "type": "object",
844
+ "properties": {
845
+ "getDevice": {
846
+ "type": "object",
847
+ "description": "Broker call to getDevice",
848
+ "properties": {
849
+ "path": {
850
+ "type": "string",
851
+ "description": "The fully qualified path of the call to getDevice (e.g. /rest/api/device/{deviceid})",
852
+ "default": ""
853
+ },
854
+ "method": {
855
+ "type": "string",
856
+ "description": "The method of the call to getDevice",
857
+ "default": "GET"
858
+ },
859
+ "query": {
860
+ "type": "string",
861
+ "description": "The stringified json object with query parameters of the call to getDevice",
862
+ "default": "{}"
863
+ },
864
+ "body": {
865
+ "type": "string",
866
+ "description": "The stringified json object with body of the call to getDevice",
867
+ "default": "{}"
868
+ },
869
+ "headers": {
870
+ "type": "string",
871
+ "description": "The stringified json object with headers of the call to getDevice",
872
+ "default": "{}"
873
+ },
874
+ "name_field": {
875
+ "type": "string",
876
+ "description": "The field in response to getDevice that contains the name of the device",
877
+ "default": "name"
878
+ },
879
+ "ostype_field": {
880
+ "type": "string",
881
+ "description": "The field in response to getDevice that contains the ostype of the device",
882
+ "default": "ostype"
883
+ },
884
+ "ostypePrefix": {
885
+ "type": "string",
886
+ "description": "Any prefix that should be added to the ostype of the device (e.g. aws-)",
887
+ "default": ""
888
+ },
889
+ "port_field": {
890
+ "type": "string",
891
+ "description": "The field in response to getDevice that contains the port of the device",
892
+ "default": "port"
893
+ },
894
+ "ip_field": {
895
+ "type": "string",
896
+ "description": "The field in response to getDevice that contains the ip address of the device",
897
+ "default": "ipaddress"
898
+ }
899
+ }
900
+ },
901
+ "getDevicesFiltered": {
902
+ "type": "object",
903
+ "description": "Broker call to getDevicesFiltered",
904
+ "properties": {
905
+ "path": {
906
+ "type": "string",
907
+ "description": "The fully qualified path of the call to getDevicesFiltered (e.g. /rest/api/devices)",
908
+ "default": ""
909
+ },
910
+ "method": {
911
+ "type": "string",
912
+ "description": "The method of the call to getDevicesFiltered",
913
+ "default": "GET"
914
+ },
915
+ "query": {
916
+ "type": "string",
917
+ "description": "The stringified json object with query parameters of the call to getDevicesFiltered",
918
+ "default": "{}"
919
+ },
920
+ "body": {
921
+ "type": "string",
922
+ "description": "The stringified json object with body of the call to getDevicesFiltered",
923
+ "default": "{}"
924
+ },
925
+ "headers": {
926
+ "type": "string",
927
+ "description": "The stringified json object with headers of the call to getDevicesFiltered",
928
+ "default": "{}"
929
+ },
930
+ "name_field": {
931
+ "type": "string",
932
+ "description": "The field in response to getDevicesFiltered that contains the name of the device",
933
+ "default": "name"
934
+ },
935
+ "ostype_field": {
936
+ "type": "string",
937
+ "description": "The field in response to getDevicesFiltered that contains the ostype of the device",
938
+ "default": "ostype"
939
+ },
940
+ "ostypePrefix": {
941
+ "type": "string",
942
+ "description": "Any prefix that should be added to the ostype of the device (e.g. aws-)",
943
+ "default": ""
944
+ },
945
+ "port_field": {
946
+ "type": "string",
947
+ "description": "The field in response to getDevicesFiltered that contains the port of the device",
948
+ "default": "port"
949
+ },
950
+ "ip_field": {
951
+ "type": "string",
952
+ "description": "The field in response to getDevicesFiltered that contains the ip address of the device",
953
+ "default": "ipaddress"
954
+ }
955
+ }
956
+ },
957
+ "isAlive": {
958
+ "type": "object",
959
+ "description": "Broker call to isAlive",
960
+ "properties": {
961
+ "path": {
962
+ "type": "string",
963
+ "description": "The fully qualified path of the call to isAlive (e.g. /rest/api/device/{deviceid})",
964
+ "default": ""
965
+ },
966
+ "method": {
967
+ "type": "string",
968
+ "description": "The method of the call to isAlive",
969
+ "default": "GET"
970
+ },
971
+ "query": {
972
+ "type": "string",
973
+ "description": "The stringified json object with query parameters of the call to isAlive",
974
+ "default": "{}"
975
+ },
976
+ "body": {
977
+ "type": "string",
978
+ "description": "The stringified json object with body of the call to isAlive",
979
+ "default": "{}"
980
+ },
981
+ "headers": {
982
+ "type": "string",
983
+ "description": "The stringified json object with headers of the call to isAlive",
984
+ "default": "{}"
985
+ },
986
+ "status_field": {
987
+ "type": "string",
988
+ "description": "The field in response to isAlive that contains the status of the device",
989
+ "default": "status"
990
+ },
991
+ "status_value": {
992
+ "type": "string",
993
+ "description": "The status of the device that says it is alive",
994
+ "default": "true"
995
+ }
996
+ }
997
+ },
998
+ "getConfig": {
999
+ "type": "object",
1000
+ "description": "Broker call to getConfig",
1001
+ "properties": {
1002
+ "path": {
1003
+ "type": "string",
1004
+ "description": "The fully qualified path of the call to getConfig (e.g. /rest/api/device/{deviceid})",
1005
+ "default": ""
1006
+ },
1007
+ "method": {
1008
+ "type": "string",
1009
+ "description": "The method of the call to getConfig",
1010
+ "default": "GET"
1011
+ },
1012
+ "query": {
1013
+ "type": "string",
1014
+ "description": "The stringified json object with query parameters of the call to getConfig",
1015
+ "default": "{}"
1016
+ },
1017
+ "body": {
1018
+ "type": "string",
1019
+ "description": "The stringified json object with body of the call to getConfig",
1020
+ "default": "{}"
1021
+ },
1022
+ "headers": {
1023
+ "type": "string",
1024
+ "description": "The stringified json object with headers of the call to getConfig",
1025
+ "default": "{}"
1026
+ }
1027
+ }
1028
+ },
1029
+ "getCount": {
1030
+ "type": "object",
1031
+ "description": "Broker call to getCount",
1032
+ "properties": {
1033
+ "path": {
1034
+ "type": "string",
1035
+ "description": "The fully qualified path of the call to getCount (e.g. /rest/api/device)",
1036
+ "default": ""
1037
+ },
1038
+ "method": {
1039
+ "type": "string",
1040
+ "description": "The method of the call to getCount",
1041
+ "default": "GET"
1042
+ },
1043
+ "query": {
1044
+ "type": "string",
1045
+ "description": "The stringified json object with query parameters of the call to getCount",
1046
+ "default": "{}"
1047
+ },
1048
+ "body": {
1049
+ "type": "string",
1050
+ "description": "The stringified json object with body of the call to getCount",
1051
+ "default": "{}"
1052
+ },
1053
+ "headers": {
1054
+ "type": "string",
1055
+ "description": "The stringified json object with headers of the call to getCount",
1056
+ "default": "{}"
1057
+ }
1058
+ }
1059
+ }
1060
+ }
823
1061
  }
824
1062
  }
825
1063
  }
Binary file
@@ -0,0 +1,95 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 1
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": 29
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.44.11"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 64
43
+ },
44
+ {
45
+ "owner": "readmeMd",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 688
48
+ },
49
+ {
50
+ "owner": "unitTestJS",
51
+ "description": "Number of lines of code in unit tests",
52
+ "value": 13271
53
+ },
54
+ {
55
+ "owner": "unitTestJS",
56
+ "description": "Number of unit tests",
57
+ "value": 852
58
+ },
59
+ {
60
+ "owner": "integrationTestJS",
61
+ "description": "Number of lines of code in integration tests",
62
+ "value": 9674
63
+ },
64
+ {
65
+ "owner": "integrationTestJS",
66
+ "description": "Number of integration tests",
67
+ "value": 334
68
+ },
69
+ {
70
+ "owner": "staticFile",
71
+ "description": "Number of lines of code in adapterBase.js",
72
+ "value": 1029
73
+ },
74
+ {
75
+ "owner": "staticFile",
76
+ "description": "Number of static files added",
77
+ "value": 34
78
+ },
79
+ {
80
+ "owner": "Overall",
81
+ "description": "Total lines of Code",
82
+ "value": 23974
83
+ },
84
+ {
85
+ "owner": "Overall",
86
+ "description": "Total Tests",
87
+ "value": 1186
88
+ },
89
+ {
90
+ "owner": "Overall",
91
+ "description": "Total Files",
92
+ "value": 6
93
+ }
94
+ ]
95
+ }
@@ -21,7 +21,10 @@
21
21
  "invalid_token_error": 401,
22
22
  "auth_field": "header.headers.Authorization",
23
23
  "auth_field_format": "Basic {b64}{username}:{password}{/b64}",
24
- "auth_logging": false
24
+ "auth_logging": false,
25
+ "client_id": "",
26
+ "client_secret": "",
27
+ "grant_type": ""
25
28
  },
26
29
  "healthcheck": {
27
30
  "type": "none",
@@ -14,7 +14,7 @@ const itParam = require('mocha-param');
14
14
 
15
15
  const utils = require('../../utils/tbUtils');
16
16
  const basicGet = require('../../utils/basicGet');
17
- const { name } = require('../../package');
17
+ const { name } = require('../../package.json');
18
18
  const { methods } = require('../../pronghorn.json');
19
19
 
20
20
  const getPronghornProps = (iapDir) => {
@@ -3,6 +3,7 @@
3
3
  // Set globals
4
4
  /* global describe it log pronghornProps */
5
5
  /* eslint no-unused-vars: warn */
6
+ /* eslint no-underscore-dangle: warn */
6
7
 
7
8
  // include required items for testing & logging
8
9
  const assert = require('assert');
@@ -13,7 +14,10 @@ const winston = require('winston');
13
14
  const { expect } = require('chai');
14
15
  const { use } = require('chai');
15
16
  const td = require('testdouble');
17
+ const util = require('util');
18
+ const pronghorn = require('../../pronghorn.json');
16
19
 
20
+ pronghorn.methodsByName = pronghorn.methods.reduce((result, meth) => ({ ...result, [meth.name]: meth }), {});
17
21
  const anything = td.matchers.anything();
18
22
 
19
23
  // stub and attemptTimeout are used throughout the code so set them here
@@ -63,7 +67,10 @@ global.pronghornProps = {
63
67
  invalid_token_error: 401,
64
68
  auth_field: 'header.headers.Authorization',
65
69
  auth_field_format: 'Basic {b64}{username}:{password}{/b64}',
66
- auth_logging: false
70
+ auth_logging: false,
71
+ client_id: '',
72
+ client_secret: '',
73
+ grant_type: ''
67
74
  },
68
75
  healthcheck: {
69
76
  type: 'none',
@@ -310,7 +317,7 @@ function saveMockData(entityName, actionName, descriptor, responseData) {
310
317
  }
311
318
 
312
319
  // require the adapter that we are going to be using
313
- const Meraki = require('../../adapter.js');
320
+ const Meraki = require('../../adapter');
314
321
 
315
322
  // begin the testing - these should be pretty well defined between the describe and the it!
316
323
  describe('[integration] Meraki Adapter Test', () => {
@@ -341,6 +348,8 @@ describe('[integration] Meraki Adapter Test', () => {
341
348
  try {
342
349
  assert.notEqual(null, a);
343
350
  assert.notEqual(undefined, a);
351
+ const checkId = global.pronghornProps.adapterProps.adapters[0].id;
352
+ assert.equal(checkId, a.id);
344
353
  assert.notEqual(null, a.allProps);
345
354
  const check = global.pronghornProps.adapterProps.adapters[0].properties.healthcheck.type;
346
355
  assert.equal(check, a.healthcheckType);
@@ -61,7 +61,10 @@ global.pronghornProps = {
61
61
  token_cache: 'local',
62
62
  auth_field: 'header.headers.Authorization',
63
63
  auth_field_format: 'Basic {b64}{username}:{password}{/b64}',
64
- auth_logging: false
64
+ auth_logging: false,
65
+ client_id: '',
66
+ client_secret: '',
67
+ grant_type: ''
65
68
  },
66
69
  healthcheck: {
67
70
  type: 'none',
@@ -194,7 +197,7 @@ function runErrorAsserts(data, error, code, origin, displayStr) {
194
197
  }
195
198
 
196
199
  // require the adapter that we are going to be using
197
- const AdapterBase = require('../../adapterBase.js');
200
+ const AdapterBase = require('../../adapterBase');
198
201
 
199
202
  // delete the .DS_Store directory in entities -- otherwise this will cause errors
200
203
  const dirPath = path.join(__dirname, '../../entities/.DS_Store');
@@ -314,8 +317,8 @@ describe('[unit] Adapter Base Test', () => {
314
317
  });
315
318
  it('should return a list of functions', (done) => {
316
319
  const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
317
- 'entityInList', 'findPath', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck',
318
- 'refreshProperties', 'runBasicGet', 'runConnectivity', 'runHealthcheck', 'suspend', 'troubleshoot', 'unsuspend', 'updateAdapterConfiguration', 'addListener',
320
+ 'entityInList', 'getAllCapabilities', 'getAllFunctions', 'healthCheck', 'iapFindAdapterPath', 'iapGetAdapterQueue', 'iapGetAdapterWorkflowFunctions', 'iapMoveAdapterEntitiesToDB',
321
+ 'iapRunAdapterBasicGet', 'iapRunAdapterConnectivity', 'iapRunAdapterHealthcheck', 'iapSuspendAdapter', 'iapTroubleshootAdapter', 'iapUnsuspendAdapter', 'iapUpdateAdapterConfiguration', 'refreshProperties', 'addListener',
319
322
  'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
320
323
  'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
321
324
  try {
@@ -334,10 +337,10 @@ describe('[unit] Adapter Base Test', () => {
334
337
  }).timeout(attemptTimeout);
335
338
  });
336
339
 
337
- describe('#getWorkflowFunctions', () => {
338
- it('should have a getWorkflowFunctions function', (done) => {
340
+ describe('#iapGetAdapterWorkflowFunctions', () => {
341
+ it('should have a iapGetAdapterWorkflowFunctions function', (done) => {
339
342
  try {
340
- assert.equal(true, typeof a.getWorkflowFunctions === 'function');
343
+ assert.equal(true, typeof a.iapGetAdapterWorkflowFunctions === 'function');
341
344
  done();
342
345
  } catch (error) {
343
346
  log.error(`Test Failure: ${error}`);
@@ -346,7 +349,7 @@ describe('[unit] Adapter Base Test', () => {
346
349
  });
347
350
  it('should retrieve workflow functions', (done) => {
348
351
  try {
349
- const expectedFunctions = a.getWorkflowFunctions([]);
352
+ const expectedFunctions = a.iapGetAdapterWorkflowFunctions([]);
350
353
  try {
351
354
  assert.equal(0, expectedFunctions.length);
352
355
  done();
@@ -423,10 +426,10 @@ describe('[unit] Adapter Base Test', () => {
423
426
  }).timeout(attemptTimeout);
424
427
  });
425
428
 
426
- describe('#getQueue', () => {
427
- it('should have a getQueue function', (done) => {
429
+ describe('#iapGetAdapterQueue', () => {
430
+ it('should have a iapGetAdapterQueue function', (done) => {
428
431
  try {
429
- assert.equal(true, typeof a.getQueue === 'function');
432
+ assert.equal(true, typeof a.iapGetAdapterQueue === 'function');
430
433
  done();
431
434
  } catch (error) {
432
435
  log.error(`Test Failure: ${error}`);
@@ -435,7 +438,7 @@ describe('[unit] Adapter Base Test', () => {
435
438
  });
436
439
  it('should get information for all of the requests currently in the queue', (done) => {
437
440
  try {
438
- const expectedFunctions = a.getQueue();
441
+ const expectedFunctions = a.iapGetAdapterQueue();
439
442
  try {
440
443
  assert.equal(0, expectedFunctions.length);
441
444
  done();
@@ -840,12 +843,10 @@ describe('[unit] Adapter Base Test', () => {
840
843
  }).timeout(attemptTimeout);
841
844
  });
842
845
 
843
- // const returnedFunctions = ['updateAdapterConfiguration'];
844
-
845
- describe('#updateAdapterConfiguration', () => {
846
- it('should have a updateAdapterConfiguration function', (done) => {
846
+ describe('#iapUpdateAdapterConfiguration', () => {
847
+ it('should have a iapUpdateAdapterConfiguration function', (done) => {
847
848
  try {
848
- assert.equal(true, typeof a.updateAdapterConfiguration === 'function');
849
+ assert.equal(true, typeof a.iapUpdateAdapterConfiguration === 'function');
849
850
  done();
850
851
  } catch (error) {
851
852
  log.error(`Test Failure: ${error}`);
@@ -854,7 +855,7 @@ describe('[unit] Adapter Base Test', () => {
854
855
  });
855
856
  it('should return no updated if no changes are provided', (done) => {
856
857
  try {
857
- a.updateAdapterConfiguration(null, null, null, null, null, (data, error) => {
858
+ a.iapUpdateAdapterConfiguration(null, null, null, null, null, (data, error) => {
858
859
  try {
859
860
  assert.equal('No configuration updates to make', data.response);
860
861
  done();
@@ -870,10 +871,10 @@ describe('[unit] Adapter Base Test', () => {
870
871
  }).timeout(attemptTimeout);
871
872
  it('should throw an error if missing configuration file', (done) => {
872
873
  try {
873
- a.updateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, (data, error) => {
874
+ a.iapUpdateAdapterConfiguration(null, { name: 'fakeChange' }, null, null, null, (data, error) => {
874
875
  try {
875
876
  const displayE = 'configFile is required';
876
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
877
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
877
878
  done();
878
879
  } catch (err) {
879
880
  log.error(`Test Failure: ${err}`);
@@ -887,10 +888,10 @@ describe('[unit] Adapter Base Test', () => {
887
888
  }).timeout(attemptTimeout);
888
889
  it('if not package.json, entity is required', (done) => {
889
890
  try {
890
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, (data, error) => {
891
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, null, null, null, (data, error) => {
891
892
  try {
892
893
  const displayE = 'Unsupported Configuration Change or Missing Entity';
893
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
894
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
894
895
  done();
895
896
  } catch (err) {
896
897
  log.error(`Test Failure: ${err}`);
@@ -904,10 +905,10 @@ describe('[unit] Adapter Base Test', () => {
904
905
  }).timeout(attemptTimeout);
905
906
  it('if not package.json, type is required', (done) => {
906
907
  try {
907
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, (data, error) => {
908
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'entity', null, null, (data, error) => {
908
909
  try {
909
910
  const displayE = 'type is required';
910
- runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
911
+ runErrorAsserts(data, error, 'AD.300', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
911
912
  done();
912
913
  } catch (err) {
913
914
  log.error(`Test Failure: ${err}`);
@@ -921,10 +922,10 @@ describe('[unit] Adapter Base Test', () => {
921
922
  }).timeout(attemptTimeout);
922
923
  it('if not package.json, entity must be valid', (done) => {
923
924
  try {
924
- a.updateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, (data, error) => {
925
+ a.iapUpdateAdapterConfiguration('notPackage', { name: 'fakeChange' }, 'fakeEntity', 'fakeType', null, (data, error) => {
925
926
  try {
926
927
  const displayE = 'Incomplete Configuration Change: Invalid Entity - fakeEntity';
927
- runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-updateAdapterConfiguration', displayE);
928
+ runErrorAsserts(data, error, 'AD.999', 'Test-Base-adapterBase-iapUpdateAdapterConfiguration', displayE);
928
929
  done();
929
930
  } catch (err) {
930
931
  log.error(`Test Failure: ${err}`);