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

[v2] fix(profiles): Pass homeDir, projectDir when creating ProfileInfo instance #3170

Merged
merged 1 commit into from
Oct 3, 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
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
Loading