Skip to content

Commit

Permalink
Merge pull request #951 from forcedotcom/ew/auth-url-padding
Browse files Browse the repository at this point in the history
Allow padding on id and secret
  • Loading branch information
shetzel authored Oct 6, 2023
2 parents efc977a + b93ac50 commit 2959d3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/org/authInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export class AuthInfo extends AsyncOptionalCreatable<AuthInfo.Options> {
sfdxAuthUrl: string
): Pick<AuthFields, 'clientId' | 'clientSecret' | 'refreshToken' | 'loginUrl'> {
const match = sfdxAuthUrl.match(
/^force:\/\/([a-zA-Z0-9._-]+):([a-zA-Z0-9._-]*):([a-zA-Z0-9._-]+={0,2})@([a-zA-Z0-9._-]+)/
/^force:\/\/([a-zA-Z0-9._-]+={0,2}):([a-zA-Z0-9._-]*={0,2}):([a-zA-Z0-9._-]+={0,2})@([a-zA-Z0-9._-]+)/
);

if (!match) {
Expand Down
10 changes: 6 additions & 4 deletions test/unit/org/authInfoTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1669,16 +1669,18 @@ describe('AuthInfo', () => {
expect(options.loginUrl).to.equal('https://test.my.salesforce.com');
});

it('should parse the token that includes = for padding', () => {
it('should parse an id, secret, and token that include = for padding', () => {
const options = AuthInfo.parseSfdxAuthUrl(
'force://PlatformCLI::5Aep861_OKMvio5gy8xCNsXxybPdupY9fVEZyeVOvb4kpOZx5Z1QLB7k7n5flEqEWKcwUQEX1I.O5DCFwjlYU==@test.my.salesforce.com'
'force://3MVG9SemV5D80oBfPBCgboxuJ9cOMLWNM1DDOZ8zgvJGsz13H3J66coUBCFF3N0zEgLYijlkqeWk4ot_Q2.4o=:438437816653243682==:5Aep861_OKMvio5gy8xCNsXxybPdupY9fVEZyeVOvb4kpOZx5Z1QLB7k7n5flEqEWKcwUQEX1I.O5DCFwjlYU==@test.my.salesforce.com'
);

expect(options.refreshToken).to.equal(
'5Aep861_OKMvio5gy8xCNsXxybPdupY9fVEZyeVOvb4kpOZx5Z1QLB7k7n5flEqEWKcwUQEX1I.O5DCFwjlYU=='
);
expect(options.clientId).to.equal('PlatformCLI');
expect(options.clientSecret).to.equal('');
expect(options.clientId).to.equal(
'3MVG9SemV5D80oBfPBCgboxuJ9cOMLWNM1DDOZ8zgvJGsz13H3J66coUBCFF3N0zEgLYijlkqeWk4ot_Q2.4o='
);
expect(options.clientSecret).to.equal('438437816653243682==');
expect(options.loginUrl).to.equal('https://test.my.salesforce.com');
});

Expand Down

0 comments on commit 2959d3f

Please sign in to comment.