diff --git a/src/commands/profiles/create.js b/src/commands/profiles/create.js index 7d35b4323..51c49819b 100644 --- a/src/commands/profiles/create.js +++ b/src/commands/profiles/create.js @@ -28,6 +28,9 @@ class ProfilesCreate extends BaseCommand { async run() { await super.run(); + // Eagerly load up the credential store. No need to proceed if this fails. + await this.secureStorage.loadKeytar(); + this.loadArguments(); await this.promptForProfileId(); diff --git a/test/commands/profiles/create.test.js b/test/commands/profiles/create.test.js index 94af3a9e6..8d91c33df 100644 --- a/test/commands/profiles/create.test.js +++ b/test/commands/profiles/create.test.js @@ -33,6 +33,7 @@ describe('commands', () => { authToken: constants.FAKE_API_SECRET }); ctx.testCmd.inquirer.prompt = fakePrompt; + ctx.testCmd.secureStorage.loadKeytar = sinon.fake.resolves(true); }); createTest() @@ -129,6 +130,14 @@ describe('commands', () => { .catch(/Could not create an API Key/) .it('fails to create an API key'); + createTest() + .do(ctx => { + ctx.testCmd.secureStorage.loadKeytar = sinon.fake.rejects('ugh'); + }) + .do(ctx => ctx.testCmd.run()) + .catch(/ugh/) + .it('fails early if keytar cannot be loaded'); + createTest(['--region', 'dev']) .nock('https://api.dev.twilio.com', api => { api.get(`/2010-04-01/Accounts/${constants.FAKE_ACCOUNT_SID}.json`).reply(200, {