From 5f09cb021cf56e9c65919612451d322144f5e05b Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Fri, 31 Jan 2025 09:42:45 -0500 Subject: [PATCH 1/5] fix: check for valid session before calling proxy setup fn Signed-off-by: Trae Yelovich --- .../zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts b/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts index e71dbcecd4..2aa8285d74 100644 --- a/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts +++ b/packages/zowe-explorer-api/src/profiles/ZoweExplorerZosmfApi.ts @@ -29,7 +29,7 @@ export namespace ZoweExplorerZosmf { /** * An implementation of the Zowe Explorer API Common interface for zOSMF. */ - class CommonApi implements MainframeInteraction.ICommon { + export class CommonApi implements MainframeInteraction.ICommon { public static getProfileTypeName(): string { return zosmf.ZosmfProfile.type; } @@ -55,7 +55,7 @@ export namespace ZoweExplorerZosmf { // todo: initialize and use logging imperative.Logger.getAppLogger().error(error as string); } - return ProfilesCache.getProfileSessionWithVscProxy(this.session); + return this.session ? ProfilesCache.getProfileSessionWithVscProxy(this.session) : undefined; } private _getSession(serviceProfile: imperative.IProfileLoaded): imperative.Session { From 2c5bc2d27a7dc1c3135d61512a4484220b0d6852 Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Fri, 31 Jan 2025 09:44:38 -0500 Subject: [PATCH 2/5] tests: CommonApi.getSession, reuse fake profile in other test Signed-off-by: Trae Yelovich --- .../ZoweExplorerZosmfApi.unit.test.ts | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts index 6a9f113f21..5ee1654a5c 100644 --- a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts +++ b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts @@ -90,37 +90,43 @@ async function expectApiWithSession({ name, spy, args, transform }: ITestApi< expect(spy).toHaveBeenCalledWith(fakeSession, ...params); } +describe("CommonApi", () => { + describe("getSession", () => { + it("returns undefined and does not throw error if the session was not created", () => { + const api = new ZoweExplorerZosmf.CommonApi(); + let session: imperative.Session; + expect(() => (session = api.getSession())).not.toThrow(); + expect(session).toBe(undefined); + }); + it("returns a built session from _getSession and does not throw error", () => { + const api = new ZoweExplorerZosmf.CommonApi(loadedProfile); + let session: imperative.Session; + const _getSessionSpy = jest.spyOn(api as any, "_getSession"); + expect(() => (session = api.getSession())).not.toThrow(); + expect(_getSessionSpy).toHaveBeenCalledTimes(1); + expect(session).not.toBeUndefined(); + }); + }); +}); + describe("ZosmfUssApi", () => { afterEach(() => { jest.clearAllMocks(); }); describe("_getSession", () => { - const exampleProfile = { - message: "", - type: "zosmf", - failNotFound: false, - name: "test.zosmf", - profile: { - host: "localhost", - password: "password", - protocol: "http", - user: "aZosmfUser", - ...fakeProperties, - }, - } as imperative.IProfileLoaded; - const exampleSession = imperative.Session.createFromUrl(new URL("http://localhost")); - exampleSession.ISession.password = exampleProfile.profile?.password; - exampleSession.ISession.user = exampleProfile.profile?.user; + const exampleSession = Object.assign(Object.create(Object.getPrototypeOf(fakeSession)), fakeSession); + exampleSession.ISession.password = loadedProfile.profile?.password; + exampleSession.ISession.user = loadedProfile.profile?.user; jest.spyOn(ProfilesCache, "getProfileSessionWithVscProxy").mockReturnValueOnce(exampleSession as any); it("should include profile properties in the built session object", () => { const api = new ZoweExplorerZosmf.UssApi(loadedProfile); - const transformedProps: Record = { ...exampleProfile.profile, hostname: exampleProfile.profile?.host, ...fakeProperties }; + const transformedProps: Record = { ...loadedProfile.profile, hostname: loadedProfile.profile?.host, ...fakeProperties }; delete transformedProps["host"]; delete transformedProps["responseTimeout"]; - expect((api as any)._getSession(exampleProfile).mISession).toMatchObject(transformedProps); + expect((api as any)._getSession(loadedProfile).mISession).toMatchObject(transformedProps); }); }); From 395a02f1af6ab8ca58f9732dc70fb7d05ee6a88a Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Fri, 31 Jan 2025 09:50:07 -0500 Subject: [PATCH 3/5] chore: update ZE changelog Signed-off-by: Trae Yelovich --- packages/zowe-explorer/CHANGELOG.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index 9c51f67e25..0d5b8c609b 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -6,6 +6,17 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### New features and enhancements +- Added Time Started, Time Ended, and Time Submitted job properties to the Jobs table view. [#3055](https://github.com/zowe/zowe-explorer-vscode/issues/3055) +- Implemented copy/paste functionality of data sets within and across LPARs. [#3012](https://github.com/zowe/zowe-explorer-vscode/issues/3012) + +### Bug fixes + +- Fixed an issue where a TypeError occurred when applying VS Code proxy settings to an invalid session. [#3425](https://github.com/zowe/zowe-explorer-vscode/issues/3425) + +## `3.1.0` + +### New features and enhancements + - Updated Zowe SDKs to `8.10.4` for technical currency. [#3306](https://github.com/zowe/zowe-explorer-vscode/pull/3306) - Added expired JSON web token detection for profiles in each tree view (Data Sets, USS, Jobs). When a user performs a search on a profile, they are prompted to log in if their token expired. [#3175](https://github.com/zowe/zowe-explorer-vscode/issues/3175) - Added integrated terminals for z/OS Unix, TSO, and MVS commands which can be enabled via the `Zowe › Commands: Use Integrated Terminals` setting. [#3079](https://github.com/zowe/zowe-explorer-vscode/pull/3079) @@ -19,8 +30,6 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen - You can now add multiple partitioned data sets or USS directories to your workspace at once using the "Add to Workspace" feature. [#3324](https://github.com/zowe/zowe-explorer-vscode/issues/3324) - Exposed read and write access to local storage keys for Zowe Explorer extenders. [#3180](https://github.com/zowe/zowe-explorer-vscode/issues/3180) - Added `Open with Encoding` to the context menu of Job Spool files. [#1941](https://github.com/zowe/zowe-explorer-vscode/issues/1941) -- Added Time Started, Time Ended, and Time Submitted job properties to the Jobs table view. [#3055](https://github.com/zowe/zowe-explorer-vscode/issues/3055) -- Implemented copy/paste functionality of data sets within and across LPARs. [#3012](https://github.com/zowe/zowe-explorer-vscode/issues/3012) ### Bug fixes From d0bc378e028db1435aa6f99ba9c1338a6297a423 Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Fri, 31 Jan 2025 09:58:24 -0500 Subject: [PATCH 4/5] fix: correct expected value in createZoweSchema test Signed-off-by: Trae Yelovich --- .../__tests__/__unit__/configuration/Profiles.unit.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/configuration/Profiles.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/configuration/Profiles.unit.test.ts index edd40750f2..687d4a501d 100644 --- a/packages/zowe-explorer/__tests__/__unit__/configuration/Profiles.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/configuration/Profiles.unit.test.ts @@ -621,10 +621,8 @@ describe("Profiles Unit Tests - Function createZoweSchema", () => { }); jest.spyOn(globalMocks.mockProfileInstance, "createNonSecureProfile").mockImplementation(); - const expectedValue = - process.platform === "win32" - ? "file:\\globalPath\\.zowe\\zowe.config.json" - : "file:/globalPath/.zowe/zowe.config.json".split(path.sep).join(path.posix.sep); + + const expectedValue = path.join("file:", "globalPath", ".zowe", "zowe.config.json"); const spyConfig = jest.spyOn(Profiles.getInstance(), "openConfigFile").mockImplementation(); await Profiles.getInstance().createZoweSchema(blockMocks.testDatasetTree); From 3e832ecd1b3bafe3b95526096ed3fe1254e18d7d Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Fri, 31 Jan 2025 11:33:29 -0500 Subject: [PATCH 5/5] lint: resolve lint error in test code Signed-off-by: Trae Yelovich --- .../__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts index 5ee1654a5c..4df0e17aed 100644 --- a/packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts +++ b/packages/zowe-explorer-api/__tests__/__unit__/profiles/ZoweExplorerZosmfApi.unit.test.ts @@ -118,7 +118,7 @@ describe("ZosmfUssApi", () => { const exampleSession = Object.assign(Object.create(Object.getPrototypeOf(fakeSession)), fakeSession); exampleSession.ISession.password = loadedProfile.profile?.password; exampleSession.ISession.user = loadedProfile.profile?.user; - jest.spyOn(ProfilesCache, "getProfileSessionWithVscProxy").mockReturnValueOnce(exampleSession as any); + jest.spyOn(ProfilesCache, "getProfileSessionWithVscProxy").mockReturnValueOnce(exampleSession); it("should include profile properties in the built session object", () => { const api = new ZoweExplorerZosmf.UssApi(loadedProfile);