@unito/integration-cli 1.3.4 → 1.4.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/boilerplate/package-lock.json +6 -6
- package/dist/schemas/configuration.json +3 -15
- package/dist/src/commands/dev.d.ts +0 -1
- package/dist/src/commands/dev.js +9 -17
- package/dist/src/commands/graph.d.ts +0 -1
- package/dist/src/commands/graph.js +9 -17
- package/dist/src/commands/oauth2.d.ts +0 -1
- package/dist/src/commands/oauth2.js +10 -31
- package/dist/src/commands/schema-snapshot.js +3 -8
- package/dist/src/commands/test.js +9 -17
- package/dist/src/configurationTypes.d.ts +3 -14
- package/dist/src/resources/configuration.d.ts +1 -5
- package/dist/src/resources/configuration.js +11 -28
- package/dist/test/commands/dev.test.js +4 -6
- package/dist/test/commands/graph.test.js +1 -3
- package/dist/test/commands/oauth2.test.js +27 -55
- package/dist/test/commands/test.test.js +5 -18
- package/dist/test/resources/configuration.test.js +28 -80
- package/dist/test/resources/decryption.test.js +3 -8
- package/oclif.manifest.json +4 -60
- package/package.json +2 -2
|
@@ -1503,9 +1503,9 @@
|
|
|
1503
1503
|
}
|
|
1504
1504
|
},
|
|
1505
1505
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
|
1506
|
-
"version": "5.0.
|
|
1507
|
-
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.
|
|
1508
|
-
"integrity": "sha512-
|
|
1506
|
+
"version": "5.0.6",
|
|
1507
|
+
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
|
1508
|
+
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
|
1509
1509
|
"dev": true,
|
|
1510
1510
|
"license": "MIT",
|
|
1511
1511
|
"dependencies": {
|
|
@@ -3280,9 +3280,9 @@
|
|
|
3280
3280
|
}
|
|
3281
3281
|
},
|
|
3282
3282
|
"node_modules/qs": {
|
|
3283
|
-
"version": "6.15.
|
|
3284
|
-
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.
|
|
3285
|
-
"integrity": "sha512-
|
|
3283
|
+
"version": "6.15.2",
|
|
3284
|
+
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
|
|
3285
|
+
"integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
|
|
3286
3286
|
"license": "BSD-3-Clause",
|
|
3287
3287
|
"dependencies": {
|
|
3288
3288
|
"side-channel": "^1.1.0"
|
|
@@ -60,22 +60,10 @@
|
|
|
60
60
|
"$ref": "https://unito.io/integration_cli/authorization.schema.json"
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
"
|
|
63
|
+
"testAccount": {
|
|
64
64
|
"type": "object",
|
|
65
|
-
"description": "The test
|
|
66
|
-
"additionalProperties":
|
|
67
|
-
"properties": {
|
|
68
|
-
"development": {
|
|
69
|
-
"type": "object",
|
|
70
|
-
"description": "Test account for local development",
|
|
71
|
-
"additionalProperties": true
|
|
72
|
-
},
|
|
73
|
-
"compliance": {
|
|
74
|
-
"type": "object",
|
|
75
|
-
"description": "Test account for compliance tests",
|
|
76
|
-
"additionalProperties": true
|
|
77
|
-
}
|
|
78
|
-
}
|
|
65
|
+
"description": "The test account of the integration",
|
|
66
|
+
"additionalProperties": true
|
|
79
67
|
},
|
|
80
68
|
"secrets": {
|
|
81
69
|
"type": "object",
|
|
@@ -9,7 +9,6 @@ export default class Dev extends BaseCommand<typeof Dev> {
|
|
|
9
9
|
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
10
|
'credential-payload': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
11
|
'credential-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
-
'test-account': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
12
|
'read-only': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
13
|
timeout: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
14
|
crawlMode: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
package/dist/src/commands/dev.js
CHANGED
|
@@ -39,11 +39,6 @@ class Dev extends baseCommand_1.BaseCommand {
|
|
|
39
39
|
description: '(advanced) credential to use.',
|
|
40
40
|
exclusive: ['credential-payload'],
|
|
41
41
|
}),
|
|
42
|
-
'test-account': core_1.Flags.string({
|
|
43
|
-
description: 'test account to use.',
|
|
44
|
-
options: Object.values(configuration_1.CredentialScope),
|
|
45
|
-
default: configuration_1.CredentialScope.DEVELOPMENT,
|
|
46
|
-
}),
|
|
47
42
|
'read-only': core_1.Flags.boolean({
|
|
48
43
|
description: 'whether or not to only perform read operations',
|
|
49
44
|
allowNo: true,
|
|
@@ -112,19 +107,16 @@ class Dev extends baseCommand_1.BaseCommand {
|
|
|
112
107
|
else if (flags['credential-payload']) {
|
|
113
108
|
credentialPayload = flags['credential-payload'];
|
|
114
109
|
}
|
|
115
|
-
else {
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
if (decryptedEntries.failed.length) {
|
|
120
|
-
throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
|
|
121
|
-
}
|
|
122
|
-
credentialPayload = JSON.stringify({
|
|
123
|
-
...decryptedEntries.successful,
|
|
124
|
-
unitoCredentialId: flags['test-account'],
|
|
125
|
-
unitoUserId: flags['test-account'],
|
|
126
|
-
});
|
|
110
|
+
else if (configuration.testAccount && Object.keys(configuration.testAccount).length) {
|
|
111
|
+
const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.testAccount);
|
|
112
|
+
if (decryptedEntries.failed.length) {
|
|
113
|
+
throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
|
|
127
114
|
}
|
|
115
|
+
credentialPayload = JSON.stringify({
|
|
116
|
+
...decryptedEntries.successful,
|
|
117
|
+
unitoCredentialId: 'testAccount',
|
|
118
|
+
unitoUserId: 'testAccount',
|
|
119
|
+
});
|
|
128
120
|
}
|
|
129
121
|
// Load secrets.
|
|
130
122
|
const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.secrets ?? {});
|
|
@@ -11,7 +11,6 @@ export default class Graph extends BaseCommand<typeof Graph> {
|
|
|
11
11
|
path: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
12
|
port: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
13
|
environment: import("@oclif/core/lib/interfaces").OptionFlag<GlobalConfiguration.Environment, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
-
'test-account': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
14
|
'credential-payload': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
15
|
'credential-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
17
16
|
'config-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -57,11 +57,6 @@ class Graph extends baseCommand_1.BaseCommand {
|
|
|
57
57
|
options: Object.values(GlobalConfiguration.Environment),
|
|
58
58
|
default: GlobalConfiguration.Environment.Production,
|
|
59
59
|
})(),
|
|
60
|
-
'test-account': core_1.Flags.string({
|
|
61
|
-
description: 'test account to use',
|
|
62
|
-
options: Object.values(configuration_1.CredentialScope),
|
|
63
|
-
default: configuration_1.CredentialScope.DEVELOPMENT,
|
|
64
|
-
}),
|
|
65
60
|
'credential-payload': core_1.Flags.string({
|
|
66
61
|
description: '(advanced) credential payload to use.',
|
|
67
62
|
exclusive: ['credential-id'],
|
|
@@ -125,19 +120,16 @@ class Graph extends baseCommand_1.BaseCommand {
|
|
|
125
120
|
else if (flags['credential-payload']) {
|
|
126
121
|
credentialPayload = flags['credential-payload'];
|
|
127
122
|
}
|
|
128
|
-
else {
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
if (decryptedEntries.failed.length) {
|
|
133
|
-
throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
|
|
134
|
-
}
|
|
135
|
-
credentialPayload = JSON.stringify({
|
|
136
|
-
...decryptedEntries.successful,
|
|
137
|
-
unitoCredentialId: flags['test-account'],
|
|
138
|
-
unitoUserId: flags['test-account'],
|
|
139
|
-
});
|
|
123
|
+
else if (configuration.testAccount && Object.keys(configuration.testAccount).length) {
|
|
124
|
+
const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.testAccount);
|
|
125
|
+
if (decryptedEntries.failed.length) {
|
|
126
|
+
throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
|
|
140
127
|
}
|
|
128
|
+
credentialPayload = JSON.stringify({
|
|
129
|
+
...decryptedEntries.successful,
|
|
130
|
+
unitoCredentialId: 'testAccount',
|
|
131
|
+
unitoUserId: 'testAccount',
|
|
132
|
+
});
|
|
141
133
|
}
|
|
142
134
|
// Load secrets — identical to dev.ts
|
|
143
135
|
const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.secrets ?? {});
|
|
@@ -5,7 +5,6 @@ export default class Oauth2 extends Command {
|
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
7
7
|
static flags: {
|
|
8
|
-
'test-account': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
9
8
|
environment: import("@oclif/core/lib/interfaces").OptionFlag<Environment, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
10
9
|
reauth: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
10
|
'config-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -11,21 +11,13 @@ const errors_1 = require("../errors");
|
|
|
11
11
|
const globalConfiguration_1 = require("../resources/globalConfiguration");
|
|
12
12
|
const decryption_1 = require("../resources/decryption");
|
|
13
13
|
class Oauth2 extends core_1.Command {
|
|
14
|
-
static summary = `Perform an OAuth2 workflow to either populate or refresh
|
|
15
|
-
static description = `The Oauth2 command allows you to perform an OAuth2 workflow to populate the
|
|
14
|
+
static summary = `Perform an OAuth2 workflow to either populate or refresh the test account's credentials.`;
|
|
15
|
+
static description = `The Oauth2 command allows you to perform an OAuth2 workflow to populate the test account's accessToken and refreshToken to be used by the 'test' and 'dev' commands.
|
|
16
16
|
|
|
17
|
-
If the test
|
|
17
|
+
If the test account is already populated, the command will refresh the credentials if the refresh token is available.
|
|
18
18
|
If you want to force a new OAuth2 flow to change the connected account or something else, use the --reauth flag.`;
|
|
19
|
-
static examples = [
|
|
20
|
-
'<%= config.bin %> <%= command.id %>',
|
|
21
|
-
'<%= config.bin %> <%= command.id %> --reauth --test-account=compliance',
|
|
22
|
-
];
|
|
19
|
+
static examples = ['<%= config.bin %> <%= command.id %>', '<%= config.bin %> <%= command.id %> --reauth'];
|
|
23
20
|
static flags = {
|
|
24
|
-
'test-account': core_1.Flags.string({
|
|
25
|
-
description: 'Test account to use.',
|
|
26
|
-
options: Object.values(configuration_1.CredentialScope),
|
|
27
|
-
default: configuration_1.CredentialScope.DEVELOPMENT,
|
|
28
|
-
}),
|
|
29
21
|
environment: core_1.Flags.custom({
|
|
30
22
|
description: 'the environment of the platform',
|
|
31
23
|
options: Object.values(globalConfiguration_1.Environment),
|
|
@@ -73,24 +65,14 @@ class Oauth2 extends core_1.Command {
|
|
|
73
65
|
throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
|
|
74
66
|
}
|
|
75
67
|
oauth2 = decryptedEntries.successful;
|
|
76
|
-
const
|
|
77
|
-
const testAccountCredentials = configuration.testAccounts?.[testAccount];
|
|
78
|
-
const testAccountsToRefresh = new Set([testAccount]);
|
|
79
|
-
// Figure out if we want to refresh other test account at the same time (like if they currently have the same values)
|
|
80
|
-
for (const [account, accountCredentials] of Object.entries(configuration.testAccounts ?? {})) {
|
|
81
|
-
if (!testAccountsToRefresh.has(account) &&
|
|
82
|
-
accountCredentials?.accessToken === testAccountCredentials?.accessToken &&
|
|
83
|
-
accountCredentials?.refreshToken === testAccountCredentials?.refreshToken) {
|
|
84
|
-
testAccountsToRefresh.add(account);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
68
|
+
const testAccountCredentials = configuration.testAccount;
|
|
87
69
|
let decryptionResult;
|
|
88
70
|
if (testAccountCredentials) {
|
|
89
71
|
decryptionResult = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, testAccountCredentials);
|
|
90
72
|
}
|
|
91
73
|
let credentials;
|
|
92
74
|
if (!testAccountCredentials?.accessToken || flags.reauth) {
|
|
93
|
-
core_1.ux.log(`Starting OAuth2 flow for test account
|
|
75
|
+
core_1.ux.log(`Starting OAuth2 flow for test account`);
|
|
94
76
|
credentials = await Oauth2Resource.performOAuth2Flow(oauth2, environment, testAccountCredentials);
|
|
95
77
|
core_1.ux.log(`OAuth2 flow... Done`);
|
|
96
78
|
}
|
|
@@ -100,7 +82,7 @@ class Oauth2 extends core_1.Command {
|
|
|
100
82
|
return;
|
|
101
83
|
}
|
|
102
84
|
const refreshToken = decryptionResult?.successful.refreshToken;
|
|
103
|
-
core_1.ux.action.start(`Refreshing test account
|
|
85
|
+
core_1.ux.action.start(`Refreshing test account`, undefined, { stdout: true });
|
|
104
86
|
credentials = await Oauth2Resource.updateToken(oauth2, refreshToken, decryptionResult?.successful, environment);
|
|
105
87
|
// If provider response doesn't contain a new refresh token, use the existing one
|
|
106
88
|
credentials.refreshToken = credentials.refreshToken ?? refreshToken;
|
|
@@ -111,12 +93,9 @@ class Oauth2 extends core_1.Command {
|
|
|
111
93
|
if (credentials.refreshToken) {
|
|
112
94
|
credentials.refreshToken = (await IntegrationsPlatform.encryptData(configuration.name, credentials.refreshToken, false)).encryptedData;
|
|
113
95
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
await (0, configuration_1.writeTestAccount)(configuration, environment, customConfigPath, credentials, account);
|
|
118
|
-
core_1.ux.action.stop();
|
|
119
|
-
}
|
|
96
|
+
core_1.ux.action.start(`Saving credentials for test account`, undefined, { stdout: true });
|
|
97
|
+
await (0, configuration_1.writeTestAccount)(configuration, environment, customConfigPath, credentials);
|
|
98
|
+
core_1.ux.action.stop();
|
|
120
99
|
}
|
|
121
100
|
}
|
|
122
101
|
exports.default = Oauth2;
|
|
@@ -35,10 +35,6 @@ class SchemaSnapshot extends baseCommand_1.BaseCommand {
|
|
|
35
35
|
options: Object.values(GlobalConfiguration.Environment),
|
|
36
36
|
default: GlobalConfiguration.Environment.Production,
|
|
37
37
|
})(),
|
|
38
|
-
'test-account': core_1.Flags.string({
|
|
39
|
-
description: 'test account to use',
|
|
40
|
-
default: configuration_1.CredentialScope.DEVELOPMENT,
|
|
41
|
-
}),
|
|
42
38
|
'config-path': core_1.Flags.string({
|
|
43
39
|
description: 'relative path to a custom ".unito.json" file',
|
|
44
40
|
}),
|
|
@@ -75,16 +71,15 @@ class SchemaSnapshot extends baseCommand_1.BaseCommand {
|
|
|
75
71
|
core_1.ux.action.stop();
|
|
76
72
|
}
|
|
77
73
|
// Resolve credentials.
|
|
78
|
-
const
|
|
79
|
-
const credentials = config.testAccounts?.[testAccount] || {};
|
|
74
|
+
const credentials = config.testAccount ?? {};
|
|
80
75
|
const decryptedCreds = await (0, decryption_1.decryptEntries)(config.name, environment, this.config.configDir, credentials);
|
|
81
76
|
if (decryptedCreds.failed.length) {
|
|
82
77
|
throw new errors_1.EntryDecryptionError(decryptedCreds.failed.at(0), environment);
|
|
83
78
|
}
|
|
84
79
|
const credentialPayload = {
|
|
85
80
|
...decryptedCreds.successful,
|
|
86
|
-
unitoCredentialId:
|
|
87
|
-
unitoUserId:
|
|
81
|
+
unitoCredentialId: 'testAccount',
|
|
82
|
+
unitoUserId: 'testAccount',
|
|
88
83
|
};
|
|
89
84
|
// Load secrets.
|
|
90
85
|
const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(config.name, environment, this.config.configDir, config.secrets ?? {});
|
|
@@ -45,11 +45,6 @@ class Test extends baseCommand_1.BaseCommand {
|
|
|
45
45
|
description: '(advanced) credential to use.',
|
|
46
46
|
exclusive: ['credential-payload'],
|
|
47
47
|
}),
|
|
48
|
-
'test-account': core_1.Flags.string({
|
|
49
|
-
description: 'test account to use.',
|
|
50
|
-
options: Object.values(configuration_1.CredentialScope),
|
|
51
|
-
default: configuration_1.CredentialScope.DEVELOPMENT,
|
|
52
|
-
}),
|
|
53
48
|
'read-only': core_1.Flags.boolean({
|
|
54
49
|
description: 'whether or not to only perform read operations',
|
|
55
50
|
allowNo: true,
|
|
@@ -130,19 +125,16 @@ class Test extends baseCommand_1.BaseCommand {
|
|
|
130
125
|
else if (flags['credential-payload']) {
|
|
131
126
|
credentialPayload = flags['credential-payload'];
|
|
132
127
|
}
|
|
133
|
-
else {
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
if (decryptedEntries.failed.length) {
|
|
138
|
-
throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
|
|
139
|
-
}
|
|
140
|
-
credentialPayload = JSON.stringify({
|
|
141
|
-
...decryptedEntries.successful,
|
|
142
|
-
unitoCredentialId: flags['test-account'],
|
|
143
|
-
unitoUserId: flags['test-account'],
|
|
144
|
-
});
|
|
128
|
+
else if (configuration.testAccount && Object.keys(configuration.testAccount).length) {
|
|
129
|
+
const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.testAccount);
|
|
130
|
+
if (decryptedEntries.failed.length) {
|
|
131
|
+
throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), environment);
|
|
145
132
|
}
|
|
133
|
+
credentialPayload = JSON.stringify({
|
|
134
|
+
...decryptedEntries.successful,
|
|
135
|
+
unitoCredentialId: 'testAccount',
|
|
136
|
+
unitoUserId: 'testAccount',
|
|
137
|
+
});
|
|
146
138
|
}
|
|
147
139
|
// Load secrets.
|
|
148
140
|
const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.secrets ?? {});
|
|
@@ -53,21 +53,10 @@ export interface Configuration {
|
|
|
53
53
|
*/
|
|
54
54
|
authorizations?: Authorization[];
|
|
55
55
|
/**
|
|
56
|
-
* The test
|
|
56
|
+
* The test account of the integration
|
|
57
57
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* Test account for local development
|
|
61
|
-
*/
|
|
62
|
-
development?: {
|
|
63
|
-
[k: string]: unknown;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Test account for compliance tests
|
|
67
|
-
*/
|
|
68
|
-
compliance?: {
|
|
69
|
-
[k: string]: unknown;
|
|
70
|
-
};
|
|
58
|
+
testAccount?: {
|
|
59
|
+
[k: string]: unknown;
|
|
71
60
|
};
|
|
72
61
|
/**
|
|
73
62
|
* The secrets of the integration
|
|
@@ -5,10 +5,6 @@ export declare enum CrawlMode {
|
|
|
5
5
|
SAMPLE = "sample",
|
|
6
6
|
SINGLE = "single"
|
|
7
7
|
}
|
|
8
|
-
export declare enum CredentialScope {
|
|
9
|
-
DEVELOPMENT = "development",
|
|
10
|
-
COMPLIANCE = "compliance"
|
|
11
|
-
}
|
|
12
8
|
export declare const DEFAULT_CONFIGURATION_NAME: string;
|
|
13
9
|
export declare const ENCRYPTION_PREFIX = "unito-secret-v1://";
|
|
14
10
|
/**
|
|
@@ -27,4 +23,4 @@ export declare function writeConfiguration(configuration: Configuration, environ
|
|
|
27
23
|
export declare function writeTestAccount(configuration: Configuration, environment: Environment | undefined, customConfigPath: string | undefined, account: {
|
|
28
24
|
accessToken: string;
|
|
29
25
|
refreshToken?: string;
|
|
30
|
-
}
|
|
26
|
+
}): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENCRYPTION_PREFIX = exports.DEFAULT_CONFIGURATION_NAME = exports.
|
|
3
|
+
exports.ENCRYPTION_PREFIX = exports.DEFAULT_CONFIGURATION_NAME = exports.CrawlMode = void 0;
|
|
4
4
|
exports.getConfigurationPath = getConfigurationPath;
|
|
5
5
|
exports.getConfiguration = getConfiguration;
|
|
6
6
|
exports.writeConfiguration = writeConfiguration;
|
|
@@ -20,11 +20,6 @@ var CrawlMode;
|
|
|
20
20
|
CrawlMode["SAMPLE"] = "sample";
|
|
21
21
|
CrawlMode["SINGLE"] = "single";
|
|
22
22
|
})(CrawlMode || (exports.CrawlMode = CrawlMode = {}));
|
|
23
|
-
var CredentialScope;
|
|
24
|
-
(function (CredentialScope) {
|
|
25
|
-
CredentialScope["DEVELOPMENT"] = "development";
|
|
26
|
-
CredentialScope["COMPLIANCE"] = "compliance";
|
|
27
|
-
})(CredentialScope || (exports.CredentialScope = CredentialScope = {}));
|
|
28
23
|
exports.DEFAULT_CONFIGURATION_NAME = '.unito.json';
|
|
29
24
|
exports.ENCRYPTION_PREFIX = 'unito-secret-v1://';
|
|
30
25
|
/**
|
|
@@ -63,12 +58,7 @@ async function getConfiguration(environment, customConfigPath) {
|
|
|
63
58
|
throw new errors_1.ConfigurationMalformed();
|
|
64
59
|
}
|
|
65
60
|
// Initialize the required structure in the configuration.
|
|
66
|
-
|
|
67
|
-
configuration.testAccounts = { development: {} };
|
|
68
|
-
}
|
|
69
|
-
if (!configuration.testAccounts.development) {
|
|
70
|
-
configuration.testAccounts.development = {};
|
|
71
|
-
}
|
|
61
|
+
configuration.testAccount ??= {};
|
|
72
62
|
for (const authorization of configuration.authorizations ?? []) {
|
|
73
63
|
if (authorization.oauth2) {
|
|
74
64
|
if (!authorization.oauth2.grantType) {
|
|
@@ -96,13 +86,8 @@ async function writeConfiguration(configuration, environment = globalConfigurati
|
|
|
96
86
|
: getConfigurationPath(environment);
|
|
97
87
|
await fs.promises.writeFile(configurationPath, JSON.stringify(configuration, null, 2));
|
|
98
88
|
}
|
|
99
|
-
async function writeTestAccount(configuration, environment = globalConfiguration_1.Environment.Production, customConfigPath, account
|
|
100
|
-
|
|
101
|
-
if (accountName !== 'development' && accountName !== 'compliance') {
|
|
102
|
-
throw new Error('Invalid account name');
|
|
103
|
-
}
|
|
104
|
-
configuration.testAccounts ??= {};
|
|
105
|
-
configuration.testAccounts[accountName] = { ...configuration.testAccounts[accountName], ...account };
|
|
89
|
+
async function writeTestAccount(configuration, environment = globalConfiguration_1.Environment.Production, customConfigPath, account) {
|
|
90
|
+
configuration.testAccount = { ...configuration.testAccount, ...account };
|
|
106
91
|
await writeConfiguration(configuration, environment, customConfigPath);
|
|
107
92
|
}
|
|
108
93
|
async function validateConfiguration(configuration) {
|
|
@@ -124,22 +109,20 @@ async function validateConfiguration(configuration) {
|
|
|
124
109
|
if (validate.errors) {
|
|
125
110
|
throw new errors_1.ConfigurationInvalid('Your configuration file is invalid!', validate.errors, (0, better_ajv_errors_1.default)(schema, configuration, validate.errors, { indent: 2 }));
|
|
126
111
|
}
|
|
127
|
-
// Validate test
|
|
128
|
-
if (configuration.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
}
|
|
112
|
+
// Validate the test account.
|
|
113
|
+
if (configuration.testAccount &&
|
|
114
|
+
Object.keys(configuration.testAccount).length &&
|
|
115
|
+
configuration.authorizations?.length) {
|
|
116
|
+
validateTestAccount(configuration.testAccount, configuration.authorizations, spec);
|
|
134
117
|
}
|
|
135
118
|
}
|
|
136
|
-
function validateTestAccount(
|
|
119
|
+
function validateTestAccount(credential, authorizationDefinitions, spec) {
|
|
137
120
|
const authorizationSchemas = authorizationDefinitions.map(constructAuthorizationSchema);
|
|
138
121
|
const schema = { anyOf: authorizationSchemas };
|
|
139
122
|
const validate = spec.compile(schema);
|
|
140
123
|
validate(credential);
|
|
141
124
|
if (validate.errors) {
|
|
142
|
-
throw new errors_1.ConfigurationInvalid(`Your testAccount
|
|
125
|
+
throw new errors_1.ConfigurationInvalid(`Your testAccount is invalid!`, validate.errors, (0, better_ajv_errors_1.default)(schema, credential, validate.errors, { indent: 2 }));
|
|
143
126
|
}
|
|
144
127
|
}
|
|
145
128
|
function constructAuthorizationSchema(authorizationDefinition) {
|
|
@@ -26,11 +26,9 @@ describe('Dev', () => {
|
|
|
26
26
|
secrets: {
|
|
27
27
|
secret: 'encryptedSecret',
|
|
28
28
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
encryptedToken: `${ConfigurationResource.ENCRYPTION_PREFIX}decrypt-me`,
|
|
33
|
-
},
|
|
29
|
+
testAccount: {
|
|
30
|
+
key: 'value',
|
|
31
|
+
encryptedToken: `${ConfigurationResource.ENCRYPTION_PREFIX}decrypt-me`,
|
|
34
32
|
},
|
|
35
33
|
};
|
|
36
34
|
let execSyncStub;
|
|
@@ -62,7 +60,7 @@ describe('Dev', () => {
|
|
|
62
60
|
.stub(ConfigurationResource, 'getConfiguration', stub => stub.returns(cliConfiguration))
|
|
63
61
|
.command(['dev'])
|
|
64
62
|
.it('decrypts credentials', () => {
|
|
65
|
-
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"key":"value","encryptedToken":"decrypted-me","unitoCredentialId":"
|
|
63
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"key":"value","encryptedToken":"decrypted-me","unitoCredentialId":"testAccount","unitoUserId":"testAccount"}');
|
|
66
64
|
});
|
|
67
65
|
test_1.test
|
|
68
66
|
.stdout()
|
|
@@ -11,9 +11,7 @@ const Integrations = tslib_1.__importStar(require("../../src/resources/integrati
|
|
|
11
11
|
const originalReadFile = fs_1.default.promises.readFile.bind(fs_1.default.promises);
|
|
12
12
|
const MOCK_CONFIG = {
|
|
13
13
|
name: 'salesforce-v2',
|
|
14
|
-
|
|
15
|
-
development: { token: 'test-token' },
|
|
16
|
-
},
|
|
14
|
+
testAccount: { token: 'test-token' },
|
|
17
15
|
secrets: {},
|
|
18
16
|
};
|
|
19
17
|
const MOCK_RESPONSE = {
|
|
@@ -35,7 +35,6 @@ describe('oauth2', () => {
|
|
|
35
35
|
oauth2: oauth2Information,
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
|
-
testAccounts: {},
|
|
39
38
|
};
|
|
40
39
|
const credentials = {
|
|
41
40
|
accessToken: 'accessToken',
|
|
@@ -62,7 +61,7 @@ describe('oauth2', () => {
|
|
|
62
61
|
...baseConfiguration,
|
|
63
62
|
authorizations: [],
|
|
64
63
|
}))
|
|
65
|
-
.command(['oauth2'
|
|
64
|
+
.command(['oauth2'])
|
|
66
65
|
.exit(-1)
|
|
67
66
|
.it("Errors out if no oauth2 authorization scheme is found in the integration's configuration");
|
|
68
67
|
test_1.test
|
|
@@ -88,7 +87,7 @@ describe('oauth2', () => {
|
|
|
88
87
|
.resolves({ encryptedData: `${Configuration.ENCRYPTION_PREFIX}encryptedRefreshToken` });
|
|
89
88
|
})
|
|
90
89
|
.stub(DecryptionResource, 'decryptEntries', stub => stub.resolves({ successful: { ...oauth2Information, clientId: 'devClientID' }, failed: [] }))
|
|
91
|
-
.command(['oauth2'
|
|
90
|
+
.command(['oauth2'])
|
|
92
91
|
.it('prioritize development authorization', () => {
|
|
93
92
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(1);
|
|
94
93
|
(0, test_1.expect)(performOAuth2FlowStub.getCall(0).args).to.deep.equal([
|
|
@@ -113,7 +112,6 @@ describe('oauth2', () => {
|
|
|
113
112
|
'production',
|
|
114
113
|
undefined,
|
|
115
114
|
credentials,
|
|
116
|
-
'development',
|
|
117
115
|
]);
|
|
118
116
|
});
|
|
119
117
|
test_1.test
|
|
@@ -121,9 +119,7 @@ describe('oauth2', () => {
|
|
|
121
119
|
.do(() => {
|
|
122
120
|
getConfigurationsStub.returns({
|
|
123
121
|
...baseConfiguration,
|
|
124
|
-
|
|
125
|
-
development: credentials,
|
|
126
|
-
},
|
|
122
|
+
testAccount: credentials,
|
|
127
123
|
});
|
|
128
124
|
sinon
|
|
129
125
|
.stub(IntegrationsPlatform, 'encryptData')
|
|
@@ -133,21 +129,18 @@ describe('oauth2', () => {
|
|
|
133
129
|
.resolves({ encryptedData: `${Configuration.ENCRYPTION_PREFIX}encryptedRefreshToken` });
|
|
134
130
|
})
|
|
135
131
|
.stub(DecryptionResource, 'decryptEntries', stub => stub.resolves({ successful: { ...oauth2Information }, failed: [] }))
|
|
136
|
-
.command(['oauth2', '--
|
|
137
|
-
.it('performs the oauth flow when there is a test
|
|
132
|
+
.command(['oauth2', '--reauth'])
|
|
133
|
+
.it('performs the oauth flow when there is a test account, the auth information are setup and --reauth flag is present', () => {
|
|
138
134
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(1);
|
|
139
135
|
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(0);
|
|
140
136
|
(0, test_1.expect)(writeTestAccountStub.getCall(0).args).to.deep.equal([
|
|
141
137
|
{
|
|
142
138
|
...baseConfiguration,
|
|
143
|
-
|
|
144
|
-
development: credentials,
|
|
145
|
-
},
|
|
139
|
+
testAccount: credentials,
|
|
146
140
|
},
|
|
147
141
|
'production',
|
|
148
142
|
undefined,
|
|
149
143
|
credentials,
|
|
150
|
-
'development',
|
|
151
144
|
]);
|
|
152
145
|
});
|
|
153
146
|
test_1.test
|
|
@@ -155,9 +148,7 @@ describe('oauth2', () => {
|
|
|
155
148
|
.do(() => {
|
|
156
149
|
getConfigurationsStub.returns({
|
|
157
150
|
...baseConfiguration,
|
|
158
|
-
|
|
159
|
-
development: { something: 'something' },
|
|
160
|
-
},
|
|
151
|
+
testAccount: {},
|
|
161
152
|
});
|
|
162
153
|
sinon
|
|
163
154
|
.stub(IntegrationsPlatform, 'encryptData')
|
|
@@ -167,21 +158,18 @@ describe('oauth2', () => {
|
|
|
167
158
|
.resolves({ encryptedData: `${Configuration.ENCRYPTION_PREFIX}encryptedRefreshToken` });
|
|
168
159
|
})
|
|
169
160
|
.stub(DecryptionResource, 'decryptEntries', stub => stub.resolves({ successful: { ...oauth2Information }, failed: [] }))
|
|
170
|
-
.command(['oauth2'
|
|
171
|
-
.it('performs the oauth flow when the
|
|
161
|
+
.command(['oauth2'])
|
|
162
|
+
.it('performs the oauth flow when the test account is not setup', () => {
|
|
172
163
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(1);
|
|
173
164
|
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(0);
|
|
174
165
|
(0, test_1.expect)(writeTestAccountStub.getCall(0).args).to.deep.equal([
|
|
175
166
|
{
|
|
176
167
|
...baseConfiguration,
|
|
177
|
-
|
|
178
|
-
development: { something: 'something' },
|
|
179
|
-
},
|
|
168
|
+
testAccount: {},
|
|
180
169
|
},
|
|
181
170
|
'production',
|
|
182
171
|
undefined,
|
|
183
172
|
credentials,
|
|
184
|
-
'compliance',
|
|
185
173
|
]);
|
|
186
174
|
});
|
|
187
175
|
test_1.test
|
|
@@ -189,9 +177,7 @@ describe('oauth2', () => {
|
|
|
189
177
|
.do(() => {
|
|
190
178
|
getConfigurationsStub.returns({
|
|
191
179
|
...baseConfiguration,
|
|
192
|
-
|
|
193
|
-
development: credentials,
|
|
194
|
-
},
|
|
180
|
+
testAccount: credentials,
|
|
195
181
|
});
|
|
196
182
|
sinon
|
|
197
183
|
.stub(IntegrationsPlatform, 'encryptData')
|
|
@@ -201,21 +187,18 @@ describe('oauth2', () => {
|
|
|
201
187
|
.resolves({ encryptedData: `${Configuration.ENCRYPTION_PREFIX}encryptedRefreshToken` });
|
|
202
188
|
})
|
|
203
189
|
.stub(DecryptionResource, 'decryptEntries', stub => stub.resolves({ successful: { ...oauth2Information }, failed: [] }))
|
|
204
|
-
.command(['oauth2'
|
|
205
|
-
.it('refresh the token when there is an existing test
|
|
190
|
+
.command(['oauth2'])
|
|
191
|
+
.it('refresh the token when there is an existing test account and the auth information are setup', () => {
|
|
206
192
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(0);
|
|
207
193
|
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(1);
|
|
208
194
|
(0, test_1.expect)(writeTestAccountStub.getCall(0).args).to.deep.equal([
|
|
209
195
|
{
|
|
210
196
|
...baseConfiguration,
|
|
211
|
-
|
|
212
|
-
development: credentials,
|
|
213
|
-
},
|
|
197
|
+
testAccount: credentials,
|
|
214
198
|
},
|
|
215
199
|
'production',
|
|
216
200
|
undefined,
|
|
217
201
|
credentials,
|
|
218
|
-
'development',
|
|
219
202
|
]);
|
|
220
203
|
});
|
|
221
204
|
test_1.test
|
|
@@ -230,11 +213,9 @@ describe('oauth2', () => {
|
|
|
230
213
|
oauth2: { ...oauth2Information, clientSecret: `${Configuration.ENCRYPTION_PREFIX}devClientID` },
|
|
231
214
|
},
|
|
232
215
|
],
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
refreshToken: `${Configuration.ENCRYPTION_PREFIX}devRefreshToken`,
|
|
237
|
-
},
|
|
216
|
+
testAccount: {
|
|
217
|
+
accessToken: `${Configuration.ENCRYPTION_PREFIX}devAccessToken`,
|
|
218
|
+
refreshToken: `${Configuration.ENCRYPTION_PREFIX}devRefreshToken`,
|
|
238
219
|
},
|
|
239
220
|
});
|
|
240
221
|
sinon
|
|
@@ -256,8 +237,8 @@ describe('oauth2', () => {
|
|
|
256
237
|
.onSecondCall()
|
|
257
238
|
.resolves({ encryptedData: `${Configuration.ENCRYPTION_PREFIX}encryptedRefreshToken` });
|
|
258
239
|
})
|
|
259
|
-
.command(['oauth2'
|
|
260
|
-
.it('decrypt oauth2 authorization entries and test
|
|
240
|
+
.command(['oauth2'])
|
|
241
|
+
.it('decrypt oauth2 authorization entries and test account', () => {
|
|
261
242
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(0);
|
|
262
243
|
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(1);
|
|
263
244
|
(0, test_1.expect)(writeTestAccountStub.getCall(0).args).to.deep.equal([
|
|
@@ -270,11 +251,9 @@ describe('oauth2', () => {
|
|
|
270
251
|
oauth2: { ...oauth2Information, clientSecret: `${Configuration.ENCRYPTION_PREFIX}devClientID` },
|
|
271
252
|
},
|
|
272
253
|
],
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
refreshToken: `${Configuration.ENCRYPTION_PREFIX}devRefreshToken`,
|
|
277
|
-
},
|
|
254
|
+
testAccount: {
|
|
255
|
+
accessToken: `${Configuration.ENCRYPTION_PREFIX}devAccessToken`,
|
|
256
|
+
refreshToken: `${Configuration.ENCRYPTION_PREFIX}devRefreshToken`,
|
|
278
257
|
},
|
|
279
258
|
},
|
|
280
259
|
'production',
|
|
@@ -283,7 +262,6 @@ describe('oauth2', () => {
|
|
|
283
262
|
accessToken: `${Configuration.ENCRYPTION_PREFIX}encryptedAccessToken`,
|
|
284
263
|
refreshToken: `${Configuration.ENCRYPTION_PREFIX}encryptedRefreshToken`,
|
|
285
264
|
},
|
|
286
|
-
'development',
|
|
287
265
|
]);
|
|
288
266
|
});
|
|
289
267
|
test_1.test
|
|
@@ -291,9 +269,7 @@ describe('oauth2', () => {
|
|
|
291
269
|
.stderr()
|
|
292
270
|
.do(() => getConfigurationsStub.returns({
|
|
293
271
|
...baseConfiguration,
|
|
294
|
-
|
|
295
|
-
development: { something: 'something' },
|
|
296
|
-
},
|
|
272
|
+
testAccount: { something: 'something' },
|
|
297
273
|
}))
|
|
298
274
|
.stub(DecryptionResource, 'decryptEntries', stub => stub.resolves({ successful: {}, failed: ['boom!'] }))
|
|
299
275
|
.command(['oauth2'])
|
|
@@ -308,9 +284,7 @@ describe('oauth2', () => {
|
|
|
308
284
|
.do(() => {
|
|
309
285
|
getConfigurationsStub.returns({
|
|
310
286
|
...baseConfiguration,
|
|
311
|
-
|
|
312
|
-
development: credentials,
|
|
313
|
-
},
|
|
287
|
+
testAccount: credentials,
|
|
314
288
|
});
|
|
315
289
|
sinon
|
|
316
290
|
.stub(IntegrationsPlatform, 'encryptData')
|
|
@@ -324,7 +298,7 @@ describe('oauth2', () => {
|
|
|
324
298
|
.resolves({ successful: { ...oauth2Information }, failed: [] })
|
|
325
299
|
.onSecondCall()
|
|
326
300
|
.resolves({ successful: { refreshToken: 'test-refresh-token' }, failed: [] }))
|
|
327
|
-
.command(['oauth2', '--
|
|
301
|
+
.command(['oauth2', '--environment', 'staging'])
|
|
328
302
|
.it('passes the staging environment to updateToken when specified', () => {
|
|
329
303
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(0);
|
|
330
304
|
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(1);
|
|
@@ -341,9 +315,7 @@ describe('oauth2', () => {
|
|
|
341
315
|
.do(() => {
|
|
342
316
|
getConfigurationsStub.returns({
|
|
343
317
|
...baseConfiguration,
|
|
344
|
-
|
|
345
|
-
development: credentials,
|
|
346
|
-
},
|
|
318
|
+
testAccount: credentials,
|
|
347
319
|
});
|
|
348
320
|
sinon
|
|
349
321
|
.stub(IntegrationsPlatform, 'encryptData')
|
|
@@ -357,7 +329,7 @@ describe('oauth2', () => {
|
|
|
357
329
|
.resolves({ successful: { ...oauth2Information }, failed: [] })
|
|
358
330
|
.onSecondCall()
|
|
359
331
|
.resolves({ successful: { refreshToken: 'test-refresh-token' }, failed: [] }))
|
|
360
|
-
.command(['oauth2'
|
|
332
|
+
.command(['oauth2'])
|
|
361
333
|
.it('defaults to production environment when no environment flag is specified', () => {
|
|
362
334
|
(0, test_1.expect)(performOAuth2FlowStub.getCalls().length).to.equal(0);
|
|
363
335
|
(0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(1);
|
|
@@ -23,14 +23,9 @@ describe('Test', () => {
|
|
|
23
23
|
success: '',
|
|
24
24
|
failure: '',
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
encryptedToken: `${ConfigurationResource.ENCRYPTION_PREFIX}decrypt-me`,
|
|
30
|
-
},
|
|
31
|
-
development: {
|
|
32
|
-
accessToken: 'developmentToken',
|
|
33
|
-
},
|
|
26
|
+
testAccount: {
|
|
27
|
+
accessToken: 'token',
|
|
28
|
+
encryptedToken: `${ConfigurationResource.ENCRYPTION_PREFIX}decrypt-me`,
|
|
34
29
|
},
|
|
35
30
|
};
|
|
36
31
|
let execSyncStub;
|
|
@@ -102,16 +97,8 @@ describe('Test', () => {
|
|
|
102
97
|
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
103
98
|
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
104
99
|
.command(['test'])
|
|
105
|
-
.it('
|
|
106
|
-
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"accessToken":"
|
|
107
|
-
});
|
|
108
|
-
test_1.test
|
|
109
|
-
.stdout()
|
|
110
|
-
.stub(ConfigurationResource, 'getConfiguration', stub => stub.resolves(cliConfiguration))
|
|
111
|
-
.stub(IntegrationResource, 'validateIsIntegrationDirectory', stub => stub.returns(true))
|
|
112
|
-
.command(['test', '--test-account', 'compliance'])
|
|
113
|
-
.it('uses compliance credentials when a flag is provided', () => {
|
|
114
|
-
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"accessToken":"token","encryptedToken":"decrypted-me","unitoCredentialId":"compliance","unitoUserId":"compliance"}');
|
|
100
|
+
.it('uses the configured test account credentials', () => {
|
|
101
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"accessToken":"token","encryptedToken":"decrypted-me","unitoCredentialId":"testAccount","unitoUserId":"testAccount"}');
|
|
115
102
|
});
|
|
116
103
|
test_1.test
|
|
117
104
|
.stdout()
|
|
@@ -16,10 +16,8 @@ describe('configuration', () => {
|
|
|
16
16
|
beforeEach(async () => {
|
|
17
17
|
originalConfiguration = {
|
|
18
18
|
name: 'my-integration',
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
accessToken: 'foo',
|
|
22
|
-
},
|
|
19
|
+
testAccount: {
|
|
20
|
+
accessToken: 'foo',
|
|
23
21
|
},
|
|
24
22
|
};
|
|
25
23
|
// Create a temporary directory
|
|
@@ -258,25 +256,16 @@ describe('configuration', () => {
|
|
|
258
256
|
},
|
|
259
257
|
},
|
|
260
258
|
],
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
},
|
|
267
|
-
compliance: {
|
|
268
|
-
apiKey: 'xyzw',
|
|
269
|
-
displayName: 'My Awesome Nickname from first grade',
|
|
270
|
-
email: 'manualtester+staging@unito.io',
|
|
271
|
-
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
272
|
-
},
|
|
259
|
+
testAccount: {
|
|
260
|
+
apiKey: 'xyzw',
|
|
261
|
+
displayName: 'My Awesome Nickname from first grade',
|
|
262
|
+
email: 'manualtester+staging@unito.io',
|
|
263
|
+
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
273
264
|
},
|
|
274
265
|
}, null, 2));
|
|
275
266
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
strict_1.default.equal(developmentKey, 'xyz');
|
|
279
|
-
strict_1.default.equal(complianceKey, 'xyzw');
|
|
267
|
+
const apiKey = configuration.testAccount?.apiKey;
|
|
268
|
+
strict_1.default.equal(apiKey, 'xyzw');
|
|
280
269
|
});
|
|
281
270
|
it('invalid test accounts', async () => {
|
|
282
271
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -299,19 +288,11 @@ describe('configuration', () => {
|
|
|
299
288
|
},
|
|
300
289
|
},
|
|
301
290
|
],
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
308
|
-
},
|
|
309
|
-
compliance: {
|
|
310
|
-
APIKEY: 'xyzw',
|
|
311
|
-
displayName: 'My Awesome Nickname from first grade',
|
|
312
|
-
email: 'manualtester+staging@unito.io',
|
|
313
|
-
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
314
|
-
},
|
|
291
|
+
testAccount: {
|
|
292
|
+
APIKEY: 'xyzw',
|
|
293
|
+
displayName: 'My Awesome Nickname from first grade',
|
|
294
|
+
email: 'manualtester+staging@unito.io',
|
|
295
|
+
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
315
296
|
},
|
|
316
297
|
}, null, 2));
|
|
317
298
|
await strict_1.default.rejects(Configuration.getConfiguration(globalConfiguration_1.Environment.Production), errors_1.ConfigurationInvalid);
|
|
@@ -377,25 +358,15 @@ describe('configuration', () => {
|
|
|
377
358
|
},
|
|
378
359
|
},
|
|
379
360
|
],
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
email: 'manualtester+staging@unito.io',
|
|
385
|
-
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
386
|
-
},
|
|
387
|
-
compliance: {
|
|
388
|
-
accessToken: 'Super_Secret_token_2',
|
|
389
|
-
email: 'manualtester+staging@unito.io',
|
|
390
|
-
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
391
|
-
},
|
|
361
|
+
testAccount: {
|
|
362
|
+
accessToken: 'Super_Secret_token_2',
|
|
363
|
+
email: 'manualtester+staging@unito.io',
|
|
364
|
+
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
392
365
|
},
|
|
393
366
|
}, null, 2));
|
|
394
367
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
strict_1.default.equal(developmentKey, 'Super_Secret_token');
|
|
398
|
-
strict_1.default.equal(complianceKey, 'Super_Secret_token_2');
|
|
368
|
+
const accessToken = configuration.testAccount?.accessToken;
|
|
369
|
+
strict_1.default.equal(accessToken, 'Super_Secret_token_2');
|
|
399
370
|
});
|
|
400
371
|
it('invalid test accounts', async () => {
|
|
401
372
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -436,13 +407,8 @@ describe('configuration', () => {
|
|
|
436
407
|
},
|
|
437
408
|
},
|
|
438
409
|
],
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
apiKey: 'xyz',
|
|
442
|
-
},
|
|
443
|
-
compliance: {
|
|
444
|
-
apiKey: 'xyzw',
|
|
445
|
-
},
|
|
410
|
+
testAccount: {
|
|
411
|
+
apiKey: 'xyzw',
|
|
446
412
|
},
|
|
447
413
|
}, null, 2));
|
|
448
414
|
await strict_1.default.rejects(Configuration.getConfiguration(globalConfiguration_1.Environment.Production), errors_1.ConfigurationInvalid);
|
|
@@ -524,23 +490,13 @@ describe('configuration', () => {
|
|
|
524
490
|
},
|
|
525
491
|
},
|
|
526
492
|
],
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
accessToken: 'Super_Secret_token',
|
|
530
|
-
displayName: 'My Awesome Nickname from first grade',
|
|
531
|
-
email: 'manualtester+staging@unito.io',
|
|
532
|
-
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
533
|
-
},
|
|
534
|
-
compliance: {
|
|
535
|
-
apiKey: 'Super_Secret_api_key_2',
|
|
536
|
-
},
|
|
493
|
+
testAccount: {
|
|
494
|
+
apiKey: 'Super_Secret_api_key_2',
|
|
537
495
|
},
|
|
538
496
|
}, null, 2));
|
|
539
497
|
const configuration = await Configuration.getConfiguration(globalConfiguration_1.Environment.Production);
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
strict_1.default.equal(developmentKey, 'Super_Secret_token');
|
|
543
|
-
strict_1.default.equal(complianceKey, 'Super_Secret_api_key_2');
|
|
498
|
+
const apiKey = configuration.testAccount?.apiKey;
|
|
499
|
+
strict_1.default.equal(apiKey, 'Super_Secret_api_key_2');
|
|
544
500
|
});
|
|
545
501
|
it('invalid test accounts', async () => {
|
|
546
502
|
await fs_1.default.promises.writeFile(Configuration.getConfigurationPath(), JSON.stringify({
|
|
@@ -597,16 +553,8 @@ describe('configuration', () => {
|
|
|
597
553
|
},
|
|
598
554
|
},
|
|
599
555
|
],
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
accessTokens: 'Super_Secret_token',
|
|
603
|
-
displayName: 'My Awesome Nickname from first grade',
|
|
604
|
-
email: 'manualtester+staging@unito.io',
|
|
605
|
-
domain: 'ftp://unitomanualtests.atlassian.net',
|
|
606
|
-
},
|
|
607
|
-
compliance: {
|
|
608
|
-
apiKeys: 'Super_Secret_api_key_2',
|
|
609
|
-
},
|
|
556
|
+
testAccount: {
|
|
557
|
+
apiKeys: 'Super_Secret_api_key_2',
|
|
610
558
|
},
|
|
611
559
|
}, null, 2));
|
|
612
560
|
await strict_1.default.rejects(Configuration.getConfiguration(globalConfiguration_1.Environment.Production), errors_1.ConfigurationInvalid);
|
|
@@ -16,14 +16,9 @@ describe('decryption helper', () => {
|
|
|
16
16
|
encryptedSecret1: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
17
17
|
encryptedSecret2: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
encryptedToken: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
23
|
-
},
|
|
24
|
-
development: {
|
|
25
|
-
accessToken: 'developmentToken',
|
|
26
|
-
},
|
|
19
|
+
testAccount: {
|
|
20
|
+
accessToken: 'token',
|
|
21
|
+
encryptedToken: `${configuration_1.ENCRYPTION_PREFIX}decrypt-me`,
|
|
27
22
|
},
|
|
28
23
|
};
|
|
29
24
|
beforeEach(() => {
|
package/oclif.manifest.json
CHANGED
|
@@ -116,18 +116,6 @@
|
|
|
116
116
|
"multiple": false,
|
|
117
117
|
"type": "option"
|
|
118
118
|
},
|
|
119
|
-
"test-account": {
|
|
120
|
-
"description": "test account to use.",
|
|
121
|
-
"name": "test-account",
|
|
122
|
-
"default": "development",
|
|
123
|
-
"hasDynamicHelp": false,
|
|
124
|
-
"multiple": false,
|
|
125
|
-
"options": [
|
|
126
|
-
"development",
|
|
127
|
-
"compliance"
|
|
128
|
-
],
|
|
129
|
-
"type": "option"
|
|
130
|
-
},
|
|
131
119
|
"read-only": {
|
|
132
120
|
"description": "whether or not to only perform read operations",
|
|
133
121
|
"name": "read-only",
|
|
@@ -315,18 +303,6 @@
|
|
|
315
303
|
],
|
|
316
304
|
"type": "option"
|
|
317
305
|
},
|
|
318
|
-
"test-account": {
|
|
319
|
-
"description": "test account to use",
|
|
320
|
-
"name": "test-account",
|
|
321
|
-
"default": "development",
|
|
322
|
-
"hasDynamicHelp": false,
|
|
323
|
-
"multiple": false,
|
|
324
|
-
"options": [
|
|
325
|
-
"development",
|
|
326
|
-
"compliance"
|
|
327
|
-
],
|
|
328
|
-
"type": "option"
|
|
329
|
-
},
|
|
330
306
|
"credential-payload": {
|
|
331
307
|
"description": "(advanced) credential payload to use.",
|
|
332
308
|
"exclusive": [
|
|
@@ -542,24 +518,12 @@
|
|
|
542
518
|
"oauth2": {
|
|
543
519
|
"aliases": [],
|
|
544
520
|
"args": {},
|
|
545
|
-
"description": "The Oauth2 command allows you to perform an OAuth2 workflow to populate the
|
|
521
|
+
"description": "The Oauth2 command allows you to perform an OAuth2 workflow to populate the test account's accessToken and refreshToken to be used by the 'test' and 'dev' commands.\n\n If the test account is already populated, the command will refresh the credentials if the refresh token is available.\n If you want to force a new OAuth2 flow to change the connected account or something else, use the --reauth flag.",
|
|
546
522
|
"examples": [
|
|
547
523
|
"<%= config.bin %> <%= command.id %>",
|
|
548
|
-
"<%= config.bin %> <%= command.id %> --reauth
|
|
524
|
+
"<%= config.bin %> <%= command.id %> --reauth"
|
|
549
525
|
],
|
|
550
526
|
"flags": {
|
|
551
|
-
"test-account": {
|
|
552
|
-
"description": "Test account to use.",
|
|
553
|
-
"name": "test-account",
|
|
554
|
-
"default": "development",
|
|
555
|
-
"hasDynamicHelp": false,
|
|
556
|
-
"multiple": false,
|
|
557
|
-
"options": [
|
|
558
|
-
"development",
|
|
559
|
-
"compliance"
|
|
560
|
-
],
|
|
561
|
-
"type": "option"
|
|
562
|
-
},
|
|
563
527
|
"environment": {
|
|
564
528
|
"description": "the environment of the platform",
|
|
565
529
|
"name": "environment",
|
|
@@ -595,7 +559,7 @@
|
|
|
595
559
|
"pluginName": "@unito/integration-cli",
|
|
596
560
|
"pluginType": "core",
|
|
597
561
|
"strict": true,
|
|
598
|
-
"summary": "Perform an OAuth2 workflow to either populate or refresh
|
|
562
|
+
"summary": "Perform an OAuth2 workflow to either populate or refresh the test account's credentials.",
|
|
599
563
|
"enableJsonFlag": false,
|
|
600
564
|
"isESM": false,
|
|
601
565
|
"relativePath": [
|
|
@@ -764,14 +728,6 @@
|
|
|
764
728
|
],
|
|
765
729
|
"type": "option"
|
|
766
730
|
},
|
|
767
|
-
"test-account": {
|
|
768
|
-
"description": "test account to use",
|
|
769
|
-
"name": "test-account",
|
|
770
|
-
"default": "development",
|
|
771
|
-
"hasDynamicHelp": false,
|
|
772
|
-
"multiple": false,
|
|
773
|
-
"type": "option"
|
|
774
|
-
},
|
|
775
731
|
"config-path": {
|
|
776
732
|
"description": "relative path to a custom \".unito.json\" file",
|
|
777
733
|
"name": "config-path",
|
|
@@ -904,18 +860,6 @@
|
|
|
904
860
|
"multiple": false,
|
|
905
861
|
"type": "option"
|
|
906
862
|
},
|
|
907
|
-
"test-account": {
|
|
908
|
-
"description": "test account to use.",
|
|
909
|
-
"name": "test-account",
|
|
910
|
-
"default": "development",
|
|
911
|
-
"hasDynamicHelp": false,
|
|
912
|
-
"multiple": false,
|
|
913
|
-
"options": [
|
|
914
|
-
"development",
|
|
915
|
-
"compliance"
|
|
916
|
-
],
|
|
917
|
-
"type": "option"
|
|
918
|
-
},
|
|
919
863
|
"read-only": {
|
|
920
864
|
"description": "whether or not to only perform read operations",
|
|
921
865
|
"name": "read-only",
|
|
@@ -1030,5 +974,5 @@
|
|
|
1030
974
|
]
|
|
1031
975
|
}
|
|
1032
976
|
},
|
|
1033
|
-
"version": "1.
|
|
977
|
+
"version": "1.4.0"
|
|
1034
978
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unito/integration-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Integration CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"integration-cli": "./bin/run"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@ngrok/ngrok": "^1.7.0",
|
|
40
40
|
"@oazapfts/runtime": "1.x",
|
|
41
41
|
"@oclif/core": "3.x",
|
|
42
|
-
"@unito/integration-debugger": "^0.32.
|
|
42
|
+
"@unito/integration-debugger": "^0.32.1",
|
|
43
43
|
"ajv": "8.x",
|
|
44
44
|
"ajv-formats": "3.x",
|
|
45
45
|
"better-ajv-errors": "1.x",
|