Skip to content

Commit

Permalink
fix: use SF envs for container mode (#1157)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc authored Sep 23, 2024
1 parent e497d02 commit dc000ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/commands/org/login/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class LoginWeb extends SfCommand<AuthFields> {

public async run(): Promise<AuthFields> {
const { flags } = await this.parse(LoginWeb);
if (isSFDXContainerMode()) {
if (isContainerMode()) {
throw new SfError(messages.getMessage('deviceWarning'), 'DEVICE_WARNING');
}

Expand Down Expand Up @@ -121,7 +121,7 @@ export default class LoginWeb extends SfCommand<AuthFields> {
}
}

const isSFDXContainerMode = (): boolean => {
const isContainerMode = (): boolean => {
const env = new Env();
return env.getBoolean('SFDX_CONTAINER_MODE');
return env.getBoolean('SF_CONTAINER_MODE', env.getBoolean('SFDX_CONTAINER_MODE'));
};
10 changes: 10 additions & 0 deletions test/commands/org/login/login.web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ describe('org:login:web', () => {
expect(err.name).to.equal('DEVICE_WARNING');
}
});
it('should throw device warning error when in container mode (SF_CONTAINER_MODE)', async () => {
stubMethod($$.SANDBOX, Env.prototype, 'getBoolean').withArgs('SF_CONTAINER_MODE').returns(true);
const login = await createNewLoginCommand([], false, undefined);
try {
await login.run();
} catch (error) {
const err = error as SfError;
expect(err.name).to.equal('DEVICE_WARNING');
}
});

it('should prompt for client secret when clientid is present', async () => {
const login = await createNewLoginCommand(['--client-id', 'CoffeeBeans'], false, undefined);
Expand Down

0 comments on commit dc000ac

Please sign in to comment.