@unito/integration-cli 0.57.0 → 0.57.2
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/dist/integrationGenerator/test/resources/integration.test.js +7 -8
- package/dist/src/commands/activity.d.ts +2 -2
- package/dist/src/commands/activity.js +2 -2
- package/dist/src/commands/dev.d.ts +4 -4
- package/dist/src/commands/dev.js +3 -2
- package/dist/src/commands/encrypt.d.ts +1 -1
- package/dist/src/commands/encrypt.js +1 -1
- package/dist/src/commands/init.d.ts +1 -1
- package/dist/src/commands/init.js +1 -1
- package/dist/src/commands/invite.d.ts +1 -1
- package/dist/src/commands/invite.js +2 -2
- package/dist/src/commands/login.d.ts +1 -1
- package/dist/src/commands/login.js +1 -1
- package/dist/src/commands/oauth2.d.ts +3 -3
- package/dist/src/commands/oauth2.js +4 -4
- package/dist/src/commands/publish.d.ts +2 -2
- package/dist/src/commands/publish.js +12 -12
- package/dist/src/commands/test.js +5 -3
- package/dist/src/commands/upgrade.js +3 -3
- package/dist/src/oauth2Helper/oauth2Helper.d.ts +4 -2
- package/dist/src/oauth2Helper/oauth2Helper.js +31 -11
- package/dist/src/services/oauth2Helper.d.ts +2 -1
- package/dist/src/services/oauth2Helper.js +4 -3
- package/dist/test/commands/activity.test.js +12 -9
- package/dist/test/commands/dev.test.js +38 -10
- package/dist/test/commands/encrypt.test.js +6 -7
- package/dist/test/commands/init.test.js +6 -8
- package/dist/test/commands/invite.test.js +11 -11
- package/dist/test/commands/login.test.js +19 -23
- package/dist/test/commands/oauth2.test.js +4 -1
- package/dist/test/commands/publish.test.js +151 -218
- package/dist/test/commands/test.test.js +43 -13
- package/dist/test/commands/upgrade.test.js +3 -6
- package/dist/test/errors.test.js +36 -36
- package/dist/test/helpers/integrations.d.ts +26 -0
- package/dist/test/helpers/integrations.js +25 -0
- package/dist/test/helpers/styles.d.ts +1 -0
- package/dist/test/helpers/styles.js +8 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.js +20 -20
- package/dist/test/resources/configuration.test.js +24 -24
- package/dist/test/resources/decryption.test.js +9 -9
- package/dist/test/resources/globalConfiguration.test.js +4 -4
- package/dist/test/services/integrationsPlatform.test.js +20 -20
- package/dist/test/services/oauth2Helper.test.js +7 -7
- package/oclif.manifest.json +1 -1
- package/package.json +3 -7
- package/dist/test/mocha.hooks.d.ts +0 -2
- package/dist/test/mocha.hooks.js +0 -37
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
5
5
|
const tmp_1 = tslib_1.__importDefault(require("tmp"));
|
|
6
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
7
|
const sinon = tslib_1.__importStar(require("sinon"));
|
|
@@ -41,19 +41,19 @@ describe('configuration', () => {
|
|
|
41
41
|
throw Error('Should have thrown NoConfigurationFileError');
|
|
42
42
|
}
|
|
43
43
|
catch (error) {
|
|
44
|
-
(0,
|
|
44
|
+
(0, strict_1.default)(error instanceof errors_2.NoConfigurationFileError);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
it('handles missing specific environment file', async () => {
|
|
48
48
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Staging);
|
|
49
|
-
|
|
49
|
+
strict_1.default.equal(configuration.name, originalConfiguration.name);
|
|
50
50
|
});
|
|
51
51
|
it('returns existing specific environment file', async () => {
|
|
52
52
|
await fs_1.default.promises.writeFile(`${process.cwd()}/.unito.${globalConfiguration_1.Environment.Staging}.json`, JSON.stringify({
|
|
53
53
|
name: 'foo',
|
|
54
54
|
}, null, 2));
|
|
55
55
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Staging);
|
|
56
|
-
|
|
56
|
+
strict_1.default.equal(configuration.name, 'foo');
|
|
57
57
|
});
|
|
58
58
|
it('throws on missing custom configuration file', async () => {
|
|
59
59
|
try {
|
|
@@ -61,7 +61,7 @@ describe('configuration', () => {
|
|
|
61
61
|
throw Error('Should have thrown NoConfigurationFileError');
|
|
62
62
|
}
|
|
63
63
|
catch (error) {
|
|
64
|
-
(0,
|
|
64
|
+
(0, strict_1.default)(error instanceof errors_2.NoConfigurationFileError);
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
it('returns existing specific environment file', async () => {
|
|
@@ -69,7 +69,7 @@ describe('configuration', () => {
|
|
|
69
69
|
name: 'foo',
|
|
70
70
|
}, null, 2));
|
|
71
71
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Staging, '/custom-config.json');
|
|
72
|
-
|
|
72
|
+
strict_1.default.equal(configuration.name, 'foo');
|
|
73
73
|
});
|
|
74
74
|
it('sets default values for "oauth2"', async () => {
|
|
75
75
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -90,9 +90,9 @@ describe('configuration', () => {
|
|
|
90
90
|
}, null, 2));
|
|
91
91
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
92
92
|
const oauth2 = configuration.authorizations?.at(0)?.oauth2;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
strict_1.default.equal(oauth2?.requestContentType, configurationTypes_1.RequestContentType.URL_ENCODED);
|
|
94
|
+
strict_1.default.equal(oauth2?.responseContentType, configurationTypes_1.RequestContentType.JSON);
|
|
95
|
+
strict_1.default.equal(oauth2?.grantType, configurationTypes_1.GrantType.AUTHORIZATION_CODE);
|
|
96
96
|
});
|
|
97
97
|
it('accepts password grant for "oauth2"', async () => {
|
|
98
98
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -114,7 +114,7 @@ describe('configuration', () => {
|
|
|
114
114
|
}, null, 2));
|
|
115
115
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
116
116
|
const oauth2 = configuration.authorizations?.at(0)?.oauth2;
|
|
117
|
-
|
|
117
|
+
strict_1.default.equal(oauth2?.grantType, configurationTypes_1.GrantType.PASSWORD);
|
|
118
118
|
});
|
|
119
119
|
it('accepts request parameters for "oauth2"', async () => {
|
|
120
120
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -149,7 +149,7 @@ describe('configuration', () => {
|
|
|
149
149
|
}, null, 2));
|
|
150
150
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
151
151
|
const oauth2 = configuration.authorizations?.at(0)?.oauth2;
|
|
152
|
-
|
|
152
|
+
strict_1.default.deepEqual(oauth2?.tokenRequestParameters, {
|
|
153
153
|
header: {
|
|
154
154
|
a: 'yo',
|
|
155
155
|
},
|
|
@@ -157,7 +157,7 @@ describe('configuration', () => {
|
|
|
157
157
|
b: false,
|
|
158
158
|
},
|
|
159
159
|
});
|
|
160
|
-
|
|
160
|
+
strict_1.default.deepEqual(oauth2?.refreshRequestParameters, {
|
|
161
161
|
body: {
|
|
162
162
|
c: 1,
|
|
163
163
|
},
|
|
@@ -172,7 +172,7 @@ describe('configuration', () => {
|
|
|
172
172
|
},
|
|
173
173
|
}, null, 2));
|
|
174
174
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
175
|
-
|
|
175
|
+
strict_1.default.deepEqual(configuration.secrets, { foo: 'unito-secret-v1://bar' });
|
|
176
176
|
});
|
|
177
177
|
it('invalid secret - type', async () => {
|
|
178
178
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -181,7 +181,7 @@ describe('configuration', () => {
|
|
|
181
181
|
foo: 123,
|
|
182
182
|
},
|
|
183
183
|
}, null, 2));
|
|
184
|
-
await
|
|
184
|
+
await strict_1.default.rejects(Configuration.getConfiguration(globalConfiguration_1.Environment.Production), errors_1.ConfigurationInvalid);
|
|
185
185
|
});
|
|
186
186
|
it('invalid secret - pattern', async () => {
|
|
187
187
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -190,7 +190,7 @@ describe('configuration', () => {
|
|
|
190
190
|
foo: 'nope',
|
|
191
191
|
},
|
|
192
192
|
}, null, 2));
|
|
193
|
-
await
|
|
193
|
+
await strict_1.default.rejects(Configuration.getConfiguration(globalConfiguration_1.Environment.Production), errors_1.ConfigurationInvalid);
|
|
194
194
|
});
|
|
195
195
|
});
|
|
196
196
|
describe('validates test accounts - custom', () => {
|
|
@@ -245,8 +245,8 @@ describe('configuration', () => {
|
|
|
245
245
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
246
246
|
const developmentKey = configuration.testAccounts?.development?.apiKey;
|
|
247
247
|
const complianceKey = configuration.testAccounts?.compliance?.apiKey;
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
strict_1.default.equal(developmentKey, 'xyz');
|
|
249
|
+
strict_1.default.equal(complianceKey, 'xyzw');
|
|
250
250
|
});
|
|
251
251
|
it('invalid test accounts', async () => {
|
|
252
252
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -284,7 +284,7 @@ describe('configuration', () => {
|
|
|
284
284
|
},
|
|
285
285
|
},
|
|
286
286
|
}, null, 2));
|
|
287
|
-
await
|
|
287
|
+
await strict_1.default.rejects(Configuration.getConfiguration(globalConfiguration_1.Environment.Production), errors_1.ConfigurationInvalid);
|
|
288
288
|
});
|
|
289
289
|
});
|
|
290
290
|
describe('validates test accounts - oauth', () => {
|
|
@@ -364,8 +364,8 @@ describe('configuration', () => {
|
|
|
364
364
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
365
365
|
const developmentKey = configuration.testAccounts?.development?.accessToken;
|
|
366
366
|
const complianceKey = configuration.testAccounts?.compliance?.accessToken;
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
strict_1.default.equal(developmentKey, 'Super_Secret_token');
|
|
368
|
+
strict_1.default.equal(complianceKey, 'Super_Secret_token_2');
|
|
369
369
|
});
|
|
370
370
|
it('invalid test accounts', async () => {
|
|
371
371
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -415,7 +415,7 @@ describe('configuration', () => {
|
|
|
415
415
|
},
|
|
416
416
|
},
|
|
417
417
|
}, null, 2));
|
|
418
|
-
await
|
|
418
|
+
await strict_1.default.rejects(Configuration.getConfiguration(globalConfiguration_1.Environment.Production), errors_1.ConfigurationInvalid);
|
|
419
419
|
});
|
|
420
420
|
});
|
|
421
421
|
describe('validates test accounts - multiple authorization methods', () => {
|
|
@@ -509,8 +509,8 @@ describe('configuration', () => {
|
|
|
509
509
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
510
510
|
const developmentKey = configuration.testAccounts?.development?.accessToken;
|
|
511
511
|
const complianceKey = configuration.testAccounts?.compliance?.apiKey;
|
|
512
|
-
|
|
513
|
-
|
|
512
|
+
strict_1.default.equal(developmentKey, 'Super_Secret_token');
|
|
513
|
+
strict_1.default.equal(complianceKey, 'Super_Secret_api_key_2');
|
|
514
514
|
});
|
|
515
515
|
it('invalid test accounts', async () => {
|
|
516
516
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -579,7 +579,7 @@ describe('configuration', () => {
|
|
|
579
579
|
},
|
|
580
580
|
},
|
|
581
581
|
}, null, 2));
|
|
582
|
-
await
|
|
582
|
+
await strict_1.default.rejects(Configuration.getConfiguration(globalConfiguration_1.Environment.Production), errors_1.ConfigurationInvalid);
|
|
583
583
|
});
|
|
584
584
|
});
|
|
585
585
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
5
5
|
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
6
|
const IntegrationsPlatformResources = tslib_1.__importStar(require("../../src/resources/integrationsPlatform"));
|
|
7
7
|
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
@@ -40,8 +40,8 @@ describe('decryption helper', () => {
|
|
|
40
40
|
accessToken: 'developmentToken',
|
|
41
41
|
accessToken1: 'developmentToken1',
|
|
42
42
|
});
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
strict_1.default.deepEqual(decryptionResult.decryptedKeys, []);
|
|
44
|
+
strict_1.default.deepEqual(decryptionResult.entries, {
|
|
45
45
|
accessToken1: 'developmentToken1',
|
|
46
46
|
accessToken: 'developmentToken',
|
|
47
47
|
});
|
|
@@ -51,8 +51,8 @@ describe('decryption helper', () => {
|
|
|
51
51
|
accessToken: 'token',
|
|
52
52
|
encryptedToken: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
53
53
|
});
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
strict_1.default.deepEqual(decryptionResult.decryptedKeys, ['encryptedToken']);
|
|
55
|
+
strict_1.default.deepEqual(decryptionResult.entries, {
|
|
56
56
|
accessToken: 'token',
|
|
57
57
|
encryptedToken: `decrypted-me`,
|
|
58
58
|
});
|
|
@@ -62,16 +62,16 @@ describe('decryption helper', () => {
|
|
|
62
62
|
encryptedSecret1: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
63
63
|
encryptedSecret2: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
64
64
|
});
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
strict_1.default.deepEqual(decryptionResult.decryptedKeys, ['encryptedSecret1', 'encryptedSecret2']);
|
|
66
|
+
strict_1.default.deepEqual(decryptionResult.entries, {
|
|
67
67
|
encryptedSecret1: 'decrypted-me',
|
|
68
68
|
encryptedSecret2: 'decrypted-me',
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
it('support empty object', async () => {
|
|
72
72
|
const decryptionResult = await decryptionHelper.decryptEntries(configuration.name, GlobalConfiguration.Environment.Local, '/path/to/config', {});
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
strict_1.default.deepEqual(decryptionResult.decryptedKeys, []);
|
|
74
|
+
strict_1.default.deepEqual(decryptionResult.entries, {});
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
5
5
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
6
6
|
const sinon = tslib_1.__importStar(require("sinon"));
|
|
7
7
|
const GlobalConfiguration = tslib_1.__importStar(require("../../src/resources/globalConfiguration"));
|
|
@@ -10,16 +10,16 @@ describe('globalConfiguration', () => {
|
|
|
10
10
|
sinon.restore();
|
|
11
11
|
});
|
|
12
12
|
it('reads', async function () {
|
|
13
|
-
const configuration =
|
|
13
|
+
const configuration = GlobalConfiguration.getDefault();
|
|
14
14
|
configuration.apiKey = 'foo';
|
|
15
15
|
sinon.stub(fs_1.default.promises, 'mkdir').resolves('');
|
|
16
16
|
sinon.stub(fs_1.default.promises, 'readFile').resolves(JSON.stringify(configuration));
|
|
17
|
-
|
|
17
|
+
strict_1.default.deepEqual(await GlobalConfiguration.read('bar'), configuration);
|
|
18
18
|
});
|
|
19
19
|
it('reads - error', async function () {
|
|
20
20
|
sinon.stub(fs_1.default.promises, 'mkdir').resolves('');
|
|
21
21
|
sinon.stub(fs_1.default.promises, 'readFile').throws();
|
|
22
|
-
|
|
22
|
+
strict_1.default.deepEqual(await GlobalConfiguration.read('bar'), GlobalConfiguration.getDefault());
|
|
23
23
|
});
|
|
24
24
|
it('writes', async function () {
|
|
25
25
|
const configuration = GlobalConfiguration.getDefault();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
5
5
|
const sinon = tslib_1.__importStar(require("sinon"));
|
|
6
6
|
const integrations_platform_client_1 = tslib_1.__importDefault(require("@unito/integrations-platform-client"));
|
|
7
7
|
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
@@ -44,46 +44,46 @@ describe('integrations platform', function () {
|
|
|
44
44
|
sinon.restore();
|
|
45
45
|
});
|
|
46
46
|
it('environment', function () {
|
|
47
|
-
|
|
47
|
+
strict_1.default.equal(integrations_platform_client_1.default.defaults.baseUrl, integrations_platform_client_1.default.servers.local);
|
|
48
48
|
IntegrationsPlatform.setEnvironment(globalConfiguration_1.Environment.Production);
|
|
49
|
-
|
|
49
|
+
strict_1.default.equal(integrations_platform_client_1.default.defaults.baseUrl, integrations_platform_client_1.default.servers.production);
|
|
50
50
|
});
|
|
51
51
|
it('apiKey', function () {
|
|
52
52
|
IntegrationsPlatform.setApiKey('foo');
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
strict_1.default.equal(IntegrationsPlatform.getApiKey(), 'foo');
|
|
54
|
+
strict_1.default.deepEqual(integrations_platform_client_1.default.defaults.headers, {
|
|
55
55
|
Authorization: 'Bearer foo',
|
|
56
56
|
});
|
|
57
57
|
IntegrationsPlatform.setApiKey(undefined);
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
strict_1.default.equal(IntegrationsPlatform.getApiKey(), undefined);
|
|
59
|
+
strict_1.default.deepEqual(integrations_platform_client_1.default.defaults.headers, {});
|
|
60
60
|
});
|
|
61
61
|
it('getProfile', async function () {
|
|
62
62
|
sinon.stub(integrations_platform_client_1.default, 'getProfile').resolves(user);
|
|
63
|
-
|
|
63
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.getProfile(), user);
|
|
64
64
|
});
|
|
65
65
|
it('getIntegration', async function () {
|
|
66
66
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves(integration);
|
|
67
|
-
|
|
67
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.getIntegration(1), integration);
|
|
68
68
|
});
|
|
69
69
|
it('getIntegrationByName', async function () {
|
|
70
70
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrationByName').resolves(integration);
|
|
71
|
-
|
|
71
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.getIntegrationByName('foo'), integration);
|
|
72
72
|
});
|
|
73
73
|
it('getIntegrations', async function () {
|
|
74
74
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrations').resolves({ total: 1, data: [integrationSummary] });
|
|
75
|
-
|
|
75
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.getIntegrations(), [integrationSummary]);
|
|
76
76
|
});
|
|
77
77
|
it('createIntegration', async function () {
|
|
78
78
|
sinon.stub(integrations_platform_client_1.default, 'createIntegration').resolves(integration);
|
|
79
79
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves(integration);
|
|
80
80
|
sinon.stub(integrations_platform_client_1.default, 'updateIntegration').resolves(integration);
|
|
81
|
-
|
|
81
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.createIntegration({ name: 'foo' }), integration);
|
|
82
82
|
});
|
|
83
83
|
it('updateIntegration', async function () {
|
|
84
84
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves(integration);
|
|
85
85
|
sinon.stub(integrations_platform_client_1.default, 'updateIntegration').resolves(integration);
|
|
86
|
-
|
|
86
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.updateIntegration(1, { name: 'foo' }), integration);
|
|
87
87
|
});
|
|
88
88
|
it('updateIntegration - create / archive authorization', async function () {
|
|
89
89
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves({
|
|
@@ -103,10 +103,10 @@ describe('integrations platform', function () {
|
|
|
103
103
|
],
|
|
104
104
|
});
|
|
105
105
|
sinon.stub(integrations_platform_client_1.default, 'updateIntegration').resolves(integration);
|
|
106
|
-
|
|
106
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.updateIntegration(1, {
|
|
107
107
|
name: 'foo',
|
|
108
108
|
authorizations: [{ name: 'bar', method: configurationTypes_1.Method.CUSTOM }],
|
|
109
|
-
})
|
|
109
|
+
}), integration);
|
|
110
110
|
});
|
|
111
111
|
it('updateIntegration - update authorization', async function () {
|
|
112
112
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves({
|
|
@@ -126,11 +126,11 @@ describe('integrations platform', function () {
|
|
|
126
126
|
],
|
|
127
127
|
});
|
|
128
128
|
sinon.stub(integrations_platform_client_1.default, 'updateIntegration').resolves(integration);
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.updateIntegration(1, { name: 'foo' }), integration);
|
|
130
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.updateIntegration(1, {
|
|
131
131
|
name: 'foo',
|
|
132
132
|
authorizations: [{ name: 'bar', method: configurationTypes_1.Method.CUSTOM }],
|
|
133
|
-
})
|
|
133
|
+
}), integration);
|
|
134
134
|
});
|
|
135
135
|
it('updateIntegration - update secrets', async function () {
|
|
136
136
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrationById').resolves({ ...integration });
|
|
@@ -143,7 +143,7 @@ describe('integrations platform', function () {
|
|
|
143
143
|
},
|
|
144
144
|
};
|
|
145
145
|
await IntegrationsPlatform.updateIntegration(integrationId, configuration);
|
|
146
|
-
|
|
146
|
+
strict_1.default.deepEqual(mockUpdateIntegration.getCall(0).args.at(1), {
|
|
147
147
|
ui: undefined,
|
|
148
148
|
authorizations: [],
|
|
149
149
|
baseUrl: undefined,
|
|
@@ -157,7 +157,7 @@ describe('integrations platform', function () {
|
|
|
157
157
|
});
|
|
158
158
|
it('encryptData', async function () {
|
|
159
159
|
sinon.stub(integrations_platform_client_1.default, 'encryptData').resolves({ encryptedData: 'encryptedFoo' });
|
|
160
|
-
|
|
160
|
+
strict_1.default.deepEqual(await IntegrationsPlatform.encryptData('mySuperIntegration', 'foo'), {
|
|
161
161
|
encryptedData: 'encryptedFoo',
|
|
162
162
|
});
|
|
163
163
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
5
5
|
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
6
|
const oauth2Helper_1 = tslib_1.__importDefault(require("../../src/oauth2Helper/oauth2Helper"));
|
|
7
7
|
const configurationTypes_1 = require("../../src/configurationTypes");
|
|
@@ -21,7 +21,7 @@ describe('OAuth2Helper', () => {
|
|
|
21
21
|
responseContentType: configurationTypes_1.RequestContentType.JSON,
|
|
22
22
|
};
|
|
23
23
|
beforeEach(() => {
|
|
24
|
-
sinon_1.default.stub(oauth2Helper_1.default.prototype, 'startServer').
|
|
24
|
+
sinon_1.default.stub(oauth2Helper_1.default.prototype, 'startServer').resolves('http://localhost:5050');
|
|
25
25
|
sinon_1.default.stub(oauth2Helper_1.default.prototype, 'stopServer');
|
|
26
26
|
sinon_1.default.stub(oauth2Helper_1.default.prototype, 'callbackIsDone');
|
|
27
27
|
sinon_1.default.stub(inquirer_1.default, 'prompt');
|
|
@@ -46,9 +46,9 @@ describe('OAuth2Helper', () => {
|
|
|
46
46
|
});
|
|
47
47
|
sinon_1.default.replace(global, 'fetch', fetchStub);
|
|
48
48
|
await oauth2HelperService.performOAuth2Flow(authorizationInfo);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
strict_1.default.equal(fetchStub.getCall(0).args.at(0), 'http://localhost:5050/health');
|
|
50
|
+
strict_1.default.equal(fetchStub.getCall(1).args.at(0), 'http://localhost:5050/credentials/new/oauth2/authorize');
|
|
51
|
+
strict_1.default.equal(fetchStub.getCall(2).args.at(0), 'http://localhost:5050/credentials/new/oauth2/token');
|
|
52
52
|
});
|
|
53
53
|
it('raises a FailedToRetrieveAccessTokenError', async () => {
|
|
54
54
|
fetchStub = sinon_1.default
|
|
@@ -61,7 +61,7 @@ describe('OAuth2Helper', () => {
|
|
|
61
61
|
.resolves({ status: 500, text: () => 'error' });
|
|
62
62
|
sinon_1.default.replace(global, 'fetch', fetchStub);
|
|
63
63
|
const response = oauth2HelperService.performOAuth2Flow(authorizationInfo);
|
|
64
|
-
await (
|
|
64
|
+
await strict_1.default.rejects(response, errors_1.FailedToRetrieveAccessTokenError);
|
|
65
65
|
});
|
|
66
66
|
it('raises a FailedToRetrieveAccessTokenError when the accessToken is not returned', async () => {
|
|
67
67
|
fetchStub = sinon_1.default
|
|
@@ -79,7 +79,7 @@ describe('OAuth2Helper', () => {
|
|
|
79
79
|
});
|
|
80
80
|
sinon_1.default.replace(global, 'fetch', fetchStub);
|
|
81
81
|
const response = oauth2HelperService.performOAuth2Flow(authorizationInfo);
|
|
82
|
-
await (
|
|
82
|
+
await strict_1.default.rejects(response, errors_1.FailedToRetrieveAccessTokenError);
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
});
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unito/integration-cli",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.2",
|
|
4
4
|
"description": "Integration CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"integration-cli": "./bin/run"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"!/bin/dev*"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@oclif/core": "
|
|
38
|
+
"@oclif/core": "3.x",
|
|
39
39
|
"@typescript-eslint/eslint-plugin": "6.x",
|
|
40
40
|
"@typescript-eslint/parser": "6.13.x",
|
|
41
41
|
"@unito/integration-debugger": "0.23.0",
|
|
@@ -56,9 +56,7 @@
|
|
|
56
56
|
"tmp": "0.x"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@oclif/test": "
|
|
60
|
-
"@types/chai": "4.x",
|
|
61
|
-
"@types/chai-as-promised": "7.x",
|
|
59
|
+
"@oclif/test": "3.x",
|
|
62
60
|
"@types/cors": "2.x",
|
|
63
61
|
"@types/express": "4.x",
|
|
64
62
|
"@types/gradient-string": "1.x",
|
|
@@ -68,8 +66,6 @@
|
|
|
68
66
|
"@types/openurl": "1.x",
|
|
69
67
|
"@types/tmp": "0.x",
|
|
70
68
|
"c8": "9.x",
|
|
71
|
-
"chai": "4.x",
|
|
72
|
-
"chai-as-promised": "7.x",
|
|
73
69
|
"json-schema-to-typescript": "13.x",
|
|
74
70
|
"mocha": "10.x",
|
|
75
71
|
"oclif": "3.x",
|
package/dist/test/mocha.hooks.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.mochaHooks = void 0;
|
|
27
|
-
const mochaHooks = () => {
|
|
28
|
-
return {
|
|
29
|
-
async beforeAll() {
|
|
30
|
-
// Allow using `chai-as-promised` in all tests.
|
|
31
|
-
const chai = await Promise.resolve().then(() => __importStar(require('chai')));
|
|
32
|
-
const chaiAsPromised = await Promise.resolve().then(() => __importStar(require('chai-as-promised')));
|
|
33
|
-
chai.use(chaiAsPromised.default);
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
exports.mochaHooks = mochaHooks;
|