Skip to content

Commit

Permalink
fix: handled false generate(p|P)assword scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Jan 28, 2021
1 parent 2fde9ba commit 1b9cc3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/commands/force/user/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export class UserCreateCommand extends SfdxCommand {
if (this.varargs) {
Object.keys(this.varargs).forEach((key) => {
defaultFields[this.lowerFirstLetter(key)] = this.varargs[key];

if (key.toLowerCase() === 'generatepassword') {
defaultFields['generatePassword'] = this.varargs[key];
}
});
}

Expand All @@ -206,6 +210,17 @@ export class UserCreateCommand extends SfdxCommand {
defaultFields['generatepassword'] = 'true';
defaultFields['generatePassword'] = true;
}
// for the false case
if (
defaultFields['generatepassword'] === 'false' ||
defaultFields['generatePassword'] === 'false' ||
defaultFields['generatePassword'] === false
) {
// since only one may be set, set both variations, prefer camelCase and boolean for coding
// this will also maintain --json backwards compatibility for the all lower case scenario
defaultFields['generatepassword'] = 'false';
defaultFields['generatePassword'] = false;
}

return defaultFields;
}
Expand Down
2 changes: 2 additions & 0 deletions test/commands/user/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ describe('force:user:create', () => {
orgId: 'abc123',
permsets: ['test1', 'test2'],
profileId: '00e2D000000bNexWWR',
generatePassword: false,
generatepassword: 'false',
timeZoneSidKey: 'America/Los_Angeles',
username: '[email protected]',
Expand Down Expand Up @@ -285,6 +286,7 @@ describe('force:user:create', () => {
languageLocaleKey: 'en_US',
lastName: 'User',
localeSidKey: 'en_US',
generatePassword: false,
generatepassword: 'false',
profileName: "'Chatter Free User'",
orgId: 'abc123',
Expand Down

0 comments on commit 1b9cc3c

Please sign in to comment.