diff --git a/src/commands/org/login/access-token.ts b/src/commands/org/login/access-token.ts index 3207354a..1565f087 100644 --- a/src/commands/org/login/access-token.ts +++ b/src/commands/org/login/access-token.ts @@ -15,7 +15,7 @@ */ import { Flags, loglevel, SfCommand } from '@salesforce/sf-plugins-core'; -import { AuthFields, AuthInfo, Messages, matchesAccessToken, SfError, StateAggregator } from '@salesforce/core'; +import { AuthFields, AuthInfo, Messages, StateAggregator } from '@salesforce/core'; import { env } from '@salesforce/kit'; import { InferredFlags } from '@oclif/core/interfaces'; @@ -23,8 +23,6 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-auth', 'accesstoken.store'); const commonMessages = Messages.loadMessages('@salesforce/plugin-auth', 'messages'); -const ACCESS_TOKEN_FORMAT = '"!"'; - export default class LoginAccessToken extends SfCommand { public static readonly summary = messages.getMessage('summary'); public static readonly description = messages.getMessage('description'); @@ -122,15 +120,12 @@ export default class LoginAccessToken extends SfCommand { } private async getAccessToken(): Promise { - const accessToken = + return ( env.getString('SF_ACCESS_TOKEN') ?? env.getString('SFDX_ACCESS_TOKEN') ?? (this.flags['no-prompt'] === true ? '' // will throw when validating - : await this.secretPrompt({ message: commonMessages.getMessage('accessTokenStdin') })); - if (!matchesAccessToken(accessToken)) { - throw new SfError(messages.getMessage('invalidAccessTokenFormat', [ACCESS_TOKEN_FORMAT])); - } - return accessToken; + : await this.secretPrompt({ message: commonMessages.getMessage('accessTokenStdin') })) + ); } } diff --git a/test/commands/org/login/access-token.test.ts b/test/commands/org/login/access-token.test.ts index 539fea84..18e83b24 100644 --- a/test/commands/org/login/access-token.test.ts +++ b/test/commands/org/login/access-token.test.ts @@ -15,7 +15,7 @@ */ import { AuthFields, AuthInfo, StateAggregator } from '@salesforce/core'; -import { assert, expect } from 'chai'; +import { expect } from 'chai'; import { TestContext } from '@salesforce/core/testSetup'; import { stubPrompter, stubSfCommandUx } from '@salesforce/sf-plugins-core'; import { env } from '@salesforce/kit'; @@ -68,19 +68,6 @@ describe('org:login:access-token', () => { expect(result).to.deep.equal(authFields); }); - it('should show invalid access token provided as input', async () => { - prompterStubs.secret.resolves('invalidaccesstokenformat'); - - try { - await Store.run(['--instance-url', 'https://foo.bar.org.salesforce.com']); - assert(false, 'should throw error'); - } catch (e) { - assert(e instanceof Error); - expect(e.message).to.include("The access token isn't in the correct format"); - } - expect(prompterStubs.secret.callCount).to.equal(1); - }); - it('should show that auth file already exists', async () => { prompterStubs.secret.resolves(accessToken); prompterStubs.confirm.resolves(false);