Skip to content

Commit

Permalink
fix: device login with instanceurl
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Dec 10, 2020
1 parent dee996e commit ebd60d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/commands/auth/device/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as os from 'os';

import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command';
import { AuthFields, DeviceOauthService, Messages, OAuth2Options } from '@salesforce/core';
import { get, Optional } from '@salesforce/ts-types';
import { Prompts } from '../../../prompts';
import { Common } from '../../../common';

Expand Down Expand Up @@ -52,7 +53,7 @@ export default class Login extends SfdxCommand {
if (await Prompts.shouldExitCommand(this.ux, this.flags.noprompt)) return {};

const oauthConfig: OAuth2Options = {
loginUrl: this.flags.instanceurl,
loginUrl: get(this.flags.instanceurl, 'href', null) as Optional<string>,
clientId: this.flags.clientid,
};

Expand Down
12 changes: 12 additions & 0 deletions test/commands/auth/device/login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ describe('auth:device:login', async () => {
expect(response.result.username).to.equal(testData.username);
});

test
.do(async () => prepareStubs())
.stdout()
.command(['auth:device:login', '-r', 'https://login.salesforce.com', '--json'])
.it('should return auth fields with instance url', (ctx) => {
const [action, response] = parseJsonResponse(ctx.stdout);
expect(action).to.deep.equal(mockAction);
expect(response.status).to.equal(0);
expect(response.result).to.deep.equal(authFields);
expect(response.result.username).to.equal(testData.username);
});

test
.do(async () => prepareStubs())
.stdout()
Expand Down

0 comments on commit ebd60d1

Please sign in to comment.