@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,56 @@
|
|
|
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 GlobalConfiguration = tslib_1.__importStar(require("../../src/resources/globalConfiguration"));
|
|
7
|
+
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
8
|
+
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
9
|
+
const IntegrationConfiguration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
10
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
11
|
+
describe('invite', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
14
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setEnvironment');
|
|
15
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setApiKey');
|
|
16
|
+
sinon_1.default
|
|
17
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName')
|
|
18
|
+
.resolves({ name: 'integrationName', id: 'foo' });
|
|
19
|
+
sinon_1.default.stub(IntegrationsPlatform, 'inviteUserToIntegration').resolves({});
|
|
20
|
+
sinon_1.default.stub(inquirer_1.default, 'prompt').resolves({ email: 'foo@bar.com' });
|
|
21
|
+
sinon_1.default.stub(IntegrationConfiguration, 'getConfiguration').resolves({ name: 'integrationName' });
|
|
22
|
+
});
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
sinon_1.default.restore();
|
|
25
|
+
});
|
|
26
|
+
test_1.test
|
|
27
|
+
.stdout()
|
|
28
|
+
.stub(GlobalConfiguration, 'read', () => ({ email: 'foo@bar.com' }))
|
|
29
|
+
.command(['invite'])
|
|
30
|
+
.it('invites user - default', ctx => {
|
|
31
|
+
(0, test_1.expect)(ctx.stdout).to.contains('User successfully added!');
|
|
32
|
+
});
|
|
33
|
+
test_1.test
|
|
34
|
+
.stdout()
|
|
35
|
+
.stub(GlobalConfiguration, 'read', () => ({ email: 'foo@bar.com' }))
|
|
36
|
+
.command(['invite', '--environment', 'staging'])
|
|
37
|
+
.it('invites user - staging', ctx => {
|
|
38
|
+
(0, test_1.expect)(ctx.stdout).to.contains('User successfully added!');
|
|
39
|
+
});
|
|
40
|
+
test_1.test
|
|
41
|
+
.stdout()
|
|
42
|
+
.stub(GlobalConfiguration, 'read', () => ({ email: 'foo@bar.com' }))
|
|
43
|
+
.command(['invite', '--environment', 'local'])
|
|
44
|
+
.it('invites user - local', ctx => {
|
|
45
|
+
(0, test_1.expect)(ctx.stdout).to.contains('User successfully added!');
|
|
46
|
+
});
|
|
47
|
+
test_1.test
|
|
48
|
+
.stdout()
|
|
49
|
+
.stub(GlobalConfiguration, 'read', () => ({ email: 'foo@bar.com' }))
|
|
50
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
51
|
+
.command(['invite'])
|
|
52
|
+
.catch(error => {
|
|
53
|
+
(0, test_1.expect)(error.message).to.equal('EEXIT: -1');
|
|
54
|
+
})
|
|
55
|
+
.it('handles unpublished integration');
|
|
56
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
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 inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
+
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
7
|
+
const child_process_1 = tslib_1.__importDefault(require("child_process"));
|
|
8
|
+
const GlobalConfiguration = tslib_1.__importStar(require("../../src/resources/globalConfiguration"));
|
|
9
|
+
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
10
|
+
const errors_1 = require("../../src/errors");
|
|
11
|
+
describe('Login', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
const execSyncStub = sinon_1.default.stub(child_process_1.default, 'execSync');
|
|
14
|
+
execSyncStub.onCall(0).returns('1');
|
|
15
|
+
execSyncStub.onCall(1).returns('2');
|
|
16
|
+
execSyncStub.onCall(2).returns('ok');
|
|
17
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setEnvironment');
|
|
18
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setApiKey');
|
|
19
|
+
});
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
sinon_1.default.restore();
|
|
22
|
+
});
|
|
23
|
+
test_1.test
|
|
24
|
+
.stdout()
|
|
25
|
+
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
26
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ apiKey: 'foo' }))
|
|
27
|
+
.stub(IntegrationsPlatform, 'getProfile', () => ({ email: 'a@b.com' }))
|
|
28
|
+
.stub(GlobalConfiguration, 'write', () => ({}))
|
|
29
|
+
.command(['login'])
|
|
30
|
+
.it('logins to the platform - default', ctx => {
|
|
31
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Hello');
|
|
32
|
+
});
|
|
33
|
+
test_1.test
|
|
34
|
+
.stdout()
|
|
35
|
+
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
36
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ apiKey: 'foo' }))
|
|
37
|
+
.stub(IntegrationsPlatform, 'getProfile', () => ({ email: 'a@b.com' }))
|
|
38
|
+
.stub(GlobalConfiguration, 'write', () => ({}))
|
|
39
|
+
.command(['login', '--environment=local'])
|
|
40
|
+
.it('logins to the platform - local', ctx => {
|
|
41
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Hello');
|
|
42
|
+
});
|
|
43
|
+
test_1.test
|
|
44
|
+
.stdout()
|
|
45
|
+
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
46
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ apiKey: 'foo' }))
|
|
47
|
+
.stub(IntegrationsPlatform, 'getProfile', () => ({ email: 'a@b.com' }))
|
|
48
|
+
.stub(GlobalConfiguration, 'write', () => ({}))
|
|
49
|
+
.command(['login', '--environment=staging'])
|
|
50
|
+
.it('logins to the platform - staging', ctx => {
|
|
51
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Hello');
|
|
52
|
+
});
|
|
53
|
+
test_1.test
|
|
54
|
+
.stdout()
|
|
55
|
+
.stub(GlobalConfiguration, 'read', () => {
|
|
56
|
+
throw new Error('boom!');
|
|
57
|
+
})
|
|
58
|
+
.command(['login'])
|
|
59
|
+
.catch(ctx => {
|
|
60
|
+
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
61
|
+
})
|
|
62
|
+
.it('handles configuration error');
|
|
63
|
+
test_1.test
|
|
64
|
+
.stdout()
|
|
65
|
+
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
66
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.reject())
|
|
67
|
+
.command(['login'])
|
|
68
|
+
.catch(ctx => {
|
|
69
|
+
(0, test_1.expect)(ctx.name).to.equal('Error');
|
|
70
|
+
})
|
|
71
|
+
.it('handles input error');
|
|
72
|
+
test_1.test
|
|
73
|
+
.stdout()
|
|
74
|
+
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
75
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ apiKey: 'foo' }))
|
|
76
|
+
.stub(IntegrationsPlatform, 'getProfile', () => Promise.reject())
|
|
77
|
+
.command(['login'])
|
|
78
|
+
.catch(ctx => {
|
|
79
|
+
(0, test_1.expect)(ctx.name).to.equal('Error');
|
|
80
|
+
})
|
|
81
|
+
.it('handles platform error');
|
|
82
|
+
test_1.test
|
|
83
|
+
.stdout()
|
|
84
|
+
.stub(GlobalConfiguration, 'read', () => {
|
|
85
|
+
throw new errors_1.MissingEnvironmentVariableError();
|
|
86
|
+
})
|
|
87
|
+
.command(['login'])
|
|
88
|
+
.exit(-1)
|
|
89
|
+
.it('handle managed exception');
|
|
90
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
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 core_1 = require("@oclif/core");
|
|
6
|
+
const sinon = tslib_1.__importStar(require("sinon"));
|
|
7
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
|
+
const Configuration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
9
|
+
const oauth2Service = tslib_1.__importStar(require("../../src/services/oauth2Helper"));
|
|
10
|
+
const configurationTypes_1 = require("../../src/configurationTypes");
|
|
11
|
+
describe('oauth2', () => {
|
|
12
|
+
const INTEGRATION_NAME = 'myintegration';
|
|
13
|
+
const sandbox = sinon.createSandbox();
|
|
14
|
+
let getConfigurationsStub;
|
|
15
|
+
let writeConfigurationStub;
|
|
16
|
+
let writeTestAccountStub;
|
|
17
|
+
let performOAuth2FlowStub;
|
|
18
|
+
let updateTokenStub;
|
|
19
|
+
const oauth2Information = {
|
|
20
|
+
clientId: 'myClientId',
|
|
21
|
+
clientSecret: 'myClientId',
|
|
22
|
+
tokenUrl: 'myTokenurl.com',
|
|
23
|
+
authorizationUrl: 'myAuthUrl.com',
|
|
24
|
+
scopes: [{ name: '', description: '' }],
|
|
25
|
+
requestContentType: configurationTypes_1.RequestContentType.URL_ENCODED,
|
|
26
|
+
responseContentType: configurationTypes_1.RequestContentType.JSON,
|
|
27
|
+
grantType: configurationTypes_1.GrantType.AUTHORIZATION_CODE,
|
|
28
|
+
};
|
|
29
|
+
const baseConfiguration = {
|
|
30
|
+
name: INTEGRATION_NAME,
|
|
31
|
+
authorizations: [
|
|
32
|
+
{
|
|
33
|
+
name: 'development',
|
|
34
|
+
method: configurationTypes_1.Method.OAUTH2,
|
|
35
|
+
oauth2: oauth2Information,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
testAccounts: {},
|
|
39
|
+
};
|
|
40
|
+
const credentials = {
|
|
41
|
+
accessToken: 'accessToken',
|
|
42
|
+
refreshToken: 'refreshToken',
|
|
43
|
+
};
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
getConfigurationsStub = sandbox.stub(Configuration, 'getConfiguration').resolves(baseConfiguration);
|
|
46
|
+
sandbox.spy(core_1.ux.action, 'start');
|
|
47
|
+
sandbox.spy(core_1.ux.action, 'stop');
|
|
48
|
+
sandbox.stub(inquirer_1.default, 'prompt').resolves({
|
|
49
|
+
oauth2Information: JSON.stringify(oauth2Information),
|
|
50
|
+
});
|
|
51
|
+
writeConfigurationStub = sandbox.stub(Configuration, 'writeConfiguration');
|
|
52
|
+
writeTestAccountStub = sandbox.stub(Configuration, 'writeTestAccount');
|
|
53
|
+
performOAuth2FlowStub = sandbox.stub(oauth2Service, 'performOAuth2Flow');
|
|
54
|
+
performOAuth2FlowStub.resolves(credentials);
|
|
55
|
+
updateTokenStub = sandbox.stub(oauth2Service, 'updateToken').resolves(credentials);
|
|
56
|
+
});
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
sandbox.restore();
|
|
59
|
+
});
|
|
60
|
+
test_1.test
|
|
61
|
+
.stdout()
|
|
62
|
+
.do(() => getConfigurationsStub.returns({
|
|
63
|
+
...baseConfiguration,
|
|
64
|
+
authorizations: [],
|
|
65
|
+
}))
|
|
66
|
+
.command(['oauth2', '--accountName', 'development'])
|
|
67
|
+
.it("asks for authentication information when it's not setup in the configuration file", () => {
|
|
68
|
+
(0, test_1.expect)(writeConfigurationStub.getCall(0)?.firstArg).to.deep.equal({
|
|
69
|
+
...baseConfiguration,
|
|
70
|
+
authorizations: [{ oauth2: oauth2Information, name: 'development', method: 'oauth2', development: true }],
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
test_1.test
|
|
74
|
+
.stdout()
|
|
75
|
+
.command(['oauth2', '--accountName', 'development'])
|
|
76
|
+
.it('performs the oauth flow when there is no test accounts and the auth information are setup', () => {
|
|
77
|
+
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(1);
|
|
78
|
+
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(0);
|
|
79
|
+
(0, test_1.expect)(writeTestAccountStub.getCall(0).args).to.deep.equal([baseConfiguration, credentials, 'development']);
|
|
80
|
+
});
|
|
81
|
+
test_1.test
|
|
82
|
+
.stdout()
|
|
83
|
+
.do(() => getConfigurationsStub.returns({
|
|
84
|
+
...baseConfiguration,
|
|
85
|
+
testAccounts: {
|
|
86
|
+
development: credentials,
|
|
87
|
+
},
|
|
88
|
+
}))
|
|
89
|
+
.command(['oauth2', '--accountName', 'development'])
|
|
90
|
+
.it('refresh the token when there is an existing test accounts and the auth information are setup', () => {
|
|
91
|
+
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(0);
|
|
92
|
+
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(1);
|
|
93
|
+
(0, test_1.expect)(writeTestAccountStub.getCall(0).args).to.deep.equal([
|
|
94
|
+
{
|
|
95
|
+
...baseConfiguration,
|
|
96
|
+
testAccounts: {
|
|
97
|
+
development: credentials,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
credentials,
|
|
101
|
+
'development',
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|