Skip to content

Commit 524a8d3

Browse files
authored
Merge pull request #14281 from OfficeDev/nintan/improve-aad-create-error
fix(core): remove playground support condition
2 parents 3227169 + 0a4429b commit 524a8d3

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

packages/fx-core/src/component/driver/aad/create.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import { hooks } from "@feathersjs/hooks/lib";
55
import {
66
FxError,
77
M365TokenProvider,
8+
Result,
89
SystemError,
910
UserError,
1011
err,
1112
ok,
12-
Result,
1313
} from "@microsoft/teamsfx-api";
1414
import axios from "axios";
1515
import { Service } from "typedi";
1616
import { GraphScopes } from "../../../common/constants";
17+
import { AadSet } from "../../../common/globalVars";
1718
import { getLocalizedString } from "../../../common/localizeUtils";
19+
import { environmentNameManager } from "../../../core/environmentName";
1820
import {
1921
HttpClientError,
2022
HttpServerError,
@@ -41,9 +43,6 @@ import {
4143
questionKeys,
4244
telemetryKeys,
4345
} from "./utility/constants";
44-
import { AadSet } from "../../../common/globalVars";
45-
import { isTestToolEnabledProject } from "../../../common/tools";
46-
import { environmentNameManager } from "../../../core/environmentName";
4746

4847
const actionName = "aadApp/create"; // DO NOT MODIFY the name
4948
const helpLink = "https://aka.ms/teamsfx-actions/aadapp-create";
@@ -212,11 +211,10 @@ export class CreateAadAppDriver implements StepDriver {
212211
getLocalizedString(logMessageKeys.failExecuteDriver, actionName, message)
213212
);
214213
if (error.response!.status >= 400 && error.response!.status < 500) {
215-
// When user don't have permission to create AAD app, and cannot use Test Tool, we will ask for AAD app id and secret
214+
// When user don't have permission to create AAD app, we will ask for AAD app id and secret
216215
if (
217216
error.response!.status === 403 &&
218217
message.includes(constants.insufficientPermissionErrorMessage) &&
219-
!isTestToolEnabledProject(context.projectPath) &&
220218
process.env.TEAMSFX_ENV == environmentNameManager.getLocalEnvName()
221219
) {
222220
context.addTelemetryProperties({

packages/fx-core/tests/component/driver/script/scriptDriver.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,29 +352,30 @@ describe("getStderrHandler", () => {
352352

353353
describe("defaultShell", () => {
354354
const sandbox = sinon.createSandbox();
355-
let restoreEnv: RestoreFn = () => {};
356355
afterEach(() => {
357356
sandbox.restore();
358-
restoreEnv();
359357
});
360358
it("SHELL", async () => {
361-
restoreEnv = mockedEnv({ SHELL: "/bin/bash" });
359+
sandbox.stub(process, "env").value({ SHELL: "/bin/bash" });
362360
const result = await defaultShell();
363361
assert.equal(result, "/bin/bash");
364362
});
365363
it("darwin - /bin/zsh", async () => {
364+
sandbox.stub(process, "env").value({});
366365
sandbox.stub(process, "platform").value("darwin");
367366
sandbox.stub(fs, "pathExists").resolves(true);
368367
const result = await defaultShell();
369368
assert.equal(result, "/bin/zsh");
370369
});
371370
it("darwin - /bin/bash", async () => {
371+
sandbox.stub(process, "env").value({});
372372
sandbox.stub(process, "platform").value("darwin");
373373
sandbox.stub(fs, "pathExists").onFirstCall().resolves(false).onSecondCall().resolves(true);
374374
const result = await defaultShell();
375375
assert.equal(result, "/bin/bash");
376376
});
377377
it("darwin - undefined", async () => {
378+
sandbox.stub(process, "env").value({});
378379
sandbox.stub(process, "platform").value("darwin");
379380
sandbox.stub(fs, "pathExists").resolves(false);
380381
const result = await defaultShell();
@@ -383,25 +384,27 @@ describe("defaultShell", () => {
383384

384385
it("win32 - ComSpec", async () => {
385386
sandbox.stub(process, "platform").value("win32");
386-
restoreEnv = mockedEnv({ ComSpec: "cmd.exe" });
387+
sandbox.stub(process, "env").value({ ComSpec: "cmd.exe" });
387388
const result = await defaultShell();
388389
assert.equal(result, "cmd.exe");
389390
});
390391
it("win32 - cmd.exe", async () => {
391392
sandbox.stub(process, "platform").value("win32");
392-
restoreEnv = mockedEnv({ ComSpec: undefined });
393+
sandbox.stub(process, "env").value({});
393394
const result = await defaultShell();
394395
assert.equal(result, "cmd.exe");
395396
});
396397

397398
it("other OS - /bin/sh", async () => {
399+
sandbox.stub(process, "env").value({});
398400
sandbox.stub(process, "platform").value("other");
399401
sandbox.stub(fs, "pathExists").resolves(true);
400402
const result = await defaultShell();
401403
assert.equal(result, "/bin/sh");
402404
});
403405

404406
it("other OS - undefined", async () => {
407+
sandbox.stub(process, "env").value({});
405408
sandbox.stub(process, "platform").value("other");
406409
sandbox.stub(fs, "pathExists").resolves(false);
407410
const result = await defaultShell();

0 commit comments

Comments
 (0)