Skip to content

Commit

Permalink
Refactor messages out of SecureStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
dprothero committed Apr 9, 2019
1 parent ca99cbd commit 2301513
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
"name": "Launch Program",
"program": "${workspaceFolder}/bin/run",
"console": "externalTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": ["-u", "tdd", "--timeout", "999999", "--colors", "${workspaceFolder}/test/**/*.test.js"],
"internalConsoleOptions": "openOnSessionStart"
}
]
}
12 changes: 10 additions & 2 deletions src/commands/project/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ const twilio = require('twilio');

const { BaseCommand, TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const { CLIRequestClient } = require('@twilio/cli-core').services;
const { STORAGE_LOCATIONS } = require('@twilio/cli-core').services.secureStorage;

const FRIENDLY_STORAGE_LOCATIONS = {
[STORAGE_LOCATIONS.KEYCHAIN]: 'in your keychain',
[STORAGE_LOCATIONS.WIN_CRED_VAULT]: 'in the Windows credential vault',
[STORAGE_LOCATIONS.LIBSECRET]: 'using libsecret'
};

class ProjectAdd extends BaseCommand {
constructor(argv, config, secureStorage) {
Expand Down Expand Up @@ -134,8 +141,9 @@ class ProjectAdd extends BaseCommand {
await this.configFile.save(this.userConfig);

this.logger.info(
`Created API Key ${apiKey.sid} and stored the secret ${this.secureStorage.platformDescription}.` +
` See: https://www.twilio.com/console/runtime/api-keys/${apiKey.sid}`
`Created API Key ${apiKey.sid} and stored the secret ${
FRIENDLY_STORAGE_LOCATIONS[this.secureStorage.storageLocation]
}. See: https://www.twilio.com/console/runtime/api-keys/${apiKey.sid}`
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/commands/project/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ describe('commands', () => {
await ctx.testCmd.run();
expect(ctx.stdout).to.equal('');
expect(ctx.stderr).to.contain('Saved default.');
expect(ctx.stderr).to.contain(`Created API Key ${constants.FAKE_API_KEY} and stored the secret `);
expect(ctx.stderr).to.contain(
`Created API Key ${constants.FAKE_API_KEY} and stored the secret using libsecret`
);
expect(ctx.stderr).to.contain(
`See: https://www.twilio.com/console/runtime/api-keys/${constants.FAKE_API_KEY}`
);
Expand Down

0 comments on commit 2301513

Please sign in to comment.