From 1b9cc3c189cb9ab53ea9f4ec00f90b3dd396941d Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Thu, 28 Jan 2021 11:21:42 -0700 Subject: [PATCH] fix: handled false generate(p|P)assword scenario --- src/commands/force/user/create.ts | 15 +++++++++++++++ test/commands/user/create.test.ts | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/commands/force/user/create.ts b/src/commands/force/user/create.ts index 50297b48..67c1807e 100644 --- a/src/commands/force/user/create.ts +++ b/src/commands/force/user/create.ts @@ -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]; + } }); } @@ -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; } diff --git a/test/commands/user/create.test.ts b/test/commands/user/create.test.ts index 880314ee..5d4c9525 100644 --- a/test/commands/user/create.test.ts +++ b/test/commands/user/create.test.ts @@ -245,6 +245,7 @@ describe('force:user:create', () => { orgId: 'abc123', permsets: ['test1', 'test2'], profileId: '00e2D000000bNexWWR', + generatePassword: false, generatepassword: 'false', timeZoneSidKey: 'America/Los_Angeles', username: '1605130295132_test-j6asqt5qoprs@example.com', @@ -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',