@unito/integration-cli 0.57.1 → 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 +4 -2
- 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
|
@@ -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
|
});
|
|
@@ -20,6 +20,9 @@ describe('Dev', () => {
|
|
|
20
20
|
const cliConfiguration = {
|
|
21
21
|
name: 'a',
|
|
22
22
|
baseUrl: 'b',
|
|
23
|
+
secrets: {
|
|
24
|
+
secret: 'encryptedSecret',
|
|
25
|
+
},
|
|
23
26
|
testAccounts: {
|
|
24
27
|
development: {
|
|
25
28
|
key: 'value',
|
|
@@ -32,9 +35,7 @@ describe('Dev', () => {
|
|
|
32
35
|
beforeEach(() => {
|
|
33
36
|
process.env.NODE_MODULES_FOLDER = '/path/to/node_modules';
|
|
34
37
|
sinon_1.default.stub(IntegrationsPlatform, 'decryptData').resolves({ decryptedData: 'decrypted-me' });
|
|
35
|
-
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
36
38
|
sinon_1.default.stub(IntegrationsPlatformResource, 'validateAuthenticated');
|
|
37
|
-
sinon_1.default.stub(ConfigurationResource, 'getConfiguration').resolves(cliConfiguration);
|
|
38
39
|
sinon_1.default.stub(IntegrationDebugger, 'readConfiguration').resolves(debuggerConfiguration);
|
|
39
40
|
execSyncStub = sinon_1.default.stub(child_process_1.default, 'execSync');
|
|
40
41
|
spawnStub = sinon_1.default.stub(child_process_1.default, 'spawn').returns({ on: (..._args) => { } });
|
|
@@ -45,6 +46,8 @@ describe('Dev', () => {
|
|
|
45
46
|
});
|
|
46
47
|
test_1.test
|
|
47
48
|
.stdout()
|
|
49
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
50
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
48
51
|
.command(['dev'])
|
|
49
52
|
.it('launches the debugger', () => {
|
|
50
53
|
(0, test_1.expect)(execSyncStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'install']);
|
|
@@ -52,15 +55,24 @@ describe('Dev', () => {
|
|
|
52
55
|
});
|
|
53
56
|
test_1.test
|
|
54
57
|
.stdout()
|
|
58
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
59
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns(cliConfiguration))
|
|
55
60
|
.command(['dev'])
|
|
56
61
|
.it('decrypts credentials', () => {
|
|
57
62
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"key":"value","encryptedToken":"decrypted-me"}');
|
|
58
63
|
});
|
|
59
64
|
test_1.test
|
|
60
65
|
.stdout()
|
|
61
|
-
.stub(
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
67
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
68
|
+
.command(['dev'])
|
|
69
|
+
.it('decrypt secrets correctly', () => {
|
|
70
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--secrets-payload={"secret":"encryptedSecret"}');
|
|
71
|
+
});
|
|
72
|
+
test_1.test
|
|
73
|
+
.stdout()
|
|
74
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.throws(new Error('boom!')))
|
|
75
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
64
76
|
.command(['dev'])
|
|
65
77
|
.catch(ctx => {
|
|
66
78
|
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
@@ -68,12 +80,16 @@ describe('Dev', () => {
|
|
|
68
80
|
.it('handle exception');
|
|
69
81
|
test_1.test
|
|
70
82
|
.stdout()
|
|
83
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
84
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
71
85
|
.command(['dev', '--verbose'])
|
|
72
86
|
.it('verbose mode', () => {
|
|
73
87
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--verbose');
|
|
74
88
|
});
|
|
75
89
|
test_1.test
|
|
76
90
|
.stdout()
|
|
91
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
92
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
77
93
|
.command(['dev', '--crawlMode=sample'])
|
|
78
94
|
.it('crawlMode - sample', () => {
|
|
79
95
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=10');
|
|
@@ -81,6 +97,8 @@ describe('Dev', () => {
|
|
|
81
97
|
});
|
|
82
98
|
test_1.test
|
|
83
99
|
.stdout()
|
|
100
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
101
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
84
102
|
.command(['dev', '--crawlMode=single'])
|
|
85
103
|
.it('crawlMode - single', () => {
|
|
86
104
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=1');
|
|
@@ -88,20 +106,24 @@ describe('Dev', () => {
|
|
|
88
106
|
});
|
|
89
107
|
test_1.test
|
|
90
108
|
.stdout()
|
|
109
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
110
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({}))
|
|
91
111
|
.command(['dev', '--checks', 'foo,bar'])
|
|
92
112
|
.it('checks', () => {
|
|
93
113
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--checks=foo,bar');
|
|
94
114
|
});
|
|
95
115
|
test_1.test
|
|
96
116
|
.stdout()
|
|
97
|
-
.stub(
|
|
117
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
118
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({ ...cliConfiguration, graphRelativeUrl: 'foo' }))
|
|
98
119
|
.command(['dev'])
|
|
99
120
|
.it('overrides --graph-relative-url', () => {
|
|
100
121
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--graph-relative-url=foo');
|
|
101
122
|
});
|
|
102
123
|
test_1.test
|
|
103
124
|
.stdout()
|
|
104
|
-
.stub(
|
|
125
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
126
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
105
127
|
...cliConfiguration,
|
|
106
128
|
credentialAccountRelativeUrl: 'foo',
|
|
107
129
|
}))
|
|
@@ -111,14 +133,19 @@ describe('Dev', () => {
|
|
|
111
133
|
});
|
|
112
134
|
test_1.test
|
|
113
135
|
.stdout()
|
|
114
|
-
.stub(
|
|
136
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
137
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
138
|
+
...cliConfiguration,
|
|
139
|
+
webhookParsingRelativeUrl: 'foo',
|
|
140
|
+
}))
|
|
115
141
|
.command(['dev'])
|
|
116
142
|
.it('overrides --webhook-parsing-relative-url', () => {
|
|
117
143
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-parsing-relative-url=foo');
|
|
118
144
|
});
|
|
119
145
|
test_1.test
|
|
120
146
|
.stdout()
|
|
121
|
-
.stub(
|
|
147
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
148
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
122
149
|
...cliConfiguration,
|
|
123
150
|
webhookSubscriptionsRelativeUrl: 'foo',
|
|
124
151
|
}))
|
|
@@ -128,7 +155,8 @@ describe('Dev', () => {
|
|
|
128
155
|
});
|
|
129
156
|
test_1.test
|
|
130
157
|
.stdout()
|
|
131
|
-
.stub(
|
|
158
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
159
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
132
160
|
...cliConfiguration,
|
|
133
161
|
webhookAcknowledgeRelativeUrl: 'bar',
|
|
134
162
|
}))
|
|
@@ -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!');
|
|
@@ -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(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton',
|
|
21
|
-
.stub(process, 'chdir',
|
|
19
|
+
.stub(inquirer_1.default, 'prompt', stub => stub.resolves({ name: 'myIntegration' }))
|
|
20
|
+
.stub(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton', 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(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton',
|
|
29
|
-
.stub(process, 'chdir',
|
|
28
|
+
.stub(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton', 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(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton',
|
|
37
|
-
throw new Error('boom!');
|
|
38
|
-
})
|
|
36
|
+
.stub(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton', 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,7 @@ describe('Login', () => {
|
|
|
81
79
|
.it('handles platform error');
|
|
82
80
|
test_1.test
|
|
83
81
|
.stdout()
|
|
84
|
-
.stub(GlobalConfiguration, 'read',
|
|
85
|
-
throw new errors_1.ConfigurationMalformed();
|
|
86
|
-
})
|
|
82
|
+
.stub(GlobalConfiguration, 'read', stub => stub.throws(new errors_1.ConfigurationMalformed()))
|
|
87
83
|
.command(['login'])
|
|
88
84
|
.exit(-1)
|
|
89
85
|
.it('handle managed exception');
|
|
@@ -83,7 +83,10 @@ describe('oauth2', () => {
|
|
|
83
83
|
.command(['oauth2', '--test-account', 'development'])
|
|
84
84
|
.it('prioritize development authorization', () => {
|
|
85
85
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(1);
|
|
86
|
-
(0, test_1.expect)(performOAuth2FlowStub.getCall(0).args).to.deep.equal([
|
|
86
|
+
(0, test_1.expect)(performOAuth2FlowStub.getCall(0).args).to.deep.equal([
|
|
87
|
+
{ ...oauth2Information, clientId: 'devClientID' },
|
|
88
|
+
'production',
|
|
89
|
+
]);
|
|
87
90
|
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(0);
|
|
88
91
|
(0, test_1.expect)(writeTestAccountStub.getCall(0).args).to.deep.equal([
|
|
89
92
|
{
|