Skip to content

Commit

Permalink
Merge pull request #2338 from zowe/fix/extenders-api-credential-manager
Browse files Browse the repository at this point in the history
fix: Zowe Explorer API to use VSCode keytar
  • Loading branch information
zFernand0 authored Jun 20, 2023
2 parents 473774c + 43678a2 commit 0349fb6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t
### New features and enhancements

- Added optional `profile` parameter to `IPromptCredentialsOptions` so developers can choose to skip rebuilding the profile with ProfilesCache.
- Fixed error when an extender's extension attempts to access the keyring in a remote VSCode session [#324](https://github.com/zowe/vscode-extension-for-cics/issues/324).

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe("ProfilesCache", () => {
const fakeLogger = { debug: jest.fn() };
const fakeZoweDir = zowe.getZoweDir();
const readProfilesFromDiskSpy = jest.spyOn(zowe.imperative.ProfileInfo.prototype, "readProfilesFromDisk");
const defaultCredMgrWithKeytarSpy = jest.spyOn(zowe.imperative.ProfileCredentials, "defaultCredMgrWithKeytar");

afterEach(() => {
jest.clearAllMocks();
Expand All @@ -132,6 +133,7 @@ describe("ProfilesCache", () => {
it("getProfileInfo should initialize ProfileInfo API", async () => {
const profInfo = await new ProfilesCache(fakeLogger as unknown as zowe.imperative.Logger, __dirname).getProfileInfo();
expect(readProfilesFromDiskSpy).toHaveBeenCalledTimes(1);
expect(defaultCredMgrWithKeytarSpy).toHaveBeenCalledTimes(1);
const teamConfig = profInfo.getTeamConfig();
expect(teamConfig.appName).toBe("zowe");
expect(teamConfig.paths).toEqual([
Expand Down
7 changes: 5 additions & 2 deletions packages/zowe-explorer-api/src/profiles/ProfilesCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { URL } from "url";

import * as zowe from "@zowe/cli";
import { ZoweExplorerApi } from "./ZoweExplorerApi";
import { getSecurityModules } from "../security";

// TODO: find a home for constants
export const CONTEXT_PREFIX = "_";
Expand Down Expand Up @@ -72,8 +73,10 @@ export class ProfilesCache {
this.cwd = cwd != null ? getFullPath(cwd) : undefined;
}

public async getProfileInfo(): Promise<zowe.imperative.ProfileInfo> {
const mProfileInfo = new zowe.imperative.ProfileInfo("zowe");
public async getProfileInfo(envTheia = false): Promise<zowe.imperative.ProfileInfo> {
const mProfileInfo = new zowe.imperative.ProfileInfo("zowe", {
credMgrOverride: zowe.imperative.ProfileCredentials.defaultCredMgrWithKeytar(() => getSecurityModules("keytar", envTheia)),
});
await mProfileInfo.readProfilesFromDisk({ homeDir: getZoweDir(), projectDir: this.cwd ?? undefined });
return mProfileInfo;
}
Expand Down

0 comments on commit 0349fb6

Please sign in to comment.