@itentialopensource/adapter-terraform_enterprise 0.1.2 → 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 (69) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.js +12 -12
  3. package/AUTH.md +39 -0
  4. package/BROKER.md +199 -0
  5. package/CALLS.md +169 -0
  6. package/CHANGELOG.md +33 -5
  7. package/CODE_OF_CONDUCT.md +12 -17
  8. package/CONTRIBUTING.md +88 -74
  9. package/ENHANCE.md +69 -0
  10. package/PROPERTIES.md +641 -0
  11. package/README.md +251 -420
  12. package/SUMMARY.md +9 -0
  13. package/SYSTEMINFO.md +11 -0
  14. package/TROUBLESHOOT.md +47 -0
  15. package/adapter.js +1220 -119
  16. package/adapterBase.js +1317 -43
  17. package/entities/.generic/action.json +214 -0
  18. package/entities/.generic/schema.json +28 -0
  19. package/entities/.system/action.json +3 -2
  20. package/entities/Account/action.json +2 -0
  21. package/entities/NotificationConfigurations/action.json +4 -0
  22. package/entities/OAuthClients/action.json +3 -0
  23. package/entities/OAuthTokens/action.json +2 -0
  24. package/entities/OrganizationMemberships/action.json +2 -0
  25. package/entities/OrganizationToken/action.json +2 -0
  26. package/entities/PlanExports/action.json +2 -0
  27. package/entities/Policies/action.json +4 -0
  28. package/entities/PolicyChecks/action.json +1 -0
  29. package/entities/PolicySetParameters/action.json +3 -0
  30. package/entities/PolicySets/action.json +8 -0
  31. package/entities/Runs/action.json +5 -0
  32. package/entities/StateVersions/action.json +1 -0
  33. package/entities/Variables/action.json +3 -0
  34. package/entities/Workspaces/action.json +5 -0
  35. package/entities/WorkspacesVariables/action.json +3 -0
  36. package/error.json +12 -0
  37. package/package.json +45 -22
  38. package/pronghorn.json +656 -7
  39. package/propertiesDecorators.json +14 -0
  40. package/propertiesSchema.json +479 -6
  41. package/refs?service=git-upload-pack +0 -0
  42. package/report/Terraform.OpenApi3Json.json +3984 -0
  43. package/report/adapterInfo.json +10 -0
  44. package/report/updateReport1594344536029.json +95 -0
  45. package/report/updateReport1615837746160.json +95 -0
  46. package/report/updateReport1653324214945.json +120 -0
  47. package/sampleProperties.json +147 -21
  48. package/test/integration/adapterTestBasicGet.js +85 -0
  49. package/test/integration/adapterTestConnectivity.js +93 -0
  50. package/test/integration/adapterTestIntegration.js +634 -3369
  51. package/test/unit/adapterBaseTestUnit.js +949 -0
  52. package/test/unit/adapterTestUnit.js +1234 -3329
  53. package/utils/adapterInfo.js +206 -0
  54. package/utils/addAuth.js +94 -0
  55. package/utils/artifactize.js +0 -1
  56. package/utils/basicGet.js +50 -0
  57. package/utils/checkMigrate.js +63 -0
  58. package/utils/entitiesToDB.js +179 -0
  59. package/utils/findPath.js +74 -0
  60. package/utils/modify.js +154 -0
  61. package/utils/packModificationScript.js +1 -1
  62. package/utils/patches2bundledDeps.js +90 -0
  63. package/utils/pre-commit.sh +3 -0
  64. package/utils/removeHooks.js +20 -0
  65. package/utils/tbScript.js +184 -0
  66. package/utils/tbUtils.js +469 -0
  67. package/utils/testRunner.js +16 -16
  68. package/utils/troubleshootingAdapter.js +190 -0
  69. package/gl-code-quality-report.json +0 -1
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": "0.1.4",
3
+ "configLines": 5464,
4
+ "scriptLines": 1707,
5
+ "codeLines": 9056,
6
+ "testLines": 7437,
7
+ "testCases": 373,
8
+ "totalCodeLines": 18200,
9
+ "wfTasks": 103
10
+ }
@@ -0,0 +1,95 @@
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": 29
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 5
23
+ },
24
+ {
25
+ "owner": "packageJson",
26
+ "description": "Number of development dependencies",
27
+ "value": 9
28
+ },
29
+ {
30
+ "owner": "packageJson",
31
+ "description": "Number of npm scripts",
32
+ "value": 10
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.34.4"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 56
43
+ },
44
+ {
45
+ "owner": "readmeMd",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 530
48
+ },
49
+ {
50
+ "owner": "unitTestJS",
51
+ "description": "Number of lines of code in unit tests",
52
+ "value": 5837
53
+ },
54
+ {
55
+ "owner": "unitTestJS",
56
+ "description": "Number of unit tests",
57
+ "value": 369
58
+ },
59
+ {
60
+ "owner": "integrationTestJS",
61
+ "description": "Number of lines of code in integration tests",
62
+ "value": 5298
63
+ },
64
+ {
65
+ "owner": "integrationTestJS",
66
+ "description": "Number of integration tests",
67
+ "value": 177
68
+ },
69
+ {
70
+ "owner": "staticFile",
71
+ "description": "Number of lines of code in adapterBase.js",
72
+ "value": 751
73
+ },
74
+ {
75
+ "owner": "staticFile",
76
+ "description": "Number of static files added",
77
+ "value": 18
78
+ },
79
+ {
80
+ "owner": "Overall",
81
+ "description": "Total lines of Code",
82
+ "value": 11886
83
+ },
84
+ {
85
+ "owner": "Overall",
86
+ "description": "Total Tests",
87
+ "value": 546
88
+ },
89
+ {
90
+ "owner": "Overall",
91
+ "description": "Total Files",
92
+ "value": 6
93
+ }
94
+ ]
95
+ }
@@ -0,0 +1,95 @@
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": 29
18
+ },
19
+ {
20
+ "owner": "packageJson",
21
+ "description": "Number of production dependencies",
22
+ "value": 12
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": 21
33
+ },
34
+ {
35
+ "owner": "packageJson",
36
+ "description": "Runtime Library dependency",
37
+ "value": "^4.39.2"
38
+ },
39
+ {
40
+ "owner": "propertiesSchemaJson",
41
+ "description": "Adapter properties defined in the propertiesSchema file",
42
+ "value": 61
43
+ },
44
+ {
45
+ "owner": "readmeMd",
46
+ "description": "Number of lines in the README.md",
47
+ "value": 615
48
+ },
49
+ {
50
+ "owner": "unitTestJS",
51
+ "description": "Number of lines of code in unit tests",
52
+ "value": 3340
53
+ },
54
+ {
55
+ "owner": "unitTestJS",
56
+ "description": "Number of unit tests",
57
+ "value": 209
58
+ },
59
+ {
60
+ "owner": "integrationTestJS",
61
+ "description": "Number of lines of code in integration tests",
62
+ "value": 2633
63
+ },
64
+ {
65
+ "owner": "integrationTestJS",
66
+ "description": "Number of integration tests",
67
+ "value": 91
68
+ },
69
+ {
70
+ "owner": "staticFile",
71
+ "description": "Number of lines of code in adapterBase.js",
72
+ "value": 1007
73
+ },
74
+ {
75
+ "owner": "staticFile",
76
+ "description": "Number of static files added",
77
+ "value": 30
78
+ },
79
+ {
80
+ "owner": "Overall",
81
+ "description": "Total lines of Code",
82
+ "value": 6980
83
+ },
84
+ {
85
+ "owner": "Overall",
86
+ "description": "Total Tests",
87
+ "value": 300
88
+ },
89
+ {
90
+ "owner": "Overall",
91
+ "description": "Total Files",
92
+ "value": 6
93
+ }
94
+ ]
95
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "errors": [],
3
+ "statistics": [
4
+ {
5
+ "owner": "errorJson",
6
+ "description": "New adapter errors available for use",
7
+ "value": 2
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": 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": 3743
78
+ },
79
+ {
80
+ "owner": "unitTestJS",
81
+ "description": "Number of unit tests",
82
+ "value": 224
83
+ },
84
+ {
85
+ "owner": "integrationTestJS",
86
+ "description": "Number of lines of code in integration tests",
87
+ "value": 2564
88
+ },
89
+ {
90
+ "owner": "integrationTestJS",
91
+ "description": "Number of integration tests",
92
+ "value": 91
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": 8090
108
+ },
109
+ {
110
+ "owner": "Overall",
111
+ "description": "Total Tests",
112
+ "value": 315
113
+ },
114
+ {
115
+ "owner": "Overall",
116
+ "description": "Total Files",
117
+ "value": 6
118
+ }
119
+ ]
120
+ }
@@ -1,28 +1,54 @@
1
1
  {
2
2
  "id": "terraform_enterprise",
3
- "type": "TerraformEnterprise",
3
+ "type": "Terraform",
4
4
  "properties": {
5
5
  "host": "localhost",
6
6
  "port": 443,
7
7
  "base_path": "/api",
8
8
  "version": "v2",
9
9
  "cache_location": "local",
10
+ "encode_pathvars": true,
11
+ "encode_queryvars": true,
12
+ "save_metric": false,
10
13
  "stub": false,
11
14
  "protocol": "https",
12
15
  "authentication": {
13
16
  "auth_method": "static_token",
14
- "auth_field": "header.headers.Authorization",
15
- "auth_field_format": "Bearer {token}",
17
+ "username": "username",
18
+ "password": "password",
16
19
  "token": "token",
17
20
  "invalid_token_error": 401,
18
21
  "token_timeout": 0,
19
- "token_cache": "local"
22
+ "token_cache": "local",
23
+ "auth_field": "header.headers.Authorization",
24
+ "auth_field_format": "Bearer {token}",
25
+ "auth_logging": false,
26
+ "client_id": "",
27
+ "client_secret": "",
28
+ "grant_type": ""
20
29
  },
21
30
  "healthcheck": {
22
31
  "type": "startup",
23
- "frequency": 300000
32
+ "frequency": 300000,
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
+ ]
24
49
  },
25
50
  "request": {
51
+ "number_redirects": 0,
26
52
  "number_retries": 3,
27
53
  "limit_retry_error": 401,
28
54
  "failover_codes": [
@@ -30,8 +56,6 @@
30
56
  405
31
57
  ],
32
58
  "attempt_timeout": 5000,
33
- "healthcheck_on_timeout": false,
34
- "archiving": false,
35
59
  "global_request": {
36
60
  "payload": {},
37
61
  "uriOptions": {},
@@ -39,30 +63,132 @@
39
63
  "Content-Type": "application/vnd.api+json"
40
64
  },
41
65
  "authData": {}
42
- }
66
+ },
67
+ "healthcheck_on_timeout": false,
68
+ "return_raw": false,
69
+ "archiving": false,
70
+ "return_request": false
71
+ },
72
+ "proxy": {
73
+ "enabled": false,
74
+ "host": "localhost",
75
+ "port": 9999,
76
+ "protocol": "http",
77
+ "username": "",
78
+ "password": ""
43
79
  },
44
80
  "ssl": {
45
81
  "ecdhCurve": "",
46
82
  "enabled": true,
47
83
  "accept_invalid_cert": true,
48
84
  "ca_file": "",
85
+ "key_file": "",
86
+ "cert_file": "",
49
87
  "secure_protocol": "",
50
88
  "ciphers": ""
51
89
  },
52
- "throttle": {
53
- "throttle_enabled": false,
54
- "number_pronghorns": 1,
55
- "sync_async": "sync",
56
- "max_in_queue": 1000,
57
- "concurrent_max": 1,
58
- "expire_timeout": 0,
59
- "avg_runtime": 200
90
+ "mongo": {
91
+ "host": "",
92
+ "port": 0,
93
+ "database": "",
94
+ "username": "",
95
+ "password": "",
96
+ "replSet": "",
97
+ "db_ssl": {
98
+ "enabled": false,
99
+ "accept_invalid_cert": false,
100
+ "ca_file": "",
101
+ "key_file": "",
102
+ "cert_file": ""
103
+ }
60
104
  },
61
- "proxy": {
62
- "enabled": false,
63
- "host": "localhost",
64
- "port": 9999,
65
- "protocol": "http"
105
+ "devicebroker": {
106
+ "getDevice": [
107
+ {
108
+ "path": "/get/devices/{id}",
109
+ "method": "GET",
110
+ "query": {},
111
+ "body": {},
112
+ "headers": {},
113
+ "handleFailure": "ignore",
114
+ "requestFields": {
115
+ "id": "name"
116
+ },
117
+ "responseDatakey": "",
118
+ "responseFields": {
119
+ "name": "host",
120
+ "ostype": "os",
121
+ "ostypePrefix": "system-",
122
+ "ipaddress": "attributes.ipaddr",
123
+ "port": "443"
124
+ }
125
+ }
126
+ ],
127
+ "getDevicesFiltered": [
128
+ {
129
+ "path": "/get/devices",
130
+ "method": "GET",
131
+ "query": {},
132
+ "body": {},
133
+ "headers": {},
134
+ "handleFailure": "ignore",
135
+ "requestFields": {},
136
+ "responseDatakey": "",
137
+ "responseFields": {
138
+ "name": "host",
139
+ "ostype": "os",
140
+ "ostypePrefix": "system-",
141
+ "ipaddress": "attributes.ipaddr",
142
+ "port": "443"
143
+ }
144
+ }
145
+ ],
146
+ "isAlive": [
147
+ {
148
+ "path": "/get/devices/{id}/status",
149
+ "method": "GET",
150
+ "query": {},
151
+ "body": {},
152
+ "headers": {},
153
+ "handleFailure": "ignore",
154
+ "requestFields": {
155
+ "id": "name"
156
+ },
157
+ "responseDatakey": "",
158
+ "responseFields": {
159
+ "status": "status",
160
+ "statusValue": "online"
161
+ }
162
+ }
163
+ ],
164
+ "getConfig": [
165
+ {
166
+ "path": "/get/devices/{id}/configPart1",
167
+ "method": "GET",
168
+ "query": {},
169
+ "body": {},
170
+ "headers": {},
171
+ "handleFailure": "ignore",
172
+ "requestFields": {
173
+ "id": "name"
174
+ },
175
+ "responseDatakey": "",
176
+ "responseFields": {}
177
+ }
178
+ ],
179
+ "getCount": [
180
+ {
181
+ "path": "/get/devices",
182
+ "method": "GET",
183
+ "query": {},
184
+ "body": {},
185
+ "headers": {},
186
+ "handleFailure": "ignore",
187
+ "requestFields": {},
188
+ "responseDatakey": "",
189
+ "responseFields": {}
190
+ }
191
+ ]
66
192
  }
67
193
  },
68
194
  "brokers": [],
@@ -0,0 +1,85 @@
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
+ const { Discovery } = require('@itential/itential-utils');
22
+ console.log('Retrieving properties.json file...');
23
+ const rawProps = require(path.join(iapDir, 'properties.json'));
24
+ console.log('Decrypting properties...');
25
+ const discovery = new Discovery();
26
+ const pronghornProps = utils.decryptProperties(rawProps, path.join(__dirname, '..'), discovery);
27
+ console.log('Found properties.\n');
28
+ return pronghornProps;
29
+ };
30
+
31
+ let a;
32
+
33
+ describe('[integration] Adapter BasicGET Test', () => {
34
+ context('Testing GET calls without query parameters', () => {
35
+ before(async () => {
36
+ const iapDir = path.join(__dirname, '../../../../../');
37
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
38
+ const sampleProperties = require('../../sampleProperties.json');
39
+ const adapter = { properties: sampleProperties };
40
+ a = basicGet.getAdapterInstance(adapter);
41
+ } else {
42
+ const pronghornProps = getPronghornProps(iapDir);
43
+ console.log('Connecting to Database...');
44
+ const database = await basicGet.connect(pronghornProps);
45
+ console.log('Connection established.');
46
+ const adapter = await database.collection(utils.SERVICE_CONFIGS_COLLECTION).findOne(
47
+ { model: name }
48
+ );
49
+ a = basicGet.getAdapterInstance(adapter);
50
+ }
51
+ });
52
+
53
+ after((done) => {
54
+ done();
55
+ });
56
+
57
+ const basicGets = methods.filter((method) => (method.route.verb === 'GET' && method.input.length === 0));
58
+ if (basicGets.length === 0) {
59
+ console.log('No non-parameter GET calls found.');
60
+ process.exit(0);
61
+ }
62
+ const functionNames = basicGets.map((g) => g.name);
63
+ const request = function request(f, ad) {
64
+ return new Promise((resolve, reject) => {
65
+ const getRespCode = (resp) => {
66
+ if (resp) {
67
+ if (resp.metrics.code !== 200) {
68
+ console.log('\x1b[31m', `Testing ${f} \nResponseCode: ${resp.metrics.code}`);
69
+ }
70
+ resolve(resp.metrics.code);
71
+ } else {
72
+ console.log('\x1b[31m', `call ${f} results in failure`);
73
+ reject(new Error(`${f} failed`));
74
+ }
75
+ };
76
+ ad[f](getRespCode, console.log);
77
+ });
78
+ };
79
+
80
+ itParam('GET call should return 200', functionNames, (fname) => {
81
+ console.log(`\t ${fname}`);
82
+ return request(fname, a).then((result) => assert.equal(result, 200));
83
+ });
84
+ });
85
+ });