@unito/integration-cli 0.55.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/LICENSE +3 -0
- package/README.md +32 -0
- package/bin/run +11 -0
- package/bin/run.cmd +3 -0
- package/dist/.eslintrc.d.ts +10 -0
- package/dist/.eslintrc.js +20 -0
- package/dist/integrationGenerator/errors.d.ts +2 -0
- package/dist/integrationGenerator/errors.js +6 -0
- package/dist/integrationGenerator/index.d.ts +2 -0
- package/dist/integrationGenerator/index.js +5 -0
- package/dist/integrationGenerator/integrationBoilerplate/.dockerignore +3 -0
- package/dist/integrationGenerator/integrationBoilerplate/.eslintrc.js +74 -0
- package/dist/integrationGenerator/integrationBoilerplate/.nvmrc +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/.prettierignore +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/.prettierrc +7 -0
- package/dist/integrationGenerator/integrationBoilerplate/.unito.json +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/Dockerfile +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/README.md +21 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.dockerignore +3 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.eslintrc.js +74 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.nvmrc +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierignore +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierrc +7 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.unito.json +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/Dockerfile +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/README.md +21 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/package.json +43 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/index.ts +94 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/logger.ts +55 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/additionalLoggingContext.ts +22 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/correlationId.ts +13 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/credentials.ts +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/request.ts +59 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/index.ts +11 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/me.ts +15 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/root.ts +12 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/tsconfig.json +37 -0
- package/dist/integrationGenerator/integrationBoilerplate/package.json +43 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/index.ts +90 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/logger.ts +37 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/correlationId.ts +18 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/credentials.ts +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/request.ts +59 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/index.ts +11 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/me.ts +15 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/root.ts +12 -0
- package/dist/integrationGenerator/integrationBoilerplate/tsconfig.json +37 -0
- package/dist/integrationGenerator/src/index.d.ts +1 -0
- package/dist/integrationGenerator/src/index.js +5 -0
- package/dist/integrationGenerator/src/resources/index.d.ts +1 -0
- package/dist/integrationGenerator/src/resources/index.js +5 -0
- package/dist/integrationGenerator/src/resources/integration.d.ts +9 -0
- package/dist/integrationGenerator/src/resources/integration.js +60 -0
- package/dist/integrationGenerator/test/resources/integration.test.d.ts +1 -0
- package/dist/integrationGenerator/test/resources/integration.test.js +51 -0
- package/dist/schemas/authorization.json +204 -0
- package/dist/schemas/automation.json +81 -0
- package/dist/schemas/configuration.json +89 -0
- package/dist/scripts/generateTypes.d.ts +8 -0
- package/dist/scripts/generateTypes.js +44 -0
- package/dist/src/baseCommand.d.ts +14 -0
- package/dist/src/baseCommand.js +39 -0
- package/dist/src/commands/activity.d.ts +12 -0
- package/dist/src/commands/activity.js +75 -0
- package/dist/src/commands/dev.d.ts +15 -0
- package/dist/src/commands/dev.js +123 -0
- package/dist/src/commands/encrypt.d.ts +11 -0
- package/dist/src/commands/encrypt.js +50 -0
- package/dist/src/commands/init.d.ts +10 -0
- package/dist/src/commands/init.js +51 -0
- package/dist/src/commands/invite.d.ts +11 -0
- package/dist/src/commands/invite.js +71 -0
- package/dist/src/commands/login.d.ts +11 -0
- package/dist/src/commands/login.js +76 -0
- package/dist/src/commands/oauth2.d.ts +10 -0
- package/dist/src/commands/oauth2.js +99 -0
- package/dist/src/commands/publish.d.ts +28 -0
- package/dist/src/commands/publish.js +302 -0
- package/dist/src/commands/test.d.ts +9 -0
- package/dist/src/commands/test.js +165 -0
- package/dist/src/commands/upgrade.d.ts +7 -0
- package/dist/src/commands/upgrade.js +88 -0
- package/dist/src/configurationTypes.d.ts +209 -0
- package/dist/src/configurationTypes.js +49 -0
- package/dist/src/errors.d.ts +38 -0
- package/dist/src/errors.js +159 -0
- package/dist/src/hooks/init/displayLogo.d.ts +3 -0
- package/dist/src/hooks/init/displayLogo.js +37 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/oauth2Helper/oauth2Helper.d.ts +63 -0
- package/dist/src/oauth2Helper/oauth2Helper.js +235 -0
- package/dist/src/oauth2Helper/types.d.ts +22 -0
- package/dist/src/oauth2Helper/types.js +2 -0
- package/dist/src/resources/configuration.d.ts +30 -0
- package/dist/src/resources/configuration.js +191 -0
- package/dist/src/resources/decryption.d.ts +5 -0
- package/dist/src/resources/decryption.js +62 -0
- package/dist/src/resources/fileSystem.d.ts +2 -0
- package/dist/src/resources/fileSystem.js +22 -0
- package/dist/src/resources/globalConfiguration.d.ts +13 -0
- package/dist/src/resources/globalConfiguration.js +44 -0
- package/dist/src/resources/integrations.d.ts +2 -0
- package/dist/src/resources/integrations.js +17 -0
- package/dist/src/resources/integrationsPlatform.d.ts +2 -0
- package/dist/src/resources/integrationsPlatform.js +33 -0
- package/dist/src/services/integrationsPlatform.d.ts +36 -0
- package/dist/src/services/integrationsPlatform.js +162 -0
- package/dist/src/services/oauth2Helper.d.ts +3 -0
- package/dist/src/services/oauth2Helper.js +34 -0
- package/dist/test/commands/activity.test.d.ts +1 -0
- package/dist/test/commands/activity.test.js +62 -0
- package/dist/test/commands/dev.test.d.ts +1 -0
- package/dist/test/commands/dev.test.js +139 -0
- package/dist/test/commands/encrypt.test.d.ts +1 -0
- package/dist/test/commands/encrypt.test.js +73 -0
- package/dist/test/commands/init.test.d.ts +1 -0
- package/dist/test/commands/init.test.js +45 -0
- package/dist/test/commands/invite.test.d.ts +1 -0
- package/dist/test/commands/invite.test.js +56 -0
- package/dist/test/commands/login.test.d.ts +1 -0
- package/dist/test/commands/login.test.js +90 -0
- package/dist/test/commands/oauth2.test.d.ts +1 -0
- package/dist/test/commands/oauth2.test.js +104 -0
- package/dist/test/commands/publish.test.d.ts +1 -0
- package/dist/test/commands/publish.test.js +429 -0
- package/dist/test/commands/test.test.d.ts +1 -0
- package/dist/test/commands/test.test.js +171 -0
- package/dist/test/commands/upgrade.test.d.ts +1 -0
- package/dist/test/commands/upgrade.test.js +47 -0
- package/dist/test/errors.test.d.ts +1 -0
- package/dist/test/errors.test.js +96 -0
- package/dist/test/helpers/init.d.ts +1 -0
- package/dist/test/helpers/init.js +6 -0
- package/dist/test/mocha.hooks.d.ts +2 -0
- package/dist/test/mocha.hooks.js +37 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.d.ts +1 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.js +150 -0
- package/dist/test/resources/configuration.test.d.ts +1 -0
- package/dist/test/resources/configuration.test.js +586 -0
- package/dist/test/resources/decryption.test.d.ts +1 -0
- package/dist/test/resources/decryption.test.js +68 -0
- package/dist/test/resources/globalConfiguration.test.d.ts +1 -0
- package/dist/test/resources/globalConfiguration.test.js +32 -0
- package/dist/test/services/integrationsPlatform.test.d.ts +1 -0
- package/dist/test/services/integrationsPlatform.test.js +168 -0
- package/dist/test/services/oauth2Helper.test.d.ts +1 -0
- package/dist/test/services/oauth2Helper.test.js +85 -0
- package/oclif.manifest.json +423 -0
- package/package.json +98 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const test_1 = require("@oclif/test");
|
|
5
|
+
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
|
+
const ngrok_1 = tslib_1.__importDefault(require("ngrok"));
|
|
7
|
+
const child_process_1 = tslib_1.__importDefault(require("child_process"));
|
|
8
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
9
|
+
const GlobalConfiguration = tslib_1.__importStar(require("../../src/resources/globalConfiguration"));
|
|
10
|
+
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
11
|
+
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
12
|
+
const IntegrationConfiguration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
13
|
+
const errors_1 = require("../../src/errors");
|
|
14
|
+
const FileSystem = tslib_1.__importStar(require("../../src/resources/fileSystem"));
|
|
15
|
+
describe('Publish', () => {
|
|
16
|
+
let createIntegrationStub;
|
|
17
|
+
let updateIntegrationStub;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
20
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setEnvironment');
|
|
21
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setApiKey');
|
|
22
|
+
sinon_1.default.stub(IntegrationsPlatform, 'publishIntegration');
|
|
23
|
+
sinon_1.default.stub(IntegrationsPlatform, 'reencryptData').resolves({ encryptedData: 'newEncryptedSecret' });
|
|
24
|
+
createIntegrationStub = sinon_1.default
|
|
25
|
+
.stub(IntegrationsPlatform, 'createIntegration')
|
|
26
|
+
.resolves({});
|
|
27
|
+
updateIntegrationStub = sinon_1.default
|
|
28
|
+
.stub(IntegrationsPlatform, 'updateIntegration')
|
|
29
|
+
.resolves({});
|
|
30
|
+
sinon_1.default.stub(ngrok_1.default, 'connect');
|
|
31
|
+
sinon_1.default.stub(child_process_1.default, 'spawn');
|
|
32
|
+
sinon_1.default.stub(IntegrationsPlatform, 'getProfile').resolves({
|
|
33
|
+
id: 1,
|
|
34
|
+
createdAt: '',
|
|
35
|
+
updatedAt: '',
|
|
36
|
+
archivedAt: null,
|
|
37
|
+
email: 'foo@bar.com',
|
|
38
|
+
defaultUnitoOrganizationId: null,
|
|
39
|
+
role: 'developer',
|
|
40
|
+
apiKey: 'foo',
|
|
41
|
+
termsAcceptedAt: null,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
sinon_1.default.restore();
|
|
46
|
+
});
|
|
47
|
+
test_1.test
|
|
48
|
+
.stdout()
|
|
49
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
50
|
+
.stub(IntegrationConfiguration, 'getConfiguration',
|
|
51
|
+
// eslint-disable-next-line
|
|
52
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
53
|
+
(environment, customPath) => {
|
|
54
|
+
(0, test_1.expect)(environment).to.equal(GlobalConfiguration.Environment.Production);
|
|
55
|
+
(0, test_1.expect)(customPath).to.be.undefined;
|
|
56
|
+
return { name: 'a' };
|
|
57
|
+
})
|
|
58
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
59
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
60
|
+
.command(['publish'])
|
|
61
|
+
.it('publish the integration - default', ctx => {
|
|
62
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
63
|
+
});
|
|
64
|
+
test_1.test
|
|
65
|
+
.stdout()
|
|
66
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
67
|
+
.stub(IntegrationConfiguration, 'getConfiguration',
|
|
68
|
+
// eslint-disable-next-line
|
|
69
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
70
|
+
(environment, customPath) => {
|
|
71
|
+
(0, test_1.expect)(environment).to.equal(GlobalConfiguration.Environment.Production);
|
|
72
|
+
(0, test_1.expect)(customPath).to.equal('/custom-config.json');
|
|
73
|
+
return { name: 'a' };
|
|
74
|
+
})
|
|
75
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
76
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
77
|
+
.command(['publish', '--config-path', '/custom-config.json'])
|
|
78
|
+
.it('publish the integration with custom config - default', ctx => {
|
|
79
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
80
|
+
});
|
|
81
|
+
test_1.test
|
|
82
|
+
.stdout()
|
|
83
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKeyLocal: 'foo' }))
|
|
84
|
+
.stub(IntegrationConfiguration, 'getConfiguration',
|
|
85
|
+
// eslint-disable-next-line
|
|
86
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
87
|
+
(environment, customPath) => {
|
|
88
|
+
(0, test_1.expect)(environment).to.equal(GlobalConfiguration.Environment.Local);
|
|
89
|
+
(0, test_1.expect)(customPath).to.be.undefined;
|
|
90
|
+
return { name: 'a' };
|
|
91
|
+
})
|
|
92
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
93
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
94
|
+
.command(['publish', '--environment', 'local'])
|
|
95
|
+
.it('publish the integration - local', ctx => {
|
|
96
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
97
|
+
});
|
|
98
|
+
test_1.test
|
|
99
|
+
.stdout()
|
|
100
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKeyLocal: 'foo' }))
|
|
101
|
+
.stub(IntegrationConfiguration, 'getConfigurationPath', () => '/.unito.local.json')
|
|
102
|
+
.stub(IntegrationConfiguration, 'getConfiguration',
|
|
103
|
+
// eslint-disable-next-line
|
|
104
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
105
|
+
(environment, customPath) => {
|
|
106
|
+
(0, test_1.expect)(environment).to.equal(GlobalConfiguration.Environment.Local);
|
|
107
|
+
(0, test_1.expect)(customPath).to.be.undefined;
|
|
108
|
+
return { name: 'a' };
|
|
109
|
+
})
|
|
110
|
+
.stub(IntegrationConfiguration, 'writeConfiguration', () => Promise)
|
|
111
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
112
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
113
|
+
.command(['publish', '--environment', 'local'])
|
|
114
|
+
.it('publish the integration using .unito.local.json - local', ctx => {
|
|
115
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
116
|
+
});
|
|
117
|
+
test_1.test
|
|
118
|
+
.stdout()
|
|
119
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKeyStaging: 'foo' }))
|
|
120
|
+
.stub(IntegrationConfiguration, 'getConfigurationPath', () => '/.unito.json')
|
|
121
|
+
.stub(IntegrationConfiguration, 'getConfiguration',
|
|
122
|
+
// eslint-disable-next-line
|
|
123
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
124
|
+
(environment, customPath) => {
|
|
125
|
+
(0, test_1.expect)(environment).to.equal(GlobalConfiguration.Environment.Staging);
|
|
126
|
+
(0, test_1.expect)(customPath).to.be.undefined;
|
|
127
|
+
return { name: 'a' };
|
|
128
|
+
})
|
|
129
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
130
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
131
|
+
.command(['publish', '--environment', 'staging'])
|
|
132
|
+
.it('publish the integration - staging', ctx => {
|
|
133
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
134
|
+
});
|
|
135
|
+
test_1.test
|
|
136
|
+
.stdout()
|
|
137
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKeyStaging: 'foo' }))
|
|
138
|
+
.stub(IntegrationConfiguration, 'getConfigurationPath', () => '/.unito.staging.json')
|
|
139
|
+
.stub(IntegrationConfiguration, 'getConfiguration',
|
|
140
|
+
// eslint-disable-next-line
|
|
141
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
142
|
+
(environment, customPath) => {
|
|
143
|
+
(0, test_1.expect)(environment).to.equal(GlobalConfiguration.Environment.Staging);
|
|
144
|
+
(0, test_1.expect)(customPath).to.be.undefined;
|
|
145
|
+
return {};
|
|
146
|
+
})
|
|
147
|
+
.stub(IntegrationConfiguration, 'writeConfiguration', () => Promise)
|
|
148
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
149
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
150
|
+
.command(['publish', '--environment', 'staging'])
|
|
151
|
+
.it('publish the integration using .unito.staging.json - staging', ctx => {
|
|
152
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
153
|
+
});
|
|
154
|
+
test_1.test
|
|
155
|
+
.stdout()
|
|
156
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
157
|
+
.stub(IntegrationConfiguration, 'getConfigurationPath', () => '/.unito.json')
|
|
158
|
+
.stub(IntegrationConfiguration, 'getConfiguration',
|
|
159
|
+
// eslint-disable-next-line
|
|
160
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
161
|
+
(environment, customPath) => {
|
|
162
|
+
(0, test_1.expect)(environment).to.equal(GlobalConfiguration.Environment.Production);
|
|
163
|
+
(0, test_1.expect)(customPath).to.equal('/my-awesome-config.json');
|
|
164
|
+
return { name: 'a' };
|
|
165
|
+
})
|
|
166
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
167
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
168
|
+
.command(['publish', '--config-path', '/my-awesome-config.json'])
|
|
169
|
+
.it('publish the integration using custom configuration', ctx => {
|
|
170
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
171
|
+
});
|
|
172
|
+
test_1.test
|
|
173
|
+
.stdout()
|
|
174
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
175
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
176
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
177
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
178
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: false }))
|
|
179
|
+
.command(['publish', '--registry-only'])
|
|
180
|
+
.it('aborts on user negative input', ctx => {
|
|
181
|
+
(0, test_1.expect)(createIntegrationStub.called).to.be.false;
|
|
182
|
+
(0, test_1.expect)(updateIntegrationStub.called).to.be.false;
|
|
183
|
+
(0, test_1.expect)(ctx.stdout).to.contain('🙊 Abort! You are safe now 🍸 relax');
|
|
184
|
+
});
|
|
185
|
+
test_1.test
|
|
186
|
+
.stdout()
|
|
187
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
188
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
189
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
190
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
191
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: false }))
|
|
192
|
+
.command(['publish', '--registry-only', '--force'])
|
|
193
|
+
.it('bypass user confirmation with --force is active', ctx => {
|
|
194
|
+
(0, test_1.expect)(createIntegrationStub.calledOnce).to.be.true;
|
|
195
|
+
(0, test_1.expect)(ctx.stdout).to.contain('created');
|
|
196
|
+
});
|
|
197
|
+
test_1.test
|
|
198
|
+
.stdout()
|
|
199
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
200
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
201
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
202
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
203
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
204
|
+
.command(['publish', '--registry-only'])
|
|
205
|
+
.it('creates the integration in the registry', ctx => {
|
|
206
|
+
(0, test_1.expect)(createIntegrationStub.calledOnce).to.be.true;
|
|
207
|
+
(0, test_1.expect)(ctx.stdout).to.contain('created');
|
|
208
|
+
});
|
|
209
|
+
test_1.test
|
|
210
|
+
.stdout()
|
|
211
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
212
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({ name: 'a' }))
|
|
213
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [{ name: 'a' }])
|
|
214
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
215
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
216
|
+
.command(['publish', '--registry-only'])
|
|
217
|
+
.it('updates the integration in the registry', ctx => {
|
|
218
|
+
(0, test_1.expect)(createIntegrationStub.called).to.be.false;
|
|
219
|
+
(0, test_1.expect)(updateIntegrationStub.calledOnce).to.be.true;
|
|
220
|
+
(0, test_1.expect)(ctx.stdout).to.contain('updated');
|
|
221
|
+
});
|
|
222
|
+
test_1.test
|
|
223
|
+
.stdout()
|
|
224
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
225
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({
|
|
226
|
+
authorizations: [{ type: 'custom', development: true }, { type: 'oauth2' }],
|
|
227
|
+
}))
|
|
228
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
229
|
+
// eslint-disable-next-line
|
|
230
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
231
|
+
.stub(IntegrationsPlatform, 'createIntegration', (config) => config)
|
|
232
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
233
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
234
|
+
.command(['publish', '--registry-only'])
|
|
235
|
+
.it('filters out "development" authorizations', ctx => {
|
|
236
|
+
(0, test_1.expect)(ctx.stdout).to.contain('oauth2');
|
|
237
|
+
(0, test_1.expect)(ctx.stdout).to.not.contain('custom');
|
|
238
|
+
});
|
|
239
|
+
test_1.test
|
|
240
|
+
.stdout()
|
|
241
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
242
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({ name: 'foo' }))
|
|
243
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
244
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
245
|
+
.command(['publish', '--preview'])
|
|
246
|
+
.it('preview the integration', ctx => {
|
|
247
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
248
|
+
});
|
|
249
|
+
test_1.test
|
|
250
|
+
.stdout()
|
|
251
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
252
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({ name: 'foo', ui: { displayName: 'Foo' } }))
|
|
253
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
254
|
+
// eslint-disable-next-line
|
|
255
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
256
|
+
.stub(IntegrationConfiguration, 'writeConfiguration', configuration => {
|
|
257
|
+
if (configuration.name === 'foo') {
|
|
258
|
+
(0, test_1.expect)(configuration).to.deep.equal({
|
|
259
|
+
name: 'foo',
|
|
260
|
+
ui: {
|
|
261
|
+
displayName: 'Foo',
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
(0, test_1.expect)(configuration).to.deep.equal({
|
|
267
|
+
name: 'foo-preview-9c88',
|
|
268
|
+
ui: {
|
|
269
|
+
displayName: 'Foo - Preview - 9c88',
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
return configuration;
|
|
274
|
+
})
|
|
275
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
276
|
+
.command(['publish', '--preview'])
|
|
277
|
+
.it('preview the integration - override the display name', ctx => {
|
|
278
|
+
(0, test_1.expect)(ctx.stdout).to.contain('published');
|
|
279
|
+
});
|
|
280
|
+
test_1.test
|
|
281
|
+
.stdout()
|
|
282
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
283
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
284
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
285
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
286
|
+
.command(['publish', '--live-preview'])
|
|
287
|
+
.it('live-preview the integration', ctx => {
|
|
288
|
+
(0, test_1.expect)(ctx.stdout).to.contain('created');
|
|
289
|
+
});
|
|
290
|
+
test_1.test
|
|
291
|
+
.stdout()
|
|
292
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
293
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({ ui: { displayName: 'Foo' } }))
|
|
294
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
295
|
+
// eslint-disable-next-line
|
|
296
|
+
// @ts-ignore typing doesn't work here, for some reason.
|
|
297
|
+
.stub(IntegrationsPlatform, 'createIntegration', (config) => config)
|
|
298
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
299
|
+
.command(['publish', '--live-preview'])
|
|
300
|
+
.it('live-preview the integration - override the display name', ctx => {
|
|
301
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Foo - Live Preview - 9c88');
|
|
302
|
+
});
|
|
303
|
+
test_1.test
|
|
304
|
+
.stdout()
|
|
305
|
+
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
306
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
307
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
308
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
309
|
+
.command(['publish'])
|
|
310
|
+
.exit(-1)
|
|
311
|
+
.it('missing api key', ctx => {
|
|
312
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Your API key is not set!\nMake sure to run the login command first');
|
|
313
|
+
});
|
|
314
|
+
test_1.test
|
|
315
|
+
.stdout()
|
|
316
|
+
.stub(GlobalConfiguration, 'read', () => {
|
|
317
|
+
throw new errors_1.NoConfigurationFileError();
|
|
318
|
+
})
|
|
319
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
320
|
+
.command(['publish'])
|
|
321
|
+
.exit(-1)
|
|
322
|
+
.it('handles exception');
|
|
323
|
+
test_1.test
|
|
324
|
+
.stdout()
|
|
325
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
326
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({
|
|
327
|
+
name: 'myIntegration',
|
|
328
|
+
authorizations: [{ name: 'oauth2', oauth2: { clientSecret: 'unito-secret-' } }],
|
|
329
|
+
secrets: { secret1: 'unito-secret-', invalidSecret: 'Should never happen anyway' },
|
|
330
|
+
}))
|
|
331
|
+
.stub(IntegrationConfiguration, 'writeConfiguration', () => ({
|
|
332
|
+
name: 'myIntegration',
|
|
333
|
+
authorizations: [{ name: 'oauth2', oauth2: { clientSecret: 'unito-secret-' } }],
|
|
334
|
+
secrets: { secret1: 'unito-secret-', invalidSecret: 'Should never happen anyway' },
|
|
335
|
+
}))
|
|
336
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
337
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
338
|
+
.command(['publish', '--preview'])
|
|
339
|
+
.it('reencrypts the clientSecret on preview', ctx => {
|
|
340
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Reencrypting oauth2:clientSecret');
|
|
341
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Reencrypting secrets:secret1');
|
|
342
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Skipping secrets:invalidSecret');
|
|
343
|
+
});
|
|
344
|
+
test_1.test
|
|
345
|
+
.stdout()
|
|
346
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
347
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({
|
|
348
|
+
name: 'myIntegration',
|
|
349
|
+
authorizations: [{ name: 'oauth2', oauth2: { clientSecret: 'unito-secret-' } }],
|
|
350
|
+
secrets: { secret1: 'unito-secret-', invalidSecret: 'Should never happen anyway' },
|
|
351
|
+
}))
|
|
352
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
353
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
354
|
+
.command(['publish', '--live-preview'])
|
|
355
|
+
.it('reencrypts the clientSecret on live-preview', ctx => {
|
|
356
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Reencrypting oauth2:clientSecret');
|
|
357
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Reencrypting secrets:secret1');
|
|
358
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Skipping secrets:invalidSecret');
|
|
359
|
+
});
|
|
360
|
+
test_1.test
|
|
361
|
+
.stdout()
|
|
362
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
363
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({
|
|
364
|
+
name: 'myIntegration',
|
|
365
|
+
authorizations: [{ name: 'oauth2', oauth2: { clientSecret: 'toto' } }],
|
|
366
|
+
}))
|
|
367
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
368
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('')))
|
|
369
|
+
.command(['publish', '--live-preview'])
|
|
370
|
+
.it('skips reencryption', ctx => {
|
|
371
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Skipping oauth2:clientSecret');
|
|
372
|
+
});
|
|
373
|
+
test_1.test
|
|
374
|
+
.stdout()
|
|
375
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
376
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({
|
|
377
|
+
authorizations: [
|
|
378
|
+
{
|
|
379
|
+
name: 'foo',
|
|
380
|
+
method: 'custom',
|
|
381
|
+
},
|
|
382
|
+
],
|
|
383
|
+
}))
|
|
384
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
385
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.resolve(Buffer.from('foo')))
|
|
386
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
387
|
+
.command(['publish', '--registry-only'])
|
|
388
|
+
.it('update assets', ctx => {
|
|
389
|
+
(0, test_1.expect)(ctx.stdout).to.contain('image: <set>');
|
|
390
|
+
(0, test_1.expect)(ctx.stdout).to.contain('markdown: <set>');
|
|
391
|
+
});
|
|
392
|
+
test_1.test
|
|
393
|
+
.stdout()
|
|
394
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
395
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({
|
|
396
|
+
authorizations: [
|
|
397
|
+
{
|
|
398
|
+
name: 'foo',
|
|
399
|
+
method: 'custom',
|
|
400
|
+
},
|
|
401
|
+
],
|
|
402
|
+
}))
|
|
403
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
404
|
+
.stub(FileSystem, 'getFileBuffer', () => Promise.reject())
|
|
405
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
406
|
+
.command(['publish', '--registry-only'])
|
|
407
|
+
.it('it logs error if file exceeds max size', ctx => {
|
|
408
|
+
(0, test_1.expect)(ctx.stdout).to.contain('File exceeds the size limit');
|
|
409
|
+
});
|
|
410
|
+
test_1.test
|
|
411
|
+
.stdout()
|
|
412
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
413
|
+
.stub(IntegrationConfiguration, 'getConfiguration', () => ({
|
|
414
|
+
authorizations: [
|
|
415
|
+
{
|
|
416
|
+
name: 'foo',
|
|
417
|
+
method: 'custom',
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
}))
|
|
421
|
+
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
422
|
+
.stub(FileSystem, 'getFileBuffer', () => null)
|
|
423
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ proceed: true }))
|
|
424
|
+
.command(['publish', '--registry-only'])
|
|
425
|
+
.it('it defaults instructions to null if no file in assets folder', ctx => {
|
|
426
|
+
(0, test_1.expect)(ctx.stdout).to.contain('image: <unset>');
|
|
427
|
+
(0, test_1.expect)(ctx.stdout).to.contain('markdown: <unset>');
|
|
428
|
+
});
|
|
429
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const test_1 = require("@oclif/test");
|
|
5
|
+
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
|
+
const child_process_1 = tslib_1.__importDefault(require("child_process"));
|
|
7
|
+
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
8
|
+
const IntegrationsPlatformResource = tslib_1.__importStar(require("../../src/resources/integrationsPlatform"));
|
|
9
|
+
const ConfigurationResource = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
10
|
+
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
11
|
+
const errors_1 = require("../../src/errors");
|
|
12
|
+
describe('Test', () => {
|
|
13
|
+
const cliConfiguration = {
|
|
14
|
+
name: 'a',
|
|
15
|
+
baseUrl: 'b',
|
|
16
|
+
testAccounts: {
|
|
17
|
+
compliance: {
|
|
18
|
+
accessToken: 'token',
|
|
19
|
+
encryptedToken: `${ConfigurationResource.ENCRYPTION_PREFIX}decrypt-me`,
|
|
20
|
+
},
|
|
21
|
+
development: {
|
|
22
|
+
accessToken: 'developmentToken',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
let execSyncStub;
|
|
27
|
+
let spawnStub;
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
process.env.NODE_MODULES_FOLDER = '/path/to/node_modules';
|
|
30
|
+
sinon_1.default.stub(IntegrationsPlatform, 'decryptData').resolves({ decryptedData: 'decrypted-me' });
|
|
31
|
+
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
32
|
+
sinon_1.default.stub(IntegrationsPlatformResource, 'validateAuthenticated');
|
|
33
|
+
sinon_1.default.stub(ConfigurationResource, 'getConfiguration').resolves(cliConfiguration);
|
|
34
|
+
execSyncStub = sinon_1.default.stub(child_process_1.default, 'execSync');
|
|
35
|
+
spawnStub = sinon_1.default.stub(child_process_1.default, 'spawn').returns({ on: (..._args) => { } });
|
|
36
|
+
});
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
process.env.NODE_MODULES_FOLDER = undefined;
|
|
39
|
+
sinon_1.default.restore();
|
|
40
|
+
});
|
|
41
|
+
test_1.test
|
|
42
|
+
.stdout()
|
|
43
|
+
.command(['test'])
|
|
44
|
+
.it('launches the debugger', () => {
|
|
45
|
+
(0, test_1.expect)(execSyncStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'install']);
|
|
46
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['node']);
|
|
47
|
+
});
|
|
48
|
+
test_1.test
|
|
49
|
+
.stdout()
|
|
50
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', () => {
|
|
51
|
+
throw new Error('boom!');
|
|
52
|
+
})
|
|
53
|
+
.command(['test'])
|
|
54
|
+
.catch(ctx => {
|
|
55
|
+
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
56
|
+
})
|
|
57
|
+
.it('unhandled exception');
|
|
58
|
+
test_1.test
|
|
59
|
+
.stdout()
|
|
60
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', () => {
|
|
61
|
+
throw new errors_1.NoIntegrationFoundError();
|
|
62
|
+
})
|
|
63
|
+
.command(['test'])
|
|
64
|
+
.exit(-1)
|
|
65
|
+
.it('handled exception');
|
|
66
|
+
test_1.test
|
|
67
|
+
.stdout()
|
|
68
|
+
.stub(ConfigurationResource, 'getConfiguration', () => {
|
|
69
|
+
return {
|
|
70
|
+
name: 'a',
|
|
71
|
+
baseUrl: 'b',
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
.command(['test', '--test-account', 'compliance'])
|
|
75
|
+
.exit(-1)
|
|
76
|
+
.it('should throw an error if no test account is configured');
|
|
77
|
+
test_1.test
|
|
78
|
+
.stdout()
|
|
79
|
+
.command(['test', '--verbose'])
|
|
80
|
+
.it('verbose mode', () => {
|
|
81
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--verbose');
|
|
82
|
+
});
|
|
83
|
+
test_1.test
|
|
84
|
+
.stdout()
|
|
85
|
+
.command(['test', '--credential-payload', '{"foo": "bar"}'])
|
|
86
|
+
.it('uses provided credentials', () => {
|
|
87
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"foo": "bar"}');
|
|
88
|
+
});
|
|
89
|
+
test_1.test
|
|
90
|
+
.stdout()
|
|
91
|
+
.command(['test'])
|
|
92
|
+
.it('defaults to test account when no flag is provided', () => {
|
|
93
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"accessToken":"developmentToken"}');
|
|
94
|
+
});
|
|
95
|
+
test_1.test
|
|
96
|
+
.stdout()
|
|
97
|
+
.command(['test', '--test-account', 'compliance'])
|
|
98
|
+
.it('uses compliance credentials when a flag is provided', () => {
|
|
99
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"accessToken":"token","encryptedToken":"decrypted-me"}');
|
|
100
|
+
});
|
|
101
|
+
test_1.test
|
|
102
|
+
.stdout()
|
|
103
|
+
.command(['test', '--output-path', 'foo.json'])
|
|
104
|
+
.it('output path', () => {
|
|
105
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--output-path=foo.json');
|
|
106
|
+
});
|
|
107
|
+
test_1.test
|
|
108
|
+
.stdout()
|
|
109
|
+
.command(['test', '--crawlMode=sample'])
|
|
110
|
+
.it('sampling crawlMode', () => {
|
|
111
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=10');
|
|
112
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-follow-next-pages=false');
|
|
113
|
+
});
|
|
114
|
+
test_1.test
|
|
115
|
+
.stdout()
|
|
116
|
+
.command(['test', '--crawlMode=single'])
|
|
117
|
+
.it('single crawlMode', () => {
|
|
118
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=1');
|
|
119
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-follow-next-pages=false');
|
|
120
|
+
});
|
|
121
|
+
test_1.test
|
|
122
|
+
.stdout()
|
|
123
|
+
.command(['test', '--checks', 'foo,bar'])
|
|
124
|
+
.it('checks', () => {
|
|
125
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--checks=foo,bar');
|
|
126
|
+
});
|
|
127
|
+
test_1.test
|
|
128
|
+
.stdout()
|
|
129
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({ ...cliConfiguration, graphRelativeUrl: 'foo' }))
|
|
130
|
+
.command(['test'])
|
|
131
|
+
.it('overrides --graph-relative-url', () => {
|
|
132
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--graph-relative-url=foo');
|
|
133
|
+
});
|
|
134
|
+
test_1.test
|
|
135
|
+
.stdout()
|
|
136
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({
|
|
137
|
+
...cliConfiguration,
|
|
138
|
+
credentialAccountRelativeUrl: 'foo',
|
|
139
|
+
}))
|
|
140
|
+
.command(['test'])
|
|
141
|
+
.it('overrides --credential-account-relative-url', () => {
|
|
142
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-account-relative-url=foo');
|
|
143
|
+
});
|
|
144
|
+
test_1.test
|
|
145
|
+
.stdout()
|
|
146
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({ ...cliConfiguration, webhookParsingRelativeUrl: 'foo' }))
|
|
147
|
+
.command(['test'])
|
|
148
|
+
.it('overrides --webhook-parsing-relative-url', () => {
|
|
149
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-parsing-relative-url=foo');
|
|
150
|
+
});
|
|
151
|
+
test_1.test
|
|
152
|
+
.stdout()
|
|
153
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({
|
|
154
|
+
...cliConfiguration,
|
|
155
|
+
webhookSubscriptionsRelativeUrl: 'foo',
|
|
156
|
+
}))
|
|
157
|
+
.command(['test'])
|
|
158
|
+
.it('overrides --webhook-subscriptions-relative-url', () => {
|
|
159
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-subscriptions-relative-url=foo');
|
|
160
|
+
});
|
|
161
|
+
test_1.test
|
|
162
|
+
.stdout()
|
|
163
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({
|
|
164
|
+
...cliConfiguration,
|
|
165
|
+
webhookAcknowledgeRelativeUrl: 'bar',
|
|
166
|
+
}))
|
|
167
|
+
.command(['test'])
|
|
168
|
+
.it('overrides --webhook-acknowledge-relative-url', () => {
|
|
169
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-acknowledge-relative-url=bar');
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const test_1 = require("@oclif/test");
|
|
5
|
+
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
|
+
const child_process_1 = tslib_1.__importDefault(require("child_process"));
|
|
7
|
+
const errors_1 = require("../../src/errors");
|
|
8
|
+
describe('Upgrade', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
process.env.NODE_MODULES_FOLDER = '/path/to/node_modules';
|
|
11
|
+
});
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
process.env.NODE_MODULES_FOLDER = undefined;
|
|
14
|
+
});
|
|
15
|
+
test_1.test
|
|
16
|
+
.stdout()
|
|
17
|
+
.stub(child_process_1.default, 'execSync', sinon_1.default.stub().onCall(0).returns('1').onCall(1).returns('2').onCall(2).returns('ok'))
|
|
18
|
+
.command(['upgrade'])
|
|
19
|
+
.it('upgrades the CLI', ctx => {
|
|
20
|
+
const execSyncStub = child_process_1.default.execSync;
|
|
21
|
+
(0, test_1.expect)(execSyncStub.callCount).to.equal(3);
|
|
22
|
+
(0, test_1.expect)(execSyncStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'list']);
|
|
23
|
+
(0, test_1.expect)(execSyncStub.getCall(1).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'show']);
|
|
24
|
+
(0, test_1.expect)(execSyncStub.getCall(2).args.at(0).split(' ').slice(0, 3)).to.deep.equal(['npm', 'install', '--force']);
|
|
25
|
+
(0, test_1.expect)(ctx.stdout).to.include('Upgraded');
|
|
26
|
+
});
|
|
27
|
+
test_1.test
|
|
28
|
+
.stdout()
|
|
29
|
+
.stub(child_process_1.default, 'execSync', sinon_1.default.stub().onCall(0).returns('1').onCall(1).returns('1'))
|
|
30
|
+
.command(['upgrade'])
|
|
31
|
+
.it('validates the CLI', ctx => {
|
|
32
|
+
const execSyncStub = child_process_1.default.execSync;
|
|
33
|
+
(0, test_1.expect)(execSyncStub.callCount).to.equal(3);
|
|
34
|
+
(0, test_1.expect)(execSyncStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'list']);
|
|
35
|
+
(0, test_1.expect)(execSyncStub.getCall(1).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'show']);
|
|
36
|
+
(0, test_1.expect)(execSyncStub.getCall(2).args.at(0).split(' ').slice(0, 3)).to.deep.equal(['npm', 'install', '--force']);
|
|
37
|
+
(0, test_1.expect)(ctx.stdout).to.include('valid');
|
|
38
|
+
});
|
|
39
|
+
test_1.test
|
|
40
|
+
.stdout()
|
|
41
|
+
.stub(child_process_1.default, 'execSync', () => {
|
|
42
|
+
throw new errors_1.MissingEnvironmentVariableError();
|
|
43
|
+
})
|
|
44
|
+
.command(['upgrade'])
|
|
45
|
+
.exit(-1)
|
|
46
|
+
.it('handle exception');
|
|
47
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|