@itentialopensource/adapter-microsoft_office365 0.1.1 → 0.2.0

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.
Files changed (56) hide show
  1. package/AUTH.md +41 -0
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +222 -0
  4. package/CHANGELOG.md +8 -1
  5. package/CODE_OF_CONDUCT.md +12 -17
  6. package/CONTRIBUTING.md +3 -148
  7. package/ENHANCE.md +69 -0
  8. package/PROPERTIES.md +641 -0
  9. package/README.md +235 -576
  10. package/SUMMARY.md +9 -0
  11. package/SYSTEMINFO.md +20 -0
  12. package/TROUBLESHOOT.md +47 -0
  13. package/adapter.js +391 -263
  14. package/adapterBase.js +854 -408
  15. package/changelogs/changelog.md +9 -0
  16. package/entities/.generic/action.json +110 -5
  17. package/entities/.generic/schema.json +6 -1
  18. package/error.json +6 -0
  19. package/metadata.json +57 -0
  20. package/package.json +28 -22
  21. package/pronghorn.json +691 -88
  22. package/propertiesDecorators.json +14 -0
  23. package/propertiesSchema.json +829 -8
  24. package/refs?service=git-upload-pack +0 -0
  25. package/report/adapter-openapi.json +509 -0
  26. package/report/adapter-openapi.yaml +349 -0
  27. package/report/adapterInfo.json +10 -0
  28. package/report/updateReport1691511327831.json +120 -0
  29. package/report/updateReport1692202817366.json +120 -0
  30. package/report/updateReport1694463941759.json +120 -0
  31. package/report/updateReport1698421603077.json +120 -0
  32. package/sampleProperties.json +153 -3
  33. package/test/integration/adapterTestBasicGet.js +3 -5
  34. package/test/integration/adapterTestConnectivity.js +91 -42
  35. package/test/integration/adapterTestIntegration.js +166 -114
  36. package/test/unit/adapterBaseTestUnit.js +388 -308
  37. package/test/unit/adapterTestUnit.js +490 -252
  38. package/utils/adapterInfo.js +206 -0
  39. package/utils/addAuth.js +94 -0
  40. package/utils/artifactize.js +1 -1
  41. package/utils/basicGet.js +1 -14
  42. package/utils/checkMigrate.js +1 -1
  43. package/utils/entitiesToDB.js +179 -0
  44. package/utils/findPath.js +1 -1
  45. package/utils/methodDocumentor.js +273 -0
  46. package/utils/modify.js +14 -16
  47. package/utils/packModificationScript.js +1 -1
  48. package/utils/patches2bundledDeps.js +90 -0
  49. package/utils/pre-commit.sh +5 -0
  50. package/utils/removeHooks.js +20 -0
  51. package/utils/taskMover.js +309 -0
  52. package/utils/tbScript.js +129 -53
  53. package/utils/tbUtils.js +125 -25
  54. package/utils/testRunner.js +17 -17
  55. package/utils/troubleshootingAdapter.js +10 -31
  56. package/workflows/README.md +0 -3
@@ -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": 17
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": 22
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^5.3.0"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 77
43
+ },
44
+ {
45
+ "owner": "markdown",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 347
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": 1799
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 88
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 732
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 19
93
+ },
94
+ {
95
+ "owner": "staticFile",
96
+ "description": "Number of lines of code in adapterBase.js",
97
+ "value": 1453
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": 3984
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 107
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -4,10 +4,12 @@
4
4
  "properties": {
5
5
  "host": "graph.microsoft.com",
6
6
  "port": 443,
7
- "base_path": "/",
7
+ "choosepath": "",
8
+ "base_path": "",
8
9
  "version": "v1.0",
9
10
  "cache_location": "none",
10
11
  "encode_pathvars": true,
12
+ "encode_queryvars": true,
11
13
  "save_metric": false,
12
14
  "stub": true,
13
15
  "protocol": "https",
@@ -25,12 +27,27 @@
25
27
  "tenant_id": "replace_tenant_id",
26
28
  "client_id": "replace_client_id",
27
29
  "grant_type": "client_credentials",
28
- "client_secret": "replace_client_secret"
30
+ "client_secret": "replace_client_secret",
31
+ "sensitive": [],
32
+ "sso": {
33
+ "protocol": "",
34
+ "host": "",
35
+ "port": 0
36
+ },
37
+ "multiStepAuthCalls": [
38
+ {
39
+ "name": "",
40
+ "requestFields": {},
41
+ "responseFields": {},
42
+ "successfullResponseCode": 200
43
+ }
44
+ ]
29
45
  },
30
46
  "healthcheck": {
31
47
  "type": "none",
32
48
  "frequency": 60000,
33
- "query_object": {}
49
+ "query_object": {},
50
+ "addlHeaders": {}
34
51
  },
35
52
  "throttle": {
36
53
  "throttle_enabled": false,
@@ -98,6 +115,139 @@
98
115
  "key_file": "",
99
116
  "cert_file": ""
100
117
  }
118
+ },
119
+ "devicebroker": {
120
+ "getDevice": [
121
+ {
122
+ "path": "/get/devices/{id}",
123
+ "method": "GET",
124
+ "query": {},
125
+ "body": {},
126
+ "headers": {},
127
+ "handleFailure": "ignore",
128
+ "requestFields": {
129
+ "id": "name"
130
+ },
131
+ "responseDatakey": "",
132
+ "responseFields": {
133
+ "name": "host",
134
+ "ostype": "os",
135
+ "ostypePrefix": "system-",
136
+ "ipaddress": "attributes.ipaddr",
137
+ "port": "443"
138
+ }
139
+ }
140
+ ],
141
+ "getDevicesFiltered": [
142
+ {
143
+ "path": "/get/devices",
144
+ "method": "GET",
145
+ "pagination": {
146
+ "offsetVar": "",
147
+ "limitVar": "",
148
+ "incrementBy": "limit",
149
+ "requestLocation": "query"
150
+ },
151
+ "query": {},
152
+ "body": {},
153
+ "headers": {},
154
+ "handleFailure": "ignore",
155
+ "requestFields": {},
156
+ "responseDatakey": "",
157
+ "responseFields": {
158
+ "name": "host",
159
+ "ostype": "os",
160
+ "ostypePrefix": "system-",
161
+ "ipaddress": "attributes.ipaddr",
162
+ "port": "443"
163
+ }
164
+ }
165
+ ],
166
+ "isAlive": [
167
+ {
168
+ "path": "/get/devices/{id}/status",
169
+ "method": "GET",
170
+ "query": {},
171
+ "body": {},
172
+ "headers": {},
173
+ "handleFailure": "ignore",
174
+ "requestFields": {
175
+ "id": "name"
176
+ },
177
+ "responseDatakey": "",
178
+ "responseFields": {
179
+ "status": "status",
180
+ "statusValue": "online"
181
+ }
182
+ }
183
+ ],
184
+ "getConfig": [
185
+ {
186
+ "path": "/get/devices/{id}/configPart1",
187
+ "method": "GET",
188
+ "query": {},
189
+ "body": {},
190
+ "headers": {},
191
+ "handleFailure": "ignore",
192
+ "requestFields": {
193
+ "id": "name"
194
+ },
195
+ "responseDatakey": "",
196
+ "responseFields": {}
197
+ }
198
+ ],
199
+ "getCount": [
200
+ {
201
+ "path": "/get/devices",
202
+ "method": "GET",
203
+ "query": {},
204
+ "body": {},
205
+ "headers": {},
206
+ "handleFailure": "ignore",
207
+ "requestFields": {},
208
+ "responseDatakey": "",
209
+ "responseFields": {}
210
+ }
211
+ ]
212
+ },
213
+ "cache": {
214
+ "enabled": false,
215
+ "entities": [
216
+ {
217
+ "entityType": "",
218
+ "frequency": 1440,
219
+ "flushOnFail": false,
220
+ "limit": 1000,
221
+ "retryAttempts": 5,
222
+ "sort": true,
223
+ "populate": [
224
+ {
225
+ "path": "",
226
+ "method": "GET",
227
+ "pagination": {
228
+ "offsetVar": "",
229
+ "limitVar": "",
230
+ "incrementBy": "limit",
231
+ "requestLocation": "query"
232
+ },
233
+ "query": {},
234
+ "body": {},
235
+ "headers": {},
236
+ "handleFailure": "ignore",
237
+ "requestFields": {},
238
+ "responseDatakey": "",
239
+ "responseFields": {}
240
+ }
241
+ ],
242
+ "cachedTasks": [
243
+ {
244
+ "name": "",
245
+ "filterField": "",
246
+ "filterLoc": ""
247
+ }
248
+ ]
249
+ }
250
+ ]
101
251
  }
102
252
  },
103
253
  "groups": [],
@@ -7,9 +7,9 @@
7
7
  /* eslint import/no-dynamic-require: warn */
8
8
  /* eslint import/no-unresolved: warn */
9
9
 
10
- const mocha = require('mocha');
11
10
  const path = require('path');
12
11
  const assert = require('assert');
12
+ const mocha = require('mocha');
13
13
  const itParam = require('mocha-param');
14
14
 
15
15
  const utils = require('../../utils/tbUtils');
@@ -18,12 +18,10 @@ const { name } = require('../../package.json');
18
18
  const { methods } = require('../../pronghorn.json');
19
19
 
20
20
  const getPronghornProps = (iapDir) => {
21
- const { Discovery } = require('@itential/itential-utils');
22
21
  console.log('Retrieving properties.json file...');
23
22
  const rawProps = require(path.join(iapDir, 'properties.json'));
24
23
  console.log('Decrypting properties...');
25
- const discovery = new Discovery();
26
- const pronghornProps = utils.decryptProperties(rawProps, path.join(__dirname, '..'), discovery);
24
+ const pronghornProps = utils.decryptProperties(rawProps, iapDir);
27
25
  console.log('Found properties.\n');
28
26
  return pronghornProps;
29
27
  };
@@ -34,7 +32,7 @@ describe('[integration] Adapter BasicGET Test', () => {
34
32
  context('Testing GET calls without query parameters', () => {
35
33
  before(async () => {
36
34
  const iapDir = path.join(__dirname, '../../../../../');
37
- if (!utils.withinIAP(iapDir)) {
35
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
38
36
  const sampleProperties = require('../../sampleProperties.json');
39
37
  const adapter = { properties: sampleProperties };
40
38
  a = basicGet.getAdapterInstance(adapter);
@@ -3,9 +3,12 @@
3
3
  /* global describe it context before after */
4
4
  /* eslint no-unused-vars: warn */
5
5
 
6
- const mocha = require('mocha');
7
6
  const assert = require('assert');
8
- const diagnostics = require('network-diagnostics');
7
+ const http = require('http');
8
+ const https = require('https');
9
+ const mocha = require('mocha');
10
+ const ping = require('ping');
11
+ const dnsLookup = require('dns-lookup-promise');
9
12
 
10
13
  let host;
11
14
  process.argv.forEach((val) => {
@@ -16,78 +19,124 @@ process.argv.forEach((val) => {
16
19
 
17
20
  describe('[integration] Adapter Test', () => {
18
21
  context(`Testing network connection on ${host}`, () => {
19
- before(() => {
20
- diagnostics.setTestURL(host);
21
- });
22
-
23
22
  after((done) => {
24
23
  done();
25
24
  });
26
25
 
27
26
  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
- });
27
+ dnsLookup(host)
28
+ .then((addresses) => {
29
+ try {
30
+ assert.ok(addresses.length > 0);
31
+ done();
32
+ } catch (error) {
33
+ done(error);
34
+ }
35
+ })
36
+ .catch((err) => {
37
+ done(err);
38
+ });
36
39
  });
37
40
 
38
41
  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
- });
42
+ ping.promise.probe(host)
43
+ .then((result) => {
44
+ try {
45
+ assert.ok(result.alive);
46
+ done();
47
+ } catch (error) {
48
+ done(error);
49
+ }
50
+ })
51
+ .catch((err) => {
52
+ done(err);
53
+ });
47
54
  });
48
55
 
49
56
  it('Support HTTP on port 80', (done) => {
50
- diagnostics.haveHTTP((result) => {
57
+ const requestOptions = {
58
+ host,
59
+ port: 80,
60
+ method: 'HEAD'
61
+ };
62
+
63
+ const req = http.request(requestOptions, (res) => {
51
64
  try {
52
- assert.equal(result, true);
65
+ assert.ok(res.statusCode >= 200 && res.statusCode < 400);
53
66
  done();
54
67
  } catch (error) {
55
68
  done(error);
56
69
  }
57
70
  });
71
+
72
+ req.on('error', (err) => {
73
+ done(err);
74
+ });
75
+
76
+ req.end();
58
77
  });
59
78
 
60
79
  it('Support HTTPS on port 443', (done) => {
61
- diagnostics.haveHTTPS((result) => {
80
+ const requestOptions = {
81
+ host,
82
+ port: 443,
83
+ method: 'HEAD'
84
+ };
85
+
86
+ const req = https.request(requestOptions, (res) => {
62
87
  try {
63
- assert.equal(result, true);
88
+ assert.ok(res.statusCode >= 200 && res.statusCode < 400);
64
89
  done();
65
90
  } catch (error) {
66
91
  done(error);
67
92
  }
68
93
  });
94
+
95
+ req.on('error', (err) => {
96
+ done(err);
97
+ });
98
+
99
+ req.end();
69
100
  });
70
101
 
71
102
  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
- });
103
+ const options = {
104
+ family: 4,
105
+ hints: dnsLookup.ADDRCONFIG
106
+ };
107
+
108
+ dnsLookup.lookup(host, options)
109
+ .then((address, family) => {
110
+ try {
111
+ assert.ok(address !== null && family === 4);
112
+ done();
113
+ } catch (error) {
114
+ done(error);
115
+ }
116
+ })
117
+ .catch((err) => {
118
+ done(err);
119
+ });
80
120
  });
81
121
 
82
122
  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
- });
123
+ const options = {
124
+ family: 6,
125
+ hints: dnsLookup.ADDRCONFIG
126
+ };
127
+
128
+ dnsLookup.lookup(host, options)
129
+ .then((address, family) => {
130
+ try {
131
+ assert.ok(address !== null && family === 6);
132
+ done();
133
+ } catch (error) {
134
+ done(error);
135
+ }
136
+ })
137
+ .catch((err) => {
138
+ done(err);
139
+ });
91
140
  });
92
141
  });
93
142
  });