@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
|
@@ -8,11 +8,15 @@ const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/in
|
|
|
8
8
|
const IntegrationsPlatformResource = tslib_1.__importStar(require("../../src/resources/integrationsPlatform"));
|
|
9
9
|
const ConfigurationResource = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
10
10
|
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
11
|
+
const CredentialResource = tslib_1.__importStar(require("../../src/resources/credentials"));
|
|
11
12
|
const errors_1 = require("../../src/errors");
|
|
12
13
|
describe('Test', () => {
|
|
13
14
|
const cliConfiguration = {
|
|
14
15
|
name: 'a',
|
|
15
16
|
baseUrl: 'b',
|
|
17
|
+
secrets: {
|
|
18
|
+
secret: 'encryptedSecret',
|
|
19
|
+
},
|
|
16
20
|
testAccounts: {
|
|
17
21
|
compliance: {
|
|
18
22
|
accessToken: 'token',
|
|
@@ -28,9 +32,7 @@ describe('Test', () => {
|
|
|
28
32
|
beforeEach(() => {
|
|
29
33
|
process.env.NODE_MODULES_FOLDER = '/path/to/node_modules';
|
|
30
34
|
sinon_1.default.stub(IntegrationsPlatform, 'decryptData').resolves({ decryptedData: 'decrypted-me' });
|
|
31
|
-
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
32
35
|
sinon_1.default.stub(IntegrationsPlatformResource, 'validateAuthenticated');
|
|
33
|
-
sinon_1.default.stub(ConfigurationResource, 'getConfiguration').resolves(cliConfiguration);
|
|
34
36
|
execSyncStub = sinon_1.default.stub(child_process_1.default, 'execSync');
|
|
35
37
|
spawnStub = sinon_1.default.stub(child_process_1.default, 'spawn').returns({ on: (..._args) => { } });
|
|
36
38
|
});
|
|
@@ -40,6 +42,8 @@ describe('Test', () => {
|
|
|
40
42
|
});
|
|
41
43
|
test_1.test
|
|
42
44
|
.stdout()
|
|
45
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns(cliConfiguration))
|
|
46
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
43
47
|
.command(['test'])
|
|
44
48
|
.it('launches the debugger', () => {
|
|
45
49
|
(0, test_1.expect)(execSyncStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'install']);
|
|
@@ -47,9 +51,9 @@ describe('Test', () => {
|
|
|
47
51
|
});
|
|
48
52
|
test_1.test
|
|
49
53
|
.stdout()
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
.stderr()
|
|
55
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
56
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.throws(new Error('boom!')))
|
|
53
57
|
.command(['test'])
|
|
54
58
|
.catch(ctx => {
|
|
55
59
|
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
@@ -57,44 +61,63 @@ describe('Test', () => {
|
|
|
57
61
|
.it('unhandled exception');
|
|
58
62
|
test_1.test
|
|
59
63
|
.stdout()
|
|
60
|
-
.stub(
|
|
61
|
-
|
|
62
|
-
})
|
|
64
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
65
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.throws(new errors_1.NoIntegrationFoundError()))
|
|
63
66
|
.command(['test'])
|
|
64
67
|
.exit(-1)
|
|
65
68
|
.it('handled exception');
|
|
66
69
|
test_1.test
|
|
67
70
|
.stdout()
|
|
71
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
72
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
68
73
|
.command(['test', '--verbose'])
|
|
69
74
|
.it('verbose mode', () => {
|
|
70
75
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--verbose');
|
|
71
76
|
});
|
|
72
77
|
test_1.test
|
|
73
78
|
.stdout()
|
|
79
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
80
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
74
81
|
.command(['test', '--credential-payload', '{"foo": "bar"}'])
|
|
75
82
|
.it('uses provided credentials', () => {
|
|
76
83
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"foo": "bar"}');
|
|
77
84
|
});
|
|
78
85
|
test_1.test
|
|
79
86
|
.stdout()
|
|
87
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
88
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
80
89
|
.command(['test'])
|
|
81
90
|
.it('defaults to test account when no flag is provided', () => {
|
|
82
91
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"accessToken":"developmentToken"}');
|
|
83
92
|
});
|
|
84
93
|
test_1.test
|
|
85
94
|
.stdout()
|
|
95
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
96
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
86
97
|
.command(['test', '--test-account', 'compliance'])
|
|
87
98
|
.it('uses compliance credentials when a flag is provided', () => {
|
|
88
99
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"accessToken":"token","encryptedToken":"decrypted-me"}');
|
|
89
100
|
});
|
|
90
101
|
test_1.test
|
|
91
102
|
.stdout()
|
|
103
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
104
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
105
|
+
.command(['test'])
|
|
106
|
+
.it('decrypt secrets correctly', () => {
|
|
107
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--secrets-payload={"secret":"encryptedSecret"}');
|
|
108
|
+
});
|
|
109
|
+
test_1.test
|
|
110
|
+
.stdout()
|
|
111
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
112
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
92
113
|
.command(['test', '--output-path', 'foo.json'])
|
|
93
114
|
.it('output path', () => {
|
|
94
115
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--output-path=foo.json');
|
|
95
116
|
});
|
|
96
117
|
test_1.test
|
|
97
118
|
.stdout()
|
|
119
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
120
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
98
121
|
.command(['test', '--crawlMode=sample'])
|
|
99
122
|
.it('sampling crawlMode', () => {
|
|
100
123
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=10');
|
|
@@ -102,6 +125,8 @@ describe('Test', () => {
|
|
|
102
125
|
});
|
|
103
126
|
test_1.test
|
|
104
127
|
.stdout()
|
|
128
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
129
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
105
130
|
.command(['test', '--crawlMode=single'])
|
|
106
131
|
.it('single crawlMode', () => {
|
|
107
132
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=1');
|
|
@@ -109,52 +134,79 @@ describe('Test', () => {
|
|
|
109
134
|
});
|
|
110
135
|
test_1.test
|
|
111
136
|
.stdout()
|
|
137
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
138
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
112
139
|
.command(['test', '--checks', 'foo,bar'])
|
|
113
140
|
.it('checks', () => {
|
|
114
141
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--checks=foo,bar');
|
|
115
142
|
});
|
|
116
143
|
test_1.test
|
|
117
144
|
.stdout()
|
|
118
|
-
.stub(ConfigurationResource, 'getConfiguration',
|
|
145
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({ ...cliConfiguration, graphRelativeUrl: 'foo' }))
|
|
146
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
119
147
|
.command(['test'])
|
|
120
148
|
.it('overrides --graph-relative-url', () => {
|
|
121
149
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--graph-relative-url=foo');
|
|
122
150
|
});
|
|
123
151
|
test_1.test
|
|
124
152
|
.stdout()
|
|
125
|
-
.stub(ConfigurationResource, 'getConfiguration',
|
|
153
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
126
154
|
...cliConfiguration,
|
|
127
155
|
credentialAccountRelativeUrl: 'foo',
|
|
128
156
|
}))
|
|
157
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
129
158
|
.command(['test'])
|
|
130
159
|
.it('overrides --credential-account-relative-url', () => {
|
|
131
160
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-account-relative-url=foo');
|
|
132
161
|
});
|
|
133
162
|
test_1.test
|
|
134
163
|
.stdout()
|
|
135
|
-
.stub(ConfigurationResource, 'getConfiguration',
|
|
164
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({ ...cliConfiguration, webhookParsingRelativeUrl: 'foo' }))
|
|
165
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
136
166
|
.command(['test'])
|
|
137
167
|
.it('overrides --webhook-parsing-relative-url', () => {
|
|
138
168
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-parsing-relative-url=foo');
|
|
139
169
|
});
|
|
140
170
|
test_1.test
|
|
141
171
|
.stdout()
|
|
142
|
-
.stub(ConfigurationResource, 'getConfiguration',
|
|
172
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
143
173
|
...cliConfiguration,
|
|
144
174
|
webhookSubscriptionsRelativeUrl: 'foo',
|
|
145
175
|
}))
|
|
176
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
146
177
|
.command(['test'])
|
|
147
178
|
.it('overrides --webhook-subscriptions-relative-url', () => {
|
|
148
179
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-subscriptions-relative-url=foo');
|
|
149
180
|
});
|
|
150
181
|
test_1.test
|
|
151
182
|
.stdout()
|
|
152
|
-
.stub(ConfigurationResource, 'getConfiguration',
|
|
183
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns({
|
|
153
184
|
...cliConfiguration,
|
|
154
185
|
webhookAcknowledgeRelativeUrl: 'bar',
|
|
155
186
|
}))
|
|
187
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
156
188
|
.command(['test'])
|
|
157
189
|
.it('overrides --webhook-acknowledge-relative-url', () => {
|
|
158
190
|
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-acknowledge-relative-url=bar');
|
|
159
191
|
});
|
|
192
|
+
test_1.test
|
|
193
|
+
.stdout()
|
|
194
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
195
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
196
|
+
.stub(CredentialResource, 'fetchCredential', stub => stub.resolves({ payload: { from: 'credential' } }))
|
|
197
|
+
.command(['test', '--credential-id=123'])
|
|
198
|
+
.it('credential-id', () => {
|
|
199
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"from":"credential"}');
|
|
200
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--read-only');
|
|
201
|
+
});
|
|
202
|
+
test_1.test
|
|
203
|
+
.stdout()
|
|
204
|
+
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
205
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
206
|
+
.stub(CredentialResource, 'fetchCredential', stub => stub.resolves({ payload: { from: 'credential' } }))
|
|
207
|
+
.command(['test', '--credential-id=123', '--no-read-only'])
|
|
208
|
+
.it('credential-id && read-only', () => {
|
|
209
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"from":"credential"}');
|
|
210
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.not.include('--read-only');
|
|
211
|
+
});
|
|
160
212
|
});
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const test_1 = require("@oclif/test");
|
|
5
|
-
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
5
|
const child_process_1 = tslib_1.__importDefault(require("child_process"));
|
|
7
6
|
const errors_1 = require("../../src/errors");
|
|
8
7
|
describe('Upgrade', () => {
|
|
@@ -14,7 +13,7 @@ describe('Upgrade', () => {
|
|
|
14
13
|
});
|
|
15
14
|
test_1.test
|
|
16
15
|
.stdout()
|
|
17
|
-
.stub(child_process_1.default, 'execSync',
|
|
16
|
+
.stub(child_process_1.default, 'execSync', stub => stub.onCall(0).returns('1').onCall(1).returns('2').onCall(2).returns('ok'))
|
|
18
17
|
.command(['upgrade'])
|
|
19
18
|
.it('upgrades the CLI', ctx => {
|
|
20
19
|
const execSyncStub = child_process_1.default.execSync;
|
|
@@ -26,7 +25,7 @@ describe('Upgrade', () => {
|
|
|
26
25
|
});
|
|
27
26
|
test_1.test
|
|
28
27
|
.stdout()
|
|
29
|
-
.stub(child_process_1.default, 'execSync',
|
|
28
|
+
.stub(child_process_1.default, 'execSync', stub => stub.onCall(0).returns('1').onCall(1).returns('1'))
|
|
30
29
|
.command(['upgrade'])
|
|
31
30
|
.it('validates the CLI', ctx => {
|
|
32
31
|
const execSyncStub = child_process_1.default.execSync;
|
|
@@ -38,9 +37,8 @@ describe('Upgrade', () => {
|
|
|
38
37
|
});
|
|
39
38
|
test_1.test
|
|
40
39
|
.stdout()
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
})
|
|
40
|
+
.stderr()
|
|
41
|
+
.stub(child_process_1.default, 'execSync', stub => stub.throws(new errors_1.ConfigurationMalformed()))
|
|
44
42
|
.command(['upgrade'])
|
|
45
43
|
.exit(-1)
|
|
46
44
|
.it('handle exception');
|
package/dist/test/errors.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
5
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
7
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
@@ -21,67 +21,67 @@ describe('handleError', () => {
|
|
|
21
21
|
afterEach(() => {
|
|
22
22
|
sinon_1.default.restore();
|
|
23
23
|
});
|
|
24
|
-
it('
|
|
24
|
+
it('handles NoIntegrationFoundError', () => {
|
|
25
25
|
const error = new errors_1.NoIntegrationFoundError();
|
|
26
26
|
const handled = (0, errors_1.handleError)(command, error);
|
|
27
|
-
(0,
|
|
28
|
-
(0,
|
|
29
|
-
|
|
30
|
-
(0,
|
|
27
|
+
(0, strict_1.default)(handled);
|
|
28
|
+
(0, strict_1.default)(stdErrStub.calledTwice);
|
|
29
|
+
strict_1.default.equal(stdErrStub.firstCall.args[0], chalk_1.default.redBright('Your directory does not seem to contain an integration :('));
|
|
30
|
+
(0, strict_1.default)(stdErrStub.secondCall.args[0].includes('Make sure you are in the right directory'));
|
|
31
31
|
});
|
|
32
|
-
it('
|
|
32
|
+
it('handles NoConfigurationFileError', () => {
|
|
33
33
|
const error = new errors_1.NoConfigurationFileError();
|
|
34
34
|
const handled = (0, errors_1.handleError)(command, error);
|
|
35
|
-
(0,
|
|
36
|
-
(0,
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
(0, strict_1.default)(handled);
|
|
36
|
+
(0, strict_1.default)(stdErrStub.calledTwice);
|
|
37
|
+
strict_1.default.equal(stdErrStub.firstCall.args[0], chalk_1.default.redBright('This command requires a configuration file for your integration :('));
|
|
38
|
+
strict_1.default.equal(stdErrStub.secondCall.args[0], `This file should be located at ${chalk_1.default.yellowBright(path_1.default.relative(process.cwd(), (0, configuration_1.getConfigurationPath)()))}.`);
|
|
39
39
|
});
|
|
40
40
|
it('should return false for unrecognized error', () => {
|
|
41
41
|
const error = new Error('Unrecognized error');
|
|
42
42
|
const handled = (0, errors_1.handleError)(command, error);
|
|
43
|
-
(
|
|
44
|
-
|
|
43
|
+
strict_1.default.equal(handled, false);
|
|
44
|
+
strict_1.default.equal(stdErrStub.called, false);
|
|
45
45
|
});
|
|
46
|
-
it('
|
|
46
|
+
it('handles ConfigurationInvalid', () => {
|
|
47
47
|
const error = new errors_1.ConfigurationInvalid('VAR_NAME', 'details', 'prettyDetails');
|
|
48
48
|
const handled = (0, errors_1.handleError)(command, error);
|
|
49
|
-
(0,
|
|
50
|
-
(0,
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
(0, strict_1.default)(handled);
|
|
50
|
+
(0, strict_1.default)(stdErrStub.calledThrice);
|
|
51
|
+
strict_1.default.equal(stdErrStub.firstCall.args[0], chalk_1.default.redBright(`Your ${chalk_1.default.yellowBright(path_1.default.basename((0, configuration_1.getConfigurationPath)()))} is invalid!`));
|
|
52
|
+
strict_1.default.equal(stdErrStub.thirdCall.args[0], 'prettyDetails');
|
|
53
53
|
});
|
|
54
|
-
it('
|
|
54
|
+
it('handles NoRefreshTokenError', () => {
|
|
55
55
|
const error = new errors_1.NoRefreshTokenError();
|
|
56
56
|
const handled = (0, errors_1.handleError)(command, error);
|
|
57
|
-
(0,
|
|
58
|
-
(0,
|
|
59
|
-
|
|
57
|
+
(0, strict_1.default)(handled);
|
|
58
|
+
(0, strict_1.default)(stdErrStub.calledOnce);
|
|
59
|
+
strict_1.default.equal(stdErrStub.firstCall.args[0], chalk_1.default.redBright('No refresh token found in your configuration file'));
|
|
60
60
|
});
|
|
61
|
-
it('
|
|
61
|
+
it('handles FailedToRetrieveAccessTokenError', () => {
|
|
62
62
|
const error = new errors_1.FailedToRetrieveAccessTokenError('Credentials invalid');
|
|
63
63
|
const handled = (0, errors_1.handleError)(command, error);
|
|
64
|
-
(0,
|
|
65
|
-
(0,
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
(0, strict_1.default)(handled);
|
|
65
|
+
(0, strict_1.default)(stdErrStub.calledThrice);
|
|
66
|
+
strict_1.default.equal(stdErrStub.firstCall.args[0], chalk_1.default.redBright('Failed to retrieve access token'));
|
|
67
|
+
strict_1.default.equal(stdErrStub.thirdCall.args[0], 'Credentials invalid');
|
|
68
68
|
});
|
|
69
|
-
it('
|
|
69
|
+
it('handles InvalidRequestContentTypeError', () => {
|
|
70
70
|
const error = new errors_1.InvalidRequestContentTypeError('Invalid content type');
|
|
71
71
|
const handled = (0, errors_1.handleError)(command, error);
|
|
72
|
-
(0,
|
|
73
|
-
(0,
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
(0, strict_1.default)(handled);
|
|
73
|
+
(0, strict_1.default)(stdErrStub.calledThrice);
|
|
74
|
+
strict_1.default.equal(stdErrStub.firstCall.args[0], chalk_1.default.redBright('Invalid request content type'));
|
|
75
|
+
strict_1.default.equal(stdErrStub.thirdCall.args[0], 'Invalid content type');
|
|
76
76
|
});
|
|
77
|
-
it('
|
|
77
|
+
it('handles DecryptionAuthenticationError', () => {
|
|
78
78
|
const error = new errors_1.DecryptionAuthenticationError('secrets');
|
|
79
79
|
const handled = (0, errors_1.handleError)(command, error);
|
|
80
|
-
(0,
|
|
80
|
+
(0, strict_1.default)(handled);
|
|
81
81
|
});
|
|
82
|
-
it('
|
|
82
|
+
it('handles EntryDecryptionError', () => {
|
|
83
83
|
const error = new errors_1.EntryDecryptionError('key', 'value', 'staging');
|
|
84
84
|
const handled = (0, errors_1.handleError)(command, error);
|
|
85
|
-
(0,
|
|
85
|
+
(0, strict_1.default)(handled);
|
|
86
86
|
});
|
|
87
87
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as IntegrationsPlatform from '../../src/services/integrationsPlatform';
|
|
2
|
+
export declare function generateIntegration(overrides?: Partial<IntegrationsPlatform.Integration>): {
|
|
3
|
+
createdAt: string;
|
|
4
|
+
updatedAt: string;
|
|
5
|
+
archivedAt: string | null;
|
|
6
|
+
id: number;
|
|
7
|
+
name: string;
|
|
8
|
+
baseUrl: string | null;
|
|
9
|
+
graphRelativeUrl: string;
|
|
10
|
+
credentialAccountRelativeUrl: string;
|
|
11
|
+
webhookParsingRelativeUrl?: string | null | undefined;
|
|
12
|
+
webhookSubscriptionsRelativeUrl?: string | null | undefined;
|
|
13
|
+
webhookAcknowledgeRelativeUrl?: string | null | undefined;
|
|
14
|
+
visibility: string;
|
|
15
|
+
unitoOrganizationIds: string[];
|
|
16
|
+
ui: {
|
|
17
|
+
displayName: string;
|
|
18
|
+
logo: string | null;
|
|
19
|
+
};
|
|
20
|
+
secrets?: {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
} | undefined;
|
|
23
|
+
disabledAt?: string | null | undefined;
|
|
24
|
+
authorizations: import("@unito/integrations-platform-client/dist/src/api").Authorization[];
|
|
25
|
+
userIds: number[];
|
|
26
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateIntegration = void 0;
|
|
4
|
+
function generateIntegration(overrides = {}) {
|
|
5
|
+
return {
|
|
6
|
+
id: 1,
|
|
7
|
+
name: 'foo',
|
|
8
|
+
baseUrl: '',
|
|
9
|
+
graphRelativeUrl: '',
|
|
10
|
+
credentialAccountRelativeUrl: '',
|
|
11
|
+
visibility: 'private',
|
|
12
|
+
unitoOrganizationIds: [],
|
|
13
|
+
createdAt: '',
|
|
14
|
+
updatedAt: '',
|
|
15
|
+
archivedAt: null,
|
|
16
|
+
authorizations: [],
|
|
17
|
+
userIds: [],
|
|
18
|
+
ui: {
|
|
19
|
+
displayName: '',
|
|
20
|
+
logo: '',
|
|
21
|
+
},
|
|
22
|
+
...overrides,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.generateIntegration = generateIntegration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function uncolorize(text: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uncolorize = void 0;
|
|
4
|
+
function uncolorize(text) {
|
|
5
|
+
// eslint-disable-next-line
|
|
6
|
+
return text.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
7
|
+
}
|
|
8
|
+
exports.uncolorize = uncolorize;
|