diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index d5dec5dda2..9820263bc2 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### Bug fixes - Fix issue where the Zowe Explorer VS Code command `Refresh Zowe Explorer` failed catastrophically. [#3100](https://github.com/zowe/zowe-explorer-vscode/issues/3100) +- Fixed an issue where the `ProfilesUtils.getProfileInfo` function returned a new `ProfileInfo` instance that did not respect the `ZOWE_CLI_HOME` environment variable and workspace paths. [#3168](https://github.com/zowe/zowe-explorer-vscode/issues/3168) ## `2.18.0` diff --git a/packages/zowe-explorer/__tests__/__unit__/utils/ProfilesUtils.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/utils/ProfilesUtils.unit.test.ts index 88eec5a8a1..34d55863bb 100644 --- a/packages/zowe-explorer/__tests__/__unit__/utils/ProfilesUtils.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/utils/ProfilesUtils.unit.test.ts @@ -1077,4 +1077,15 @@ describe("ProfilesUtils unit tests", () => { ); }); }); + + describe("setupDefaultCredentialManager", () => { + it("calls readProfilesFromDisk with homeDir and projectDir", async () => { + const readProfilesFromDiskMock = jest.spyOn(zowe.imperative.ProfileInfo.prototype, "readProfilesFromDisk").mockImplementation(); + await profUtils.ProfilesUtils.setupDefaultCredentialManager(); + expect(readProfilesFromDiskMock).toHaveBeenCalledWith({ + homeDir: zowe.getZoweDir(), + projectDir: vscode.workspace.workspaceFolders?.[0].uri.fsPath, + }); + }); + }); }); diff --git a/packages/zowe-explorer/src/utils/ProfilesUtils.ts b/packages/zowe-explorer/src/utils/ProfilesUtils.ts index 11a94b5a39..4a7dee995e 100644 --- a/packages/zowe-explorer/src/utils/ProfilesUtils.ts +++ b/packages/zowe-explorer/src/utils/ProfilesUtils.ts @@ -371,8 +371,12 @@ export class ProfilesUtils { const profileInfo = new imperative.ProfileInfo("zowe", { credMgrOverride: defaultCredentialManager, }); + const workspaceFolder = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath; // Trigger initialize() function of credential manager to throw an error early if failed to load - await profileInfo.readProfilesFromDisk(); + await profileInfo.readProfilesFromDisk({ + homeDir: getZoweDir(), + projectDir: workspaceFolder ? getFullPath(workspaceFolder) : undefined, + }); return profileInfo; } catch (err) { if (err instanceof imperative.ProfInfoErr && err.errorCode === imperative.ProfInfoErr.LOAD_CRED_MGR_FAILED) {