From 8011ae7364307eae0f1ba7f9646f64e834c56af3 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Tue, 13 Jun 2023 09:59:04 -0400 Subject: [PATCH 1/4] Patchwork fix to use VSCode keytar Signed-off-by: Andrew W. Harn --- packages/zowe-explorer-api/src/profiles/ProfilesCache.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/zowe-explorer-api/src/profiles/ProfilesCache.ts b/packages/zowe-explorer-api/src/profiles/ProfilesCache.ts index 857d67783f..ca57331240 100644 --- a/packages/zowe-explorer-api/src/profiles/ProfilesCache.ts +++ b/packages/zowe-explorer-api/src/profiles/ProfilesCache.ts @@ -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 = "_"; @@ -72,8 +73,10 @@ export class ProfilesCache { this.cwd = cwd != null ? getFullPath(cwd) : undefined; } - public async getProfileInfo(): Promise { - const mProfileInfo = new zowe.imperative.ProfileInfo("zowe"); + public async getProfileInfo(envTheia = false): Promise { + 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; } From bb861b108210a685ecc7e18f567d2b3336baf687 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Tue, 13 Jun 2023 10:17:40 -0400 Subject: [PATCH 2/4] Update changelog Signed-off-by: Andrew W. Harn --- packages/zowe-explorer-api/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/zowe-explorer-api/CHANGELOG.md b/packages/zowe-explorer-api/CHANGELOG.md index 0ff987e7dd..5100b35835 100644 --- a/packages/zowe-explorer-api/CHANGELOG.md +++ b/packages/zowe-explorer-api/CHANGELOG.md @@ -13,6 +13,7 @@ All notable changes to the "zowe-explorer-api" extension will be documented in t ### Bug fixes +- 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). - Fixed error shown by API when accessing the `name` and `type` property of a profile when updating the profile arrays [#2334](https://github.com/zowe/vscode-extension-for-zowe/issues/2334). ## `2.8.1` From 8b7617858c0f9353d477882d377919c02930bafa Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Thu, 15 Jun 2023 08:10:41 -0400 Subject: [PATCH 3/4] Add condition to initialization test Signed-off-by: Andrew W. Harn --- .../__tests__/__unit__/profiles/ProfilesCache.unit.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts index b7b5567805..c091c46f63 100644 --- a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts +++ b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts @@ -14,6 +14,8 @@ import * as path from "path"; import * as zowe from "@zowe/cli"; import { ProfilesCache } from "../../../src/profiles/ProfilesCache"; import { ZoweExplorerApi } from "../../../src"; +import { getSecurityModules } from "../../../src/security/KeytarCredentialManager"; +jest.mock("../../../src/security/KeytarCredentialManager"); jest.mock("fs"); jest.mock("@zowe/cli", () => { @@ -124,6 +126,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(); @@ -132,6 +135,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([ From 9652fa911418be058df1169120dbff88ae33eb7a Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Thu, 15 Jun 2023 08:44:15 -0400 Subject: [PATCH 4/4] Removed unused import Signed-off-by: Andrew W. Harn --- .../__tests__/__unit__/profiles/ProfilesCache.unit.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts index c091c46f63..ac1aa333cb 100644 --- a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts +++ b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ProfilesCache.unit.test.ts @@ -14,8 +14,6 @@ import * as path from "path"; import * as zowe from "@zowe/cli"; import { ProfilesCache } from "../../../src/profiles/ProfilesCache"; import { ZoweExplorerApi } from "../../../src"; -import { getSecurityModules } from "../../../src/security/KeytarCredentialManager"; -jest.mock("../../../src/security/KeytarCredentialManager"); jest.mock("fs"); jest.mock("@zowe/cli", () => {