Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use SF envs for container mode #1157

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading