@unito/integration-cli 0.55.5 → 0.56.1
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/integrationBoilerplate/.nvmrc +1 -1
- package/dist/integrationGenerator/integrationBoilerplate/Dockerfile +2 -2
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.nvmrc +1 -1
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/Dockerfile +2 -2
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/package.json +2 -2
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/additionalLoggingContext.ts +1 -1
- package/dist/integrationGenerator/integrationBoilerplate/package.json +2 -2
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/additionalLoggingContext.ts +1 -1
- package/dist/src/commands/activity.js +14 -5
- package/dist/src/commands/dev.js +10 -4
- package/dist/src/commands/encrypt.js +1 -1
- package/dist/src/commands/init.js +1 -1
- package/dist/src/commands/invite.js +14 -5
- package/dist/src/commands/login.js +1 -1
- package/dist/src/commands/oauth2.d.ts +6 -1
- package/dist/src/commands/oauth2.js +59 -56
- package/dist/src/commands/publish.js +14 -3
- package/dist/src/commands/test.js +10 -4
- package/dist/src/commands/upgrade.js +1 -1
- package/dist/src/errors.d.ts +4 -1
- package/dist/src/errors.js +47 -37
- package/dist/src/resources/configuration.d.ts +1 -1
- package/dist/src/resources/configuration.js +5 -2
- package/dist/src/resources/decryption.d.ts +10 -4
- package/dist/src/resources/decryption.js +13 -40
- package/dist/src/services/integrationsPlatform.d.ts +1 -1
- package/dist/src/services/integrationsPlatform.js +1 -8
- package/dist/test/commands/activity.test.js +3 -1
- package/dist/test/commands/encrypt.test.js +2 -2
- package/dist/test/commands/invite.test.js +3 -1
- package/dist/test/commands/oauth2.test.js +155 -11
- package/dist/test/commands/publish.test.js +25 -25
- package/dist/test/errors.test.js +45 -40
- package/dist/test/resources/decryption.test.js +28 -19
- package/dist/test/services/integrationsPlatform.test.js +0 -4
- package/oclif.manifest.json +36 -5
- package/package.json +3 -3
|
@@ -55,7 +55,7 @@ describe('Publish', () => {
|
|
|
55
55
|
(0, test_1.expect)(customPath).to.be.undefined;
|
|
56
56
|
return { name: 'a' };
|
|
57
57
|
})
|
|
58
|
-
.stub(IntegrationsPlatform, '
|
|
58
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
59
59
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
60
60
|
.command(['publish'])
|
|
61
61
|
.it('publish the integration - default', ctx => {
|
|
@@ -72,7 +72,7 @@ describe('Publish', () => {
|
|
|
72
72
|
(0, test_1.expect)(customPath).to.equal('/custom-config.json');
|
|
73
73
|
return { name: 'a' };
|
|
74
74
|
})
|
|
75
|
-
.stub(IntegrationsPlatform, '
|
|
75
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
76
76
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
77
77
|
.command(['publish', '--config-path', '/custom-config.json'])
|
|
78
78
|
.it('publish the integration with custom config - default', ctx => {
|
|
@@ -89,7 +89,7 @@ describe('Publish', () => {
|
|
|
89
89
|
(0, test_1.expect)(customPath).to.be.undefined;
|
|
90
90
|
return { name: 'a' };
|
|
91
91
|
})
|
|
92
|
-
.stub(IntegrationsPlatform, '
|
|
92
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
93
93
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
94
94
|
.command(['publish', '--environment', 'local'])
|
|
95
95
|
.it('publish the integration - local', ctx => {
|
|
@@ -108,7 +108,7 @@ describe('Publish', () => {
|
|
|
108
108
|
return { name: 'a' };
|
|
109
109
|
})
|
|
110
110
|
.stub(IntegrationConfiguration, 'writeConfiguration', () => Promise)
|
|
111
|
-
.stub(IntegrationsPlatform, '
|
|
111
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
112
112
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
113
113
|
.command(['publish', '--environment', 'local'])
|
|
114
114
|
.it('publish the integration using .unito.local.json - local', ctx => {
|
|
@@ -126,7 +126,7 @@ describe('Publish', () => {
|
|
|
126
126
|
(0, test_1.expect)(customPath).to.be.undefined;
|
|
127
127
|
return { name: 'a' };
|
|
128
128
|
})
|
|
129
|
-
.stub(IntegrationsPlatform, '
|
|
129
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
130
130
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
131
131
|
.command(['publish', '--environment', 'staging'])
|
|
132
132
|
.it('publish the integration - staging', ctx => {
|
|
@@ -145,7 +145,7 @@ describe('Publish', () => {
|
|
|
145
145
|
return {};
|
|
146
146
|
})
|
|
147
147
|
.stub(IntegrationConfiguration, 'writeConfiguration', () => Promise)
|
|
148
|
-
.stub(IntegrationsPlatform, '
|
|
148
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
149
149
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
150
150
|
.command(['publish', '--environment', 'staging'])
|
|
151
151
|
.it('publish the integration using .unito.staging.json - staging', ctx => {
|
|
@@ -163,7 +163,7 @@ describe('Publish', () => {
|
|
|
163
163
|
(0, test_1.expect)(customPath).to.equal('/my-awesome-config.json');
|
|
164
164
|
return { name: 'a' };
|
|
165
165
|
})
|
|
166
|
-
.stub(IntegrationsPlatform, '
|
|
166
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
167
167
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
168
168
|
.command(['publish', '--config-path', '/my-awesome-config.json'])
|
|
169
169
|
.it('publish the integration using custom configuration', ctx => {
|
|
@@ -173,7 +173,7 @@ describe('Publish', () => {
|
|
|
173
173
|
.stdout()
|
|
174
174
|
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
175
175
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
176
|
-
.stub(IntegrationsPlatform, '
|
|
176
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
177
177
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
178
178
|
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: false }))
|
|
179
179
|
.command(['publish', '--registry-only'])
|
|
@@ -186,7 +186,7 @@ describe('Publish', () => {
|
|
|
186
186
|
.stdout()
|
|
187
187
|
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
188
188
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
189
|
-
.stub(IntegrationsPlatform, '
|
|
189
|
+
.stub(IntegrationsPlatform, 'getIntegration', () => undefined)
|
|
190
190
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
191
191
|
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: false }))
|
|
192
192
|
.command(['publish', '--registry-only', '--force'])
|
|
@@ -198,7 +198,7 @@ describe('Publish', () => {
|
|
|
198
198
|
.stdout()
|
|
199
199
|
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
200
200
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
201
|
-
.stub(IntegrationsPlatform, '
|
|
201
|
+
.stub(IntegrationsPlatform, 'getIntegration', () => undefined)
|
|
202
202
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
203
203
|
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
204
204
|
.command(['publish', '--registry-only'])
|
|
@@ -210,7 +210,7 @@ describe('Publish', () => {
|
|
|
210
210
|
.stdout()
|
|
211
211
|
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
212
212
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({ name: 'a' }))
|
|
213
|
-
.stub(IntegrationsPlatform, '
|
|
213
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => ({ name: 'a' }))
|
|
214
214
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
215
215
|
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
216
216
|
.command(['publish', '--registry-only'])
|
|
@@ -225,7 +225,7 @@ describe('Publish', () => {
|
|
|
225
225
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({
|
|
226
226
|
authorizations: [{ type: 'custom', development: true }, { type: 'oauth2' }],
|
|
227
227
|
}))
|
|
228
|
-
.stub(IntegrationsPlatform, '
|
|
228
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
229
229
|
// eslint-disable-next-line
|
|
230
230
|
// @ts-ignore typing doesn't work here, for some reason.
|
|
231
231
|
.stub(IntegrationsPlatform, 'createIntegration', (config) => config)
|
|
@@ -240,7 +240,7 @@ describe('Publish', () => {
|
|
|
240
240
|
.stdout()
|
|
241
241
|
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
242
242
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({ name: 'foo' }))
|
|
243
|
-
.stub(IntegrationsPlatform, '
|
|
243
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
244
244
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
245
245
|
.command(['publish', '--preview'])
|
|
246
246
|
.it('preview the integration', ctx => {
|
|
@@ -250,7 +250,7 @@ describe('Publish', () => {
|
|
|
250
250
|
.stdout()
|
|
251
251
|
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
252
252
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({ name: 'foo', ui: { displayName: 'Foo' } }))
|
|
253
|
-
.stub(IntegrationsPlatform, '
|
|
253
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
254
254
|
// eslint-disable-next-line
|
|
255
255
|
// @ts-ignore typing doesn't work here, for some reason.
|
|
256
256
|
.stub(IntegrationConfiguration, 'writeConfiguration', configuration => {
|
|
@@ -281,7 +281,7 @@ describe('Publish', () => {
|
|
|
281
281
|
.stdout()
|
|
282
282
|
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
283
283
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
284
|
-
.stub(IntegrationsPlatform, '
|
|
284
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
285
285
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
286
286
|
.command(['publish', '--live-preview'])
|
|
287
287
|
.it('live-preview the integration', ctx => {
|
|
@@ -291,7 +291,7 @@ describe('Publish', () => {
|
|
|
291
291
|
.stdout()
|
|
292
292
|
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
293
293
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({ ui: { displayName: 'Foo' } }))
|
|
294
|
-
.stub(IntegrationsPlatform, '
|
|
294
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
295
295
|
// eslint-disable-next-line
|
|
296
296
|
// @ts-ignore typing doesn't work here, for some reason.
|
|
297
297
|
.stub(IntegrationsPlatform, 'createIntegration', (config) => config)
|
|
@@ -301,15 +301,15 @@ describe('Publish', () => {
|
|
|
301
301
|
(0, test_1.expect)(ctx.stdout).to.contain('Foo - Live Preview - 9c88');
|
|
302
302
|
});
|
|
303
303
|
test_1.test
|
|
304
|
-
.
|
|
304
|
+
.stderr()
|
|
305
305
|
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
306
306
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
307
|
-
.stub(IntegrationsPlatform, '
|
|
307
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
308
308
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
309
309
|
.command(['publish'])
|
|
310
310
|
.exit(-1)
|
|
311
311
|
.it('missing api key', ctx => {
|
|
312
|
-
(0, test_1.expect)(ctx.
|
|
312
|
+
(0, test_1.expect)(ctx.stderr).to.contain('Your API key is not set!\nMake sure to run the login command first');
|
|
313
313
|
});
|
|
314
314
|
test_1.test
|
|
315
315
|
.stdout()
|
|
@@ -333,7 +333,7 @@ describe('Publish', () => {
|
|
|
333
333
|
authorizations: [{ name: 'oauth2', oauth2: { clientSecret: 'unito-secret-' } }],
|
|
334
334
|
secrets: { secret1: 'unito-secret-', invalidSecret: 'Should never happen anyway' },
|
|
335
335
|
}))
|
|
336
|
-
.stub(IntegrationsPlatform, '
|
|
336
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
337
337
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
338
338
|
.command(['publish', '--preview'])
|
|
339
339
|
.it('reencrypts the clientSecret on preview', ctx => {
|
|
@@ -349,7 +349,7 @@ describe('Publish', () => {
|
|
|
349
349
|
authorizations: [{ name: 'oauth2', oauth2: { clientSecret: 'unito-secret-' } }],
|
|
350
350
|
secrets: { secret1: 'unito-secret-', invalidSecret: 'Should never happen anyway' },
|
|
351
351
|
}))
|
|
352
|
-
.stub(IntegrationsPlatform, '
|
|
352
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
353
353
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
354
354
|
.command(['publish', '--live-preview'])
|
|
355
355
|
.it('reencrypts the clientSecret on live-preview', ctx => {
|
|
@@ -364,7 +364,7 @@ describe('Publish', () => {
|
|
|
364
364
|
name: 'myIntegration',
|
|
365
365
|
authorizations: [{ name: 'oauth2', oauth2: { clientSecret: 'toto' } }],
|
|
366
366
|
}))
|
|
367
|
-
.stub(IntegrationsPlatform, '
|
|
367
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
368
368
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
369
369
|
.command(['publish', '--live-preview'])
|
|
370
370
|
.it('skips reencryption', ctx => {
|
|
@@ -381,7 +381,7 @@ describe('Publish', () => {
|
|
|
381
381
|
},
|
|
382
382
|
],
|
|
383
383
|
}))
|
|
384
|
-
.stub(IntegrationsPlatform, '
|
|
384
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
385
385
|
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('foo')))
|
|
386
386
|
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
387
387
|
.command(['publish', '--registry-only'])
|
|
@@ -400,7 +400,7 @@ describe('Publish', () => {
|
|
|
400
400
|
},
|
|
401
401
|
],
|
|
402
402
|
}))
|
|
403
|
-
.stub(IntegrationsPlatform, '
|
|
403
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
404
404
|
.stub(FileSystem, 'getFileBuffer', () => Promise.reject())
|
|
405
405
|
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
406
406
|
.command(['publish', '--registry-only'])
|
|
@@ -418,7 +418,7 @@ describe('Publish', () => {
|
|
|
418
418
|
},
|
|
419
419
|
],
|
|
420
420
|
}))
|
|
421
|
-
.stub(IntegrationsPlatform, '
|
|
421
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
422
422
|
.stub(FileSystem, 'getFileBuffer', () => null)
|
|
423
423
|
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
424
424
|
.command(['publish', '--registry-only'])
|
package/dist/test/errors.test.js
CHANGED
|
@@ -4,93 +4,98 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const chai_1 = require("chai");
|
|
5
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
7
|
-
const core_1 = require("@oclif/core");
|
|
8
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
8
|
const errors_1 = require("../src/errors");
|
|
10
9
|
const configuration_1 = require("../src/resources/configuration");
|
|
10
|
+
const publish_1 = tslib_1.__importDefault(require("../src/commands/publish"));
|
|
11
11
|
describe('handleError', () => {
|
|
12
|
-
|
|
12
|
+
class DummyCommand extends publish_1.default {
|
|
13
|
+
logToStderr = () => { };
|
|
14
|
+
}
|
|
15
|
+
let command;
|
|
16
|
+
let stdErrStub;
|
|
13
17
|
beforeEach(() => {
|
|
14
|
-
|
|
18
|
+
command = new DummyCommand([], {});
|
|
19
|
+
stdErrStub = sinon_1.default.stub(command, 'logToStderr');
|
|
15
20
|
});
|
|
16
21
|
afterEach(() => {
|
|
17
22
|
sinon_1.default.restore();
|
|
18
23
|
});
|
|
19
24
|
it('should handle NoIntegrationFoundError', () => {
|
|
20
25
|
const error = new errors_1.NoIntegrationFoundError();
|
|
21
|
-
const handled = (0, errors_1.handleError)(error);
|
|
26
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
22
27
|
(0, chai_1.expect)(handled).to.be.true;
|
|
23
|
-
(0, chai_1.expect)(
|
|
24
|
-
(0, chai_1.expect)(
|
|
25
|
-
(0, chai_1.expect)(
|
|
28
|
+
(0, chai_1.expect)(stdErrStub.calledTwice).to.be.true;
|
|
29
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('Your directory does not seem to contain an integration :('));
|
|
30
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.include('Make sure you are in the right directory');
|
|
26
31
|
});
|
|
27
32
|
it('should handle NoConfigurationFileError', () => {
|
|
28
33
|
const error = new errors_1.NoConfigurationFileError();
|
|
29
|
-
const handled = (0, errors_1.handleError)(error);
|
|
34
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
30
35
|
(0, chai_1.expect)(handled).to.be.true;
|
|
31
|
-
(0, chai_1.expect)(
|
|
32
|
-
(0, chai_1.expect)(
|
|
33
|
-
(0, chai_1.expect)(
|
|
36
|
+
(0, chai_1.expect)(stdErrStub.calledTwice).to.be.true;
|
|
37
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('This command requires a configuration file for your integration :('));
|
|
38
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.equal(`This file should be located at ${chalk_1.default.yellowBright(path_1.default.relative(process.cwd(), (0, configuration_1.getConfigurationPath)()))}.`);
|
|
34
39
|
});
|
|
35
40
|
it('should handle MissingEnvironmentVariableError', () => {
|
|
36
41
|
const error = new errors_1.MissingEnvironmentVariableError('VAR_NAME');
|
|
37
|
-
const handled = (0, errors_1.handleError)(error);
|
|
42
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
38
43
|
(0, chai_1.expect)(handled).to.be.true;
|
|
39
|
-
(0, chai_1.expect)(
|
|
40
|
-
(0, chai_1.expect)(
|
|
41
|
-
(0, chai_1.expect)(
|
|
44
|
+
(0, chai_1.expect)(stdErrStub.calledTwice).to.be.true;
|
|
45
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('This command requires a variable which is missing from your environment :('));
|
|
46
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.equal(`Make sure the environment variable ${chalk_1.default.yellowBright('VAR_NAME')} is defined.`);
|
|
42
47
|
});
|
|
43
48
|
it('should return false for unrecognized error', () => {
|
|
44
49
|
const error = new Error('Unrecognized error');
|
|
45
|
-
const handled = (0, errors_1.handleError)(error);
|
|
50
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
46
51
|
(0, chai_1.expect)(handled).to.be.false;
|
|
47
|
-
(0, chai_1.expect)(
|
|
52
|
+
(0, chai_1.expect)(stdErrStub.called).to.be.false;
|
|
48
53
|
});
|
|
49
54
|
it('should handle MissingEnvironmentVariableError', () => {
|
|
50
55
|
const error = new errors_1.ConfigurationInvalid('VAR_NAME', 'details', 'prettyDetails');
|
|
51
|
-
const handled = (0, errors_1.handleError)(error);
|
|
56
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
52
57
|
(0, chai_1.expect)(handled).to.be.true;
|
|
53
|
-
(0, chai_1.expect)(
|
|
54
|
-
(0, chai_1.expect)(
|
|
55
|
-
(0, chai_1.expect)(
|
|
58
|
+
(0, chai_1.expect)(stdErrStub.calledThrice).to.be.true;
|
|
59
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright(`Your ${chalk_1.default.yellowBright(path_1.default.basename((0, configuration_1.getConfigurationPath)()))} is invalid!`));
|
|
60
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal('prettyDetails');
|
|
56
61
|
});
|
|
57
62
|
it('should handle NoRefreshTokenError', () => {
|
|
58
63
|
const error = new errors_1.NoRefreshTokenError();
|
|
59
|
-
const handled = (0, errors_1.handleError)(error);
|
|
64
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
60
65
|
(0, chai_1.expect)(handled).to.be.true;
|
|
61
|
-
(0, chai_1.expect)(
|
|
62
|
-
(0, chai_1.expect)(
|
|
66
|
+
(0, chai_1.expect)(stdErrStub.calledOnce).to.be.true;
|
|
67
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('No refresh token found in your configuration file'));
|
|
63
68
|
});
|
|
64
69
|
it('should handle FailedToRetrieveAccessTokenError', () => {
|
|
65
70
|
const error = new errors_1.FailedToRetrieveAccessTokenError('Credentials invalid');
|
|
66
|
-
const handled = (0, errors_1.handleError)(error);
|
|
71
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
67
72
|
(0, chai_1.expect)(handled).to.be.true;
|
|
68
|
-
(0, chai_1.expect)(
|
|
69
|
-
(0, chai_1.expect)(
|
|
70
|
-
(0, chai_1.expect)(
|
|
73
|
+
(0, chai_1.expect)(stdErrStub.calledThrice).to.be.true;
|
|
74
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('Failed to retrieve access token'));
|
|
75
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal('Credentials invalid');
|
|
71
76
|
});
|
|
72
77
|
it('should handle InvalidRequestContentTypeError', () => {
|
|
73
78
|
const error = new errors_1.InvalidRequestContentTypeError('Invalid content type');
|
|
74
|
-
const handled = (0, errors_1.handleError)(error);
|
|
79
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
75
80
|
(0, chai_1.expect)(handled).to.be.true;
|
|
76
|
-
(0, chai_1.expect)(
|
|
77
|
-
(0, chai_1.expect)(
|
|
78
|
-
(0, chai_1.expect)(
|
|
81
|
+
(0, chai_1.expect)(stdErrStub.calledThrice).to.be.true;
|
|
82
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('Invalid request content type'));
|
|
83
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal('Invalid content type');
|
|
79
84
|
});
|
|
80
85
|
it('should handle DecryptionAuthenticationError', () => {
|
|
81
86
|
const error = new errors_1.DecryptionAuthenticationError('secrets');
|
|
82
|
-
const handled = (0, errors_1.handleError)(error);
|
|
87
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
83
88
|
(0, chai_1.expect)(handled).to.be.true;
|
|
84
|
-
(0, chai_1.expect)(
|
|
85
|
-
(0, chai_1.expect)(
|
|
86
|
-
(0, chai_1.expect)(
|
|
89
|
+
(0, chai_1.expect)(stdErrStub.calledThrice).to.be.true;
|
|
90
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.equal(chalk_1.default.yellowBright('Your configuration contains encrypted secrets.'));
|
|
91
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal('To use them locally, you must be authenticated to Unito.');
|
|
87
92
|
});
|
|
88
93
|
it('should handle EntryDecryptionError', () => {
|
|
89
94
|
const error = new errors_1.EntryDecryptionError('key', 'value', 'staging');
|
|
90
|
-
const handled = (0, errors_1.handleError)(error);
|
|
95
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
91
96
|
(0, chai_1.expect)(handled).to.be.true;
|
|
92
|
-
(0, chai_1.expect)(
|
|
93
|
-
(0, chai_1.expect)(
|
|
94
|
-
(0, chai_1.expect)(
|
|
97
|
+
(0, chai_1.expect)(stdErrStub.called).to.be.true;
|
|
98
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.equal(chalk_1.default.yellowBright('Error decrypting entry:'));
|
|
99
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal(chalk_1.default.redBright('key: value'));
|
|
95
100
|
});
|
|
96
101
|
});
|
|
@@ -8,7 +8,7 @@ const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/in
|
|
|
8
8
|
const GlobalConfiguration = tslib_1.__importStar(require("../../src/resources/globalConfiguration"));
|
|
9
9
|
const configuration_1 = require("../../src/resources/configuration");
|
|
10
10
|
const decryptionHelper = tslib_1.__importStar(require("../../src/resources/decryption"));
|
|
11
|
-
describe('
|
|
11
|
+
describe('decryption helper', () => {
|
|
12
12
|
const configuration = {
|
|
13
13
|
name: 'a',
|
|
14
14
|
baseUrl: 'b',
|
|
@@ -34,35 +34,44 @@ describe('decryptionHelper', () => {
|
|
|
34
34
|
afterEach(() => {
|
|
35
35
|
sinon_1.default.restore();
|
|
36
36
|
});
|
|
37
|
-
describe('
|
|
38
|
-
it('support unencrypted
|
|
39
|
-
const
|
|
40
|
-
|
|
37
|
+
describe('decryptEntries', () => {
|
|
38
|
+
it('support unencrypted entries', async () => {
|
|
39
|
+
const decryptionResult = await decryptionHelper.decryptEntries(configuration.name, GlobalConfiguration.Environment.Local, '/path/to/config', {
|
|
40
|
+
accessToken: 'developmentToken',
|
|
41
|
+
accessToken1: 'developmentToken1',
|
|
42
|
+
});
|
|
43
|
+
(0, chai_1.expect)(decryptionResult.decryptedKeys).to.deep.equal([]);
|
|
44
|
+
(0, chai_1.expect)(decryptionResult.entries).to.deep.equal({
|
|
45
|
+
accessToken1: 'developmentToken1',
|
|
41
46
|
accessToken: 'developmentToken',
|
|
42
47
|
});
|
|
43
48
|
});
|
|
44
|
-
it('support encrypted
|
|
45
|
-
const
|
|
46
|
-
|
|
49
|
+
it('support mixed encrypted and not encrypted entries', async () => {
|
|
50
|
+
const decryptionResult = await decryptionHelper.decryptEntries(configuration.name, GlobalConfiguration.Environment.Local, '/path/to/config', {
|
|
51
|
+
accessToken: 'token',
|
|
52
|
+
encryptedToken: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
53
|
+
});
|
|
54
|
+
(0, chai_1.expect)(decryptionResult.decryptedKeys).to.deep.equal(['encryptedToken']);
|
|
55
|
+
(0, chai_1.expect)(decryptionResult.entries).to.deep.equal({
|
|
47
56
|
accessToken: 'token',
|
|
48
57
|
encryptedToken: `decrypted-me`,
|
|
49
58
|
});
|
|
50
59
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
it('support multiple encrypted entries', async () => {
|
|
61
|
+
const decryptionResult = await decryptionHelper.decryptEntries(configuration.name, GlobalConfiguration.Environment.Local, '/path/to/config', {
|
|
62
|
+
encryptedSecret1: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
63
|
+
encryptedSecret2: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
64
|
+
});
|
|
65
|
+
(0, chai_1.expect)(decryptionResult.decryptedKeys).to.deep.equal(['encryptedSecret1', 'encryptedSecret2']);
|
|
66
|
+
(0, chai_1.expect)(decryptionResult.entries).to.deep.equal({
|
|
56
67
|
encryptedSecret1: 'decrypted-me',
|
|
57
68
|
encryptedSecret2: 'decrypted-me',
|
|
58
69
|
});
|
|
59
70
|
});
|
|
60
|
-
it('support empty
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, GlobalConfiguration.Environment.Local, '/path/to/config');
|
|
65
|
-
(0, chai_1.expect)(decryptedSecrets).to.deep.equal({});
|
|
71
|
+
it('support empty object', async () => {
|
|
72
|
+
const decryptionResult = await decryptionHelper.decryptEntries(configuration.name, GlobalConfiguration.Environment.Local, '/path/to/config', {});
|
|
73
|
+
(0, chai_1.expect)(decryptionResult.decryptedKeys).to.deep.equal([]);
|
|
74
|
+
(0, chai_1.expect)(decryptionResult.entries).to.deep.equal({});
|
|
66
75
|
});
|
|
67
76
|
});
|
|
68
77
|
});
|
|
@@ -70,10 +70,6 @@ describe('integrations platform', function () {
|
|
|
70
70
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrationByName').resolves(integration);
|
|
71
71
|
(0, chai_1.expect)(await IntegrationsPlatform.getIntegrationByName('foo')).to.deep.equal(integration);
|
|
72
72
|
});
|
|
73
|
-
it('getIntegrationByName - error', async function () {
|
|
74
|
-
sinon.stub(integrations_platform_client_1.default, 'getIntegrationByName').throws();
|
|
75
|
-
(0, chai_1.expect)(await IntegrationsPlatform.getIntegrationByName('foo')).to.deep.equal(null);
|
|
76
|
-
});
|
|
77
73
|
it('getIntegrations', async function () {
|
|
78
74
|
sinon.stub(integrations_platform_client_1.default, 'getIntegrations').resolves({ total: 1, data: [integrationSummary] });
|
|
79
75
|
(0, chai_1.expect)(await IntegrationsPlatform.getIntegrations()).to.deep.equal([integrationSummary]);
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.56.1",
|
|
3
3
|
"commands": {
|
|
4
4
|
"activity": {
|
|
5
5
|
"id": "activity",
|
|
@@ -201,7 +201,8 @@
|
|
|
201
201
|
},
|
|
202
202
|
"oauth2": {
|
|
203
203
|
"id": "oauth2",
|
|
204
|
-
"
|
|
204
|
+
"summary": "Perform an OAuth2 workflow locally",
|
|
205
|
+
"description": "The Oauth2 command allows you to perform an OAuth2 workflow locally, either to create a new test account or to refresh an existing one.",
|
|
205
206
|
"strict": true,
|
|
206
207
|
"pluginName": "@unito/integration-cli",
|
|
207
208
|
"pluginAlias": "@unito/integration-cli",
|
|
@@ -211,10 +212,40 @@
|
|
|
211
212
|
"<%= config.bin %> <%= command.id %>"
|
|
212
213
|
],
|
|
213
214
|
"flags": {
|
|
214
|
-
"
|
|
215
|
-
"name": "
|
|
215
|
+
"test-account": {
|
|
216
|
+
"name": "test-account",
|
|
217
|
+
"type": "option",
|
|
218
|
+
"description": "Test account to use.",
|
|
219
|
+
"multiple": false,
|
|
220
|
+
"options": [
|
|
221
|
+
"development",
|
|
222
|
+
"compliance"
|
|
223
|
+
],
|
|
224
|
+
"default": "development"
|
|
225
|
+
},
|
|
226
|
+
"environment": {
|
|
227
|
+
"name": "environment",
|
|
228
|
+
"type": "option",
|
|
229
|
+
"description": "the environment of the platform",
|
|
230
|
+
"multiple": false,
|
|
231
|
+
"options": [
|
|
232
|
+
"local",
|
|
233
|
+
"staging",
|
|
234
|
+
"production"
|
|
235
|
+
],
|
|
236
|
+
"default": "production"
|
|
237
|
+
},
|
|
238
|
+
"reauth": {
|
|
239
|
+
"name": "reauth",
|
|
240
|
+
"type": "boolean",
|
|
241
|
+
"description": "triggers a new oauth2 flow to collect credentials and overwrite the current one",
|
|
242
|
+
"allowNo": false
|
|
243
|
+
},
|
|
244
|
+
"config-path": {
|
|
245
|
+
"name": "config-path",
|
|
216
246
|
"type": "option",
|
|
217
|
-
"
|
|
247
|
+
"summary": "relative path to a custom \".unito.json\" file",
|
|
248
|
+
"description": "Use a custom configuration file instead of the default '.unito.json' or other environment specific\n ones.\n\n If you want to force the CLI to use a specific configuration file, you can use this flag to specify the relative\n path from your integration's root folder (with a leading '/').\n\n Usage: <%= config.bin %> <%= command.id %> --config-path=/myCustomConfig.json",
|
|
218
249
|
"multiple": false
|
|
219
250
|
}
|
|
220
251
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unito/integration-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.1",
|
|
4
4
|
"description": "Integration CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"integration-cli": "./bin/run"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"compile:watch": "tsc --build -w",
|
|
26
26
|
"test": "mocha $(find test -name '*.test.ts') $(find integrationGenerator/test -name '*.test.ts')",
|
|
27
27
|
"test:debug": "mocha test/**/*.test.ts integrationGenerator/test/**/*.test.ts --inspect-brk",
|
|
28
|
-
"ci:test": "
|
|
28
|
+
"ci:test": "c8 npm run test"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"/bin",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"@types/node": "18.x",
|
|
68
68
|
"@types/openurl": "1.x",
|
|
69
69
|
"@types/tmp": "0.x",
|
|
70
|
+
"c8": "9.x",
|
|
70
71
|
"chai": "4.x",
|
|
71
72
|
"chai-as-promised": "7.x",
|
|
72
73
|
"json-schema-to-typescript": "13.x",
|
|
73
74
|
"mocha": "10.x",
|
|
74
|
-
"nyc": "15.x",
|
|
75
75
|
"oclif": "3.x",
|
|
76
76
|
"shx": "0.x",
|
|
77
77
|
"sinon": "16.x",
|