@unito/integration-cli 1.3.5 → 1.5.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.
@@ -19,7 +19,7 @@ class Test extends baseCommand_1.BaseCommand {
19
19
  environment: core_1.Flags.custom({
20
20
  description: 'the environment of the platform',
21
21
  options: Object.values(GlobalConfiguration.Environment),
22
- default: GlobalConfiguration.Environment.Production,
22
+ default: GlobalConfiguration.Environment.Local,
23
23
  })(),
24
24
  verbose: core_1.Flags.boolean({
25
25
  description: 'output more (debug) information',
@@ -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,
@@ -113,12 +108,11 @@ class Test extends baseCommand_1.BaseCommand {
113
108
  core_1.ux.action.stop();
114
109
  }
115
110
  // Resolve the configuration.
116
- const environment = flags.environment ?? GlobalConfiguration.Environment.Production;
117
- const configuration = await (0, configuration_1.getConfiguration)(environment, flags['config-path']);
111
+ const configuration = await (0, configuration_1.getConfiguration)(flags.environment, flags['config-path']);
118
112
  let credentialPayload = '{}';
119
113
  let readOnly = flags['read-only'] ?? false;
120
114
  if (flags['credential-id']) {
121
- const credential = await (0, credentials_1.fetchCredential)(environment, this.config.configDir, flags['credential-id']);
115
+ const credential = await (0, credentials_1.fetchCredential)(flags.environment, this.config.configDir, flags['credential-id']);
122
116
  credentialPayload = JSON.stringify({
123
117
  ...credential.payload,
124
118
  unitoCredentialId: credential.id,
@@ -130,27 +124,24 @@ class Test extends baseCommand_1.BaseCommand {
130
124
  else if (flags['credential-payload']) {
131
125
  credentialPayload = flags['credential-payload'];
132
126
  }
133
- else {
134
- const credentials = configuration.testAccounts?.[flags['test-account']];
135
- if (credentials) {
136
- const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, credentials);
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
- });
127
+ else if (configuration.testAccount && Object.keys(configuration.testAccount).length) {
128
+ const decryptedEntries = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, configuration.testAccount);
129
+ if (decryptedEntries.failed.length) {
130
+ throw new errors_1.EntryDecryptionError(decryptedEntries.failed.at(0), flags.environment);
145
131
  }
132
+ credentialPayload = JSON.stringify({
133
+ ...decryptedEntries.successful,
134
+ unitoCredentialId: 'testAccount',
135
+ unitoUserId: 'testAccount',
136
+ });
146
137
  }
147
138
  // Load secrets.
148
- const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.secrets ?? {});
139
+ const { successful: secrets, failed: failedSecrets } = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, configuration.secrets ?? {});
149
140
  if (failedSecrets.length) {
150
- throw new errors_1.EntryDecryptionError(failedSecrets.at(0), environment);
141
+ throw new errors_1.EntryDecryptionError(failedSecrets.at(0), flags.environment);
151
142
  }
152
143
  // Load environment variables.
153
- const { successful: environmentVariables, failed: failedEnvironmentVariables } = await (0, decryption_1.decryptEntries)(configuration.name, environment, this.config.configDir, configuration.environmentVariables ?? {});
144
+ const { successful: environmentVariables, failed: failedEnvironmentVariables } = await (0, decryption_1.decryptEntries)(configuration.name, flags.environment, this.config.configDir, configuration.environmentVariables ?? {});
154
145
  for (const environmentVariable of failedEnvironmentVariables) {
155
146
  if (!process.env[environmentVariable]) {
156
147
  core_1.ux.log();
@@ -53,21 +53,10 @@ export interface Configuration {
53
53
  */
54
54
  authorizations?: Authorization[];
55
55
  /**
56
- * The test accounts of the integration
56
+ * The test account of the integration
57
57
  */
58
- testAccounts?: {
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
- }, accountName: string): Promise<void>;
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.CredentialScope = exports.CrawlMode = void 0;
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
- if (!configuration.testAccounts) {
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, accountName) {
100
- // istanbul ignore next
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 accounts.
128
- if (configuration.testAccounts && configuration.authorizations?.length) {
129
- for (const [name, account] of Object.entries(configuration.testAccounts)) {
130
- if (Object.keys(account).length) {
131
- validateTestAccount(name, account, configuration.authorizations, spec);
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(credentialName, credential, authorizationDefinitions, spec) {
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 ${credentialName} is invalid!`, validate.errors, (0, better_ajv_errors_1.default)(schema, credential, validate.errors, { indent: 2 }));
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
- testAccounts: {
30
- development: {
31
- key: 'value',
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":"development","unitoUserId":"development"}');
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()
@@ -34,14 +34,14 @@ describe('encrypt', () => {
34
34
  test_1.test
35
35
  .stdout()
36
36
  .stub(GlobalConfiguration, 'read', stub => stub.returns({ apiKey: 'foo' }))
37
- .command(['encrypt'])
37
+ .command(['encrypt', '--environment=production'])
38
38
  .it('encrypts data - default', ctx => {
39
39
  (0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
40
40
  });
41
41
  test_1.test
42
42
  .stdout()
43
43
  .stub(GlobalConfiguration, 'read', stub => stub.returns({ apiKey: 'foo' }))
44
- .command(['encrypt', '--sensitive'])
44
+ .command(['encrypt', '--sensitive', '--environment=production'])
45
45
  .it('encrypts data - sensitive', ctx => {
46
46
  (0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
47
47
  });
@@ -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
- testAccounts: {
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', '--test-account', 'development'])
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,12 +87,12 @@ 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', '--test-account', 'development'])
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([
95
94
  { ...oauth2Information, clientId: 'devClientID' },
96
- 'production',
95
+ 'local',
97
96
  undefined,
98
97
  ]);
99
98
  (0, test_1.expect)(updateTokenStub.getCalls().length).to.equal(0);
@@ -110,10 +109,9 @@ describe('oauth2', () => {
110
109
  },
111
110
  ],
112
111
  },
113
- 'production',
112
+ 'local',
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
- testAccounts: {
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', '--test-account', 'development', '--reauth'])
137
- .it('performs the oauth flow when there is a test accounts, the auth information are setup and --reauth flag is present', () => {
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
- testAccounts: {
144
- development: credentials,
145
- },
139
+ testAccount: credentials,
146
140
  },
147
- 'production',
141
+ 'local',
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
- testAccounts: {
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', '--test-account', 'compliance'])
171
- .it('performs the oauth flow when the requested test account is not setup', () => {
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
- testAccounts: {
178
- development: { something: 'something' },
179
- },
168
+ testAccount: {},
180
169
  },
181
- 'production',
170
+ 'local',
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
- testAccounts: {
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', '--test-account', 'development'])
205
- .it('refresh the token when there is an existing test accounts and the auth information are setup', () => {
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
- testAccounts: {
212
- development: credentials,
213
- },
197
+ testAccount: credentials,
214
198
  },
215
- 'production',
199
+ 'local',
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
- testAccounts: {
234
- development: {
235
- accessToken: `${Configuration.ENCRYPTION_PREFIX}devAccessToken`,
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', '--test-account', 'development'])
260
- .it('decrypt oauth2 authorization entries and test-account', () => {
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,20 +251,17 @@ describe('oauth2', () => {
270
251
  oauth2: { ...oauth2Information, clientSecret: `${Configuration.ENCRYPTION_PREFIX}devClientID` },
271
252
  },
272
253
  ],
273
- testAccounts: {
274
- development: {
275
- accessToken: `${Configuration.ENCRYPTION_PREFIX}devAccessToken`,
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
- 'production',
259
+ 'local',
281
260
  undefined,
282
261
  {
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
- testAccounts: {
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
- testAccounts: {
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', '--test-account', 'development', '--environment', 'staging'])
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
- testAccounts: {
345
- development: credentials,
346
- },
318
+ testAccount: credentials,
347
319
  });
348
320
  sinon
349
321
  .stub(IntegrationsPlatform, 'encryptData')
@@ -357,16 +329,16 @@ describe('oauth2', () => {
357
329
  .resolves({ successful: { ...oauth2Information }, failed: [] })
358
330
  .onSecondCall()
359
331
  .resolves({ successful: { refreshToken: 'test-refresh-token' }, failed: [] }))
360
- .command(['oauth2', '--test-account', 'development'])
361
- .it('defaults to production environment when no environment flag is specified', () => {
332
+ .command(['oauth2'])
333
+ .it('defaults to local 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);
364
- // Verify that updateToken was called with the default production environment
336
+ // Verify that updateToken was called with the default local environment
365
337
  const updateTokenCall = updateTokenStub.getCall(0);
366
338
  (0, test_1.expect)(updateTokenCall.args).to.have.lengthOf(4);
367
339
  (0, test_1.expect)(updateTokenCall.args[0]).to.deep.equal(oauth2Information); // oauth2 config
368
340
  (0, test_1.expect)(updateTokenCall.args[1]).to.equal('test-refresh-token'); // refresh token
369
341
  (0, test_1.expect)(updateTokenCall.args[2]).to.deep.equal({ refreshToken: 'test-refresh-token' }); // credential payload
370
- (0, test_1.expect)(updateTokenCall.args[3]).to.equal('production'); // environment (default)
342
+ (0, test_1.expect)(updateTokenCall.args[3]).to.equal('local'); // environment (default)
371
343
  });
372
344
  });