Skip to content

Commit

Permalink
Addressed the review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ravali-rimmalapudi committed Jun 28, 2021
1 parent e621ea6 commit 8f7b136
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
22 changes: 11 additions & 11 deletions src/commands/profiles/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,6 @@ class ProfilesCreate extends BaseCommand {
}
}

async removeKeytarKeysByProfileId(profileId) {
if (this.userConfig.projects.find((p) => p.id === profileId)) {
const removed = await this.secureStorage.removeCredentials(profileId);
if (removed === true) {
this.logger.info('Deleted key from keytar.');
} else {
this.logger.warn('Could not delete key from keytar.');
}
}
}

async saveCredentials() {
const apiKeyFriendlyName = this.getApiKeyFriendlyName();
let apiKey = null;
Expand All @@ -250,6 +239,17 @@ class ProfilesCreate extends BaseCommand {
);
this.logger.info(configSavedMessage);
}

async removeKeytarKeysByProfileId(profileId) {
if (this.userConfig.projects.find((p) => p.id === profileId)) {
const removed = await this.secureStorage.removeCredentials(profileId);
if (removed === true) {
this.logger.info('Deleted key from keytar.');
} else {
this.logger.warn(`Could not delete ${profileId} key from keytar.`);
}
}
}
}

ProfilesCreate.aliases = ['profiles:add', 'login'];
Expand Down
6 changes: 2 additions & 4 deletions test/commands/profiles/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ describe('commands', () => {
.twilioFakeProfile(ConfigData)
.do((ctx) => {
ctx.userConfig = new ConfigData();
for (let i = 0; i <= addProjects.length; i++) {
ctx.userConfig.addProject(addProjects[i], constants.FAKE_ACCOUNT_SID);
}
addProjects.forEach((project) => ctx.userConfig.addProject(project, constants.FAKE_ACCOUNT_SID));
})
.twilioCliEnv(Config)
.twilioCreateCommand(ProfilesCreate, commandArgs)
Expand Down Expand Up @@ -98,7 +96,7 @@ describe('commands', () => {
expect(ctx.stdout).to.equal('');
expect(ctx.stderr).to.contain(helpMessages.AUTH_TOKEN_NOT_SAVED);
expect(ctx.stderr).to.contain('Saved profile1.');
expect(ctx.stderr).to.contain('Could not delete key from keytar');
expect(ctx.stderr).to.contain('Could not delete profile1 key from keytar.');
expect(ctx.stderr).to.contain('configuration saved');
expect(ctx.stderr).to.contain(`Created API Key ${constants.FAKE_API_KEY} and stored the secret in Config.`);
expect(ctx.stderr).to.contain(
Expand Down

0 comments on commit 8f7b136

Please sign in to comment.