@unito/integration-cli 0.57.1 → 0.58.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.
- package/dist/.eslintrc.d.ts +6 -0
- package/dist/.eslintrc.js +9 -2
- package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/src/index.ts +1 -3
- package/dist/src/commands/activity.d.ts +2 -2
- package/dist/src/commands/activity.js +2 -2
- package/dist/src/commands/dev.d.ts +8 -4
- package/dist/src/commands/dev.js +42 -5
- 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 +3 -3
- 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 +19 -14
- package/dist/src/commands/publish.d.ts +2 -2
- package/dist/src/commands/publish.js +12 -12
- package/dist/src/commands/test.js +32 -8
- package/dist/src/commands/upgrade.js +3 -3
- package/dist/src/errors.d.ts +8 -0
- package/dist/src/errors.js +35 -18
- package/dist/src/resources/configuration.js +0 -2
- package/dist/src/resources/credentials.d.ts +3 -0
- package/dist/src/resources/credentials.js +26 -0
- package/dist/src/resources/integrations.d.ts +1 -0
- package/dist/src/resources/integrations.js +37 -2
- package/dist/src/resources/oauth2Helper.d.ts +4 -0
- package/dist/src/resources/oauth2Helper.js +30 -0
- package/dist/src/services/integrationsPlatform.d.ts +1 -0
- package/dist/src/services/integrationsPlatform.js +5 -1
- package/dist/src/services/oauth2Helper.d.ts +78 -3
- package/dist/src/services/oauth2Helper.js +229 -29
- package/dist/test/commands/activity.test.js +12 -9
- package/dist/test/commands/dev.test.js +59 -10
- package/dist/test/commands/encrypt.test.js +6 -7
- package/dist/test/commands/init.test.js +7 -9
- package/dist/test/commands/invite.test.js +11 -11
- package/dist/test/commands/login.test.js +20 -23
- package/dist/test/commands/oauth2.test.js +6 -2
- package/dist/test/commands/publish.test.js +152 -218
- package/dist/test/commands/test.test.js +65 -13
- package/dist/test/commands/upgrade.test.js +4 -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 +112 -128
- 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/resources/integrations.test.js +37 -0
- package/dist/test/resources/oauth2Helper.test.js +55 -0
- package/dist/test/services/integrationsPlatform.test.js +20 -20
- package/oclif.manifest.json +64 -9
- package/package.json +10 -14
- package/dist/integrationGenerator/errors.d.ts +0 -2
- package/dist/integrationGenerator/errors.js +0 -6
- package/dist/integrationGenerator/index.d.ts +0 -2
- package/dist/integrationGenerator/index.js +0 -5
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.dockerignore +0 -3
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.eslintrc.js +0 -74
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.nvmrc +0 -1
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierignore +0 -1
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierrc +0 -7
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.unito.json +0 -1
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/Dockerfile +0 -38
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/README.md +0 -21
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/index.ts +0 -94
- package/dist/integrationGenerator/integrationBoilerplate/package.json +0 -43
- package/dist/integrationGenerator/integrationBoilerplate/src/logger.ts +0 -55
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/additionalLoggingContext.ts +0 -22
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/correlationId.ts +0 -13
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/credentials.ts +0 -38
- package/dist/integrationGenerator/integrationBoilerplate/src/request.ts +0 -59
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/index.ts +0 -11
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/me.ts +0 -15
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/root.ts +0 -12
- package/dist/integrationGenerator/integrationBoilerplate/tsconfig.json +0 -37
- package/dist/integrationGenerator/src/index.d.ts +0 -1
- package/dist/integrationGenerator/src/index.js +0 -5
- package/dist/integrationGenerator/src/resources/index.d.ts +0 -1
- package/dist/integrationGenerator/src/resources/index.js +0 -5
- package/dist/integrationGenerator/src/resources/integration.d.ts +0 -9
- package/dist/integrationGenerator/src/resources/integration.js +0 -60
- package/dist/integrationGenerator/test/resources/integration.test.js +0 -51
- package/dist/src/oauth2Helper/oauth2Helper.d.ts +0 -63
- package/dist/src/oauth2Helper/oauth2Helper.js +0 -235
- package/dist/src/oauth2Helper/types.d.ts +0 -22
- package/dist/src/oauth2Helper/types.js +0 -2
- package/dist/test/mocha.hooks.d.ts +0 -2
- package/dist/test/mocha.hooks.js +0 -37
- package/dist/test/services/oauth2Helper.test.js +0 -85
- /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.dockerignore +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.eslintrc.js +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.nvmrc +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.prettierignore +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.prettierrc +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/.unito.json +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/Dockerfile +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate → boilerplate}/README.md +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/package.json +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/logger.ts +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/middlewares/additionalLoggingContext.ts +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/middlewares/correlationId.ts +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/middlewares/credentials.ts +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/request.ts +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/routes/index.ts +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/routes/me.ts +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/src/routes/root.ts +0 -0
- /package/dist/{integrationGenerator/integrationBoilerplate/integrationBoilerplate → boilerplate}/tsconfig.json +0 -0
- /package/dist/{integrationGenerator/test/resources/integration.test.d.ts → test/resources/integrations.test.d.ts} +0 -0
- /package/dist/test/{services → resources}/oauth2Helper.test.d.ts +0 -0
|
@@ -6,26 +6,26 @@ const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
|
6
6
|
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
7
7
|
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
8
8
|
const IntegrationConfiguration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
9
|
+
const integrations_1 = require("../helpers/integrations");
|
|
9
10
|
describe('activity', () => {
|
|
11
|
+
const integration = (0, integrations_1.generateIntegration)();
|
|
10
12
|
let getIntegrationEventsStub;
|
|
11
13
|
beforeEach(() => {
|
|
12
14
|
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
13
15
|
sinon_1.default.stub(IntegrationsPlatform, 'setEnvironment');
|
|
14
16
|
sinon_1.default.stub(IntegrationsPlatform, 'setApiKey');
|
|
15
|
-
sinon_1.default
|
|
16
|
-
.stub(IntegrationsPlatform, 'getIntegrationByName')
|
|
17
|
-
.resolves({ name: 'integrationName', id: 'foo' });
|
|
18
17
|
getIntegrationEventsStub = sinon_1.default.stub(IntegrationsPlatform, 'getIntegrationEvents').resolves([
|
|
19
18
|
{ date: '1', text: 'This is a foo', title: 'foo', tags: ['a', 'b', 'c'] },
|
|
20
19
|
{ date: '2', text: 'This is a bar', title: 'bar', tags: ['x', 'y', 'z'] },
|
|
21
20
|
]);
|
|
22
|
-
sinon_1.default.stub(IntegrationConfiguration, 'getConfiguration').resolves({ name: '
|
|
21
|
+
sinon_1.default.stub(IntegrationConfiguration, 'getConfiguration').resolves({ name: 'foo' });
|
|
23
22
|
});
|
|
24
23
|
afterEach(() => {
|
|
25
24
|
sinon_1.default.restore();
|
|
26
25
|
});
|
|
27
26
|
test_1.test
|
|
28
27
|
.stdout()
|
|
28
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
29
29
|
.command(['activity'])
|
|
30
30
|
.it('displays activity', ctx => {
|
|
31
31
|
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
@@ -33,14 +33,16 @@ describe('activity', () => {
|
|
|
33
33
|
});
|
|
34
34
|
test_1.test
|
|
35
35
|
.stdout()
|
|
36
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
36
37
|
.command(['activity', '--number', '1'])
|
|
37
38
|
.it('displays only specified number of activity entries', ctx => {
|
|
38
39
|
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
39
40
|
(0, test_1.expect)(ctx.stdout).to.contains('bar');
|
|
40
|
-
sinon_1.default.assert.calledWithExactly(getIntegrationEventsStub,
|
|
41
|
+
sinon_1.default.assert.calledWithExactly(getIntegrationEventsStub, 1, { $from: undefined, limit: 1 });
|
|
41
42
|
});
|
|
42
43
|
test_1.test
|
|
43
44
|
.stdout()
|
|
45
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
44
46
|
.command(['activity', '--environment', 'staging'])
|
|
45
47
|
.it('displays activity - staging', ctx => {
|
|
46
48
|
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
@@ -48,6 +50,7 @@ describe('activity', () => {
|
|
|
48
50
|
});
|
|
49
51
|
test_1.test
|
|
50
52
|
.stdout()
|
|
53
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
51
54
|
.command(['activity', '--environment', 'local'])
|
|
52
55
|
.it('displays activity - local', ctx => {
|
|
53
56
|
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
@@ -55,9 +58,7 @@ describe('activity', () => {
|
|
|
55
58
|
});
|
|
56
59
|
test_1.test
|
|
57
60
|
.stdout()
|
|
58
|
-
.stub(IntegrationsPlatform, 'getIntegrationByName',
|
|
59
|
-
throw new Error();
|
|
60
|
-
})
|
|
61
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.throws(new Error()))
|
|
61
62
|
.command(['activity'])
|
|
62
63
|
.catch(error => {
|
|
63
64
|
(0, test_1.expect)(error.message).to.equal('EEXIT: -1');
|
|
@@ -65,6 +66,7 @@ describe('activity', () => {
|
|
|
65
66
|
.it('handles unpublished integration');
|
|
66
67
|
test_1.test
|
|
67
68
|
.stdout()
|
|
69
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
68
70
|
.command(['activity', '--follow'])
|
|
69
71
|
.it('displays activity - follow', ctx => {
|
|
70
72
|
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
@@ -72,10 +74,11 @@ describe('activity', () => {
|
|
|
72
74
|
});
|
|
73
75
|
test_1.test
|
|
74
76
|
.stdout()
|
|
77
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
75
78
|
.command(['activity', '--follow', '--number', '1'])
|
|
76
79
|
.it('displays activity - follow', ctx => {
|
|
77
80
|
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
78
81
|
(0, test_1.expect)(ctx.stdout).to.contains('bar');
|
|
79
|
-
sinon_1.default.assert.calledWithExactly(getIntegrationEventsStub,
|
|
82
|
+
sinon_1.default.assert.calledWithExactly(getIntegrationEventsStub, 1, { $from: undefined, limit: 1 });
|
|
80
83
|
});
|
|
81
84
|
});
|
|
@@ -9,6 +9,7 @@ const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/in
|
|
|
9
9
|
const IntegrationsPlatformResource = tslib_1.__importStar(require("../../src/resources/integrationsPlatform"));
|
|
10
10
|
const ConfigurationResource = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
11
11
|
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
12
|
+
const CredentialResource = tslib_1.__importStar(require("../../src/resources/credentials"));
|
|
12
13
|
describe('Dev', () => {
|
|
13
14
|
const debuggerConfiguration = {
|
|
14
15
|
...IntegrationDebugger.getDefaultConfiguration(),
|
|
@@ -20,6 +21,9 @@ describe('Dev', () => {
|
|
|
20
21
|
const cliConfiguration = {
|
|
21
22
|
name: 'a',
|
|
22
23
|
baseUrl: 'b',
|
|
24
|
+
secrets: {
|
|
25
|
+
secret: 'encryptedSecret',
|
|
26
|
+
},
|
|
23
27
|
testAccounts: {
|
|
24
28
|
development: {
|
|
25
29
|
key: 'value',
|
|
@@ -32,9 +36,7 @@ describe('Dev', () => {
|
|
|
32
36
|
beforeEach(() => {
|
|
33
37
|
process.env.NODE_MODULES_FOLDER = '/path/to/node_modules';
|
|
34
38
|
sinon_1.default.stub(IntegrationsPlatform, 'decryptData').resolves({ decryptedData: 'decrypted-me' });
|
|
35
|
-
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
36
39
|
sinon_1.default.stub(IntegrationsPlatformResource, 'validateAuthenticated');
|
|
37
|
-
sinon_1.default.stub(ConfigurationResource, 'getConfiguration').resolves(cliConfiguration);
|
|
38
40
|
sinon_1.default.stub(IntegrationDebugger, 'readConfiguration').resolves(debuggerConfiguration);
|
|
39
41
|
execSyncStub = sinon_1.default.stub(child_process_1.default, 'execSync');
|
|
40
42
|
spawnStub = sinon_1.default.stub(child_process_1.default, 'spawn').returns({ on: (..._args) => { } });
|
|
@@ -45,6 +47,8 @@ describe('Dev', () => {
|
|
|
45
47
|
});
|
|
46
48
|
test_1.test
|
|
47
49
|
.stdout()
|
|
50
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
51
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
48
52
|
.command(['dev'])
|
|
49
53
|
.it('launches the debugger', () => {
|
|
50
54
|
(0, test_1.expect)(execSyncStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'install']);
|
|
@@ -52,15 +56,24 @@ describe('Dev', () => {
|
|
|
52
56
|
});
|
|
53
57
|
test_1.test
|
|
54
58
|
.stdout()
|
|
59
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
60
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns(cliConfiguration))
|
|
55
61
|
.command(['dev'])
|
|
56
62
|
.it('decrypts credentials', () => {
|
|
57
63
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"key":"value","encryptedToken":"decrypted-me"}');
|
|
58
64
|
});
|
|
59
65
|
test_1.test
|
|
60
66
|
.stdout()
|
|
61
|
-
.stub(
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
68
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
69
|
+
.command(['dev'])
|
|
70
|
+
.it('decrypt secrets correctly', () => {
|
|
71
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--secrets-payload={"secret":"encryptedSecret"}');
|
|
72
|
+
});
|
|
73
|
+
test_1.test
|
|
74
|
+
.stdout()
|
|
75
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.throws(new Error('boom!')))
|
|
76
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
64
77
|
.command(['dev'])
|
|
65
78
|
.catch(ctx => {
|
|
66
79
|
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
@@ -68,12 +81,16 @@ describe('Dev', () => {
|
|
|
68
81
|
.it('handle exception');
|
|
69
82
|
test_1.test
|
|
70
83
|
.stdout()
|
|
84
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
85
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
71
86
|
.command(['dev', '--verbose'])
|
|
72
87
|
.it('verbose mode', () => {
|
|
73
88
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--verbose');
|
|
74
89
|
});
|
|
75
90
|
test_1.test
|
|
76
91
|
.stdout()
|
|
92
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
93
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
77
94
|
.command(['dev', '--crawlMode=sample'])
|
|
78
95
|
.it('crawlMode - sample', () => {
|
|
79
96
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=10');
|
|
@@ -81,6 +98,8 @@ describe('Dev', () => {
|
|
|
81
98
|
});
|
|
82
99
|
test_1.test
|
|
83
100
|
.stdout()
|
|
101
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
102
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
84
103
|
.command(['dev', '--crawlMode=single'])
|
|
85
104
|
.it('crawlMode - single', () => {
|
|
86
105
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=1');
|
|
@@ -88,20 +107,24 @@ describe('Dev', () => {
|
|
|
88
107
|
});
|
|
89
108
|
test_1.test
|
|
90
109
|
.stdout()
|
|
110
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
111
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
91
112
|
.command(['dev', '--checks', 'foo,bar'])
|
|
92
113
|
.it('checks', () => {
|
|
93
114
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--checks=foo,bar');
|
|
94
115
|
});
|
|
95
116
|
test_1.test
|
|
96
117
|
.stdout()
|
|
97
|
-
.stub(
|
|
118
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
119
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({ ...cliConfiguration, graphRelativeUrl: 'foo' }))
|
|
98
120
|
.command(['dev'])
|
|
99
121
|
.it('overrides --graph-relative-url', () => {
|
|
100
122
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--graph-relative-url=foo');
|
|
101
123
|
});
|
|
102
124
|
test_1.test
|
|
103
125
|
.stdout()
|
|
104
|
-
.stub(
|
|
126
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
127
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
105
128
|
...cliConfiguration,
|
|
106
129
|
credentialAccountRelativeUrl: 'foo',
|
|
107
130
|
}))
|
|
@@ -111,14 +134,19 @@ describe('Dev', () => {
|
|
|
111
134
|
});
|
|
112
135
|
test_1.test
|
|
113
136
|
.stdout()
|
|
114
|
-
.stub(
|
|
137
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
138
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
139
|
+
...cliConfiguration,
|
|
140
|
+
webhookParsingRelativeUrl: 'foo',
|
|
141
|
+
}))
|
|
115
142
|
.command(['dev'])
|
|
116
143
|
.it('overrides --webhook-parsing-relative-url', () => {
|
|
117
144
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-parsing-relative-url=foo');
|
|
118
145
|
});
|
|
119
146
|
test_1.test
|
|
120
147
|
.stdout()
|
|
121
|
-
.stub(
|
|
148
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
149
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
122
150
|
...cliConfiguration,
|
|
123
151
|
webhookSubscriptionsRelativeUrl: 'foo',
|
|
124
152
|
}))
|
|
@@ -128,7 +156,8 @@ describe('Dev', () => {
|
|
|
128
156
|
});
|
|
129
157
|
test_1.test
|
|
130
158
|
.stdout()
|
|
131
|
-
.stub(
|
|
159
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
160
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
132
161
|
...cliConfiguration,
|
|
133
162
|
webhookAcknowledgeRelativeUrl: 'bar',
|
|
134
163
|
}))
|
|
@@ -136,4 +165,24 @@ describe('Dev', () => {
|
|
|
136
165
|
.it('overrides --webhook-acknowledge-relative-url', () => {
|
|
137
166
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-acknowledge-relative-url=bar');
|
|
138
167
|
});
|
|
168
|
+
test_1.test
|
|
169
|
+
.stdout()
|
|
170
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
171
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
172
|
+
.stub(CredentialResource, 'fetchCredential', stub => stub.resolves({ payload: { from: 'credential' } }))
|
|
173
|
+
.command(['dev', '--credential-id=123'])
|
|
174
|
+
.it('credential-id', () => {
|
|
175
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"from":"credential"}');
|
|
176
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--read-only');
|
|
177
|
+
});
|
|
178
|
+
test_1.test
|
|
179
|
+
.stdout()
|
|
180
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
181
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
182
|
+
.stub(CredentialResource, 'fetchCredential', stub => stub.resolves({ payload: { from: 'credential' } }))
|
|
183
|
+
.command(['dev', '--credential-id=123', '--no-read-only'])
|
|
184
|
+
.it('credential-id && read-only', () => {
|
|
185
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"from":"credential"}');
|
|
186
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.not.include('--read-only');
|
|
187
|
+
});
|
|
139
188
|
});
|
|
@@ -33,28 +33,29 @@ describe('encrypt', () => {
|
|
|
33
33
|
});
|
|
34
34
|
test_1.test
|
|
35
35
|
.stdout()
|
|
36
|
-
.stub(GlobalConfiguration, 'read',
|
|
36
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({ apiKey: 'foo' }))
|
|
37
37
|
.command(['encrypt'])
|
|
38
38
|
.it('encrypts data - default', ctx => {
|
|
39
39
|
(0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
|
|
40
40
|
});
|
|
41
41
|
test_1.test
|
|
42
42
|
.stdout()
|
|
43
|
-
.stub(GlobalConfiguration, 'read',
|
|
43
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({ apiKeyLocal: 'foo' }))
|
|
44
44
|
.command(['encrypt', '--environment=local'])
|
|
45
45
|
.it('encrypts data - local', ctx => {
|
|
46
46
|
(0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
|
|
47
47
|
});
|
|
48
48
|
test_1.test
|
|
49
49
|
.stdout()
|
|
50
|
-
.stub(GlobalConfiguration, 'read',
|
|
50
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({ apiKeyStaging: 'foo' }))
|
|
51
51
|
.command(['encrypt', '--environment', 'staging'])
|
|
52
52
|
.it('encrypts data - staging', ctx => {
|
|
53
53
|
(0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
|
|
54
54
|
});
|
|
55
55
|
test_1.test
|
|
56
|
+
.stdout()
|
|
56
57
|
.stderr()
|
|
57
|
-
.stub(GlobalConfiguration, 'read',
|
|
58
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({}))
|
|
58
59
|
.command(['encrypt'])
|
|
59
60
|
.exit(-1)
|
|
60
61
|
.it('missing api key', ctx => {
|
|
@@ -62,9 +63,7 @@ describe('encrypt', () => {
|
|
|
62
63
|
});
|
|
63
64
|
test_1.test
|
|
64
65
|
.stdout()
|
|
65
|
-
.stub(GlobalConfiguration, 'read',
|
|
66
|
-
throw new Error('boom!');
|
|
67
|
-
})
|
|
66
|
+
.stub(GlobalConfiguration, 'read', stub => stub.throws(new Error('boom!')))
|
|
68
67
|
.command(['encrypt'])
|
|
69
68
|
.catch(ctx => {
|
|
70
69
|
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const test_1 = require("@oclif/test");
|
|
5
5
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
6
|
const sinon = tslib_1.__importStar(require("sinon"));
|
|
7
|
-
const
|
|
7
|
+
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
8
8
|
const Configuration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
9
9
|
describe('init', () => {
|
|
10
10
|
beforeEach(() => {
|
|
@@ -16,26 +16,24 @@ describe('init', () => {
|
|
|
16
16
|
sinon.restore();
|
|
17
17
|
});
|
|
18
18
|
test_1.test
|
|
19
|
-
.stub(inquirer_1.default, 'prompt',
|
|
20
|
-
.stub(
|
|
21
|
-
.stub(process, 'chdir',
|
|
19
|
+
.stub(inquirer_1.default, 'prompt', stub => stub.resolves({ name: 'myIntegration' }))
|
|
20
|
+
.stub(IntegrationResource, 'copyBoilerplate', stub => stub.returns('/my/super/path/myIntegration'))
|
|
21
|
+
.stub(process, 'chdir', stub => stub.returns(''))
|
|
22
22
|
.stdout()
|
|
23
23
|
.command(['init'])
|
|
24
24
|
.it('runs init', ctx => {
|
|
25
25
|
(0, test_1.expect)(ctx.stdout).to.contain('Your integration is available at');
|
|
26
26
|
});
|
|
27
27
|
test_1.test
|
|
28
|
-
.stub(
|
|
29
|
-
.stub(process, 'chdir',
|
|
28
|
+
.stub(IntegrationResource, 'copyBoilerplate', stub => stub.returns('/my/super/path/myIntegration'))
|
|
29
|
+
.stub(process, 'chdir', stub => stub.returns(''))
|
|
30
30
|
.stdout()
|
|
31
31
|
.command(['init', '-n', 'myIntegration'])
|
|
32
32
|
.it('runs init with flag', ctx => {
|
|
33
33
|
(0, test_1.expect)(ctx.stdout).to.contain('Your integration is available at');
|
|
34
34
|
});
|
|
35
35
|
test_1.test
|
|
36
|
-
.stub(
|
|
37
|
-
throw new Error('boom!');
|
|
38
|
-
})
|
|
36
|
+
.stub(IntegrationResource, 'copyBoilerplate', stub => stub.throws(new Error('boom!')))
|
|
39
37
|
.stdout()
|
|
40
38
|
.command(['init', '-n', 'myIntegration'])
|
|
41
39
|
.catch(ctx => {
|
|
@@ -3,19 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const test_1 = require("@oclif/test");
|
|
5
5
|
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
7
|
const GlobalConfiguration = tslib_1.__importStar(require("../../src/resources/globalConfiguration"));
|
|
7
8
|
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
8
9
|
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
9
10
|
const IntegrationConfiguration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
10
|
-
const
|
|
11
|
+
const integrations_1 = require("../helpers/integrations");
|
|
11
12
|
describe('invite', () => {
|
|
13
|
+
const integration = (0, integrations_1.generateIntegration)();
|
|
12
14
|
beforeEach(() => {
|
|
13
15
|
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
14
16
|
sinon_1.default.stub(IntegrationsPlatform, 'setEnvironment');
|
|
15
17
|
sinon_1.default.stub(IntegrationsPlatform, 'setApiKey');
|
|
16
|
-
sinon_1.default
|
|
17
|
-
.stub(IntegrationsPlatform, 'getIntegrationByName')
|
|
18
|
-
.resolves({ name: 'integrationName', id: 'foo' });
|
|
19
18
|
sinon_1.default.stub(IntegrationsPlatform, 'inviteUserToIntegration').resolves({});
|
|
20
19
|
sinon_1.default.stub(inquirer_1.default, 'prompt').resolves({ email: 'foo@bar.com' });
|
|
21
20
|
sinon_1.default.stub(IntegrationConfiguration, 'getConfiguration').resolves({ name: 'integrationName' });
|
|
@@ -25,31 +24,32 @@ describe('invite', () => {
|
|
|
25
24
|
});
|
|
26
25
|
test_1.test
|
|
27
26
|
.stdout()
|
|
28
|
-
.stub(GlobalConfiguration, 'read',
|
|
27
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({ email: 'foo@bar.com' }))
|
|
28
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
29
29
|
.command(['invite'])
|
|
30
30
|
.it('invites user - default', ctx => {
|
|
31
31
|
(0, test_1.expect)(ctx.stdout).to.contains('User successfully added!');
|
|
32
32
|
});
|
|
33
33
|
test_1.test
|
|
34
34
|
.stdout()
|
|
35
|
-
.stub(GlobalConfiguration, 'read',
|
|
35
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({ email: 'foo@bar.com' }))
|
|
36
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
36
37
|
.command(['invite', '--environment', 'staging'])
|
|
37
38
|
.it('invites user - staging', ctx => {
|
|
38
39
|
(0, test_1.expect)(ctx.stdout).to.contains('User successfully added!');
|
|
39
40
|
});
|
|
40
41
|
test_1.test
|
|
41
42
|
.stdout()
|
|
42
|
-
.stub(GlobalConfiguration, 'read',
|
|
43
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({ email: 'foo@bar.com' }))
|
|
44
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.resolves(integration))
|
|
43
45
|
.command(['invite', '--environment', 'local'])
|
|
44
46
|
.it('invites user - local', ctx => {
|
|
45
47
|
(0, test_1.expect)(ctx.stdout).to.contains('User successfully added!');
|
|
46
48
|
});
|
|
47
49
|
test_1.test
|
|
48
50
|
.stdout()
|
|
49
|
-
.stub(GlobalConfiguration, 'read',
|
|
50
|
-
.stub(IntegrationsPlatform, 'getIntegrationByName',
|
|
51
|
-
throw new Error();
|
|
52
|
-
})
|
|
51
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({ email: 'foo@bar.com' }))
|
|
52
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', stub => stub.throws(new Error()))
|
|
53
53
|
.command(['invite'])
|
|
54
54
|
.catch(error => {
|
|
55
55
|
(0, test_1.expect)(error.message).to.equal('EEXIT: -1');
|
|
@@ -22,39 +22,37 @@ describe('Login', () => {
|
|
|
22
22
|
});
|
|
23
23
|
test_1.test
|
|
24
24
|
.stdout()
|
|
25
|
-
.stub(GlobalConfiguration, 'read',
|
|
26
|
-
.stub(inquirer_1.default, 'prompt',
|
|
27
|
-
.stub(IntegrationsPlatform, 'getProfile',
|
|
28
|
-
.stub(GlobalConfiguration, 'write',
|
|
25
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({}))
|
|
26
|
+
.stub(inquirer_1.default, 'prompt', stub => stub.resolves({ apiKey: 'foo' }))
|
|
27
|
+
.stub(IntegrationsPlatform, 'getProfile', stub => stub.returns({ email: 'a@b.com' }))
|
|
28
|
+
.stub(GlobalConfiguration, 'write', stub => stub.returns({}))
|
|
29
29
|
.command(['login'])
|
|
30
30
|
.it('logins to the platform - default', ctx => {
|
|
31
31
|
(0, test_1.expect)(ctx.stdout).to.contain('Hello');
|
|
32
32
|
});
|
|
33
33
|
test_1.test
|
|
34
34
|
.stdout()
|
|
35
|
-
.stub(GlobalConfiguration, 'read',
|
|
36
|
-
.stub(inquirer_1.default, 'prompt',
|
|
37
|
-
.stub(IntegrationsPlatform, 'getProfile',
|
|
38
|
-
.stub(GlobalConfiguration, 'write',
|
|
35
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({}))
|
|
36
|
+
.stub(inquirer_1.default, 'prompt', stub => stub.resolves({ apiKey: 'foo' }))
|
|
37
|
+
.stub(IntegrationsPlatform, 'getProfile', stub => stub.returns({ email: 'a@b.com' }))
|
|
38
|
+
.stub(GlobalConfiguration, 'write', stub => stub.returns({}))
|
|
39
39
|
.command(['login', '--environment=local'])
|
|
40
40
|
.it('logins to the platform - local', ctx => {
|
|
41
41
|
(0, test_1.expect)(ctx.stdout).to.contain('Hello');
|
|
42
42
|
});
|
|
43
43
|
test_1.test
|
|
44
44
|
.stdout()
|
|
45
|
-
.stub(GlobalConfiguration, 'read',
|
|
46
|
-
.stub(inquirer_1.default, 'prompt',
|
|
47
|
-
.stub(IntegrationsPlatform, 'getProfile',
|
|
48
|
-
.stub(GlobalConfiguration, 'write',
|
|
45
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({}))
|
|
46
|
+
.stub(inquirer_1.default, 'prompt', stub => stub.resolves({ apiKey: 'foo' }))
|
|
47
|
+
.stub(IntegrationsPlatform, 'getProfile', stub => stub.returns({ email: 'a@b.com' }))
|
|
48
|
+
.stub(GlobalConfiguration, 'write', stub => stub.returns({}))
|
|
49
49
|
.command(['login', '--environment=staging'])
|
|
50
50
|
.it('logins to the platform - staging', ctx => {
|
|
51
51
|
(0, test_1.expect)(ctx.stdout).to.contain('Hello');
|
|
52
52
|
});
|
|
53
53
|
test_1.test
|
|
54
54
|
.stdout()
|
|
55
|
-
.stub(GlobalConfiguration, 'read',
|
|
56
|
-
throw new Error('boom!');
|
|
57
|
-
})
|
|
55
|
+
.stub(GlobalConfiguration, 'read', stub => stub.throws(new Error('boom!')))
|
|
58
56
|
.command(['login'])
|
|
59
57
|
.catch(ctx => {
|
|
60
58
|
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
@@ -62,8 +60,8 @@ describe('Login', () => {
|
|
|
62
60
|
.it('handles configuration error');
|
|
63
61
|
test_1.test
|
|
64
62
|
.stdout()
|
|
65
|
-
.stub(GlobalConfiguration, 'read',
|
|
66
|
-
.stub(inquirer_1.default, 'prompt',
|
|
63
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({}))
|
|
64
|
+
.stub(inquirer_1.default, 'prompt', stub => stub.rejects())
|
|
67
65
|
.command(['login'])
|
|
68
66
|
.catch(ctx => {
|
|
69
67
|
(0, test_1.expect)(ctx.name).to.equal('Error');
|
|
@@ -71,9 +69,9 @@ describe('Login', () => {
|
|
|
71
69
|
.it('handles input error');
|
|
72
70
|
test_1.test
|
|
73
71
|
.stdout()
|
|
74
|
-
.stub(GlobalConfiguration, 'read',
|
|
75
|
-
.stub(inquirer_1.default, 'prompt',
|
|
76
|
-
.stub(IntegrationsPlatform, 'getProfile',
|
|
72
|
+
.stub(GlobalConfiguration, 'read', stub => stub.returns({}))
|
|
73
|
+
.stub(inquirer_1.default, 'prompt', stub => stub.resolves({ apiKey: 'foo' }))
|
|
74
|
+
.stub(IntegrationsPlatform, 'getProfile', stub => stub.rejects())
|
|
77
75
|
.command(['login'])
|
|
78
76
|
.catch(ctx => {
|
|
79
77
|
(0, test_1.expect)(ctx.name).to.equal('Error');
|
|
@@ -81,9 +79,8 @@ describe('Login', () => {
|
|
|
81
79
|
.it('handles platform error');
|
|
82
80
|
test_1.test
|
|
83
81
|
.stdout()
|
|
84
|
-
.
|
|
85
|
-
|
|
86
|
-
})
|
|
82
|
+
.stderr()
|
|
83
|
+
.stub(GlobalConfiguration, 'read', stub => stub.throws(new errors_1.ConfigurationMalformed()))
|
|
87
84
|
.command(['login'])
|
|
88
85
|
.exit(-1)
|
|
89
86
|
.it('handle managed exception');
|
|
@@ -6,7 +6,7 @@ const core_1 = require("@oclif/core");
|
|
|
6
6
|
const sinon = tslib_1.__importStar(require("sinon"));
|
|
7
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
8
|
const Configuration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
9
|
-
const oauth2Service = tslib_1.__importStar(require("../../src/
|
|
9
|
+
const oauth2Service = tslib_1.__importStar(require("../../src/resources/oauth2Helper"));
|
|
10
10
|
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
11
11
|
const decryptionResource = tslib_1.__importStar(require("../../src/resources/decryption"));
|
|
12
12
|
const configurationTypes_1 = require("../../src/configurationTypes");
|
|
@@ -59,6 +59,7 @@ describe('oauth2', () => {
|
|
|
59
59
|
});
|
|
60
60
|
test_1.test
|
|
61
61
|
.stdout()
|
|
62
|
+
.stderr()
|
|
62
63
|
.do(() => getConfigurationsStub.returns({
|
|
63
64
|
...baseConfiguration,
|
|
64
65
|
authorizations: [],
|
|
@@ -83,7 +84,10 @@ describe('oauth2', () => {
|
|
|
83
84
|
.command(['oauth2', '--test-account', 'development'])
|
|
84
85
|
.it('prioritize development authorization', () => {
|
|
85
86
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(1);
|
|
86
|
-
(0, test_1.expect)(performOAuth2FlowStub.getCall(0).args).to.deep.equal([
|
|
87
|
+
(0, test_1.expect)(performOAuth2FlowStub.getCall(0).args).to.deep.equal([
|
|
88
|
+
{ ...oauth2Information, clientId: 'devClientID' },
|
|
89
|
+
'production',
|
|
90
|
+
]);
|
|
87
91
|
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(0);
|
|
88
92
|
(0, test_1.expect)(writeTestAccountStub.getCall(0).args).to.deep.equal([
|
|
89
93
|
{
|