From 4fff10dfade5bcdba6143fa83666ddd861adfb04 Mon Sep 17 00:00:00 2001 From: soridalac Date: Fri, 22 Aug 2025 13:25:21 -0700 Subject: [PATCH 1/4] fix: remove warning and throw error --- messages/logout.md | 6 ++---- src/commands/org/logout.ts | 6 ++---- test/commands/org/logout.test.ts | 9 +++++++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/messages/logout.md b/messages/logout.md index 21cb1ec0..11b8778c 100644 --- a/messages/logout.md +++ b/messages/logout.md @@ -44,7 +44,7 @@ All orgs includes Dev Hubs, sandboxes, DE orgs, and expired, deleted, and unknow # flags.client-app.summary -Client app to log out of. +Client app to log out of. # logoutOrgCommandSuccess @@ -98,8 +98,6 @@ You must specify a target-org (or default target-org config is set) or use --all You must specify a target-org (or default target-org config is set) or use --all flag when using the --json flag. -# warning.NoAuthFoundForTargetOrg +# noOrgFoundForTarget No authenticated org found with the %s username or alias. - -NOTE: Starting September 2025, this warning will be converted to an error. As a result, the exit code when you try to log out of an unauthenticated org will change from 0 to 1. diff --git a/src/commands/org/logout.ts b/src/commands/org/logout.ts index 2030eb74..eab4c4ff 100644 --- a/src/commands/org/logout.ts +++ b/src/commands/org/logout.ts @@ -98,10 +98,8 @@ export default class Logout extends SfCommand { if (orgAuths.length === 0) { if (flags['target-org']) { - this.warn(messages.createWarning('warning.NoAuthFoundForTargetOrg', [flags['target-org']])); - // user specified a target org but it was not resolved, issue success message and return - this.logSuccess(messages.getMessage('logoutOrgCommandSuccess', [flags['target-org']])); - return [flags['target-org']]; + // user specified a target org but it was not resolved, throw error + throw messages.createError('noOrgFoundForTarget', [flags['target-org']]); } this.info(messages.getMessage('noOrgsFound')); return []; diff --git a/test/commands/org/logout.test.ts b/test/commands/org/logout.test.ts index 4181bcff..ef282c5c 100644 --- a/test/commands/org/logout.test.ts +++ b/test/commands/org/logout.test.ts @@ -157,7 +157,12 @@ describe('org:logout', () => { aliases: { TestAlias: testOrg1.username }, authInfoConfigDoesNotExist: true, }); - const response = await Logout.run(['-p', '-o', testOrg1.username, '--json']); - expect(response).to.deep.equal([testOrg1.username]); + try { + await Logout.run(['-p', '-o', testOrg1.username, '--json']); + expect.fail('Expected error to be thrown'); + } catch (e) { + expect((e as Error).name).to.equal('NoOrgFoundForTargetError'); + expect((e as Error).message).to.include('No authenticated org found'); + } }); }); From b9cd4663223d42a0b9c5b2f225553f64b20c8e18 Mon Sep 17 00:00:00 2001 From: soridalac Date: Fri, 22 Aug 2025 13:37:38 -0700 Subject: [PATCH 2/4] fix: rename message title --- messages/logout.md | 2 +- src/commands/org/logout.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/messages/logout.md b/messages/logout.md index 11b8778c..8c055624 100644 --- a/messages/logout.md +++ b/messages/logout.md @@ -98,6 +98,6 @@ You must specify a target-org (or default target-org config is set) or use --all You must specify a target-org (or default target-org config is set) or use --all flag when using the --json flag. -# noOrgFoundForTarget +# noAuthFoundForTargetOrg No authenticated org found with the %s username or alias. diff --git a/src/commands/org/logout.ts b/src/commands/org/logout.ts index eab4c4ff..7b2bd3b7 100644 --- a/src/commands/org/logout.ts +++ b/src/commands/org/logout.ts @@ -99,7 +99,7 @@ export default class Logout extends SfCommand { if (orgAuths.length === 0) { if (flags['target-org']) { // user specified a target org but it was not resolved, throw error - throw messages.createError('noOrgFoundForTarget', [flags['target-org']]); + throw messages.createError('noAuthFoundForTargetOrg', [flags['target-org']]); } this.info(messages.getMessage('noOrgsFound')); return []; From 4e182654ffb835ddde939b9478f3acbcdcfc6b2e Mon Sep 17 00:00:00 2001 From: soridalac Date: Fri, 22 Aug 2025 13:38:52 -0700 Subject: [PATCH 3/4] fix: update test --- test/commands/org/logout.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/commands/org/logout.test.ts b/test/commands/org/logout.test.ts index ef282c5c..48fbdb2d 100644 --- a/test/commands/org/logout.test.ts +++ b/test/commands/org/logout.test.ts @@ -161,7 +161,7 @@ describe('org:logout', () => { await Logout.run(['-p', '-o', testOrg1.username, '--json']); expect.fail('Expected error to be thrown'); } catch (e) { - expect((e as Error).name).to.equal('NoOrgFoundForTargetError'); + expect((e as Error).name).to.equal('NoAuthFoundForTargetOrgError'); expect((e as Error).message).to.include('No authenticated org found'); } }); From a5119574cef663430015176173f87d9d4c353786 Mon Sep 17 00:00:00 2001 From: soridalac Date: Fri, 22 Aug 2025 13:46:51 -0700 Subject: [PATCH 4/4] fix: update NUT --- test/commands/org/login/login.jwt.nut.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/commands/org/login/login.jwt.nut.ts b/test/commands/org/login/login.jwt.nut.ts index 9e9fd268..9161761a 100644 --- a/test/commands/org/login/login.jwt.nut.ts +++ b/test/commands/org/login/login.jwt.nut.ts @@ -35,10 +35,6 @@ describe('org:login:jwt NUTs', () => { await testSession?.clean(); }); - afterEach(() => { - execCmd(`auth:logout -p -o ${username}`, { ensureExitCode: 0 }); - }); - it('should authorize an org using jwt (json)', () => { const command = `org:login:jwt -d -o ${username} -i ${clientId} -f ${jwtKey} -r ${instanceUrl} --json`; const json = execCmd(command, { ensureExitCode: 0 }).jsonOutput?.result as AuthFields; @@ -48,6 +44,7 @@ describe('org:login:jwt NUTs', () => { expectUrlToExist(json, 'loginUrl'); expect(json.privateKey).to.equal(path.join(testSession.homeDir, 'jwtKey')); expect(json.username).to.equal(username); + execCmd(`auth:logout -p -o ${username}`, { ensureExitCode: 0 }); }); it('should authorize an org using jwt (human readable)', () => { @@ -55,6 +52,7 @@ describe('org:login:jwt NUTs', () => { const result = execCmd(command, { ensureExitCode: 0 }); const output = getString(result, 'shellOutput.stdout'); expect(output).to.include(`Successfully authorized ${username} with org ID`); + execCmd(`auth:logout -p -o ${username}`, { ensureExitCode: 0 }); }); it('should throw correct error for JwtAuthError', () => {