diff --git a/__tests__/__packages__/cli-test-utils/package.json b/__tests__/__packages__/cli-test-utils/package.json index 955e3b2ebc..e9f85b05d8 100644 --- a/__tests__/__packages__/cli-test-utils/package.json +++ b/__tests__/__packages__/cli-test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cli-test-utils", - "version": "8.8.3", + "version": "8.10.0", "description": "Test utilities package for Zowe CLI plug-ins", "author": "Zowe", "license": "EPL-2.0", @@ -43,7 +43,7 @@ "devDependencies": { "@types/js-yaml": "^4.0.9", "@types/uuid": "^10.0.0", - "@zowe/imperative": "8.8.3" + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" diff --git a/lerna.json b/lerna.json index 8d7b46ef3a..20d40cb3b5 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "8.9.1", + "version": "8.10.0", "command": { "publish": { "ignoreChanges": [ diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 2579acc821..486f42b2ad 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -52,7 +52,7 @@ }, "__tests__/__packages__/cli-test-utils": { "name": "@zowe/cli-test-utils", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { "find-up": "^5.0.0", @@ -63,7 +63,7 @@ "devDependencies": { "@types/js-yaml": "^4.0.9", "@types/uuid": "^10.0.0", - "@zowe/imperative": "8.8.3" + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" @@ -16269,21 +16269,21 @@ }, "packages/cli": { "name": "@zowe/cli", - "version": "8.9.1", + "version": "8.10.0", "hasInstallScript": true, "license": "EPL-2.0", "dependencies": { - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3", - "@zowe/provisioning-for-zowe-sdk": "8.8.3", - "@zowe/zos-console-for-zowe-sdk": "8.8.3", - "@zowe/zos-files-for-zowe-sdk": "8.9.1", - "@zowe/zos-jobs-for-zowe-sdk": "8.9.1", - "@zowe/zos-logs-for-zowe-sdk": "8.8.3", - "@zowe/zos-tso-for-zowe-sdk": "8.8.3", - "@zowe/zos-uss-for-zowe-sdk": "8.8.3", - "@zowe/zos-workflows-for-zowe-sdk": "8.9.1", - "@zowe/zosmf-for-zowe-sdk": "8.8.3", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0", + "@zowe/provisioning-for-zowe-sdk": "8.10.0", + "@zowe/zos-console-for-zowe-sdk": "8.10.0", + "@zowe/zos-files-for-zowe-sdk": "8.10.0", + "@zowe/zos-jobs-for-zowe-sdk": "8.10.0", + "@zowe/zos-logs-for-zowe-sdk": "8.10.0", + "@zowe/zos-tso-for-zowe-sdk": "8.10.0", + "@zowe/zos-uss-for-zowe-sdk": "8.10.0", + "@zowe/zos-workflows-for-zowe-sdk": "8.10.0", + "@zowe/zosmf-for-zowe-sdk": "8.10.0", "find-process": "1.4.7", "lodash": "4.17.21", "minimatch": "9.0.5", @@ -16296,7 +16296,7 @@ "@types/diff": "^5.0.9", "@types/lodash": "^4.17.6", "@types/tar": "^6.1.11", - "@zowe/cli-test-utils": "8.8.3", + "@zowe/cli-test-utils": "8.10.0", "comment-json": "^4.2.3", "strip-ansi": "^6.0.1", "which": "^4.0.0" @@ -16352,15 +16352,15 @@ }, "packages/core": { "name": "@zowe/core-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { "comment-json": "~4.2.3", "string-width": "^4.2.3" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16371,7 +16371,7 @@ }, "packages/imperative": { "name": "@zowe/imperative", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { "@types/yargs": "^17.0.32", @@ -16565,16 +16565,16 @@ }, "packages/provisioning": { "name": "@zowe/provisioning-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { "js-yaml": "^4.1.0" }, "devDependencies": { "@types/js-yaml": "^4.0.9", - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16599,15 +16599,15 @@ }, "packages/workflows": { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.9.1", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.9.1" + "@zowe/zos-files-for-zowe-sdk": "8.10.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16619,12 +16619,12 @@ }, "packages/zosconsole": { "name": "@zowe/zos-console-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16636,17 +16636,17 @@ }, "packages/zosfiles": { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.9.1", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { "lodash": "^4.17.21", "minimatch": "^9.0.5" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3", - "@zowe/zos-uss-for-zowe-sdk": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0", + "@zowe/zos-uss-for-zowe-sdk": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16678,15 +16678,15 @@ }, "packages/zosjobs": { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.9.1", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.9.1" + "@zowe/zos-files-for-zowe-sdk": "8.10.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16698,12 +16698,12 @@ }, "packages/zoslogs": { "name": "@zowe/zos-logs-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16715,12 +16715,12 @@ }, "packages/zosmf": { "name": "@zowe/zosmf-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16732,15 +16732,15 @@ }, "packages/zostso": { "name": "@zowe/zos-tso-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { - "@zowe/zosmf-for-zowe-sdk": "8.8.3" + "@zowe/zosmf-for-zowe-sdk": "8.10.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" @@ -16752,15 +16752,15 @@ }, "packages/zosuss": { "name": "@zowe/zos-uss-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "license": "EPL-2.0", "dependencies": { "ssh2": "^1.15.0" }, "devDependencies": { "@types/ssh2": "^1.11.19", - "@zowe/cli-test-utils": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/imperative": "8.10.0" }, "engines": { "node": ">=18.12.0" diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 979fb828ea..0533d487e2 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,7 +1,7 @@ # Change Log All notable changes to the Zowe CLI package will be documented in this file. -## Recent Changes +## `8.10.0` -Enhancement: The `zowe zos-files copy data-set` command now copies members from a source partitioned data set to an existing target partitioned data set.[#2386](https://github.com/zowe/zowe-cli/pull/2386) ## `8.9.0` diff --git a/packages/cli/package.json b/packages/cli/package.json index 8e49ec1c10..6f4a7fec69 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cli", - "version": "8.9.1", + "version": "8.10.0", "zoweVersion": "v3.0.0", "description": "Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.", "author": "Zowe", @@ -58,17 +58,17 @@ "preshrinkwrap": "node ../../scripts/rewriteShrinkwrap.js" }, "dependencies": { - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3", - "@zowe/provisioning-for-zowe-sdk": "8.8.3", - "@zowe/zos-console-for-zowe-sdk": "8.8.3", - "@zowe/zos-files-for-zowe-sdk": "8.9.1", - "@zowe/zos-jobs-for-zowe-sdk": "8.9.1", - "@zowe/zos-logs-for-zowe-sdk": "8.8.3", - "@zowe/zos-tso-for-zowe-sdk": "8.8.3", - "@zowe/zos-uss-for-zowe-sdk": "8.8.3", - "@zowe/zos-workflows-for-zowe-sdk": "8.9.1", - "@zowe/zosmf-for-zowe-sdk": "8.8.3", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0", + "@zowe/provisioning-for-zowe-sdk": "8.10.0", + "@zowe/zos-console-for-zowe-sdk": "8.10.0", + "@zowe/zos-files-for-zowe-sdk": "8.10.0", + "@zowe/zos-jobs-for-zowe-sdk": "8.10.0", + "@zowe/zos-logs-for-zowe-sdk": "8.10.0", + "@zowe/zos-tso-for-zowe-sdk": "8.10.0", + "@zowe/zos-uss-for-zowe-sdk": "8.10.0", + "@zowe/zos-workflows-for-zowe-sdk": "8.10.0", + "@zowe/zosmf-for-zowe-sdk": "8.10.0", "find-process": "1.4.7", "lodash": "4.17.21", "minimatch": "9.0.5", @@ -78,7 +78,7 @@ "@types/diff": "^5.0.9", "@types/lodash": "^4.17.6", "@types/tar": "^6.1.11", - "@zowe/cli-test-utils": "8.8.3", + "@zowe/cli-test-utils": "8.10.0", "comment-json": "^4.2.3", "strip-ansi": "^6.0.1", "which": "^4.0.0" diff --git a/packages/core/package.json b/packages/core/package.json index abc273e430..bd4db2f727 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/core-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "description": "Core libraries shared by Zowe SDK packages", "author": "Zowe", "license": "EPL-2.0", @@ -49,8 +49,8 @@ "string-width": "^4.2.3" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 8531bdc5ca..31d5b27ac3 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,10 +2,16 @@ All notable changes to the Imperative package will be documented in this file. + ## Recent Changes - BugFix: Resolved an issue where base profiles in a team configuration file were overwritten when a user configuration file did not include a base profile. [#2383](https://github.com/zowe/zowe-cli/pull/2383) +## `8.10.0` + +- BugFix: Modified location of Proxy-Authorization header to be located in the agent instead of the request. [#2389](https://github.com/zowe/zowe-cli/issues/2389) + + ## `8.8.3` - BugFix: Modified 8.8.2 bugfix to correct web help alias. [#2361](https://github.com/zowe/zowe-cli/pull/2361) diff --git a/packages/imperative/package.json b/packages/imperative/package.json index 6b197330b6..addb75bd41 100644 --- a/packages/imperative/package.json +++ b/packages/imperative/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/imperative", - "version": "8.8.3", + "version": "8.10.0", "description": "framework for building configurable CLIs", "author": "Zowe", "license": "EPL-2.0", diff --git a/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts b/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts index fcd7669552..98005ccff5 100644 --- a/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts +++ b/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts @@ -1502,22 +1502,6 @@ describe("AbstractRestClient tests", () => { const result = privateRestClient.buildOptions(resource, request, reqHeaders); expect(Object.keys(result)).toContain('agent'); }); - - it('Should use session proxy options over env vars for proxy agent', () => { - restSession.ISession.proxy = { proxy_authorization: 'proxy_auth_string'}; - const resource = '/resource'; - const request = ''; - const reqHeaders: any[] = []; - const url = new URL('https://www.zowe.com'); - const proxyAgent = new HttpsProxyAgent(url, { rejectUnauthorized: true }); - getSystemProxyUrlSpy.mockReturnValue(url); - getProxyAgentSpy.mockReturnValue(proxyAgent); - setCertPemAuthSpy.mockReturnValue(true); - const headerSpy = jest.spyOn(privateRestClient, "appendHeaders"); - const result = privateRestClient.buildOptions(resource, request, reqHeaders); - expect(Object.keys(result)).toContain('agent'); - expect(headerSpy).toHaveBeenCalledWith([{'Proxy-Authorization': restSession.ISession.proxy.proxy_authorization}]); - }); }); }); }); diff --git a/packages/imperative/src/rest/__tests__/client/ProxySettings.unit.test.ts b/packages/imperative/src/rest/__tests__/client/ProxySettings.unit.test.ts index 952b9e298f..f6ff5aac4c 100644 --- a/packages/imperative/src/rest/__tests__/client/ProxySettings.unit.test.ts +++ b/packages/imperative/src/rest/__tests__/client/ProxySettings.unit.test.ts @@ -23,7 +23,7 @@ describe("Proxy tests", () => { const session = { hostname: "fake.com", port: 443, - rejectUnauthorized: false + rejectUnauthorized: false, } as ISession; const privateProxy = ProxySettings as any; const httpUrl = "http://www.zowe.com"; @@ -31,7 +31,9 @@ describe("Proxy tests", () => { const noProxyList = "www.zowe.com, fake.com,ibm.com,broadcom.com "; const passedUrl = "passedurl.com"; let getProxySettingsSpy: jest.SpyInstance; + let getProxyAuthSettingSpy: jest.SpyInstance; let checkUrlSpy: jest.SpyInstance; + let matchesNoProxySettingsSpy: jest.SpyInstance; describe("recognise passed proxy values in session", () => { const noProxySpy = jest.spyOn(privateProxy, "matchesNoProxySettings"); @@ -40,7 +42,7 @@ describe("Proxy tests", () => { checkUrlSpy = jest.spyOn(privateProxy, "checkUrl"); const expected = { proxyUrl: passedUrl, - protocol: HTTPS_PROTOCOL + protocol: HTTPS_PROTOCOL, }; beforeEach(() => { @@ -55,7 +57,9 @@ describe("Proxy tests", () => { expect(httpEnvVarSpy).not.toHaveBeenCalled(); expect(httpsEnvVarSpy).not.toHaveBeenCalled(); checkUrlSpy.mockReturnValueOnce(passedUrl); - expect(JSON.stringify(ProxySettings["getProxySettings"](session))).toEqual(JSON.stringify(expected)); + expect( + JSON.stringify(ProxySettings["getProxySettings"](session)) + ).toEqual(JSON.stringify(expected)); noProxySpy.mockClear(); checkUrlSpy.mockClear(); }); @@ -67,34 +71,89 @@ describe("Proxy tests", () => { expect(httpEnvVarSpy).not.toHaveBeenCalled(); expect(httpsEnvVarSpy).not.toHaveBeenCalled(); checkUrlSpy.mockReturnValueOnce(passedUrl); - expect(JSON.stringify(ProxySettings["getProxySettings"](session))).toEqual(JSON.stringify(expected)); + expect( + JSON.stringify(ProxySettings["getProxySettings"](session)) + ).toEqual(JSON.stringify(expected)); noProxySpy.mockClear(); checkUrlSpy.mockClear(); }); }); describe("getProxyAgent", () => { + const headers = { + "Proxy-Authorization": "Basic ==ThisIsATest123", + }; + beforeEach(() => { jest.clearAllMocks(); + jest.restoreAllMocks(); + jest.resetModules(); + jest.resetAllMocks(); getProxySettingsSpy = jest.spyOn(privateProxy, "getProxySettings"); + getProxyAuthSettingSpy = jest.spyOn( + privateProxy, + "getProxyAuthHeader" + ); }); it("Should retrieve the HTTP proxy agent", () => { - const expected = new HttpProxyAgent(httpUrl); + const expected = new HttpProxyAgent(httpUrl, { headers }); getProxySettingsSpy.mockReturnValue({ proxyUrl: httpUrl, - protocol: HTTP_PROTOCOL + protocol: HTTP_PROTOCOL, }); - expect(JSON.stringify(ProxySettings.getProxyAgent(session))).toEqual(JSON.stringify(expected)); + getProxyAuthSettingSpy.mockReturnValue(headers); + expect( + JSON.stringify(ProxySettings.getProxyAgent(session)) + ).toEqual(JSON.stringify(expected)); }); it("Should retrieve the HTTPS proxy agent", () => { - const expected = new HttpsProxyAgent(httpsUrl, { rejectUnauthorized: false }); + const expected = new HttpsProxyAgent(httpsUrl, { + rejectUnauthorized: false, + }); getProxySettingsSpy.mockReturnValue({ proxyUrl: httpsUrl, - protocol: HTTPS_PROTOCOL + protocol: HTTPS_PROTOCOL, }); - expect(JSON.stringify(ProxySettings.getProxyAgent(session))).toEqual(JSON.stringify(expected)); + expect( + JSON.stringify(ProxySettings.getProxyAgent(session)) + ).toEqual(JSON.stringify(expected)); + }); + + it("Should return undefined when a protocol is not defined in the session", () => { + const noProtocolSession = { ...session }; + noProtocolSession.protocol = undefined; + expect(ProxySettings.getProxyAgent(session)).toEqual(undefined); + }); + }); + + describe("getProxyAuthHeader", () => { + beforeEach(() => { + jest.clearAllMocks(); + jest.restoreAllMocks(); + jest.resetModules(); + jest.resetAllMocks(); + }); + + it("Should retrieve the auth header from the proxy settings", () => { + const proxyAuthSetting = "Basic ==ThisIsATest123"; + expect( + ProxySettings["getProxyAuthHeader"]({ + authSetting: proxyAuthSetting, + proxyUrl: new URL("https://www.google.com/"), + protocol: HTTPS_PROTOCOL, + }) + ).toEqual({ "Proxy-Authorization": proxyAuthSetting }); + }); + + it("Should return undefined if the proxy auth setting is not in the proxy settings", () => { + expect( + ProxySettings["getProxyAuthHeader"]({ + proxyUrl: new URL("https://www.google.com/"), + protocol: HTTPS_PROTOCOL, + }) + ).toEqual(undefined); }); }); @@ -107,7 +166,7 @@ describe("Proxy tests", () => { it("Should retrieve the system proxy URL", () => { getProxySettingsSpy.mockReturnValue({ proxyUrl: httpsUrl, - protocol: HTTPS_PROTOCOL + protocol: HTTPS_PROTOCOL, }); expect(ProxySettings.getSystemProxyUrl(session)).toEqual(httpsUrl); }); @@ -116,16 +175,36 @@ describe("Proxy tests", () => { describe("getProxySettings", () => { beforeEach(() => { jest.clearAllMocks(); + jest.restoreAllMocks(); + jest.resetModules(); + jest.resetAllMocks(); checkUrlSpy = jest.spyOn(privateProxy, "checkUrl"); + matchesNoProxySettingsSpy = jest.spyOn( + privateProxy, + "matchesNoProxySettings" + ); }); it("Should return proxy settings from session", () => { const expected = { proxyUrl: httpsUrl, - protocol: HTTPS_PROTOCOL + protocol: HTTPS_PROTOCOL, + authSetting: "Basic ==ThisIsATest123", }; checkUrlSpy.mockReturnValue(httpsUrl); - expect(ProxySettings["getProxySettings"](session)).toEqual(expected); + session.proxy = { + proxy_authorization: "Basic ==ThisIsATest123", + }; + expect(ProxySettings["getProxySettings"](session)).toEqual( + expected + ); + }); + + it("Should return undefined proxy url matchesNoProxySettings", () => { + matchesNoProxySettingsSpy.mockReturnValue(true); + expect(ProxySettings["getProxySettings"](session)).toEqual( + undefined + ); }); }); @@ -143,28 +222,46 @@ describe("Proxy tests", () => { }); describe("matchesNoProxySettings", () => { - it("Should match session hostname with no_proxy", () => { + beforeEach(() => { + jest.clearAllMocks(); + jest.restoreAllMocks(); + jest.resetModules(); + jest.resetAllMocks(); + }); + + it("Should match session hostname with no_proxy", () => { const expected = true; process.env["NO_PROXY"] = noProxyList; - expect(ProxySettings["matchesNoProxySettings"](session)).toEqual(expected); + expect(ProxySettings["matchesNoProxySettings"](session)).toEqual( + expected + ); process.env["NO_PROXY"] = undefined; }); it("Should return true for match with no_proxy passed with session proxy", () => { session.proxy = { http_proxy: passedUrl, no_proxy: ["fake.com"] }; session.protocol = HTTP_PROTOCOL; - expect(ProxySettings["matchesNoProxySettings"](session)).toEqual(true); + expect(ProxySettings["matchesNoProxySettings"](session)).toEqual( + true + ); }); - it("Should not match session hostname with no_proxy", () => { + it("Should not match session hostname with no_proxy", () => { const expected = false; process.env["NO_PROXY"] = noProxyList; session.hostname = "microsoft.com"; - expect(ProxySettings["matchesNoProxySettings"](session)).toEqual(expected); + expect(ProxySettings["matchesNoProxySettings"](session)).toEqual( + expected + ); process.env["NO_PROXY"] = undefined; }); it("Should return false for match with no_proxy passed with session proxy", () => { - session.proxy = { http_proxy: passedUrl, no_proxy: ["false.com", "blah.com"] }; + session.proxy = { + http_proxy: passedUrl, + no_proxy: ["false.com", "blah.com"], + }; session.protocol = HTTP_PROTOCOL; - expect(ProxySettings["matchesNoProxySettings"](session)).toEqual(false); + expect(ProxySettings["matchesNoProxySettings"](session)).toEqual( + false + ); }); }); }); diff --git a/packages/imperative/src/rest/src/client/AbstractRestClient.ts b/packages/imperative/src/rest/src/client/AbstractRestClient.ts index 9da363a5cd..c4f908709c 100644 --- a/packages/imperative/src/rest/src/client/AbstractRestClient.ts +++ b/packages/imperative/src/rest/src/client/AbstractRestClient.ts @@ -476,9 +476,6 @@ export abstract class AbstractRestClient { this.mLogger.info(`Proxy setting "${proxyUrl.href}" will not be used as hostname was found listed under "no_proxy" setting.`); } else { this.mLogger.info(`Using the following proxy setting for the request: ${proxyUrl.href}`); - if (this.session.ISession.proxy?.proxy_authorization) { - reqHeaders.push({ 'Proxy-Authorization': this.session.ISession.proxy.proxy_authorization}); - } options.agent = ProxySettings.getProxyAgent(this.session.ISession); } } diff --git a/packages/imperative/src/rest/src/client/ProxySettings.ts b/packages/imperative/src/rest/src/client/ProxySettings.ts index c414003a64..56b8438d3f 100644 --- a/packages/imperative/src/rest/src/client/ProxySettings.ts +++ b/packages/imperative/src/rest/src/client/ProxySettings.ts @@ -9,14 +9,18 @@ * */ -import { env } from 'process'; -import { URL } from 'url'; -import { Agent } from 'https'; -import { HttpProxyAgent } from 'http-proxy-agent'; -import { HttpsProxyAgent } from 'https-proxy-agent'; +import { env } from "process"; +import { URL } from "url"; +import { Agent } from "https"; +import { HttpProxyAgent } from "http-proxy-agent"; +import { HttpsProxyAgent } from "https-proxy-agent"; -import { HTTP_PROTOCOL_CHOICES, HTTP_PROTOCOL, HTTPS_PROTOCOL } from '../session/SessConstants'; -import { ISession } from '../session/doc/ISession'; +import { + HTTP_PROTOCOL_CHOICES, + HTTP_PROTOCOL, + HTTPS_PROTOCOL, +} from "../session/SessConstants"; +import { ISession } from "../session/doc/ISession"; /** * Utility class to provide an http agent to REST APIs that is configured for @@ -33,7 +37,6 @@ import { ISession } from '../session/doc/ISession'; * to match with the hostname of the Zowe profile. */ export class ProxySettings { - /** * Retrieve an appropriate http.agent instance if proxy environment variables can be found. * @static @@ -45,12 +48,21 @@ export class ProxySettings { */ public static getProxyAgent(session: ISession): Agent | undefined { const proxySetting = this.getProxySettings(session); - if (proxySetting?.protocol === HTTP_PROTOCOL) { - return new HttpProxyAgent(proxySetting.proxyUrl); + const proxyOptions = {} as ProxyOptions; + const authHeader = ProxySettings.getProxyAuthHeader(proxySetting); + if (authHeader) { + proxyOptions.headers = authHeader; + } + if (!proxySetting?.protocol) { + return; } - if (proxySetting?.protocol === HTTPS_PROTOCOL) { - return new HttpsProxyAgent(proxySetting.proxyUrl, - { rejectUnauthorized: session.rejectUnauthorized ?? true }); + if (proxySetting.protocol === HTTP_PROTOCOL) { + return new HttpProxyAgent(proxySetting.proxyUrl, proxyOptions); + } + if (proxySetting.protocol === HTTPS_PROTOCOL) { + proxyOptions.rejectUnauthorized = + session.rejectUnauthorized ?? true; + return new HttpsProxyAgent(proxySetting.proxyUrl, proxyOptions); } } @@ -78,7 +90,8 @@ export class ProxySettings { * @memberof ProxySettings */ public static matchesNoProxySettings(session: ISession): boolean { - const noProxyValues = session.proxy?.no_proxy ?? this.getNoProxyEnvVariables(); + const noProxyValues = + session.proxy?.no_proxy ?? this.getNoProxyEnvVariables(); if (!noProxyValues) { return false; } @@ -88,6 +101,14 @@ export class ProxySettings { return false; } + private static getProxyAuthHeader( + proxySetting: ProxySetting + ): { [key: string]: string } | undefined { + return proxySetting?.authSetting + ? { "Proxy-Authorization": proxySetting.authSetting } + : undefined; + } + /** * Parses environment variables for proxy servers. * @private @@ -96,21 +117,29 @@ export class ProxySettings { * @returns instance of private `ProxySetting` or `undefined` * @memberof ProxySettings */ - private static getProxySettings(session: ISession): ProxySetting | undefined { + private static getProxySettings( + session: ISession + ): ProxySetting | undefined { if (this.matchesNoProxySettings(session)) { return; } const protocol = session.protocol ?? HTTPS_PROTOCOL; let envVariable: string | undefined; if (protocol === HTTP_PROTOCOL) { - envVariable = session.proxy?.http_proxy ?? this.getHttpEnvVariables(); - } - else if (protocol === HTTPS_PROTOCOL) { - envVariable = session.proxy?.https_proxy ?? this.getHttpsEnvVariables(); + envVariable = + session.proxy?.http_proxy ?? this.getHttpEnvVariables(); + } else if (protocol === HTTPS_PROTOCOL) { + envVariable = + session.proxy?.https_proxy ?? this.getHttpsEnvVariables(); } const proxyUrl = this.checkUrl(envVariable); + + const authSetting = session.proxy?.proxy_authorization; + if (authSetting) { + return { proxyUrl, protocol, authSetting }; + } if (proxyUrl) { - return {proxyUrl, protocol}; + return { proxyUrl, protocol }; } } @@ -149,7 +178,9 @@ export class ProxySettings { if (!noProxyValue) { return; } - return noProxyValue.split(',').map(entry => entry.trim().toLocaleLowerCase()); + return noProxyValue + .split(",") + .map((entry) => entry.trim().toLocaleLowerCase()); } /** @@ -173,6 +204,12 @@ export class ProxySettings { * Internal interface to group proxy settings */ interface ProxySetting { - proxyUrl: URL, - protocol: HTTP_PROTOCOL_CHOICES + proxyUrl: URL; + protocol: HTTP_PROTOCOL_CHOICES; + authSetting?: string; +} + +interface ProxyOptions { + headers?: { [key: string]: string }; + rejectUnauthorized?: boolean; } diff --git a/packages/provisioning/package.json b/packages/provisioning/package.json index 74ba89c9c2..2453327ebf 100644 --- a/packages/provisioning/package.json +++ b/packages/provisioning/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/provisioning-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "description": "Zowe SDK to interact with the z/OS provisioning APIs", "author": "Zowe", "license": "EPL-2.0", @@ -49,9 +49,9 @@ }, "devDependencies": { "@types/js-yaml": "^4.0.9", - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/workflows/package.json b/packages/workflows/package.json index 6bccd466ac..696c7bf8b8 100644 --- a/packages/workflows/package.json +++ b/packages/workflows/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.9.1", + "version": "8.10.0", "description": "Zowe SDK to interact with the z/OS workflows APIs", "author": "Zowe", "license": "EPL-2.0", @@ -45,12 +45,12 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.9.1" + "@zowe/zos-files-for-zowe-sdk": "8.10.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosconsole/package.json b/packages/zosconsole/package.json index cd8be18e9c..1f0e7d4dad 100644 --- a/packages/zosconsole/package.json +++ b/packages/zosconsole/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-console-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "description": "Zowe SDK to interact with the z/OS console", "author": "Zowe", "license": "EPL-2.0", @@ -45,9 +45,9 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosfiles/CHANGELOG.md b/packages/zosfiles/CHANGELOG.md index 50a6326d17..739c33feaa 100644 --- a/packages/zosfiles/CHANGELOG.md +++ b/packages/zosfiles/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe z/OS files SDK package will be documented in this file. -## Recent Changes +## `8.10.0` - Enhancement: The `Copy.dataset` method now recognizes partitioned data sets and can copy members of a source PDS into an existing target PDS. [#2386](https://github.com/zowe/zowe-cli/pull/2386) ## `8.9.1` diff --git a/packages/zosfiles/package.json b/packages/zosfiles/package.json index d04f8d8499..27302db5f8 100644 --- a/packages/zosfiles/package.json +++ b/packages/zosfiles/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.9.1", + "version": "8.10.0", "description": "Zowe SDK to interact with files and data sets on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -50,10 +50,10 @@ "minimatch": "^9.0.5" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3", - "@zowe/zos-uss-for-zowe-sdk": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0", + "@zowe/zos-uss-for-zowe-sdk": "8.10.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosjobs/package.json b/packages/zosjobs/package.json index 17db41fd33..d403fdb683 100644 --- a/packages/zosjobs/package.json +++ b/packages/zosjobs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.9.1", + "version": "8.10.0", "description": "Zowe SDK to interact with jobs on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -46,12 +46,12 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.9.1" + "@zowe/zos-files-for-zowe-sdk": "8.10.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zoslogs/package.json b/packages/zoslogs/package.json index 954d6aa8cb..4d5cce70e9 100644 --- a/packages/zoslogs/package.json +++ b/packages/zoslogs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-logs-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "description": "Zowe SDK to interact with the z/OS logs", "author": "Zowe", "license": "EPL-2.0", @@ -45,9 +45,9 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosmf/package.json b/packages/zosmf/package.json index 1dee4b9536..fa09136aa6 100644 --- a/packages/zosmf/package.json +++ b/packages/zosmf/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zosmf-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "description": "Zowe SDK to interact with the z/OS Management Facility", "author": "Zowe", "license": "EPL-2.0", @@ -44,9 +44,9 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zostso/package.json b/packages/zostso/package.json index 92baabc181..41a72be750 100644 --- a/packages/zostso/package.json +++ b/packages/zostso/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-tso-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "description": "Zowe SDK to interact with TSO on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -45,12 +45,12 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zosmf-for-zowe-sdk": "8.8.3" + "@zowe/zosmf-for-zowe-sdk": "8.10.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.8.3", - "@zowe/core-for-zowe-sdk": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/core-for-zowe-sdk": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosuss/package.json b/packages/zosuss/package.json index 70da59fb65..60e7ffbd0a 100644 --- a/packages/zosuss/package.json +++ b/packages/zosuss/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-uss-for-zowe-sdk", - "version": "8.8.3", + "version": "8.10.0", "description": "Zowe SDK to interact with USS on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -49,8 +49,8 @@ }, "devDependencies": { "@types/ssh2": "^1.11.19", - "@zowe/cli-test-utils": "8.8.3", - "@zowe/imperative": "8.8.3" + "@zowe/cli-test-utils": "8.10.0", + "@zowe/imperative": "8.10.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0"