Skip to content

Commit

Permalink
fix(v2): Pass homeDir and projectDir to ProfileInfo (#3170)
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok authored Oct 3, 2024
1 parent 1a5ac1f commit d090118
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
});
});
});
6 changes: 5 additions & 1 deletion packages/zowe-explorer/src/utils/ProfilesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d090118

Please sign in to comment.