From bb4ea27479c9855b05ded7887820d78f3e48f538 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:11:41 -0400 Subject: [PATCH 01/69] PoC Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- packages/zosmf/src/CheckStatus.ts | 4 + .../zosmf/src/constants/Zosmf.constants.ts | 9 ++ packages/zostso/src/IssueTso.ts | 101 +++++++++++------- .../zostso/src/doc/IIssueTsoCmdResponse.ts | 21 ++++ .../zostso/src/doc/input/IIssueTsoCmdParms.ts | 19 ++++ packages/zostso/src/index.ts | 2 + 6 files changed, 120 insertions(+), 36 deletions(-) create mode 100644 packages/zostso/src/doc/IIssueTsoCmdResponse.ts create mode 100644 packages/zostso/src/doc/input/IIssueTsoCmdParms.ts diff --git a/packages/zosmf/src/CheckStatus.ts b/packages/zosmf/src/CheckStatus.ts index b378c8ba2b..c46687ed74 100644 --- a/packages/zosmf/src/CheckStatus.ts +++ b/packages/zosmf/src/CheckStatus.ts @@ -36,6 +36,10 @@ export class CheckStatus { return ZosmfRestClient.getExpectJSON(session, infoEndpoint); } + public static async isZosVersionGreaterThan(session: AbstractSession, version: string): Promise { + return (await CheckStatus.getZosmfInfo(session)).zosmf_version >= version; + } + /** * Get Log * @returns {Logger} applicationLogger. diff --git a/packages/zosmf/src/constants/Zosmf.constants.ts b/packages/zosmf/src/constants/Zosmf.constants.ts index f8bce03178..5c3930ecfc 100644 --- a/packages/zosmf/src/constants/Zosmf.constants.ts +++ b/packages/zosmf/src/constants/Zosmf.constants.ts @@ -67,6 +67,15 @@ export const ZosmfConstants: { [key: string]: any } = { * @type {string} */ UNABLE_TO_VERIFY_LEAF_SIGNATURE: "UNABLE_TO_VERIFY_LEAF_SIGNATURE" + }, + + VERSIONS: { + V2R1: "24", + V2R2: "25", + V2R3: "26", + V2R4: "27", + V2R5: "28", + V3R1: "29", } }; diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 77fd62b361..2f130f4d31 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -9,15 +9,19 @@ * */ -import { AbstractSession, ImperativeError } from "@zowe/imperative"; +import { AbstractSession, Headers, ImperativeError } from "@zowe/imperative"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; -import { noAccountNumber, noCommandInput } from "./TsoConstants"; +import { noAccountNumber, noCommandInput, TsoConstants } from "./TsoConstants"; import { SendTso } from "./SendTso"; import { StartTso } from "./StartTso"; import { IIssueResponse } from "./doc/IIssueResponse"; import { StopTso } from "./StopTso"; import { TsoValidator } from "./TsoValidator"; import { IIssueTsoParms } from "./doc/input/IIssueTsoParms"; +import { CheckStatus, ZosmfConstants } from "@zowe/zosmf-for-zowe-sdk"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { IIssueTsoCmdResponse } from "./doc/IIssueTsoCmdResponse"; +import { IIssueTsoCmdParms } from "./doc/input/IIssueTsoCmdParms"; /** * Class to handle issue command to TSO @@ -25,7 +29,59 @@ import { IIssueTsoParms } from "./doc/input/IIssueTsoParms"; */ export class IssueTso { + public static async issueTsoCmd(session: AbstractSession, commandInfo: string | IIssueTsoCmdParms, addressSpaceOptions?: IStartTsoParms): + Promise { + + const command = typeof commandInfo === "string" ? commandInfo : commandInfo.command; + const version = typeof commandInfo === "string" ? "v1" : commandInfo.version ?? "v1"; + const isStateful = typeof commandInfo === "string" ? false : commandInfo.isStateful ?? false; + + if (addressSpaceOptions == null && await CheckStatus.isZosVersionGreaterThan(session, ZosmfConstants.VERSIONS.V2R4)) { + // use new api + const endpoint = TsoConstants.RESOURCE + "/" + version + "/" + TsoConstants.RES_START_TSO; + const response = await ZosmfRestClient.putExpectJSON(session, endpoint, [Headers.APPLICATION_JSON], { + "tsoCmd": command, + "cmdState": isStateful ? "stateful" : "stateless" + }); + + return response; + + } else if (addressSpaceOptions != null) { + // use old behavior + TsoValidator.validateSession(session); + TsoValidator.validateNotEmptyString(addressSpaceOptions.account, noAccountNumber.message); + TsoValidator.validateNotEmptyString(command, noCommandInput.message); + + const response: IIssueResponse = { + success: false, + startResponse: null, + startReady: false, + zosmfResponse: null, + commandResponse: null, + stopResponse: null + }; + response.startResponse = await StartTso.start(session, addressSpaceOptions.account, addressSpaceOptions || {}); + + if (!response.startResponse.success) { + throw new ImperativeError({ + msg: `TSO address space failed to start.`, + additionalDetails: response.startResponse.failureResponse?.message + }); + } + + const sendResponse = await SendTso.sendDataToTSOCollect(session, response.startResponse.servletKey, command); + response.success = sendResponse.success; + response.zosmfResponse = sendResponse.zosmfResponse; + response.commandResponse = sendResponse.commandResponse; + response.stopResponse = await StopTso.stop(session, response.startResponse.servletKey); + return response; + } else { + throw "ERROR"; + } + } + /** + * @deprecated Use issueTsoCmd instead * API method to start a TSO address space, issue a command, collect responses until prompt is reached, and terminate the address space. * @param {AbstractSession} session - z/OSMF connection info * @param {string} accountNumber - accounting info for Jobs @@ -34,50 +90,23 @@ export class IssueTso { * @returns {Promise} IssueTso response object, @see {IIssueResponse} * @memberof IssueTso */ - public static async issueTsoCommand(session: AbstractSession, accountNumber: string, command: string, startParams?: IStartTsoParms) { - - TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); - TsoValidator.validateNotEmptyString(command, noCommandInput.message); - - const response: IIssueResponse = { - success: false, - startResponse: null, - startReady: false, - zosmfResponse: null, - commandResponse: null, - stopResponse: null - }; - response.startResponse = await StartTso.start(session, accountNumber, startParams || {}); + public static async issueTsoCommand(session: AbstractSession, accountNumber: string, command: string, startParams?: IStartTsoParms): Promise { + return await IssueTso.issueTsoCmd(session, command, { ...startParams, account: accountNumber }) as IIssueResponse; - if (!response.startResponse.success) { - throw new ImperativeError({ - msg: `TSO address space failed to start.`, - additionalDetails: response.startResponse.failureResponse?.message - }); - } - - const sendResponse = await SendTso.sendDataToTSOCollect(session, response.startResponse.servletKey, command); - response.success = sendResponse.success; - response.zosmfResponse = sendResponse.zosmfResponse; - response.commandResponse = sendResponse.commandResponse; - response.stopResponse = await StopTso.stop(session, response.startResponse.servletKey); - return response; } /** + * @deprecated use issueTsoCmd instead * API method to start a TSO address space with provided parameters, issue a command, * collect responses until prompt is reached, and terminate the address space. * @param {AbstractSession} session - z/OSMF connection info * @param {IIssueTsoParms} commandParms - object with required parameters, @see {IIssueTsoParms} * @returns {Promise} */ - public static async issueTsoCommandCommon(session: AbstractSession, commandParms: IIssueTsoParms) { - - TsoValidator.validateSession(session); - TsoValidator.validateIssueParams(commandParms); - TsoValidator.validateNotEmptyString(commandParms.command, noCommandInput.message); - return IssueTso.issueTsoCommand(session, commandParms.accountNumber, commandParms.command, commandParms.startParams); + public static async issueTsoCommandCommon(session: AbstractSession, commandParms: IIssueTsoParms): Promise { + return await IssueTso.issueTsoCmd(session, commandParms.command, { + ...commandParms.startParams, account: commandParms.accountNumber + }) as IIssueResponse; } } diff --git a/packages/zostso/src/doc/IIssueTsoCmdResponse.ts b/packages/zostso/src/doc/IIssueTsoCmdResponse.ts new file mode 100644 index 0000000000..2537831e02 --- /dev/null +++ b/packages/zostso/src/doc/IIssueTsoCmdResponse.ts @@ -0,0 +1,21 @@ +/* +* This program and the accompanying materials are made available under the terms of the +* Eclipse Public License v2.0 which accompanies this distribution, and is available at +* https://www.eclipse.org/legal/epl-v20.html +* +* SPDX-License-Identifier: EPL-2.0 +* +* Copyright Contributors to the Zowe Project. +* +*/ + +export interface IIssueTsoCmdResponse { + + cmdResponse: {message: string}[]; + + tsoPromptReceived: "Y" | "N", + + servletKey?: string; + + keywordDetected?: "Y" | "N", +} diff --git a/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts b/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts new file mode 100644 index 0000000000..04cfbea2c8 --- /dev/null +++ b/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts @@ -0,0 +1,19 @@ +/* +* This program and the accompanying materials are made available under the terms of the +* Eclipse Public License v2.0 which accompanies this distribution, and is available at +* https://www.eclipse.org/legal/epl-v20.html +* +* SPDX-License-Identifier: EPL-2.0 +* +* Copyright Contributors to the Zowe Project. +* +*/ + +export interface IIssueTsoCmdParms { + + command: string; + + isStateful?: boolean; + + version?: string; +} diff --git a/packages/zostso/src/index.ts b/packages/zostso/src/index.ts index cd43f1a60a..a9592a8893 100644 --- a/packages/zostso/src/index.ts +++ b/packages/zostso/src/index.ts @@ -12,6 +12,7 @@ export * from "./constants/ZosTso.constants"; export * from "./constants/ZosTso.profile"; +export * from "./doc/input/IIssueTsoCmdParms"; export * from "./doc/input/IIssueTsoParms"; export * from "./doc/input/ISendTsoParms"; export * from "./doc/input/IStartTsoParms"; @@ -28,6 +29,7 @@ export * from "./doc/zosmf/IZosmfPingResponse"; export * from "./doc/zosmf/IZosmfTsoResponse"; export * from "./doc/ICollectedResponses"; +export * from "./doc/IIssueTsoCmdResponse"; export * from "./doc/IIssueResponse"; export * from "./doc/IPingResponse"; export * from "./doc/ISendResponse"; From 3190936ac507b4167c3da697d07d0b83d1fe4b84 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 27 Aug 2024 09:51:45 -0400 Subject: [PATCH 02/69] issueTsoCmd() and deprecated issueTsoCommand() Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 60 ++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 2f130f4d31..ed2a607e27 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -22,45 +22,58 @@ import { CheckStatus, ZosmfConstants } from "@zowe/zosmf-for-zowe-sdk"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { IIssueTsoCmdResponse } from "./doc/IIssueTsoCmdResponse"; import { IIssueTsoCmdParms } from "./doc/input/IIssueTsoCmdParms"; - +const { ProfileInfo } = require("@zowe/imperative"); /** * Class to handle issue command to TSO * @class IssueTso */ export class IssueTso { - public static async issueTsoCmd(session: AbstractSession, commandInfo: string | IIssueTsoCmdParms, addressSpaceOptions?: IStartTsoParms): - Promise { - - const command = typeof commandInfo === "string" ? commandInfo : commandInfo.command; - const version = typeof commandInfo === "string" ? "v1" : commandInfo.version ?? "v1"; - const isStateful = typeof commandInfo === "string" ? false : commandInfo.isStateful ?? false; - + public static async issueTsoCmd( + session: AbstractSession, + commandInfo: string | IIssueTsoCmdParms, + addressSpaceOptions?: IStartTsoParms + ): Promise { + let command: string | IIssueTsoCmdParms; + let version: string; + let isStateful: boolean; + const useNewApi = addressSpaceOptions == null && await CheckStatus.isZosVersionGreaterThan(session, ZosmfConstants.VERSIONS.V2R4); + let newApiFailureOverride: boolean = false; if (addressSpaceOptions == null && await CheckStatus.isZosVersionGreaterThan(session, ZosmfConstants.VERSIONS.V2R4)) { - // use new api - const endpoint = TsoConstants.RESOURCE + "/" + version + "/" + TsoConstants.RES_START_TSO; - const response = await ZosmfRestClient.putExpectJSON(session, endpoint, [Headers.APPLICATION_JSON], { - "tsoCmd": command, - "cmdState": isStateful ? "stateful" : "stateless" - }); - - return response; + command = commandInfo; + version = "v1"; + isStateful = false; + try { + const endpoint = `${TsoConstants.RESOURCE}/${version}/${TsoConstants.RES_START_TSO}`; + return await ZosmfRestClient.putExpectJSON(session, endpoint, [Headers.APPLICATION_JSON], { + "tsoCmd": command, + "cmdState": isStateful ? "stateful" : "stateless" + }); + } catch { + newApiFailureOverride = true; + const profInfo = new ProfileInfo("zowe"); + await profInfo.readProfilesFromDisk(); + addressSpaceOptions = profInfo.getTeamConfig().api.profiles.defaultGet("tso"); + } + } - } else if (addressSpaceOptions != null) { - // use old behavior + // Old behavior + if ((addressSpaceOptions != null || !useNewApi) || newApiFailureOverride) { + command = typeof commandInfo === "string" ? commandInfo : commandInfo.command; + version = typeof commandInfo === "string" ? "v1" : commandInfo.version ?? "v1"; + isStateful = typeof commandInfo === "string" ? false : commandInfo.isStateful ?? false; TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString(addressSpaceOptions.account, noAccountNumber.message); - TsoValidator.validateNotEmptyString(command, noCommandInput.message); + TsoValidator.validateNotEmptyString(addressSpaceOptions?.account, noAccountNumber.message); + TsoValidator.validateNotEmptyString(command as string, noCommandInput.message); const response: IIssueResponse = { success: false, - startResponse: null, + startResponse: await StartTso.start(session, addressSpaceOptions?.account, addressSpaceOptions || {}), startReady: false, zosmfResponse: null, commandResponse: null, stopResponse: null }; - response.startResponse = await StartTso.start(session, addressSpaceOptions.account, addressSpaceOptions || {}); if (!response.startResponse.success) { throw new ImperativeError({ @@ -69,7 +82,7 @@ export class IssueTso { }); } - const sendResponse = await SendTso.sendDataToTSOCollect(session, response.startResponse.servletKey, command); + const sendResponse = await SendTso.sendDataToTSOCollect(session, response.startResponse.servletKey, command as string); response.success = sendResponse.success; response.zosmfResponse = sendResponse.zosmfResponse; response.commandResponse = sendResponse.commandResponse; @@ -92,7 +105,6 @@ export class IssueTso { */ public static async issueTsoCommand(session: AbstractSession, accountNumber: string, command: string, startParams?: IStartTsoParms): Promise { return await IssueTso.issueTsoCmd(session, command, { ...startParams, account: accountNumber }) as IIssueResponse; - } /** From 5b7c83414751c391239514a37ab2fed71bc3289e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 27 Aug 2024 12:03:20 -0400 Subject: [PATCH 03/69] lint and changelog Signed-off-by: jace-roell --- packages/zostso/CHANGELOG.md | 4 + packages/zostso/src/IssueTso.ts | 125 +++++++++++++++++++++++--------- 2 files changed, 93 insertions(+), 36 deletions(-) diff --git a/packages/zostso/CHANGELOG.md b/packages/zostso/CHANGELOG.md index f408ac489a..0090c6c9ed 100644 --- a/packages/zostso/CHANGELOG.md +++ b/packages/zostso/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe z/OS TSO SDK package will be documented in this file. +## Recent Changes + +- Enhancement: Deprecated `IssueTsoCommand()` function and replaced with `IssueTsoCmd()` for compatibility with z/Os version 2.5. [#2240](https://github.com/zowe/zowe-cli/pull/2240) + ## `8.0.0-next.202408131445` - Update: See `7.28.3` for details diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index ed2a607e27..339686db84 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -1,13 +1,13 @@ /* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ import { AbstractSession, Headers, ImperativeError } from "@zowe/imperative"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; @@ -28,7 +28,6 @@ const { ProfileInfo } = require("@zowe/imperative"); * @class IssueTso */ export class IssueTso { - public static async issueTsoCmd( session: AbstractSession, commandInfo: string | IIssueTsoCmdParms, @@ -37,56 +36,99 @@ export class IssueTso { let command: string | IIssueTsoCmdParms; let version: string; let isStateful: boolean; - const useNewApi = addressSpaceOptions == null && await CheckStatus.isZosVersionGreaterThan(session, ZosmfConstants.VERSIONS.V2R4); + const useNewApi = + addressSpaceOptions == null && + await CheckStatus.isZosVersionGreaterThan( + session, + ZosmfConstants.VERSIONS.V2R4 + ); let newApiFailureOverride: boolean = false; - if (addressSpaceOptions == null && await CheckStatus.isZosVersionGreaterThan(session, ZosmfConstants.VERSIONS.V2R4)) { + if (useNewApi) { command = commandInfo; version = "v1"; isStateful = false; try { const endpoint = `${TsoConstants.RESOURCE}/${version}/${TsoConstants.RES_START_TSO}`; - return await ZosmfRestClient.putExpectJSON(session, endpoint, [Headers.APPLICATION_JSON], { - "tsoCmd": command, - "cmdState": isStateful ? "stateful" : "stateless" - }); + return await ZosmfRestClient.putExpectJSON( + session, + endpoint, + [Headers.APPLICATION_JSON], + { + tsoCmd: command, + cmdState: isStateful ? "stateful" : "stateless", + } + ); } catch { newApiFailureOverride = true; const profInfo = new ProfileInfo("zowe"); await profInfo.readProfilesFromDisk(); - addressSpaceOptions = profInfo.getTeamConfig().api.profiles.defaultGet("tso"); + addressSpaceOptions = profInfo + .getTeamConfig() + .api.profiles.defaultGet("tso"); } } - // Old behavior - if ((addressSpaceOptions != null || !useNewApi) || newApiFailureOverride) { - command = typeof commandInfo === "string" ? commandInfo : commandInfo.command; - version = typeof commandInfo === "string" ? "v1" : commandInfo.version ?? "v1"; - isStateful = typeof commandInfo === "string" ? false : commandInfo.isStateful ?? false; + // Deprecated API Behavior [formerly issueTsoCommand()] + if ( + addressSpaceOptions != null || + !useNewApi || + newApiFailureOverride + ) { + command = + typeof commandInfo === "string" + ? commandInfo + : commandInfo.command; + version = + typeof commandInfo === "string" + ? "v1" + : commandInfo.version ?? "v1"; + isStateful = + typeof commandInfo === "string" + ? false + : commandInfo.isStateful ?? false; TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString(addressSpaceOptions?.account, noAccountNumber.message); - TsoValidator.validateNotEmptyString(command as string, noCommandInput.message); + TsoValidator.validateNotEmptyString( + addressSpaceOptions?.account, + noAccountNumber.message + ); + TsoValidator.validateNotEmptyString( + command as string, + noCommandInput.message + ); const response: IIssueResponse = { success: false, - startResponse: await StartTso.start(session, addressSpaceOptions?.account, addressSpaceOptions || {}), + startResponse: await StartTso.start( + session, + addressSpaceOptions?.account, + addressSpaceOptions || {} + ), startReady: false, zosmfResponse: null, commandResponse: null, - stopResponse: null + stopResponse: null, }; if (!response.startResponse.success) { throw new ImperativeError({ msg: `TSO address space failed to start.`, - additionalDetails: response.startResponse.failureResponse?.message + additionalDetails: + response.startResponse.failureResponse?.message, }); } - const sendResponse = await SendTso.sendDataToTSOCollect(session, response.startResponse.servletKey, command as string); + const sendResponse = await SendTso.sendDataToTSOCollect( + session, + response.startResponse.servletKey, + command as string + ); response.success = sendResponse.success; response.zosmfResponse = sendResponse.zosmfResponse; response.commandResponse = sendResponse.commandResponse; - response.stopResponse = await StopTso.stop(session, response.startResponse.servletKey); + response.stopResponse = await StopTso.stop( + session, + response.startResponse.servletKey + ); return response; } else { throw "ERROR"; @@ -103,8 +145,16 @@ export class IssueTso { * @returns {Promise} IssueTso response object, @see {IIssueResponse} * @memberof IssueTso */ - public static async issueTsoCommand(session: AbstractSession, accountNumber: string, command: string, startParams?: IStartTsoParms): Promise { - return await IssueTso.issueTsoCmd(session, command, { ...startParams, account: accountNumber }) as IIssueResponse; + public static async issueTsoCommand( + session: AbstractSession, + accountNumber: string, + command: string, + startParams?: IStartTsoParms + ): Promise { + return (await IssueTso.issueTsoCmd(session, command, { + ...startParams, + account: accountNumber, + })) as IIssueResponse; } /** @@ -115,10 +165,13 @@ export class IssueTso { * @param {IIssueTsoParms} commandParms - object with required parameters, @see {IIssueTsoParms} * @returns {Promise} */ - public static async issueTsoCommandCommon(session: AbstractSession, commandParms: IIssueTsoParms): Promise { - return await IssueTso.issueTsoCmd(session, commandParms.command, { - ...commandParms.startParams, account: commandParms.accountNumber - }) as IIssueResponse; + public static async issueTsoCommandCommon( + session: AbstractSession, + commandParms: IIssueTsoParms + ): Promise { + return (await IssueTso.issueTsoCmd(session, commandParms.command, { + ...commandParms.startParams, + account: commandParms.accountNumber, + })) as IIssueResponse; } - } From c41f3267f127bf2502b32772481c0aa566e7cde6 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 28 Aug 2024 10:41:21 -0400 Subject: [PATCH 04/69] return object type for issueTsoCmd on Command.handler Signed-off-by: jace-roell --- .../src/zostso/issue/command/Command.handler.ts | 14 +++++--------- packages/zostso/src/IssueTso.ts | 17 +++++++++++++---- packages/zostso/src/doc/IIssueResponse.ts | 4 ++-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index 9afde947c2..e0d6544e1e 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -10,7 +10,7 @@ */ import { IHandlerParameters } from "@zowe/imperative"; -import { IIssueResponse, IssueTso, ZosTsoBaseHandler } from "@zowe/zos-tso-for-zowe-sdk"; +import { IIssueResponse, IIssueTsoCmdResponse, IssueTso, ZosTsoBaseHandler } from "@zowe/zos-tso-for-zowe-sdk"; /** * Handler to issue command to TSO address space @@ -24,17 +24,13 @@ export default class Handler extends ZosTsoBaseHandler { public async processCmd(params: IHandlerParameters) { // Issue the TSO command - const response: IIssueResponse = await IssueTso.issueTsoCommand( - this.mSession, - params.arguments.account, - params.arguments.commandText, - this.mTsoStart); + const response: IIssueResponse = await IssueTso.issueTsoCmd(this.mSession,params.arguments.commandText); // If requested, suppress the startup - if (!params.arguments.suppressStartupMessages) { - this.console.log(response.startResponse.messages); + if (!params.arguments.suppressStartupMessages && response.startResponse != null) { + this.console.log((response as any).startResponse.messages); } - this.console.log(response.commandResponse); + this.console.log((response as any).commandResponse); // Return as an object when using --response-format-json this.data.setObj(response); } diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 339686db84..cc0dce2acc 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -23,6 +23,7 @@ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { IIssueTsoCmdResponse } from "./doc/IIssueTsoCmdResponse"; import { IIssueTsoCmdParms } from "./doc/input/IIssueTsoCmdParms"; const { ProfileInfo } = require("@zowe/imperative"); + /** * Class to handle issue command to TSO * @class IssueTso @@ -32,7 +33,7 @@ export class IssueTso { session: AbstractSession, commandInfo: string | IIssueTsoCmdParms, addressSpaceOptions?: IStartTsoParms - ): Promise { + ): Promise { let command: string | IIssueTsoCmdParms; let version: string; let isStateful: boolean; @@ -49,7 +50,7 @@ export class IssueTso { isStateful = false; try { const endpoint = `${TsoConstants.RESOURCE}/${version}/${TsoConstants.RES_START_TSO}`; - return await ZosmfRestClient.putExpectJSON( + const apiResponse = await ZosmfRestClient.putExpectJSON( session, endpoint, [Headers.APPLICATION_JSON], @@ -58,7 +59,15 @@ export class IssueTso { cmdState: isStateful ? "stateful" : "stateless", } ); - } catch { + const response: IIssueResponse = { + success: apiResponse.tsoPromptReceived === 'Y', + startReady: apiResponse.cmdResponse[apiResponse.cmdResponse.length - 1].message.trim() === 'READY', + zosmfResponse: apiResponse as any, + commandResponse: apiResponse.cmdResponse.map(item => item.message).join(', ') + }; + return response; + } catch(e) { + if(!e.mMessage.includes("status 404")) throw e; newApiFailureOverride = true; const profInfo = new ProfileInfo("zowe"); await profInfo.readProfilesFromDisk(); @@ -68,7 +77,7 @@ export class IssueTso { } } - // Deprecated API Behavior [formerly issueTsoCommand()] + // Deprecated API Behavior [former issueTsoCommand() behavior] if ( addressSpaceOptions != null || !useNewApi || diff --git a/packages/zostso/src/doc/IIssueResponse.ts b/packages/zostso/src/doc/IIssueResponse.ts index cc5cb4b82c..b54ab48062 100644 --- a/packages/zostso/src/doc/IIssueResponse.ts +++ b/packages/zostso/src/doc/IIssueResponse.ts @@ -30,7 +30,7 @@ export interface IIssueResponse { * @type {IStartStopResponse} * @memberof ISendResponse */ - startResponse: IStartStopResponses; + startResponse?: IStartStopResponses; /** * Indicates if started TSO containes "READY " message @@ -44,7 +44,7 @@ export interface IIssueResponse { * @type {IStartStopResponse} * @memberof IIssueResponse */ - stopResponse: IStartStopResponse; + stopResponse?: IStartStopResponse; /** * The list of zOSMF send API responses. May issue multiple requests or * to ensure that all messages are collected. Each individual response is placed here. From 857eb44160bfa0bb286666120a040b8e6fe3397e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 29 Aug 2024 12:11:04 -0400 Subject: [PATCH 05/69] added stateful flag to tso issue cmd and added support for zos issue TSO cmd Signed-off-by: jace-roell --- .../issue/command/Command.definition.ts | 10 ++++++- .../zostso/issue/command/Command.handler.ts | 3 +-- packages/zostso/src/IssueTso.ts | 26 +++++++++++-------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index b6c07bdb2a..885379560b 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -37,7 +37,15 @@ export const CommandDefinition: ICommandDefinition = { name: "suppress-startup-messages", aliases: ["ssm"], type: "boolean", - description: "Suppress console messages from start of address space." + description: "Suppress console messages from start of address space.", + defaultValue: true + }, + { + name: "stateful", + aliases: ["sf"], + type: "boolean", + description: "Statefulness of address space created for TSO Command.", + defaultValue: false } ] as ICommandOptionDefinition[]).concat(TsoProfileConstants.TSO_PROFILE_OPTIONS), examples: [ diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index e0d6544e1e..22865f2ad6 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -24,8 +24,7 @@ export default class Handler extends ZosTsoBaseHandler { public async processCmd(params: IHandlerParameters) { // Issue the TSO command - const response: IIssueResponse = await IssueTso.issueTsoCmd(this.mSession,params.arguments.commandText); - + const response: IIssueResponse = await IssueTso.issueTsoCmd(this.mSession,params.arguments.commandText,params.arguments.stateful,params.arguments.ssm); // If requested, suppress the startup if (!params.arguments.suppressStartupMessages && response.startResponse != null) { this.console.log((response as any).startResponse.messages); diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index cc0dce2acc..dc869c1b2e 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -32,22 +32,25 @@ export class IssueTso { public static async issueTsoCmd( session: AbstractSession, commandInfo: string | IIssueTsoCmdParms, - addressSpaceOptions?: IStartTsoParms + addressSpaceOptions?: IStartTsoParms, + isStateful?: boolean, + suppressStartupMessage?: boolean, ): Promise { let command: string | IIssueTsoCmdParms; let version: string; - let isStateful: boolean; + if(!isStateful) isStateful = false; + if(!suppressStartupMessage) suppressStartupMessage = true; + const useNewApi = addressSpaceOptions == null && await CheckStatus.isZosVersionGreaterThan( session, ZosmfConstants.VERSIONS.V2R4 - ); + ) && isStateful === true; let newApiFailureOverride: boolean = false; if (useNewApi) { command = commandInfo; version = "v1"; - isStateful = false; try { const endpoint = `${TsoConstants.RESOURCE}/${version}/${TsoConstants.RES_START_TSO}`; const apiResponse = await ZosmfRestClient.putExpectJSON( @@ -60,7 +63,7 @@ export class IssueTso { } ); const response: IIssueResponse = { - success: apiResponse.tsoPromptReceived === 'Y', + success: true, startReady: apiResponse.cmdResponse[apiResponse.cmdResponse.length - 1].message.trim() === 'READY', zosmfResponse: apiResponse as any, commandResponse: apiResponse.cmdResponse.map(item => item.message).join(', ') @@ -69,20 +72,21 @@ export class IssueTso { } catch(e) { if(!e.mMessage.includes("status 404")) throw e; newApiFailureOverride = true; - const profInfo = new ProfileInfo("zowe"); - await profInfo.readProfilesFromDisk(); - addressSpaceOptions = profInfo - .getTeamConfig() - .api.profiles.defaultGet("tso"); + + } } - // Deprecated API Behavior [former issueTsoCommand() behavior] if ( addressSpaceOptions != null || !useNewApi || newApiFailureOverride ) { + const profInfo = new ProfileInfo("zowe"); + await profInfo.readProfilesFromDisk(); + addressSpaceOptions = profInfo + .getTeamConfig() + .api.profiles.defaultGet("tso"); command = typeof commandInfo === "string" ? commandInfo From 723f8261c62c43a0b6d7d2acc830107a49cc7414 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 29 Aug 2024 14:42:27 -0400 Subject: [PATCH 06/69] fix params Signed-off-by: jace-roell --- packages/cli/src/zostso/issue/command/Command.handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index 22865f2ad6..c6cb072822 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -24,7 +24,7 @@ export default class Handler extends ZosTsoBaseHandler { public async processCmd(params: IHandlerParameters) { // Issue the TSO command - const response: IIssueResponse = await IssueTso.issueTsoCmd(this.mSession,params.arguments.commandText,params.arguments.stateful,params.arguments.ssm); + const response: IIssueResponse = await IssueTso.issueTsoCmd(this.mSession,params.arguments.commandText,undefined,params.arguments.stateful,params.arguments.ssm); // If requested, suppress the startup if (!params.arguments.suppressStartupMessages && response.startResponse != null) { this.console.log((response as any).startResponse.messages); From c91de9e6715ac0bc81094008aa53783a2dde3845 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 08:28:46 -0400 Subject: [PATCH 07/69] command handler tests Signed-off-by: jace-roell --- .../command/Command.handler.unit.test.ts | 29 +++++++++++++++++++ .../Command.definition.unit.test.ts.snap | 10 +++++++ .../zostso/issue/command/Command.handler.ts | 6 ++-- packages/zostso/src/IssueTso.ts | 21 +++++--------- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index 6bf449c70d..3798922916 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -21,6 +21,7 @@ import { UNIT_TEST_TSO_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; +import { ZosmfBaseHandler } from "@zowe/zosmf-for-zowe-sdk"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: { @@ -31,6 +32,11 @@ const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ definition: CommandDefinition, profiles: UNIT_TEST_PROFILES_ZOSMF_TSO }); +let PARAMS_NO_SSM_STATEFUL = DEFAULT_PARAMETERS; +PARAMS_NO_SSM_STATEFUL.positionals = ["zos-tso","issue","cmd","TIME","--sf","--no-ssm"]; +PARAMS_NO_SSM_STATEFUL.arguments.stateful = false; +PARAMS_NO_SSM_STATEFUL.arguments.suppressStartupMessages = false; +PARAMS_NO_SSM_STATEFUL.arguments.commandText = "TIME"; describe("issue command handler tests", () => { @@ -73,4 +79,27 @@ describe("issue command handler tests", () => { expect(error instanceof ImperativeError).toBe(true); expect(error.message).toMatchSnapshot(); }); + + it("should issue command with issueTsoCmd", async () => { + IssueTso.issueTsoCmd = jest.fn().mockReturnValue({ + success: true, + startReady: true, + zosmfResponse: { + cmdResponse: [ + { + message: "IKJ56650I TIME-00:00:00 AM. CPU-00:00:00 SERVICE-554 SESSION-00:00:00 JANUARY 1,2024", + }, + { + message: "READY ", + }, + ], + tsoPromptReceived: "Y", + }, + commandResponse: "IKJ56650I TIME-00:00:00 AM. CPU-00:00:00 SERVICE-554 SESSION-00:00:00 JANUARY 1,2024\nREADY ", + }); + const handler = new Command.default(); + const params = Object.assign({}, ...[PARAMS_NO_SSM_STATEFUL]); + await handler.process(params); + expect(IssueTso.issueTsoCmd).toHaveBeenCalledTimes(1); + }); }); diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap index 0b53de6316..c931e9f2dd 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap @@ -18,10 +18,20 @@ Object { "aliases": Array [ "ssm", ], + "defaultValue": true, "description": "Suppress console messages from start of address space.", "name": "suppress-startup-messages", "type": "boolean", }, + Object { + "aliases": Array [ + "sf", + ], + "defaultValue": false, + "description": "Statefulness of address space created for TSO Command.", + "name": "stateful", + "type": "boolean", + }, Object { "aliases": Array [ "a", diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index c6cb072822..2eebdac1da 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -24,12 +24,12 @@ export default class Handler extends ZosTsoBaseHandler { public async processCmd(params: IHandlerParameters) { // Issue the TSO command - const response: IIssueResponse = await IssueTso.issueTsoCmd(this.mSession,params.arguments.commandText,undefined,params.arguments.stateful,params.arguments.ssm); + const response: IIssueResponse = await IssueTso.issueTsoCmd(this.mSession,params.arguments.commandText,undefined,params.arguments.stateful,params.arguments.suppressStartupMessages); // If requested, suppress the startup if (!params.arguments.suppressStartupMessages && response.startResponse != null) { - this.console.log((response as any).startResponse.messages); + this.console.log(response.startResponse.messages); } - this.console.log((response as any).commandResponse); + this.console.log(response.commandResponse); // Return as an object when using --response-format-json this.data.setObj(response); } diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index dc869c1b2e..a9cab9cb37 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -38,16 +38,15 @@ export class IssueTso { ): Promise { let command: string | IIssueTsoCmdParms; let version: string; - if(!isStateful) isStateful = false; - if(!suppressStartupMessage) suppressStartupMessage = true; + if(!isStateful) isStateful = false + if(!suppressStartupMessage) suppressStartupMessage = false; - const useNewApi = + let useNewApi = addressSpaceOptions == null && await CheckStatus.isZosVersionGreaterThan( session, ZosmfConstants.VERSIONS.V2R4 - ) && isStateful === true; - let newApiFailureOverride: boolean = false; + ) && suppressStartupMessage === true; if (useNewApi) { command = commandInfo; version = "v1"; @@ -66,22 +65,16 @@ export class IssueTso { success: true, startReady: apiResponse.cmdResponse[apiResponse.cmdResponse.length - 1].message.trim() === 'READY', zosmfResponse: apiResponse as any, - commandResponse: apiResponse.cmdResponse.map(item => item.message).join(', ') + commandResponse: apiResponse.cmdResponse.map(item => item.message).join('\n') }; return response; } catch(e) { if(!e.mMessage.includes("status 404")) throw e; - newApiFailureOverride = true; - - + useNewApi = false; } } // Deprecated API Behavior [former issueTsoCommand() behavior] - if ( - addressSpaceOptions != null || - !useNewApi || - newApiFailureOverride - ) { + if (addressSpaceOptions != null || !useNewApi) { const profInfo = new ProfileInfo("zowe"); await profInfo.readProfilesFromDisk(); addressSpaceOptions = profInfo From 2bb090f095e12c20ff08a474df302c87bec8877a Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 11:18:29 -0400 Subject: [PATCH 08/69] issueTso unit testing Signed-off-by: jace-roell --- .../command/Command.handler.unit.test.ts | 70 +++++++++++-------- .../Command.handler.unit.test.ts.snap | 12 +--- .../zostso/issue/command/Command.handler.ts | 42 +++++++---- .../__tests__/__unit__/IssueTso.unit.test.ts | 69 +++++++++++++++++- packages/zostso/src/IssueTso.ts | 47 +++++++------ 5 files changed, 161 insertions(+), 79 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index 3798922916..94578013fa 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -1,13 +1,13 @@ /* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ jest.mock("../../../../../../zostso/lib/IssueTso"); import { IssueTso } from "@zowe/zos-tso-for-zowe-sdk"; @@ -18,34 +18,39 @@ import { StartTsoData } from "../../../__resources__/StartTsoData"; import { UNIT_TEST_ZOSMF_PROF_OPTS, UNIT_TEST_PROFILES_ZOSMF_TSO, - UNIT_TEST_TSO_PROF_OPTS + UNIT_TEST_TSO_PROF_OPTS, } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; -import { ZosmfBaseHandler } from "@zowe/zosmf-for-zowe-sdk"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: { ...UNIT_TEST_ZOSMF_PROF_OPTS, - ...UNIT_TEST_TSO_PROF_OPTS + ...UNIT_TEST_TSO_PROF_OPTS, }, positionals: ["zos-tso", "issue", "address-space"], definition: CommandDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF_TSO + profiles: UNIT_TEST_PROFILES_ZOSMF_TSO, }); let PARAMS_NO_SSM_STATEFUL = DEFAULT_PARAMETERS; -PARAMS_NO_SSM_STATEFUL.positionals = ["zos-tso","issue","cmd","TIME","--sf","--no-ssm"]; +PARAMS_NO_SSM_STATEFUL.positionals = [ + "zos-tso", + "issue", + "cmd", + "TIME", + "--sf", + "--no-ssm", +]; PARAMS_NO_SSM_STATEFUL.arguments.stateful = false; PARAMS_NO_SSM_STATEFUL.arguments.suppressStartupMessages = false; PARAMS_NO_SSM_STATEFUL.arguments.commandText = "TIME"; describe("issue command handler tests", () => { - afterEach(() => { jest.resetAllMocks(); }); it("should issue command", async () => { - IssueTso.issueTsoCommand = jest.fn((session, acc, cmd, prof) => { + IssueTso.issueTsoCmd = jest.fn((session, acc, cmd, prof) => { expect(prof).toBeDefined(); expect(prof).toMatchSnapshot(); return StartTsoData.SAMPLE_ISSUE_RESPONSE_WITH_MSG; @@ -55,15 +60,16 @@ describe("issue command handler tests", () => { params.arguments.acc = "acc"; params.arguments.cmd = "time"; await handler.process(params); - expect(IssueTso.issueTsoCommand).toHaveBeenCalledTimes(1); + expect(IssueTso.issueTsoCmd).toHaveBeenCalledTimes(1); }); it("should be able respond with error message", async () => { - const failMessage = "IZUG1126E: z/OSMF cannot correlate the request for key \"ZOSMFAD-SYS2-55-aaakaaac\"\n" + + const failMessage = + 'IZUG1126E: z/OSMF cannot correlate the request for key "ZOSMFAD-SYS2-55-aaakaaac"\n' + "with an active z/OS application session."; let error; - IssueTso.issueTsoCommand = jest.fn((session, servletKey) => { - throw new ImperativeError({msg: failMessage}); + IssueTso.issueTsoCmd = jest.fn((session, servletKey) => { + throw new ImperativeError({ msg: failMessage }); }); const handler = new Command.default(); const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); @@ -74,7 +80,7 @@ describe("issue command handler tests", () => { } catch (thrownError) { error = thrownError; } - expect(IssueTso.issueTsoCommand).toHaveBeenCalledTimes(1); + expect(IssueTso.issueTsoCmd).toHaveBeenCalledTimes(1); expect(error).toBeDefined(); expect(error instanceof ImperativeError).toBe(true); expect(error.message).toMatchSnapshot(); @@ -82,20 +88,22 @@ describe("issue command handler tests", () => { it("should issue command with issueTsoCmd", async () => { IssueTso.issueTsoCmd = jest.fn().mockReturnValue({ - success: true, - startReady: true, - zosmfResponse: { - cmdResponse: [ + success: true, + startReady: true, + zosmfResponse: { + cmdResponse: [ { - message: "IKJ56650I TIME-00:00:00 AM. CPU-00:00:00 SERVICE-554 SESSION-00:00:00 JANUARY 1,2024", + message: + "IKJ56650I TIME-00:00:00 AM. CPU-00:00:00 SERVICE-554 SESSION-00:00:00 JANUARY 1,2024", }, { - message: "READY ", + message: "READY ", }, - ], - tsoPromptReceived: "Y", - }, - commandResponse: "IKJ56650I TIME-00:00:00 AM. CPU-00:00:00 SERVICE-554 SESSION-00:00:00 JANUARY 1,2024\nREADY ", + ], + tsoPromptReceived: "Y", + }, + commandResponse: + "IKJ56650I TIME-00:00:00 AM. CPU-00:00:00 SERVICE-554 SESSION-00:00:00 JANUARY 1,2024\nREADY ", }); const handler = new Command.default(); const params = Object.assign({}, ...[PARAMS_NO_SSM_STATEFUL]); diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap index 9b7887bb8f..c225435f55 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap @@ -5,17 +5,7 @@ exports[`issue command handler tests should be able respond with error message 1 with an active z/OS application session." `; -exports[`issue command handler tests should issue command 1`] = ` -Object { - "account": "fake", - "characterSet": undefined, - "codePage": undefined, - "columns": undefined, - "logonProcedure": undefined, - "regionSize": undefined, - "rows": undefined, -} -`; +exports[`issue command handler tests should issue command 1`] = `false`; exports[`issue command handler tests should issue command 2`] = `"messages from TSO"`; diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index 2eebdac1da..2d8466bc92 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -1,17 +1,20 @@ /* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ import { IHandlerParameters } from "@zowe/imperative"; -import { IIssueResponse, IIssueTsoCmdResponse, IssueTso, ZosTsoBaseHandler } from "@zowe/zos-tso-for-zowe-sdk"; - +import { + IIssueResponse, + IssueTso, + ZosTsoBaseHandler, +} from "@zowe/zos-tso-for-zowe-sdk"; /** * Handler to issue command to TSO address space * @export @@ -19,17 +22,26 @@ import { IIssueResponse, IIssueTsoCmdResponse, IssueTso, ZosTsoBaseHandler } fro * @implements {ICommandHandler} */ export default class Handler extends ZosTsoBaseHandler { - // Process the command and produce the TSO response public async processCmd(params: IHandlerParameters) { - // Issue the TSO command - const response: IIssueResponse = await IssueTso.issueTsoCmd(this.mSession,params.arguments.commandText,undefined,params.arguments.stateful,params.arguments.suppressStartupMessages); + const response: IIssueResponse = await IssueTso.issueTsoCmd( + this.mSession, + params.arguments.commandText, + undefined, + params.arguments.stateful, + params.arguments.suppressStartupMessages + ); + // If requested, suppress the startup - if (!params.arguments.suppressStartupMessages && response.startResponse != null) { + if ( + !params.arguments.suppressStartupMessages && + response.startResponse != null + ) { this.console.log(response.startResponse.messages); } this.console.log(response.commandResponse); + // Return as an object when using --response-format-json this.data.setObj(response); } diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index fe6e071827..4e7efc0662 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -12,6 +12,7 @@ import { ImperativeError, Session } from "@zowe/imperative"; import { IIssueTsoParms, ISendResponse, IssueTso, IStartStopResponse, IStartTsoParms, IZosmfTsoResponse, SendTso, StartTso, StopTso } from "../../src"; +import { CheckStatus } from "@zowe/zosmf-for-zowe-sdk"; const PRETEND_SESSION = new Session({ user: "user", @@ -19,7 +20,7 @@ const PRETEND_SESSION = new Session({ hostname: "host.com", port: 443, type: "basic", - rejectUnauthorized: false + rejectUnauthorized: false, }); const SEND_RESPONSE = { success: true, @@ -129,7 +130,7 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { }); }); -describe("TsoIssue issueTsoCommand", () => { +describe("TsoIssue issueTsoCommand - Deprecated API", () => { it("should succeed", async () => { (StartTso.start as any) = jest.fn(() => { return new Promise((resolve) => { @@ -190,3 +191,67 @@ describe("TsoIssue issueTsoCommand", () => { expect(response).toBeDefined(); }); }); + +describe("TsoIssue issueTsoCmd - Revised API", () => { + it("should succeed", async () => { + (StartTso.start as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(START_RESPONSE); + }); + }); + }); + (SendTso.getAllResponses as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve({}); + }); + }); + }); + (SendTso.sendDataToTSOCollect as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(SEND_RESPONSE); + }); + }); + }); + (StopTso.stop as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(null); + }); + }); + }); + + let error: ImperativeError; + let response: ISendResponse; + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TEST", undefined, true, false); + } catch (thrownError) { + error = thrownError; + } + expect(error).not.toBeDefined(); + expect(response).toBeDefined(); + }); + + it("should succeed (with params)", async () => { + (IssueTso.issueTsoCmd as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve({}); + }); + }); + }); + let error: ImperativeError; + let response: ISendResponse; + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "command", undefined, true, false); + } catch (thrownError) { + error = thrownError; + } + expect(error).not.toBeDefined(); + expect(response).toBeDefined(); + }); +}); \ No newline at end of file diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index a9cab9cb37..dbfe62bd1d 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -34,42 +34,49 @@ export class IssueTso { commandInfo: string | IIssueTsoCmdParms, addressSpaceOptions?: IStartTsoParms, isStateful?: boolean, - suppressStartupMessage?: boolean, + suppressStartupMessage?: boolean ): Promise { let command: string | IIssueTsoCmdParms; let version: string; - if(!isStateful) isStateful = false - if(!suppressStartupMessage) suppressStartupMessage = false; + if (!isStateful) isStateful = false; + if (!suppressStartupMessage) suppressStartupMessage = false; let useNewApi = addressSpaceOptions == null && - await CheckStatus.isZosVersionGreaterThan( + (await CheckStatus.isZosVersionGreaterThan( session, ZosmfConstants.VERSIONS.V2R4 - ) && suppressStartupMessage === true; + )) && + suppressStartupMessage === true; if (useNewApi) { command = commandInfo; version = "v1"; try { const endpoint = `${TsoConstants.RESOURCE}/${version}/${TsoConstants.RES_START_TSO}`; - const apiResponse = await ZosmfRestClient.putExpectJSON( - session, - endpoint, - [Headers.APPLICATION_JSON], - { - tsoCmd: command, - cmdState: isStateful ? "stateful" : "stateless", - } - ); + const apiResponse = + await ZosmfRestClient.putExpectJSON( + session, + endpoint, + [Headers.APPLICATION_JSON], + { + tsoCmd: command, + cmdState: isStateful ? "stateful" : "stateless", + } + ); const response: IIssueResponse = { success: true, - startReady: apiResponse.cmdResponse[apiResponse.cmdResponse.length - 1].message.trim() === 'READY', + startReady: + apiResponse.cmdResponse[ + apiResponse.cmdResponse.length - 1 + ].message.trim() === "READY", zosmfResponse: apiResponse as any, - commandResponse: apiResponse.cmdResponse.map(item => item.message).join('\n') + commandResponse: apiResponse.cmdResponse + .map((item) => item.message) + .join("\n"), }; return response; - } catch(e) { - if(!e.mMessage.includes("status 404")) throw e; + } catch (e) { + if (!e.mMessage.includes("status 404")) throw e; useNewApi = false; } } @@ -78,8 +85,8 @@ export class IssueTso { const profInfo = new ProfileInfo("zowe"); await profInfo.readProfilesFromDisk(); addressSpaceOptions = profInfo - .getTeamConfig() - .api.profiles.defaultGet("tso"); + .getTeamConfig() + .api.profiles.defaultGet("tso"); command = typeof commandInfo === "string" ? commandInfo From a675e566b0696d3d4d7d963ce0c58c05c287d8a4 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 11:28:53 -0400 Subject: [PATCH 09/69] changelog Signed-off-by: jace-roell --- packages/zosmf/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/zosmf/CHANGELOG.md b/packages/zosmf/CHANGELOG.md index bf98b7b890..108e9dd757 100644 --- a/packages/zosmf/CHANGELOG.md +++ b/packages/zosmf/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe z/OSMF SDK package will be documented in this file. +## Recent Changes + +- Enhancement: Created `isZosVersionsGreaterThan` function to allow for dynamic behavior based on z/OS version + ## `8.0.0-next.202408131445` - Update: See `7.28.3` for details From 3bb1e38f9f8d48d5b5f3dbcbd3bfa9716be32d6b Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 11:37:29 -0400 Subject: [PATCH 10/69] changelog Signed-off-by: jace-roell --- packages/cli/CHANGELOG.md | 5 +++++ packages/zosmf/CHANGELOG.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index ced8ed2a89..54e5af3990 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the Zowe CLI package will be documented in this file. +## Recent Changes + +- Enhancement: Deprecated `issueTsoCommand()` function and replaced with `issueTsoCmd()` to allow for dynamic behavior +based on z/OS version to utilize 2.4 TSO command behavior. [#2240](https://github.com/zowe/zowe-cli/pull/2240) + ## `8.0.0-next.202408261543` - BugFix: Updated `micromatch` dependency for technical currency. [#2242](https://github.com/zowe/zowe-cli/pull/2242) diff --git a/packages/zosmf/CHANGELOG.md b/packages/zosmf/CHANGELOG.md index 108e9dd757..bab12469d6 100644 --- a/packages/zosmf/CHANGELOG.md +++ b/packages/zosmf/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe z/OSMF SDK package will be documented in this fi ## Recent Changes -- Enhancement: Created `isZosVersionsGreaterThan` function to allow for dynamic behavior based on z/OS version +- Enhancement: Created `isZosVersionsGreaterThan()` function to allow for dynamic behavior based on z/OS version. [#2240](https://github.com/zowe/zowe-cli/pull/2240) ## `8.0.0-next.202408131445` From 934387ca1cb8b735b837db86578fb058057fd4c0 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 12:56:56 -0400 Subject: [PATCH 11/69] lint Signed-off-by: jace-roell --- .../command/Command.handler.unit.test.ts | 80 +++++-------------- .../__system__/api.TsoIssue.system.test.ts | 1 + .../__tests__/__unit__/IssueTso.unit.test.ts | 28 +++++++ packages/zostso/src/IssueTso.ts | 4 +- 4 files changed, 50 insertions(+), 63 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index 8a86f1a478..1f388be4e6 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -1,57 +1,41 @@ /* - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ +* This program and the accompanying materials are made available under the terms of the +* Eclipse Public License v2.0 which accompanies this distribution, and is available at +* https://www.eclipse.org/legal/epl-v20.html +* +* SPDX-License-Identifier: EPL-2.0 +* +* Copyright Contributors to the Zowe Project. +* +*/ +/* eslint-disable deprecation/deprecation */ jest.mock("../../../../../../zostso/lib/IssueTso"); import { IssueTso } from "@zowe/zos-tso-for-zowe-sdk"; import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import * as Command from "../../../../../src/zostso/issue/command/Command.handler"; import { CommandDefinition } from "../../../../../src/zostso/issue/command/Command.definition"; import { StartTsoData } from "../../../__resources__/StartTsoData"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF_TSO, - UNIT_TEST_TSO_PROF_OPTS, -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; import { UNIT_TEST_ZOSMF_PROF_OPTS, UNIT_TEST_TSO_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: { ...UNIT_TEST_ZOSMF_PROF_OPTS, - ...UNIT_TEST_TSO_PROF_OPTS, + ...UNIT_TEST_TSO_PROF_OPTS }, positionals: ["zos-tso", "issue", "address-space"], - definition: CommandDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF_TSO, + definition: CommandDefinition }); -let PARAMS_NO_SSM_STATEFUL = DEFAULT_PARAMETERS; -PARAMS_NO_SSM_STATEFUL.positionals = [ - "zos-tso", - "issue", - "cmd", - "TIME", - "--sf", - "--no-ssm", -]; -PARAMS_NO_SSM_STATEFUL.arguments.stateful = false; -PARAMS_NO_SSM_STATEFUL.arguments.suppressStartupMessages = false; -PARAMS_NO_SSM_STATEFUL.arguments.commandText = "TIME"; describe("issue command handler tests", () => { + afterEach(() => { jest.resetAllMocks(); }); it("should issue command", async () => { - IssueTso.issueTsoCmd = jest.fn((session, acc, cmd, prof) => { + IssueTso.issueTsoCommand = jest.fn((session, acc, cmd, prof) => { expect(prof).toBeDefined(); expect(prof).toMatchSnapshot(); return StartTsoData.SAMPLE_ISSUE_RESPONSE_WITH_MSG; @@ -61,16 +45,15 @@ describe("issue command handler tests", () => { params.arguments.acc = "acc"; params.arguments.cmd = "time"; await handler.process(params); - expect(IssueTso.issueTsoCmd).toHaveBeenCalledTimes(1); + expect(IssueTso.issueTsoCommand).toHaveBeenCalledTimes(1); }); it("should be able respond with error message", async () => { - const failMessage = - 'IZUG1126E: z/OSMF cannot correlate the request for key "ZOSMFAD-SYS2-55-aaakaaac"\n' + + const failMessage = "IZUG1126E: z/OSMF cannot correlate the request for key \"ZOSMFAD-SYS2-55-aaakaaac\"\n" + "with an active z/OS application session."; let error; - IssueTso.issueTsoCmd = jest.fn((session, servletKey) => { - throw new ImperativeError({ msg: failMessage }); + IssueTso.issueTsoCommand = jest.fn((session, servletKey) => { + throw new ImperativeError({msg: failMessage}); }); const handler = new Command.default(); const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); @@ -81,34 +64,9 @@ describe("issue command handler tests", () => { } catch (thrownError) { error = thrownError; } - expect(IssueTso.issueTsoCmd).toHaveBeenCalledTimes(1); + expect(IssueTso.issueTsoCommand).toHaveBeenCalledTimes(1); expect(error).toBeDefined(); expect(error instanceof ImperativeError).toBe(true); expect(error.message).toMatchSnapshot(); }); - - it("should issue command with issueTsoCmd", async () => { - IssueTso.issueTsoCmd = jest.fn().mockReturnValue({ - success: true, - startReady: true, - zosmfResponse: { - cmdResponse: [ - { - message: - "IKJ56650I TIME-00:00:00 AM. CPU-00:00:00 SERVICE-554 SESSION-00:00:00 JANUARY 1,2024", - }, - { - message: "READY ", - }, - ], - tsoPromptReceived: "Y", - }, - commandResponse: - "IKJ56650I TIME-00:00:00 AM. CPU-00:00:00 SERVICE-554 SESSION-00:00:00 JANUARY 1,2024\nREADY ", - }); - const handler = new Command.default(); - const params = Object.assign({}, ...[PARAMS_NO_SSM_STATEFUL]); - await handler.process(params); - expect(IssueTso.issueTsoCmd).toHaveBeenCalledTimes(1); - }); }); diff --git a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts index c2bff8aa3f..ed48b1dfe4 100644 --- a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts @@ -9,6 +9,7 @@ * */ +/* eslint-disable deprecation/deprecation */ import { ImperativeError, Session } from "@zowe/imperative"; import { IIssueResponse, IIssueTsoParms, IssueTso, IStartTsoParms } from "../../src"; import * as fs from "fs"; diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index 4e7efc0662..95278f92f1 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -9,6 +9,7 @@ * */ +/* eslint-disable deprecation/deprecation */ import { ImperativeError, Session } from "@zowe/imperative"; import { IIssueTsoParms, ISendResponse, IssueTso, IStartStopResponse, IStartTsoParms, IZosmfTsoResponse, SendTso, StartTso, StopTso } from "../../src"; @@ -254,4 +255,31 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { expect(error).not.toBeDefined(); expect(response).toBeDefined(); }); +}); + +describe("TsoIssue issueTsoCmd - failing scenarios", () => { + it("should fail for null command text", async () => { + let error: ImperativeError; + let response: ISendResponse; + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "fake_command", undefined, true, false); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + }); + it("should fail for empty command text", async () => { + let error: ImperativeError; + let response: ISendResponse; + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "", undefined, true, false); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + }); }); \ No newline at end of file diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index dbfe62bd1d..2361d6e24f 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -43,10 +43,10 @@ export class IssueTso { let useNewApi = addressSpaceOptions == null && - (await CheckStatus.isZosVersionGreaterThan( + await CheckStatus.isZosVersionGreaterThan( session, ZosmfConstants.VERSIONS.V2R4 - )) && + ) && suppressStartupMessage === true; if (useNewApi) { command = commandInfo; From 6f827a10588b5f3f02e1d914b637d09a23caed10 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 13:04:51 -0400 Subject: [PATCH 12/69] unused code Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 2361d6e24f..2db8cd1686 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -91,14 +91,6 @@ export class IssueTso { typeof commandInfo === "string" ? commandInfo : commandInfo.command; - version = - typeof commandInfo === "string" - ? "v1" - : commandInfo.version ?? "v1"; - isStateful = - typeof commandInfo === "string" - ? false - : commandInfo.isStateful ?? false; TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( addressSpaceOptions?.account, From 01004f4c5f7706d8957dad9475cc7c5a67d9fc67 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 14:06:49 -0400 Subject: [PATCH 13/69] codecov Signed-off-by: jace-roell --- .../__tests__/__unit__/IssueTso.unit.test.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index 95278f92f1..c8c03724dd 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -255,6 +255,47 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { expect(error).not.toBeDefined(); expect(response).toBeDefined(); }); + + it("should utilize new API logic path", async () => { + (IssueTso.issueTsoCmd as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve({}); + }); + }); + }); + let error: ImperativeError; + let response: ISendResponse; + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", null, true, true); + } catch (thrownError) { + error = thrownError; + } + expect(error).not.toBeDefined(); + expect(response).toBeDefined(); + }); + + it("should throw and handle 404 error", async () => { + // Mock IssueTso.issueTsoCmd to throw an error + (IssueTso.issueTsoCmd as any) = jest.fn(() => { + return new Promise((_, reject) => { + process.nextTick(() => { + reject(new Error("status 404")); + }); + }); + }); + let error: ImperativeError; + let response: ISendResponse; + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", null, true, true); + } catch (thrownError) { + error = thrownError; + } + expect(error).toBeDefined(); + expect(error.message).toBe("status 404"); + expect(response).not.toBeDefined(); + }); }); describe("TsoIssue issueTsoCmd - failing scenarios", () => { From 30806a4bf42eabfd115e53fb0ee1c5158cd34b13 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 14:14:48 -0400 Subject: [PATCH 14/69] snapshots Signed-off-by: jace-roell --- .../command/Command.handler.unit.test.ts | 12 ++--- .../Command.handler.unit.test.ts.snap | 44 ++++++++++++++++++- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index 1f388be4e6..b58450c7c5 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -35,9 +35,9 @@ describe("issue command handler tests", () => { }); it("should issue command", async () => { - IssueTso.issueTsoCommand = jest.fn((session, acc, cmd, prof) => { - expect(prof).toBeDefined(); - expect(prof).toMatchSnapshot(); + let response = IssueTso.issueTsoCmd = jest.fn((session, cmd, undefined) => { + expect(response).toBeDefined(); + expect(response).toMatchSnapshot(); return StartTsoData.SAMPLE_ISSUE_RESPONSE_WITH_MSG; }); const handler = new Command.default(); @@ -45,14 +45,14 @@ describe("issue command handler tests", () => { params.arguments.acc = "acc"; params.arguments.cmd = "time"; await handler.process(params); - expect(IssueTso.issueTsoCommand).toHaveBeenCalledTimes(1); + expect(IssueTso.issueTsoCmd).toHaveBeenCalledTimes(1); }); it("should be able respond with error message", async () => { const failMessage = "IZUG1126E: z/OSMF cannot correlate the request for key \"ZOSMFAD-SYS2-55-aaakaaac\"\n" + "with an active z/OS application session."; let error; - IssueTso.issueTsoCommand = jest.fn((session, servletKey) => { + IssueTso.issueTsoCmd = jest.fn((session, servletKey) => { throw new ImperativeError({msg: failMessage}); }); const handler = new Command.default(); @@ -64,7 +64,7 @@ describe("issue command handler tests", () => { } catch (thrownError) { error = thrownError; } - expect(IssueTso.issueTsoCommand).toHaveBeenCalledTimes(1); + expect(IssueTso.issueTsoCmd).toHaveBeenCalledTimes(1); expect(error).toBeDefined(); expect(error instanceof ImperativeError).toBe(true); expect(error.message).toMatchSnapshot(); diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap index c225435f55..62b7d563be 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap @@ -5,7 +5,49 @@ exports[`issue command handler tests should be able respond with error message 1 with an active z/OS application session." `; -exports[`issue command handler tests should issue command 1`] = `false`; +exports[`issue command handler tests should issue command 1`] = ` +[MockFunction] { + "calls": Array [ + Array [ + Session { + "mISession": Object { + "base64EncodedAuth": "c29tZW9uZTpmYWtl", + "basePath": "", + "hostname": "somewhere.com", + "password": "fake", + "port": "43443", + "protocol": "https", + "rejectUnauthorized": true, + "secureProtocol": "SSLv23_method", + "strictSSL": true, + "type": "basic", + "user": "someone", + }, + "mLog": Logger { + "category": "imperative", + "initStatus": false, + "mJsLogger": Logger { + "callStackSkipIndex": 0, + "category": "imperative", + "context": Object {}, + "parseCallStack": [Function], + }, + }, + }, + undefined, + undefined, + undefined, + undefined, + ], + ], + "results": Array [ + Object { + "type": "incomplete", + "value": undefined, + }, + ], +} +`; exports[`issue command handler tests should issue command 2`] = `"messages from TSO"`; From 3d51fbfe2513c26ef0961330ff81f7e41d6ac736 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 3 Sep 2024 14:20:26 -0400 Subject: [PATCH 15/69] lint Signed-off-by: jace-roell --- .../zostso/__unit__/issue/command/Command.handler.unit.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index b58450c7c5..019a458699 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -35,7 +35,8 @@ describe("issue command handler tests", () => { }); it("should issue command", async () => { - let response = IssueTso.issueTsoCmd = jest.fn((session, cmd, undefined) => { + /* eslint-disable-next-line */ + const response = IssueTso.issueTsoCmd = jest.fn((session, cmd, undefined) => { expect(response).toBeDefined(); expect(response).toMatchSnapshot(); return StartTsoData.SAMPLE_ISSUE_RESPONSE_WITH_MSG; From d144f522a7a1505cac9dfaf5debc871cf0b380d8 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 4 Sep 2024 09:50:37 -0400 Subject: [PATCH 16/69] codecov test update Signed-off-by: jace-roell --- .../__tests__/__unit__/IssueTso.unit.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index c8c03724dd..e954b8795c 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -14,6 +14,7 @@ import { ImperativeError, Session } from "@zowe/imperative"; import { IIssueTsoParms, ISendResponse, IssueTso, IStartStopResponse, IStartTsoParms, IZosmfTsoResponse, SendTso, StartTso, StopTso } from "../../src"; import { CheckStatus } from "@zowe/zosmf-for-zowe-sdk"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; const PRETEND_SESSION = new Session({ user: "user", @@ -257,13 +258,12 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { }); it("should utilize new API logic path", async () => { - (IssueTso.issueTsoCmd as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve({}); - }); - }); - }); + const zosmfResponse = { + cmdResponse: [{message: 'IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024'}, + {message: 'READY '}], + tsoPromptReceived: 'Y' + }; + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue(Promise.resolve(zosmfResponse)); let error: ImperativeError; let response: ISendResponse; jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); From 76dbf57b944f8993023293b6fd6343f6f742b245 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 4 Sep 2024 10:54:50 -0400 Subject: [PATCH 17/69] unit testing Signed-off-by: jace-roell --- packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts | 9 +++++++-- packages/zostso/src/IssueTso.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index e954b8795c..52af3e529a 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -125,7 +125,6 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { } catch (thrownError) { error = thrownError; } - expect(StartTso.start).toHaveBeenCalledTimes(1); expect(response).not.toBeDefined(); expect(error).toBeDefined(); expect(error.message).toBe("TSO address space failed to start."); @@ -227,9 +226,15 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { let error: ImperativeError; let response: ISendResponse; + const zosmfResponse = { + cmdResponse: [{message: 'IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024'}, + {message: 'READY '}], + tsoPromptReceived: 'Y' + }; + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue(Promise.resolve(zosmfResponse)); jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TEST", undefined, true, false); + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TEST", undefined); } catch (thrownError) { error = thrownError; } diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 2db8cd1686..069a4f1d7e 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -38,8 +38,8 @@ export class IssueTso { ): Promise { let command: string | IIssueTsoCmdParms; let version: string; + if (!suppressStartupMessage) suppressStartupMessage = true; if (!isStateful) isStateful = false; - if (!suppressStartupMessage) suppressStartupMessage = false; let useNewApi = addressSpaceOptions == null && From e519c707c6753ba08b06fcafbe015af9e4aec405 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 4 Sep 2024 11:06:52 -0400 Subject: [PATCH 18/69] update Signed-off-by: jace-roell --- .../zostso/issue/command/Command.handler.ts | 18 +++++++++--------- packages/zostso/src/IssueTso.ts | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index 2d8466bc92..c95a34ac53 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -1,13 +1,13 @@ /* - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ +* This program and the accompanying materials are made available under the terms of the +* Eclipse Public License v2.0 which accompanies this distribution, and is available at +* https://www.eclipse.org/legal/epl-v20.html +* +* SPDX-License-Identifier: EPL-2.0 +* +* Copyright Contributors to the Zowe Project. +* +*/ import { IHandlerParameters } from "@zowe/imperative"; import { diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 069a4f1d7e..c63647c88c 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -1,13 +1,13 @@ /* - * This program and the accompanying materials are made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v20.html - * - * SPDX-License-Identifier: EPL-2.0 - * - * Copyright Contributors to the Zowe Project. - * - */ +* This program and the accompanying materials are made available under the terms of the +* Eclipse Public License v2.0 which accompanies this distribution, and is available at +* https://www.eclipse.org/legal/epl-v20.html +* +* SPDX-License-Identifier: EPL-2.0 +* +* Copyright Contributors to the Zowe Project. +* +*/ import { AbstractSession, Headers, ImperativeError } from "@zowe/imperative"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; From a4706f37871c7f0e37f52cb014e1339859035921 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 4 Sep 2024 14:08:26 -0400 Subject: [PATCH 19/69] mocking tso profile get in unit tests Signed-off-by: jace-roell --- .../__tests__/__unit__/IssueTso.unit.test.ts | 218 +++++++++++++----- packages/zostso/src/IssueTso.ts | 10 +- 2 files changed, 167 insertions(+), 61 deletions(-) diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index 52af3e529a..6d028217a7 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -1,20 +1,30 @@ /* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ /* eslint-disable deprecation/deprecation */ -import { ImperativeError, Session } from "@zowe/imperative"; -import { IIssueTsoParms, ISendResponse, IssueTso, IStartStopResponse, IStartTsoParms, IZosmfTsoResponse, SendTso, - StartTso, StopTso } from "../../src"; +import { ImperativeConfig, ImperativeError, Session } from "@zowe/imperative"; +import { + IIssueTsoParms, + ISendResponse, + IssueTso, + IStartStopResponse, + IStartTsoParms, + IZosmfTsoResponse, + SendTso, + StartTso, + StopTso, +} from "../../src"; import { CheckStatus } from "@zowe/zosmf-for-zowe-sdk"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +const { ProfileInfo } = require("@zowe/imperative"); const PRETEND_SESSION = new Session({ user: "user", @@ -27,7 +37,7 @@ const PRETEND_SESSION = new Session({ const SEND_RESPONSE = { success: true, zosmfResponse: {}, - commandResponse: "messages" + commandResponse: "messages", }; const PRETEND_REQUIRED_PARMS: IStartTsoParms = { logonProcedure: "IZUFPROC", @@ -36,12 +46,12 @@ const PRETEND_REQUIRED_PARMS: IStartTsoParms = { rows: "24", columns: "80", regionSize: "4096", - account: "DEFAULT" + account: "DEFAULT", }; const PRETEND_ISSUE_PARMS: IIssueTsoParms = { startParams: PRETEND_REQUIRED_PARMS, command: "COMMAND", - accountNumber: "acc" + accountNumber: "acc", }; const ZOSMF_RESPONSE: IZosmfTsoResponse = { servletKey: "ZOSMFAD-SYS2-55-aaakaaac", @@ -50,28 +60,32 @@ const ZOSMF_RESPONSE: IZosmfTsoResponse = { reused: false, timeout: false, sessionID: "0x37", - tsoData: [{ - "TSO MESSAGE": { - VERSION: "0100", - DATA: "ZOSMFAD LOGON IN PROGRESS AT 01:12:04 ON JULY 17, 2017" - } - }] + tsoData: [ + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "ZOSMFAD LOGON IN PROGRESS AT 01:12:04 ON JULY 17, 2017", + }, + }, + ], }; const START_RESPONSE: IStartStopResponse = { success: true, zosmfTsoResponse: ZOSMF_RESPONSE, - servletKey: ZOSMF_RESPONSE.servletKey + servletKey: ZOSMF_RESPONSE.servletKey, }; - describe("TsoIssue issueTsoCommand - failing scenarios", () => { - it("should fail for null account number", async () => { let error: ImperativeError; let response: ISendResponse; try { - response = await IssueTso.issueTsoCommand(PRETEND_SESSION, null, "command"); + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + null, + "command" + ); } catch (thrownError) { error = thrownError; } @@ -83,7 +97,11 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { let response: ISendResponse; try { - response = await IssueTso.issueTsoCommand(PRETEND_SESSION, "", "command"); + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "", + "command" + ); } catch (thrownError) { error = thrownError; } @@ -95,7 +113,11 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { let response: ISendResponse; try { - response = await IssueTso.issueTsoCommand(PRETEND_SESSION, "acc", null); + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "acc", + null + ); } catch (thrownError) { error = thrownError; } @@ -107,7 +129,11 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { let response: ISendResponse; try { - response = await IssueTso.issueTsoCommand(PRETEND_SESSION, "acc", ""); + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "acc", + "" + ); } catch (thrownError) { error = thrownError; } @@ -118,10 +144,20 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { let error: ImperativeError; let response: ISendResponse; - jest.spyOn(StartTso, "start").mockResolvedValueOnce({ success: false } as any); - + jest.spyOn(StartTso, "start").mockResolvedValueOnce({ + success: false, + } as any); + jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ + config: { + api: { profiles: { defaultGet: () => ({ account: "acc" }) } }, + }, + } as any); try { - response = await IssueTso.issueTsoCommand(PRETEND_SESSION, "acc", "command"); + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "acc", + "command" + ); } catch (thrownError) { error = thrownError; } @@ -161,11 +197,19 @@ describe("TsoIssue issueTsoCommand - Deprecated API", () => { }); }); }); - + jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ + config: { + api: { profiles: { defaultGet: () => ({ account: "acc" }) } }, + }, + } as any); let error: ImperativeError; let response: ISendResponse; try { - response = await IssueTso.issueTsoCommand(PRETEND_SESSION, "acc", "command"); + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "acc", + "command" + ); } catch (thrownError) { error = thrownError; } @@ -181,10 +225,18 @@ describe("TsoIssue issueTsoCommand - Deprecated API", () => { }); }); }); + jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ + config: { + api: { profiles: { defaultGet: () => ({ account: "acc" }) } }, + }, + } as any); let error: ImperativeError; let response: ISendResponse; try { - response = await IssueTso.issueTsoCommandCommon(PRETEND_SESSION, PRETEND_ISSUE_PARMS); + response = await IssueTso.issueTsoCommandCommon( + PRETEND_SESSION, + PRETEND_ISSUE_PARMS + ); } catch (thrownError) { error = thrownError; } @@ -227,14 +279,27 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { let error: ImperativeError; let response: ISendResponse; const zosmfResponse = { - cmdResponse: [{message: 'IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024'}, - {message: 'READY '}], - tsoPromptReceived: 'Y' + cmdResponse: [ + { + message: + "IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024", + }, + { message: "READY " }, + ], + tsoPromptReceived: "Y", }; - jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue(Promise.resolve(zosmfResponse)); - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue( + Promise.resolve(zosmfResponse) + ); + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TEST", undefined); + response = await IssueTso.issueTsoCmd( + PRETEND_SESSION, + "TEST", + undefined + ); } catch (thrownError) { error = thrownError; } @@ -252,9 +317,17 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { }); let error: ImperativeError; let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "command", undefined, true, false); + response = await IssueTso.issueTsoCmd( + PRETEND_SESSION, + "command", + undefined, + true, + false + ); } catch (thrownError) { error = thrownError; } @@ -264,16 +337,31 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { it("should utilize new API logic path", async () => { const zosmfResponse = { - cmdResponse: [{message: 'IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024'}, - {message: 'READY '}], - tsoPromptReceived: 'Y' + cmdResponse: [ + { + message: + "IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024", + }, + { message: "READY " }, + ], + tsoPromptReceived: "Y", }; - jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue(Promise.resolve(zosmfResponse)); + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue( + Promise.resolve(zosmfResponse) + ); let error: ImperativeError; let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", null, true, true); + response = await IssueTso.issueTsoCmd( + PRETEND_SESSION, + "TIME", + null, + true, + true + ); } catch (thrownError) { error = thrownError; } @@ -293,7 +381,13 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { let error: ImperativeError; let response: ISendResponse; try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", null, true, true); + response = await IssueTso.issueTsoCmd( + PRETEND_SESSION, + "TIME", + null, + true, + true + ); } catch (thrownError) { error = thrownError; } @@ -307,9 +401,17 @@ describe("TsoIssue issueTsoCmd - failing scenarios", () => { it("should fail for null command text", async () => { let error: ImperativeError; let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "fake_command", undefined, true, false); + response = await IssueTso.issueTsoCmd( + PRETEND_SESSION, + "fake_command", + undefined, + true, + false + ); } catch (thrownError) { error = thrownError; } @@ -319,13 +421,21 @@ describe("TsoIssue issueTsoCmd - failing scenarios", () => { it("should fail for empty command text", async () => { let error: ImperativeError; let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue(Promise.resolve(true)); + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "", undefined, true, false); + response = await IssueTso.issueTsoCmd( + PRETEND_SESSION, + "", + undefined, + true, + false + ); } catch (thrownError) { error = thrownError; } expect(response).not.toBeDefined(); expect(error).toBeDefined(); }); -}); \ No newline at end of file +}); diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index c63647c88c..752120ac62 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -9,7 +9,7 @@ * */ -import { AbstractSession, Headers, ImperativeError } from "@zowe/imperative"; +import { AbstractSession, Headers, ImperativeConfig, ImperativeError } from "@zowe/imperative"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; import { noAccountNumber, noCommandInput, TsoConstants } from "./TsoConstants"; import { SendTso } from "./SendTso"; @@ -22,7 +22,6 @@ import { CheckStatus, ZosmfConstants } from "@zowe/zosmf-for-zowe-sdk"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { IIssueTsoCmdResponse } from "./doc/IIssueTsoCmdResponse"; import { IIssueTsoCmdParms } from "./doc/input/IIssueTsoCmdParms"; -const { ProfileInfo } = require("@zowe/imperative"); /** * Class to handle issue command to TSO @@ -82,11 +81,8 @@ export class IssueTso { } // Deprecated API Behavior [former issueTsoCommand() behavior] if (addressSpaceOptions != null || !useNewApi) { - const profInfo = new ProfileInfo("zowe"); - await profInfo.readProfilesFromDisk(); - addressSpaceOptions = profInfo - .getTeamConfig() - .api.profiles.defaultGet("tso"); + const profInfo = ImperativeConfig.instance.config.api.profiles.defaultGet("tso"); + addressSpaceOptions = { ...addressSpaceOptions, ...profInfo}; command = typeof commandInfo === "string" ? commandInfo From 30afc5629cab2a80eadeb8cebde07b5f78b80cb9 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 4 Sep 2024 15:44:58 -0400 Subject: [PATCH 20/69] snapshot Signed-off-by: jace-roell --- .../cli.zos-tso.issue.cmd.integration.test.ts.snap | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap index ceddc6e604..5a9876216d 100644 --- a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap @@ -34,6 +34,14 @@ exports[`zos-tso issue command should display the help 1`] = ` Suppress console messages from start of address space. + Default value: true + + --stateful | --sf (boolean) + + Statefulness of address space created for TSO Command. + + Default value: false + TSO ADDRESS SPACE OPTIONS ------------------------- @@ -185,8 +193,8 @@ exports[`zos-tso issue command should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: command.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: true\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO Command.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: true\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO Command.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" }" `; From 90209ad0b21e153d6be986c52f788a60f6d9631c Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 5 Sep 2024 10:43:28 -0400 Subject: [PATCH 21/69] linting, documentation, interface consolidation Signed-off-by: jace-roell --- .../Command.handler.unit.test.ts.snap | 7 ++- .../zostso/issue/command/Command.handler.ts | 26 +++++---- .../__tests__/__unit__/IssueTso.unit.test.ts | 57 ++++++++----------- packages/zostso/src/IssueTso.ts | 35 +++++------- .../zostso/src/doc/IIssueTsoCmdResponse.ts | 23 ++++++++ .../zostso/src/doc/input/IIssueTsoCmdOpts.ts | 40 +++++++++++++ .../zostso/src/doc/input/IIssueTsoCmdParms.ts | 16 +++++- 7 files changed, 132 insertions(+), 72 deletions(-) create mode 100644 packages/zostso/src/doc/input/IIssueTsoCmdOpts.ts diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap index 62b7d563be..68d1652a6c 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap @@ -35,9 +35,10 @@ exports[`issue command handler tests should issue command 1`] = ` }, }, undefined, - undefined, - undefined, - undefined, + Object { + "isStateful": undefined, + "suppressStartupMessage": undefined, + }, ], ], "results": Array [ diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index c95a34ac53..c242a8182a 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -1,13 +1,13 @@ /* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ import { IHandlerParameters } from "@zowe/imperative"; import { @@ -28,9 +28,11 @@ export default class Handler extends ZosTsoBaseHandler { const response: IIssueResponse = await IssueTso.issueTsoCmd( this.mSession, params.arguments.commandText, - undefined, - params.arguments.stateful, - params.arguments.suppressStartupMessages + { + isStateful: params.arguments.stateful, + suppressStartupMessage: + params.arguments.suppressStartupMessages, + } ); // If requested, suppress the startup diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index 6d028217a7..fe40d75fb9 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -24,7 +24,6 @@ import { } from "../../src"; import { CheckStatus } from "@zowe/zosmf-for-zowe-sdk"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -const { ProfileInfo } = require("@zowe/imperative"); const PRETEND_SESSION = new Session({ user: "user", @@ -297,8 +296,7 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { try { response = await IssueTso.issueTsoCmd( PRETEND_SESSION, - "TEST", - undefined + "TEST" ); } catch (thrownError) { error = thrownError; @@ -321,13 +319,10 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { Promise.resolve(true) ); try { - response = await IssueTso.issueTsoCmd( - PRETEND_SESSION, - "command", - undefined, - true, - false - ); + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "command", { + isStateful: true, + suppressStartupMessage: false, + }); } catch (thrownError) { error = thrownError; } @@ -355,13 +350,11 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { Promise.resolve(true) ); try { - response = await IssueTso.issueTsoCmd( - PRETEND_SESSION, - "TIME", - null, - true, - true - ); + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", { + addressSpaceOptions: null, + isStateful: true, + suppressStartupMessage: true, + }); } catch (thrownError) { error = thrownError; } @@ -381,13 +374,11 @@ describe("TsoIssue issueTsoCmd - Revised API", () => { let error: ImperativeError; let response: ISendResponse; try { - response = await IssueTso.issueTsoCmd( - PRETEND_SESSION, - "TIME", - null, - true, - true - ); + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", { + addressSpaceOptions: null, + isStateful: true, + suppressStartupMessage: true, + }); } catch (thrownError) { error = thrownError; } @@ -408,9 +399,10 @@ describe("TsoIssue issueTsoCmd - failing scenarios", () => { response = await IssueTso.issueTsoCmd( PRETEND_SESSION, "fake_command", - undefined, - true, - false + { + isStateful: true, + suppressStartupMessage: false, + } ); } catch (thrownError) { error = thrownError; @@ -425,13 +417,10 @@ describe("TsoIssue issueTsoCmd - failing scenarios", () => { Promise.resolve(true) ); try { - response = await IssueTso.issueTsoCmd( - PRETEND_SESSION, - "", - undefined, - true, - false - ); + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "", { + isStateful: true, + suppressStartupMessage: false, + }); } catch (thrownError) { error = thrownError; } diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 752120ac62..7977a2c498 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -22,7 +22,7 @@ import { CheckStatus, ZosmfConstants } from "@zowe/zosmf-for-zowe-sdk"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { IIssueTsoCmdResponse } from "./doc/IIssueTsoCmdResponse"; import { IIssueTsoCmdParms } from "./doc/input/IIssueTsoCmdParms"; - +import { IIssueTsoCmdOpts } from "./doc/input/IIssueTsoCmdOpts" /** * Class to handle issue command to TSO * @class IssueTso @@ -31,22 +31,19 @@ export class IssueTso { public static async issueTsoCmd( session: AbstractSession, commandInfo: string | IIssueTsoCmdParms, - addressSpaceOptions?: IStartTsoParms, - isStateful?: boolean, - suppressStartupMessage?: boolean + opts?: IIssueTsoCmdOpts ): Promise { let command: string | IIssueTsoCmdParms; let version: string; - if (!suppressStartupMessage) suppressStartupMessage = true; - if (!isStateful) isStateful = false; + opts = opts || {}; let useNewApi = - addressSpaceOptions == null && + opts.addressSpaceOptions == null && await CheckStatus.isZosVersionGreaterThan( session, ZosmfConstants.VERSIONS.V2R4 ) && - suppressStartupMessage === true; + (opts.suppressStartupMessage ?? true); if (useNewApi) { command = commandInfo; version = "v1"; @@ -59,7 +56,7 @@ export class IssueTso { [Headers.APPLICATION_JSON], { tsoCmd: command, - cmdState: isStateful ? "stateful" : "stateless", + cmdState: opts.isStateful ? "stateful" : "stateless", } ); const response: IIssueResponse = { @@ -80,16 +77,16 @@ export class IssueTso { } } // Deprecated API Behavior [former issueTsoCommand() behavior] - if (addressSpaceOptions != null || !useNewApi) { + if (opts.addressSpaceOptions != null || !useNewApi) { const profInfo = ImperativeConfig.instance.config.api.profiles.defaultGet("tso"); - addressSpaceOptions = { ...addressSpaceOptions, ...profInfo}; + opts.addressSpaceOptions = { ...opts.addressSpaceOptions, ...profInfo}; command = typeof commandInfo === "string" ? commandInfo : commandInfo.command; TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( - addressSpaceOptions?.account, + opts.addressSpaceOptions?.account, noAccountNumber.message ); TsoValidator.validateNotEmptyString( @@ -101,8 +98,8 @@ export class IssueTso { success: false, startResponse: await StartTso.start( session, - addressSpaceOptions?.account, - addressSpaceOptions || {} + opts.addressSpaceOptions?.account, + opts.addressSpaceOptions || {} ), startReady: false, zosmfResponse: null, @@ -152,10 +149,7 @@ export class IssueTso { command: string, startParams?: IStartTsoParms ): Promise { - return (await IssueTso.issueTsoCmd(session, command, { - ...startParams, - account: accountNumber, - })) as IIssueResponse; + return (await IssueTso.issueTsoCmd(session, command, { addressSpaceOptions: {...startParams, account: accountNumber}})); } /** @@ -170,9 +164,6 @@ export class IssueTso { session: AbstractSession, commandParms: IIssueTsoParms ): Promise { - return (await IssueTso.issueTsoCmd(session, commandParms.command, { - ...commandParms.startParams, - account: commandParms.accountNumber, - })) as IIssueResponse; + return (await IssueTso.issueTsoCmd(session, commandParms.command, { addressSpaceOptions: {...commandParms.startParams,account: commandParms.accountNumber}})); } } diff --git a/packages/zostso/src/doc/IIssueTsoCmdResponse.ts b/packages/zostso/src/doc/IIssueTsoCmdResponse.ts index 2537831e02..81034ec848 100644 --- a/packages/zostso/src/doc/IIssueTsoCmdResponse.ts +++ b/packages/zostso/src/doc/IIssueTsoCmdResponse.ts @@ -11,11 +11,34 @@ export interface IIssueTsoCmdResponse { + /** + * Command response + * @type {{message: string}[]} + * @memberof IIssueTsoCmdResponse + */ cmdResponse: {message: string}[]; + /** + * Whether the TSO PROMPT sign is received in the command response. + * "Y": TSO Prompt is Recieved. "N": TSO Prompt is not recieved yet. + * @type {"Y" | "N"} + * @memberof IIssueTsoCmdResponse + */ tsoPromptReceived: "Y" | "N", + /** + * Unique identifier for the servlet entry. + * It maps to the TSO/E address space in which the TSO/E command is issued. servletKey is returned only when cmdState is stateful for z/OS 2.4 and above + * @type {string} + * @memberof IIssueTsoCmdResponse + */ servletKey?: string; + /** + * The result of the response detection request. This is returned when the keyword is specified. + * "Y": Matching record in the response was found. "N": Matching record in the response was not found. + * @type {"Y" | "N"} + * @memberof IIssueTsoCmdResponse + */ keywordDetected?: "Y" | "N", } diff --git a/packages/zostso/src/doc/input/IIssueTsoCmdOpts.ts b/packages/zostso/src/doc/input/IIssueTsoCmdOpts.ts new file mode 100644 index 0000000000..15784e33ff --- /dev/null +++ b/packages/zostso/src/doc/input/IIssueTsoCmdOpts.ts @@ -0,0 +1,40 @@ +/* +* This program and the accompanying materials are made available under the terms of the +* Eclipse Public License v2.0 which accompanies this distribution, and is available at +* https://www.eclipse.org/legal/epl-v20.html +* +* SPDX-License-Identifier: EPL-2.0 +* +* Copyright Contributors to the Zowe Project. +* +*/ + +import { IStartTsoParms } from "./IStartTsoParms"; + +/** + * Interface for command options passed in from command handler + * @export + * @interface IIssueTsoCmdOpts + */ +export interface IIssueTsoCmdOpts { + /** + * address space options for TSO Command + * @type {string} + * @memberof IIssueTsoCmdOpts + */ + addressSpaceOptions?: IStartTsoParms; + + /** + * z/OS >2.4 TSO Command statefulness of address space + * @type {boolean} + * @memberof IIssueTsoCmdOpts + */ + isStateful?: boolean; + + /** + * suppressing broadcast message from TSO address space + * @type {boolean} + * @memberof IIssueTsoCmdOpts + */ + suppressStartupMessage?: boolean; +} diff --git a/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts b/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts index 04cfbea2c8..1a9850102a 100644 --- a/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts +++ b/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts @@ -10,10 +10,24 @@ */ export interface IIssueTsoCmdParms { - + /** + * command being ran on TSO address space + * @type {string} + * @memberof IIssueTsoCmdParms + */ command: string; + /** + * z/OS >2.4 TSO Command statefulness of address space + * @type {boolean} + * @memberof IIssueTsoCmdParms + */ isStateful?: boolean; + /** + * current version of z/OS connection + * @type {string} + * @memberof IIssueTsoCmdParms + */ version?: string; } From cd24334cbc967f7b976dd08e92e70c7e3463b910 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 5 Sep 2024 10:53:50 -0400 Subject: [PATCH 22/69] changelog linting Signed-off-by: jace-roell --- packages/zostso/CHANGELOG.md | 3 ++- packages/zostso/src/IssueTso.ts | 7 ++++--- packages/zostso/src/doc/IIssueTsoCmdResponse.ts | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/zostso/CHANGELOG.md b/packages/zostso/CHANGELOG.md index 0090c6c9ed..43241a6386 100644 --- a/packages/zostso/CHANGELOG.md +++ b/packages/zostso/CHANGELOG.md @@ -4,7 +4,8 @@ All notable changes to the Zowe z/OS TSO SDK package will be documented in this ## Recent Changes -- Enhancement: Deprecated `IssueTsoCommand()` function and replaced with `IssueTsoCmd()` for compatibility with z/Os version 2.5. [#2240](https://github.com/zowe/zowe-cli/pull/2240) +- Enhancement: Deprecated `IssueTsoCommand()` function and replaced with `IssueTsoCmd()` for compatibility with z/OS version 2.4. [#2240](https://github.com/zowe/zowe-cli/pull/2240) +- Enhancement: Modified `IIssueReponse` to handle z/OS 2.4 and newer TSO command response. [#2240](https://github.com/zowe/zowe-cli/pull/2240) ## `8.0.0-next.202408131445` diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 7977a2c498..90541a37b6 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -22,7 +22,7 @@ import { CheckStatus, ZosmfConstants } from "@zowe/zosmf-for-zowe-sdk"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { IIssueTsoCmdResponse } from "./doc/IIssueTsoCmdResponse"; import { IIssueTsoCmdParms } from "./doc/input/IIssueTsoCmdParms"; -import { IIssueTsoCmdOpts } from "./doc/input/IIssueTsoCmdOpts" +import { IIssueTsoCmdOpts } from "./doc/input/IIssueTsoCmdOpts"; /** * Class to handle issue command to TSO * @class IssueTso @@ -149,7 +149,7 @@ export class IssueTso { command: string, startParams?: IStartTsoParms ): Promise { - return (await IssueTso.issueTsoCmd(session, command, { addressSpaceOptions: {...startParams, account: accountNumber}})); + return await IssueTso.issueTsoCmd(session, command, { addressSpaceOptions: {...startParams, account: accountNumber}}); } /** @@ -164,6 +164,7 @@ export class IssueTso { session: AbstractSession, commandParms: IIssueTsoParms ): Promise { - return (await IssueTso.issueTsoCmd(session, commandParms.command, { addressSpaceOptions: {...commandParms.startParams,account: commandParms.accountNumber}})); + return await IssueTso.issueTsoCmd(session, commandParms.command, + { addressSpaceOptions: {...commandParms.startParams,account: commandParms.accountNumber}}); } } diff --git a/packages/zostso/src/doc/IIssueTsoCmdResponse.ts b/packages/zostso/src/doc/IIssueTsoCmdResponse.ts index 81034ec848..231c53bc15 100644 --- a/packages/zostso/src/doc/IIssueTsoCmdResponse.ts +++ b/packages/zostso/src/doc/IIssueTsoCmdResponse.ts @@ -28,7 +28,8 @@ export interface IIssueTsoCmdResponse { /** * Unique identifier for the servlet entry. - * It maps to the TSO/E address space in which the TSO/E command is issued. servletKey is returned only when cmdState is stateful for z/OS 2.4 and above + * It maps to the TSO/E address space in which the TSO/E command is issued. + * servletKey is returned only when cmdState is stateful for z/OS 2.4 and above * @type {string} * @memberof IIssueTsoCmdResponse */ From 67634afc80ad9cc2219441853ce9c4803477bebd Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 5 Sep 2024 13:07:04 -0400 Subject: [PATCH 23/69] changelog Signed-off-by: jace-roell --- packages/cli/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 54e5af3990..658407132b 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -4,8 +4,8 @@ All notable changes to the Zowe CLI package will be documented in this file. ## Recent Changes -- Enhancement: Deprecated `issueTsoCommand()` function and replaced with `issueTsoCmd()` to allow for dynamic behavior -based on z/OS version to utilize 2.4 TSO command behavior. [#2240](https://github.com/zowe/zowe-cli/pull/2240) +- Enhancement: Deprecated `issueTsoCommand()` function and replaced with `issueTsoCmd()` to allow for dynamic system behavior +based on the z/OS version in use to utilize 2.4 TSO command behavior. [#2240](https://github.com/zowe/zowe-cli/pull/2240) ## `8.0.0-next.202408261543` From e1af1b2c9f4f35095a2a3591bba718bb9d50bc6e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 11 Sep 2024 13:14:52 -0400 Subject: [PATCH 24/69] system test files mac support Signed-off-by: jace-roell --- .../__tests__/auth/__system__/__scripts__/create_team_cfg.sh | 0 .../issue/__scripts__/command/command_console.sh | 2 +- .../issue/__scripts__/command/command_console_rfj.sh | 2 +- .../__system__/issue/__scripts__/command/command_console.sh | 2 +- .../__system__/issue/__scripts__/command/command_console_rfj.sh | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 packages/cli/__tests__/auth/__system__/__scripts__/create_team_cfg.sh diff --git a/packages/cli/__tests__/auth/__system__/__scripts__/create_team_cfg.sh b/packages/cli/__tests__/auth/__system__/__scripts__/create_team_cfg.sh old mode 100644 new mode 100755 diff --git a/packages/cli/__tests__/zosconsole/__integration__/issue/__scripts__/command/command_console.sh b/packages/cli/__tests__/zosconsole/__integration__/issue/__scripts__/command/command_console.sh index 6f1c161a35..b8ce1a4fcd 100755 --- a/packages/cli/__tests__/zosconsole/__integration__/issue/__scripts__/command/command_console.sh +++ b/packages/cli/__tests__/zosconsole/__integration__/issue/__scripts__/command/command_console.sh @@ -2,7 +2,7 @@ set -e # Generate console name: 6 characters + "CN" -CONSOLE_NAME=`cat /dev/urandom | tr -dc '[:upper:]' | fold -w 6 | head -n 1` +CONSOLE_NAME=`cat /dev/urandom | LC_CTYPE=C tr -dc '[:upper:]' | fold -w 6 | head -n 1` CONSOLE_NAME="${CONSOLE_NAME}CN" # Ensure that console doesn't exist diff --git a/packages/cli/__tests__/zosconsole/__integration__/issue/__scripts__/command/command_console_rfj.sh b/packages/cli/__tests__/zosconsole/__integration__/issue/__scripts__/command/command_console_rfj.sh index e269b59473..bce5b4b415 100755 --- a/packages/cli/__tests__/zosconsole/__integration__/issue/__scripts__/command/command_console_rfj.sh +++ b/packages/cli/__tests__/zosconsole/__integration__/issue/__scripts__/command/command_console_rfj.sh @@ -2,7 +2,7 @@ set -e # Generate console name: 6 characters + "CN" -CONSOLE_NAME=`cat /dev/urandom | tr -dc '[:upper:]' | fold -w 6 | head -n 1` +CONSOLE_NAME=`cat /dev/urandom | LC_CTYPE=C tr -dc '[:upper:]' | fold -w 6 | head -n 1` CONSOLE_NAME="${CONSOLE_NAME}CN" # Ensure that console doesn't exist diff --git a/packages/cli/__tests__/zosconsole/__system__/issue/__scripts__/command/command_console.sh b/packages/cli/__tests__/zosconsole/__system__/issue/__scripts__/command/command_console.sh index 6f1c161a35..b8ce1a4fcd 100755 --- a/packages/cli/__tests__/zosconsole/__system__/issue/__scripts__/command/command_console.sh +++ b/packages/cli/__tests__/zosconsole/__system__/issue/__scripts__/command/command_console.sh @@ -2,7 +2,7 @@ set -e # Generate console name: 6 characters + "CN" -CONSOLE_NAME=`cat /dev/urandom | tr -dc '[:upper:]' | fold -w 6 | head -n 1` +CONSOLE_NAME=`cat /dev/urandom | LC_CTYPE=C tr -dc '[:upper:]' | fold -w 6 | head -n 1` CONSOLE_NAME="${CONSOLE_NAME}CN" # Ensure that console doesn't exist diff --git a/packages/cli/__tests__/zosconsole/__system__/issue/__scripts__/command/command_console_rfj.sh b/packages/cli/__tests__/zosconsole/__system__/issue/__scripts__/command/command_console_rfj.sh index e269b59473..bce5b4b415 100755 --- a/packages/cli/__tests__/zosconsole/__system__/issue/__scripts__/command/command_console_rfj.sh +++ b/packages/cli/__tests__/zosconsole/__system__/issue/__scripts__/command/command_console_rfj.sh @@ -2,7 +2,7 @@ set -e # Generate console name: 6 characters + "CN" -CONSOLE_NAME=`cat /dev/urandom | tr -dc '[:upper:]' | fold -w 6 | head -n 1` +CONSOLE_NAME=`cat /dev/urandom | LC_CTYPE=C tr -dc '[:upper:]' | fold -w 6 | head -n 1` CONSOLE_NAME="${CONSOLE_NAME}CN" # Ensure that console doesn't exist From 96dbc945c59f3af00216ab61d9c7aa8351b40962 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 12 Sep 2024 10:27:46 -0400 Subject: [PATCH 25/69] updated unit tests, system tests and minor logic changes Signed-off-by: jace-roell --- .../Command.handler.unit.test.ts.snap | 9 ++++ .../zostso/issue/command/Command.handler.ts | 1 + .../__system__/api.TsoIssue.system.test.ts | 44 +++++++++++++++++-- .../__tests__/__unit__/IssueTso.unit.test.ts | 6 +++ packages/zostso/src/IssueTso.ts | 5 +-- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap index 68d1652a6c..88bd085302 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap @@ -36,6 +36,15 @@ exports[`issue command handler tests should issue command 1`] = ` }, undefined, Object { + "addressSpaceOptions": Object { + "account": "fake", + "characterSet": undefined, + "codePage": undefined, + "columns": undefined, + "logonProcedure": undefined, + "regionSize": undefined, + "rows": undefined, + }, "isStateful": undefined, "suppressStartupMessage": undefined, }, diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index c242a8182a..42e939301e 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -32,6 +32,7 @@ export default class Handler extends ZosTsoBaseHandler { isStateful: params.arguments.stateful, suppressStartupMessage: params.arguments.suppressStartupMessages, + addressSpaceOptions: this.mTsoStart } ); diff --git a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts index ed48b1dfe4..c17ebef463 100644 --- a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts @@ -16,7 +16,8 @@ import * as fs from "fs"; import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; - +import { IIssueTsoCmdParms } from "../../src"; +import { IIssueTsoCmdOpts } from "../../src/doc/input/IIssueTsoCmdOpts"; let testEnvironment: ITestEnvironment; let systemProperties: ITestPropertiesSchema; let REAL_SESSION: Session; @@ -24,7 +25,8 @@ let ACCOUNT_NUMBER: string; let START_PARAMS: IStartTsoParms; let ISSUE_PARAMS: IIssueTsoParms; - +let COMMAND_PARAMS: IIssueTsoCmdParms; +let AS_OPTIONS: IIssueTsoCmdOpts; describe("IssueTso.issueTsoCommand", () => { beforeAll(async () => { @@ -50,9 +52,18 @@ describe("IssueTso.issueTsoCommand", () => { accountNumber: ACCOUNT_NUMBER, startParams: START_PARAMS }; - + COMMAND_PARAMS = { + command: "TIME" + } + AS_OPTIONS = { + addressSpaceOptions: START_PARAMS + } + }); + afterAll(async () => { + AS_OPTIONS = { + addressSpaceOptions: START_PARAMS + } }); - it("should display time", async () => { let error: ImperativeError; let response: IIssueResponse; @@ -81,4 +92,29 @@ describe("IssueTso.issueTsoCommand", () => { const regex = fs.readFileSync(__dirname + "/__regex__/d_time.regex").toString(); expect(new RegExp(regex, "g").test(response.commandResponse.toString())).toBe(true); }); + it("should display time - issueTsoCmd() - new API - pass", async () => { + let error: ImperativeError; + let response: IIssueResponse; + try { + response = await IssueTso.issueTsoCmd(REAL_SESSION, "TIME", AS_OPTIONS); + } catch (thrownError) { + error = thrownError; + } + expect(error).toBeUndefined(); + expect(response).toBeDefined(); + const regex = fs.readFileSync(__dirname + "/__regex__/d_time.regex").toString(); + expect(new RegExp(regex, "g").test(response.commandResponse.toString())).toBe(true); + }); + it("should fail - issueTsoCmd() - 404 error", async () => { + REAL_SESSION.ISession.basePath = "/bad/path/to/nothing" + let error: ImperativeError; + let response: IIssueResponse; + try { + response = await IssueTso.issueTsoCmd(REAL_SESSION, "TIME", AS_OPTIONS); + } catch (thrownError) { + error = thrownError; + } + expect(error).toBeDefined(); + expect(response).toBeUndefined(); + }); }); diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index fe40d75fb9..3404c65026 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -140,6 +140,9 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { expect(error).toBeDefined(); }); it("should fail when StartTSO fails", async () => { + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(false) + ); let error: ImperativeError; let response: ISendResponse; @@ -168,6 +171,9 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { describe("TsoIssue issueTsoCommand - Deprecated API", () => { it("should succeed", async () => { + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(false) + ); (StartTso.start as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 90541a37b6..c9f12525e4 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -36,9 +36,8 @@ export class IssueTso { let command: string | IIssueTsoCmdParms; let version: string; opts = opts || {}; - let useNewApi = - opts.addressSpaceOptions == null && + opts.addressSpaceOptions == null || await CheckStatus.isZosVersionGreaterThan( session, ZosmfConstants.VERSIONS.V2R4 @@ -78,8 +77,6 @@ export class IssueTso { } // Deprecated API Behavior [former issueTsoCommand() behavior] if (opts.addressSpaceOptions != null || !useNewApi) { - const profInfo = ImperativeConfig.instance.config.api.profiles.defaultGet("tso"); - opts.addressSpaceOptions = { ...opts.addressSpaceOptions, ...profInfo}; command = typeof commandInfo === "string" ? commandInfo From a1549e233f203fc3697778894f49948f1e6668a2 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 12 Sep 2024 10:32:41 -0400 Subject: [PATCH 26/69] linting Signed-off-by: jace-roell --- packages/cli/src/zostso/issue/command/Command.handler.ts | 2 +- .../__tests__/__system__/api.TsoIssue.system.test.ts | 8 ++++---- packages/zostso/src/IssueTso.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index 42e939301e..d1b9790875 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -32,7 +32,7 @@ export default class Handler extends ZosTsoBaseHandler { isStateful: params.arguments.stateful, suppressStartupMessage: params.arguments.suppressStartupMessages, - addressSpaceOptions: this.mTsoStart + addressSpaceOptions: this.mTsoStart } ); diff --git a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts index c17ebef463..22bf915403 100644 --- a/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoIssue.system.test.ts @@ -54,15 +54,15 @@ describe("IssueTso.issueTsoCommand", () => { }; COMMAND_PARAMS = { command: "TIME" - } + }; AS_OPTIONS = { addressSpaceOptions: START_PARAMS - } + }; }); afterAll(async () => { AS_OPTIONS = { addressSpaceOptions: START_PARAMS - } + }; }); it("should display time", async () => { let error: ImperativeError; @@ -106,7 +106,7 @@ describe("IssueTso.issueTsoCommand", () => { expect(new RegExp(regex, "g").test(response.commandResponse.toString())).toBe(true); }); it("should fail - issueTsoCmd() - 404 error", async () => { - REAL_SESSION.ISession.basePath = "/bad/path/to/nothing" + REAL_SESSION.ISession.basePath = "/bad/path/to/nothing"; let error: ImperativeError; let response: IIssueResponse; try { diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index c9f12525e4..0ad775d1d1 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -9,7 +9,7 @@ * */ -import { AbstractSession, Headers, ImperativeConfig, ImperativeError } from "@zowe/imperative"; +import { AbstractSession, Headers, ImperativeError } from "@zowe/imperative"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; import { noAccountNumber, noCommandInput, TsoConstants } from "./TsoConstants"; import { SendTso } from "./SendTso"; From 939196da95f9274110e7ad933dc5cbca09662e27 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 12 Sep 2024 15:01:06 -0400 Subject: [PATCH 27/69] testing update Signed-off-by: jace-roell --- .../__tests__/__unit__/IssueTso.unit.test.ts | 653 +++++++++--------- 1 file changed, 340 insertions(+), 313 deletions(-) diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index 3404c65026..dfdedf814c 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -73,364 +73,391 @@ const START_RESPONSE: IStartStopResponse = { zosmfTsoResponse: ZOSMF_RESPONSE, servletKey: ZOSMF_RESPONSE.servletKey, }; +describe("all tests", () => { + describe("TsoIssue issueTsoCommand - failing scenarios", () => { + it("should fail for null account number", async () => { + let error: ImperativeError; + let response: ISendResponse; -describe("TsoIssue issueTsoCommand - failing scenarios", () => { - it("should fail for null account number", async () => { - let error: ImperativeError; - let response: ISendResponse; + try { + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + null, + "command" + ); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + }); + it("should fail for empty account number", async () => { + let error: ImperativeError; + let response: ISendResponse; - try { - response = await IssueTso.issueTsoCommand( - PRETEND_SESSION, - null, - "command" - ); - } catch (thrownError) { - error = thrownError; - } - expect(response).not.toBeDefined(); - expect(error).toBeDefined(); - }); - it("should fail for empty account number", async () => { - let error: ImperativeError; - let response: ISendResponse; + try { + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "", + "command" + ); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + }); + it("should fail for null command text", async () => { + let error: ImperativeError; + let response: ISendResponse; - try { - response = await IssueTso.issueTsoCommand( - PRETEND_SESSION, - "", - "command" - ); - } catch (thrownError) { - error = thrownError; - } - expect(response).not.toBeDefined(); - expect(error).toBeDefined(); - }); - it("should fail for null command text", async () => { - let error: ImperativeError; - let response: ISendResponse; + try { + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "acc", + null + ); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + }); + it("should fail for empty command text", async () => { + let error: ImperativeError; + let response: ISendResponse; - try { - response = await IssueTso.issueTsoCommand( - PRETEND_SESSION, - "acc", - null + try { + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "acc", + "" + ); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + }); + it("should fail when StartTSO fails", async () => { + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(false) ); - } catch (thrownError) { - error = thrownError; - } - expect(response).not.toBeDefined(); - expect(error).toBeDefined(); - }); - it("should fail for empty command text", async () => { - let error: ImperativeError; - let response: ISendResponse; + let error: ImperativeError; + let response: ISendResponse; - try { - response = await IssueTso.issueTsoCommand( - PRETEND_SESSION, - "acc", - "" - ); - } catch (thrownError) { - error = thrownError; - } - expect(response).not.toBeDefined(); - expect(error).toBeDefined(); + jest.spyOn(StartTso, "start").mockResolvedValueOnce({ + success: false, + } as any); + jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ + config: { + api: { + profiles: { defaultGet: () => ({ account: "acc" }) }, + }, + }, + } as any); + try { + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "acc", + "command" + ); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + expect(error.message).toBe("TSO address space failed to start."); + }); }); - it("should fail when StartTSO fails", async () => { - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( - Promise.resolve(false) - ); - let error: ImperativeError; - let response: ISendResponse; - jest.spyOn(StartTso, "start").mockResolvedValueOnce({ - success: false, - } as any); - jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ - config: { - api: { profiles: { defaultGet: () => ({ account: "acc" }) } }, - }, - } as any); - try { - response = await IssueTso.issueTsoCommand( - PRETEND_SESSION, - "acc", - "command" + describe("TsoIssue issueTsoCommand - Deprecated API", () => { + it("should succeed", async () => { + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(false) ); - } catch (thrownError) { - error = thrownError; - } - expect(response).not.toBeDefined(); - expect(error).toBeDefined(); - expect(error.message).toBe("TSO address space failed to start."); - }); -}); - -describe("TsoIssue issueTsoCommand - Deprecated API", () => { - it("should succeed", async () => { - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( - Promise.resolve(false) - ); - (StartTso.start as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve(START_RESPONSE); + (StartTso.start as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(START_RESPONSE); + }); }); }); - }); - (SendTso.getAllResponses as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve({}); + (SendTso.getAllResponses as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve({}); + }); }); }); - }); - (SendTso.sendDataToTSOCollect as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve(SEND_RESPONSE); + (SendTso.sendDataToTSOCollect as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(SEND_RESPONSE); + }); }); }); - }); - (StopTso.stop as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve(null); + (StopTso.stop as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(null); + }); }); }); + jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ + config: { + api: { + profiles: { defaultGet: () => ({ account: "acc" }) }, + }, + }, + } as any); + let error: ImperativeError; + let response: ISendResponse; + try { + response = await IssueTso.issueTsoCommand( + PRETEND_SESSION, + "acc", + "command" + ); + } catch (thrownError) { + error = thrownError; + } + expect(error).not.toBeDefined(); + expect(response).toBeDefined(); }); - jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ - config: { - api: { profiles: { defaultGet: () => ({ account: "acc" }) } }, - }, - } as any); - let error: ImperativeError; - let response: ISendResponse; - try { - response = await IssueTso.issueTsoCommand( - PRETEND_SESSION, - "acc", - "command" - ); - } catch (thrownError) { - error = thrownError; - } - expect(error).not.toBeDefined(); - expect(response).toBeDefined(); - }); - it("should succeed (with params)", async () => { - (IssueTso.issueTsoCommand as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve({}); + it("should succeed (with params)", async () => { + (IssueTso.issueTsoCommand as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve({}); + }); }); }); + jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ + config: { + api: { + profiles: { defaultGet: () => ({ account: "acc" }) }, + }, + }, + } as any); + let error: ImperativeError; + let response: ISendResponse; + try { + response = await IssueTso.issueTsoCommandCommon( + PRETEND_SESSION, + PRETEND_ISSUE_PARMS + ); + } catch (thrownError) { + error = thrownError; + } + expect(error).not.toBeDefined(); + expect(response).toBeDefined(); }); - jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ - config: { - api: { profiles: { defaultGet: () => ({ account: "acc" }) } }, - }, - } as any); - let error: ImperativeError; - let response: ISendResponse; - try { - response = await IssueTso.issueTsoCommandCommon( - PRETEND_SESSION, - PRETEND_ISSUE_PARMS - ); - } catch (thrownError) { - error = thrownError; - } - expect(error).not.toBeDefined(); - expect(response).toBeDefined(); }); -}); -describe("TsoIssue issueTsoCmd - Revised API", () => { - it("should succeed", async () => { - (StartTso.start as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve(START_RESPONSE); + describe("TsoIssue issueTsoCmd - Revised API", () => { + it("should succeed", async () => { + (StartTso.start as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(START_RESPONSE); + }); }); }); - }); - (SendTso.getAllResponses as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve({}); + (SendTso.getAllResponses as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve({}); + }); }); }); - }); - (SendTso.sendDataToTSOCollect as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve(SEND_RESPONSE); + (SendTso.sendDataToTSOCollect as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(SEND_RESPONSE); + }); }); }); - }); - (StopTso.stop as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve(null); + (StopTso.stop as any) = jest.fn(() => { + return new Promise((resolve) => { + process.nextTick(() => { + resolve(null); + }); }); }); + + let error: ImperativeError; + let response: ISendResponse; + const zosmfResponse = { + cmdResponse: [ + { + message: + "IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024", + }, + { message: "READY " }, + ], + tsoPromptReceived: "Y", + }; + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValueOnce( + Promise.resolve(zosmfResponse) + ); + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TEST"); + } catch (thrownError) { + error = thrownError; + } + expect(error).not.toBeDefined(); + expect(response).toBeDefined(); }); - let error: ImperativeError; - let response: ISendResponse; - const zosmfResponse = { - cmdResponse: [ - { - message: - "IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024", - }, - { message: "READY " }, - ], - tsoPromptReceived: "Y", - }; - jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue( - Promise.resolve(zosmfResponse) - ); - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( - Promise.resolve(true) - ); - try { - response = await IssueTso.issueTsoCmd( - PRETEND_SESSION, - "TEST" + it("should succeed (with params)", async () => { + let error: ImperativeError; + let response: ISendResponse; + + // Mock the CheckStatus to simulate Z/OS version check + jest.spyOn( + CheckStatus, + "isZosVersionGreaterThan" + ).mockReturnValueOnce(Promise.resolve(true)); + const zosmfResponse = { + cmdResponse: [ + { + message: + "IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024", + }, + { message: "READY " }, + ], + tsoPromptReceived: "Y", + }; + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValueOnce( + Promise.resolve(zosmfResponse) ); - } catch (thrownError) { - error = thrownError; - } - expect(error).not.toBeDefined(); - expect(response).toBeDefined(); - }); + try { + response = await IssueTso.issueTsoCmd( + PRETEND_SESSION, + "command", + { + isStateful: true, + suppressStartupMessage: false, + } + ); + } catch (thrownError) { + error = thrownError; + } + + expect(error).not.toBeDefined(); + expect(response).toBeDefined(); + }); - it("should succeed (with params)", async () => { - (IssueTso.issueTsoCmd as any) = jest.fn(() => { - return new Promise((resolve) => { - process.nextTick(() => { - resolve({}); + it("should utilize new API logic path", async () => { + const zosmfResponse = { + cmdResponse: [ + { + message: + "IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024", + }, + { message: "READY " }, + ], + tsoPromptReceived: "Y", + }; + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValueOnce( + Promise.resolve(zosmfResponse) + ); + let error: ImperativeError; + let response: ISendResponse; + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", { + addressSpaceOptions: null, + isStateful: true, + suppressStartupMessage: true, }); - }); + } catch (thrownError) { + error = thrownError; + } + expect(error).not.toBeDefined(); + expect(response).toBeDefined(); }); - let error: ImperativeError; - let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( - Promise.resolve(true) - ); - try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "command", { - isStateful: true, - suppressStartupMessage: false, - }); - } catch (thrownError) { - error = thrownError; - } - expect(error).not.toBeDefined(); - expect(response).toBeDefined(); - }); - it("should utilize new API logic path", async () => { - const zosmfResponse = { - cmdResponse: [ - { - message: - "IKJ56650I TIME-09:42:15 AM. CPU-00:00:00 SERVICE-555 SESSION-00:04:15 SEPTEMBER 4,2024", - }, - { message: "READY " }, - ], - tsoPromptReceived: "Y", - }; - jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue( - Promise.resolve(zosmfResponse) - ); - let error: ImperativeError; - let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( - Promise.resolve(true) - ); - try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", { - addressSpaceOptions: null, - isStateful: true, - suppressStartupMessage: true, - }); - } catch (thrownError) { - error = thrownError; - } - expect(error).not.toBeDefined(); - expect(response).toBeDefined(); - }); + it("should throw and handle non-404 error", async () => { + + // Mock ZosmfRestClient to throw an error + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockRejectedValueOnce( + new ImperativeError({ + msg: "status 403", + }) + ); - it("should throw and handle 404 error", async () => { - // Mock IssueTso.issueTsoCmd to throw an error - (IssueTso.issueTsoCmd as any) = jest.fn(() => { - return new Promise((_, reject) => { - process.nextTick(() => { - reject(new Error("status 404")); + let error: ImperativeError; + let response: ISendResponse; + + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", { + addressSpaceOptions: null, + isStateful: true, + suppressStartupMessage: true, }); - }); + } catch (thrownError) { + error = thrownError; + } + + expect(error).toBeDefined(); + expect(error.message).toBe("status 403"); + expect(response).not.toBeDefined(); }); - let error: ImperativeError; - let response: ISendResponse; - try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", { - addressSpaceOptions: null, - isStateful: true, - suppressStartupMessage: true, - }); - } catch (thrownError) { - error = thrownError; - } - expect(error).toBeDefined(); - expect(error.message).toBe("status 404"); - expect(response).not.toBeDefined(); }); -}); -describe("TsoIssue issueTsoCmd - failing scenarios", () => { - it("should fail for null command text", async () => { - let error: ImperativeError; - let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( - Promise.resolve(true) - ); - try { - response = await IssueTso.issueTsoCmd( - PRETEND_SESSION, - "fake_command", - { + describe("TsoIssue issueTsoCmd - failing scenarios", () => { + it("should fail for null command text", async () => { + let error: ImperativeError; + let response: ISendResponse; + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); + try { + response = await IssueTso.issueTsoCmd( + PRETEND_SESSION, + "fake_command", + { + isStateful: true, + suppressStartupMessage: false, + } + ); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + }); + it("should fail for empty command text", async () => { + jest.clearAllMocks(); + let error: ImperativeError; + let response: ISendResponse; + + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockRejectedValueOnce( + new ImperativeError({ + msg: "status 403", + }) + ); + jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + Promise.resolve(true) + ); + try { + response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "", { isStateful: true, suppressStartupMessage: false, - } - ); - } catch (thrownError) { - error = thrownError; - } - expect(response).not.toBeDefined(); - expect(error).toBeDefined(); - }); - it("should fail for empty command text", async () => { - let error: ImperativeError; - let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( - Promise.resolve(true) - ); - try { - response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "", { - isStateful: true, - suppressStartupMessage: false, - }); - } catch (thrownError) { - error = thrownError; - } - expect(response).not.toBeDefined(); - expect(error).toBeDefined(); + }); + } catch (thrownError) { + error = thrownError; + } + expect(response).not.toBeDefined(); + expect(error).toBeDefined(); + }); }); }); From 56ab6299f149af6bfd8ad07c94c82abc0394ef55 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 13 Sep 2024 09:51:30 -0400 Subject: [PATCH 28/69] changelog, documentation Signed-off-by: jace-roell --- packages/cli/CHANGELOG.md | 4 ++-- packages/cli/src/zostso/issue/command/Command.definition.ts | 3 +++ packages/zosmf/src/constants/Zosmf.constants.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 3f4470a76b..1be8e0886d 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -4,8 +4,8 @@ All notable changes to the Zowe CLI package will be documented in this file. ## Recent Changes -- Enhancement: Deprecated `issueTsoCommand()` function and replaced with `issueTsoCmd()` to allow for dynamic system behavior -based on the z/OS version in use to utilize 2.4 TSO command behavior. [#2240](https://github.com/zowe/zowe-cli/pull/2240) +- Enhancement: Added `--stateful` flag to `zos-tso issue cmd` to allow declaring the statefulness of the address space being created. [#2240](https://github.com/zowe/zowe-cli/pull/2240) +- Enhancement: `--suppress-startup-messages` flag default value changed to `true`. [#2240](https://github.com/zowe/zowe-cli/pull/2240) ## `8.0.0-next.202408261543` diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index 885379560b..5f6a8667f9 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -34,6 +34,8 @@ export const CommandDefinition: ICommandDefinition = { ], options: ([ { + // Old API behavior will be utilized upon specifying --ssm to be false, otherwise try new API and if it fails, fallback to old API. + // Specifying --ssm to be false makes the value of --stateful have no impact on behavior since old API behavior does not utilize statefulness. name: "suppress-startup-messages", aliases: ["ssm"], type: "boolean", @@ -41,6 +43,7 @@ export const CommandDefinition: ICommandDefinition = { defaultValue: true }, { + // --stateful has no impact if --suppress-startup-messages is set to false. name: "stateful", aliases: ["sf"], type: "boolean", diff --git a/packages/zosmf/src/constants/Zosmf.constants.ts b/packages/zosmf/src/constants/Zosmf.constants.ts index 5c3930ecfc..86d6f30b1c 100644 --- a/packages/zosmf/src/constants/Zosmf.constants.ts +++ b/packages/zosmf/src/constants/Zosmf.constants.ts @@ -68,7 +68,7 @@ export const ZosmfConstants: { [key: string]: any } = { */ UNABLE_TO_VERIFY_LEAF_SIGNATURE: "UNABLE_TO_VERIFY_LEAF_SIGNATURE" }, - + // https://www.ibm.com/docs/en/zos/2.5.0?topic=service-retrieve-zosmf-information VERSIONS: { V2R1: "24", V2R2: "25", From db69be93f61e49b8a335cae89eafdbda22d0c4fa Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 16 Sep 2024 15:27:42 -0400 Subject: [PATCH 29/69] profile option on No secure properties found in your config Signed-off-by: jace-roell --- .../config/cmd/secure/secure.definition.ts | 7 ++++++ .../src/config/cmd/secure/secure.handler.ts | 23 +++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts b/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts index db10cab504..dae9e5b377 100644 --- a/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts +++ b/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts @@ -39,6 +39,13 @@ export const secureDefinition: ICommandDefinition = { aliases: ["p"], type: "boolean", defaultValue: false + }, + { + name: "profile", + description: "temp", + type: "string", + aliases: ["pf"], + defaultValue: null } ], examples: [ diff --git a/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts b/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts index 582be79f75..ef0b97c8b6 100644 --- a/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts +++ b/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts @@ -11,6 +11,7 @@ import { ICommandArguments, ICommandHandler, IHandlerParameters } from "../../../../../cmd"; import { Config, ConfigConstants, ConfigSchema } from "../../../../../config"; +import { ConfigProfiles } from "../../../../../config/src/api"; import { ConfigAutoStore } from "../../../../../config/src/ConfigAutoStore"; import { ConfigUtils } from "../../../../../config/src/ConfigUtils"; import { ImperativeError } from "../../../../../error"; @@ -23,7 +24,6 @@ export default class SecureHandler implements ICommandHandler { * The parameters object passed to the command handler. */ private params: IHandlerParameters; - /** * Process the command and input. * @@ -50,15 +50,26 @@ export default class SecureHandler implements ICommandHandler { // Create the config, load the secure values, and activate the desired layer config.api.layers.activate(params.arguments.userConfig, params.arguments.globalConfig); - const secureProps: string[] = config.api.secure.secureFields(); + let secureProps: string[] = config.api.secure.secureFields(); if (secureProps.length === 0) { params.response.console.log("No secure properties found in your config"); return; } - + if(params.arguments.profile) + { + let filteredSecureProps = secureProps.filter(prop => config.api.profiles.getProfileNameFromPath(prop).toLowerCase() === params.arguments.profile.toLowerCase()); + if(filteredSecureProps.length === 0 && secureProps.length > 0) + { + params.response.console.log(`No secure properties from profile '${params.arguments.profile}' found.`); + } + else + { + secureProps = filteredSecureProps; + } + } // Prompt for values designated as secure - for (const propName of secureProps) { + for (const propName of secureProps){ if (propName.endsWith(".tokenValue")) { params.response.console.log(`Processing secure properties for profile: ${config.api.profiles.getProfileNameFromPath(propName)}`); let propValue = await this.handlePromptForAuthToken(config, propName); @@ -128,3 +139,7 @@ export default class SecureHandler implements ICommandHandler { } } } +function getProfileNameFromPath(prop: string) { + throw new Error("Function not implemented."); +} + From 64ea88ea5be6f33fa4367d12286f713c4c898a5d Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 17 Sep 2024 12:27:29 -0400 Subject: [PATCH 30/69] initial test commit Signed-off-by: jace-roell --- .../cmd/secure/secure.handler.unit.test.ts | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts index c3194cc9c6..fcb1f3c77a 100644 --- a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts +++ b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Logger } from "../../../../../logger"; -import { Config } from "../../../../../config/src/Config"; +import { Config, ConfigConstants, ConfigSchema } from "../../../../../config"; import { IConfig, IConfigOpts, IConfigProfile } from "../../../../../config"; import { ImperativeConfig } from "../../../../../utilities"; import { IImperativeConfig } from "../../../../src/doc/IImperativeConfig"; @@ -28,6 +28,7 @@ import { SessConstants } from "../../../../../rest"; import { setupConfigToLoad } from "../../../../../../__tests__/src/TestUtil"; import { IHandlerParameters } from "../../../../../cmd"; import { EventOperator, EventUtils } from "../../../../../events"; +import { ConfigProfiles } from "@zowe/imperative/lib/config/src/api"; let readPromptSpy: any; const getIHandlerParametersObject = (): IHandlerParameters => { @@ -792,5 +793,44 @@ describe("Configuration Secure command handler", () => { expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(0); expect(writeFileSyncSpy).toHaveBeenCalledTimes(0); }); + it("should filter secure properties based on the provided profile", async () => { + const handler = new SecureHandler(); + const params = getIHandlerParametersObject(); + + params.arguments.userConfig = true; + params.arguments.globalConfig = true; + //params.arguments.profiles = "testProfiles"; + // Start doing fs mocks + // And the prompting of the secure handler + keytarGetPasswordSpy.mockReturnValue(fakeSecureData); + keytarSetPasswordSpy.mockImplementation(); + keytarDeletePasswordSpy.mockImplementation(); + readFileSyncSpy = jest.spyOn(fs, "readFileSync"); + writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); + existsSyncSpy = jest.spyOn(fs, "existsSync"); + + const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); + eco.$schema = "./fakeapp.schema.json"; + + readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); + existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) + .mockReturnValue(false); // Only the global user config exists + writeFileSyncSpy.mockImplementation(); + searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + + await setupConfigToLoad(undefined, configOpts); // Setup the config + + // We aren't testing the config initialization - clear the spies + searchSpy.mockClear(); + writeFileSyncSpy.mockClear(); + existsSyncSpy.mockClear(); + readFileSyncSpy.mockClear(); + + jest.spyOn(ImperativeConfig.instance.config.api.profiles, "getProfileNameFromPath").mockReturnValueOnce("testProfiles"); + + await handler.process(params); + + expect(params.arguments.profiles.length).toBeDefined(); + }); }); }); From 34e7e708d65944b0529d07460e26f8243a73b95d Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 17 Sep 2024 13:15:37 -0400 Subject: [PATCH 31/69] temp test Signed-off-by: jace-roell --- .../cmd/secure/secure.handler.unit.test.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts index fcb1f3c77a..2669b8dcaa 100644 --- a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts +++ b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts @@ -799,7 +799,7 @@ describe("Configuration Secure command handler", () => { params.arguments.userConfig = true; params.arguments.globalConfig = true; - //params.arguments.profiles = "testProfiles"; + params.arguments.profile = "GoodProfile"; // Start doing fs mocks // And the prompting of the secure handler keytarGetPasswordSpy.mockReturnValue(fakeSecureData); @@ -825,12 +825,15 @@ describe("Configuration Secure command handler", () => { writeFileSyncSpy.mockClear(); existsSyncSpy.mockClear(); readFileSyncSpy.mockClear(); - - jest.spyOn(ImperativeConfig.instance.config.api.profiles, "getProfileNameFromPath").mockReturnValueOnce("testProfiles"); - - await handler.process(params); - - expect(params.arguments.profiles.length).toBeDefined(); + let caughtError; + jest.spyOn(ImperativeConfig.instance.config.api.secure,"secureFields").mockReturnValue(["profiles.noMatchProfile.properties.password","profiles.GoodProfile.properties.password"]) + try { + await handler.process(params); + } catch (error) { + caughtError = error; + } + expect(caughtError).toBeUndefined(); + expect(params.arguments.profile).toBeDefined(); }); }); }); From 10729bfd25e548aa444d8fd3061cbed08bf36b1b Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 17 Sep 2024 15:20:27 -0400 Subject: [PATCH 32/69] test cases and linting Signed-off-by: jace-roell --- .../cmd/secure/secure.handler.unit.test.ts | 198 ++++++++++++++++-- .../src/config/cmd/secure/secure.handler.ts | 148 +++++++++---- 2 files changed, 290 insertions(+), 56 deletions(-) diff --git a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts index 2669b8dcaa..7ddfae33a1 100644 --- a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts +++ b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Logger } from "../../../../../logger"; -import { Config, ConfigConstants, ConfigSchema } from "../../../../../config"; +import { Config } from "../../../../../config"; import { IConfig, IConfigOpts, IConfigProfile } from "../../../../../config"; import { ImperativeConfig } from "../../../../../utilities"; import { IImperativeConfig } from "../../../../src/doc/IImperativeConfig"; @@ -761,7 +761,7 @@ describe("Configuration Secure command handler", () => { expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjPath, JSON.stringify(compObj, null, 4)); // Config }); - it("should fail to invoke auth handler if it throws an error", async () => { + it("should only prompt for profiles that matched profile param", async () => { const eco = lodash.cloneDeep(expectedProjConfigObjectWithToken); readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); @@ -793,47 +793,219 @@ describe("Configuration Secure command handler", () => { expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(0); expect(writeFileSyncSpy).toHaveBeenCalledTimes(0); }); - it("should filter secure properties based on the provided profile", async () => { + it("should only prompt for secure values that match the profile passed in through params", async () => { const handler = new SecureHandler(); const params = getIHandlerParametersObject(); - + params.arguments.userConfig = true; params.arguments.globalConfig = true; params.arguments.profile = "GoodProfile"; + // Start doing fs mocks - // And the prompting of the secure handler keytarGetPasswordSpy.mockReturnValue(fakeSecureData); keytarSetPasswordSpy.mockImplementation(); keytarDeletePasswordSpy.mockImplementation(); readFileSyncSpy = jest.spyOn(fs, "readFileSync"); writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); existsSyncSpy = jest.spyOn(fs, "existsSync"); - + const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); eco.$schema = "./fakeapp.schema.json"; - + readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) .mockReturnValue(false); // Only the global user config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return - + searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); + await setupConfigToLoad(undefined, configOpts); // Setup the config + // Clear spies after config setup + searchSpy.mockClear(); + writeFileSyncSpy.mockClear(); + existsSyncSpy.mockClear(); + readFileSyncSpy.mockClear(); + jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue([ + "profiles.noMatchProfile.properties.tokenValue", + "profiles.GoodProfile.properties.tokenValue", + "profiles.abcdefg.properties.tokenValue", + ]); + // Mock the console prompt to return an empty string + const myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); + let caughtError; + try { + await handler.process(params); + } catch (error) { + caughtError = error; + } + // Verify that the prompt included "profiles.GoodProfile.properties.tokenValue" + expect(myPromptSpy.mock.calls[0][0].indexOf("profiles.GoodProfile.properties.tokenValue") >= 0).toBeTruthy(); + expect(myPromptSpy).toHaveBeenCalledTimes(1); + expect(myPromptSpy).toHaveBeenCalledWith( + expect.stringContaining("profiles.GoodProfile.properties.tokenValue"), + {"hideText": true} + ); + expect(caughtError).toBeUndefined(); + }); + it("should only prompt for secure values that match the profile passed in through params - nested profile", async () => { + const handler = new SecureHandler(); + const params = getIHandlerParametersObject(); + + params.arguments.userConfig = true; + params.arguments.globalConfig = true; + params.arguments.profile = "lpar1.GoodProfile"; + + // Start doing fs mocks + keytarGetPasswordSpy.mockReturnValue(fakeSecureData); + keytarSetPasswordSpy.mockImplementation(); + keytarDeletePasswordSpy.mockImplementation(); + readFileSyncSpy = jest.spyOn(fs, "readFileSync"); + writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); + existsSyncSpy = jest.spyOn(fs, "existsSync"); + + const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); + eco.$schema = "./fakeapp.schema.json"; + + readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); + existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) + .mockReturnValue(false); // Only the global user config exists + writeFileSyncSpy.mockImplementation(); + searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); + await setupConfigToLoad(undefined, configOpts); // Setup the config + // Clear spies after config setup + searchSpy.mockClear(); + writeFileSyncSpy.mockClear(); + existsSyncSpy.mockClear(); + readFileSyncSpy.mockClear(); + jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue([ + "profiles.noMatchProfile.properties.tokenValue", + "profiles.lpar1.profiles.GoodProfile.properties.tokenValue", + "profiles.abcdefg.properties.tokenValue", + ]); + // Mock the console prompt to return an empty string + const myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); + let caughtError; + try { + await handler.process(params); + } catch (error) { + caughtError = error; + } + // Verify that the prompt included "profiles.GoodProfile.properties.tokenValue" + expect(myPromptSpy.mock.calls[0][0].indexOf("profiles.GoodProfile.properties.tokenValue") >= 0).toBeTruthy(); + expect(myPromptSpy).toHaveBeenCalledTimes(1); + expect(myPromptSpy).toHaveBeenCalledWith( + expect.stringContaining("profiles.lpar1.profiles.GoodProfile.properties.tokenValue"), + {"hideText": true} + ); + expect(caughtError).toBeUndefined(); + }); + it("should only prompt for secure values that match the profile passed in through params - ignore casing", async () => { + const handler = new SecureHandler(); + const params = getIHandlerParametersObject(); + + params.arguments.userConfig = true; + params.arguments.globalConfig = true; + params.arguments.profile = "gOODpROFILE"; + + // Start doing fs mocks + keytarGetPasswordSpy.mockReturnValue(fakeSecureData); + keytarSetPasswordSpy.mockImplementation(); + keytarDeletePasswordSpy.mockImplementation(); + readFileSyncSpy = jest.spyOn(fs, "readFileSync"); + writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); + existsSyncSpy = jest.spyOn(fs, "existsSync"); + + const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); + eco.$schema = "./fakeapp.schema.json"; + + readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); + existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) + .mockReturnValue(false); // Only the global user config exists + writeFileSyncSpy.mockImplementation(); + searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); + await setupConfigToLoad(undefined, configOpts); // Setup the config + // Clear spies after config setup + searchSpy.mockClear(); + writeFileSyncSpy.mockClear(); + existsSyncSpy.mockClear(); + readFileSyncSpy.mockClear(); + jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue([ + "profiles.noMatchProfile.properties.tokenValue", + "profiles.GoodProfile.properties.tokenValue", + "profiles.abcdefg.properties.tokenValue", + ]); + // Mock the console prompt to return an empty string + const myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); + let caughtError; + try { + await handler.process(params); + } catch (error) { + caughtError = error; + } + // Verify that the prompt included "profiles.GoodProfile.properties.tokenValue" + expect(myPromptSpy.mock.calls[0][0].indexOf("profiles.GoodProfile.properties.tokenValue") >= 0).toBeTruthy(); + expect(myPromptSpy).toHaveBeenCalledTimes(1); + expect(myPromptSpy).toHaveBeenCalledWith( + expect.stringContaining("profiles.GoodProfile.properties.tokenValue"), + {"hideText": true} + ); + expect(caughtError).toBeUndefined(); + }); + it("should prompt for all secure values given a profile in which no secure profile value matches", async () => { + const handler = new SecureHandler(); + const params = getIHandlerParametersObject(); + + params.arguments.userConfig = true; + params.arguments.globalConfig = true; + params.arguments.profile = "noMatchProfile"; + + // Start doing fs mocks + keytarGetPasswordSpy.mockReturnValue(fakeSecureData); + keytarSetPasswordSpy.mockImplementation(); + keytarDeletePasswordSpy.mockImplementation(); + readFileSyncSpy = jest.spyOn(fs, "readFileSync"); + writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); + existsSyncSpy = jest.spyOn(fs, "existsSync"); + + const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); + eco.$schema = "./fakeapp.schema.json"; + + readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); + existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) + .mockReturnValue(false); // Only the global user config exists + writeFileSyncSpy.mockImplementation(); + searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); await setupConfigToLoad(undefined, configOpts); // Setup the config - - // We aren't testing the config initialization - clear the spies + // Clear spies after config setup searchSpy.mockClear(); writeFileSyncSpy.mockClear(); existsSyncSpy.mockClear(); readFileSyncSpy.mockClear(); + jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue([ + "profiles.lpar1.profiles.test.properties.tokenValue", + "profiles.GoodProfile.properties.tokenValue", + "profiles.abcdefg.properties.tokenValue", + ]); + // Mock the console prompt to return an empty string + const myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); let caughtError; - jest.spyOn(ImperativeConfig.instance.config.api.secure,"secureFields").mockReturnValue(["profiles.noMatchProfile.properties.password","profiles.GoodProfile.properties.password"]) try { await handler.process(params); } catch (error) { caughtError = error; } + expect(myPromptSpy).toHaveBeenCalledTimes(3); + expect(myPromptSpy).toHaveBeenCalledWith( + expect.stringContaining("profiles.lpar1.profiles.test.properties.tokenValue"), + {"hideText": true} + ); + expect(myPromptSpy).toHaveBeenCalledWith( + expect.stringContaining("profiles.GoodProfile.properties.tokenValue"), + {"hideText": true} + ); + expect(myPromptSpy).toHaveBeenCalledWith( + expect.stringContaining("profiles.abcdefg.properties.tokenValue"), + {"hideText": true} + ); expect(caughtError).toBeUndefined(); - expect(params.arguments.profile).toBeDefined(); }); }); }); diff --git a/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts b/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts index ef0b97c8b6..67ea80943c 100644 --- a/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts +++ b/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts @@ -1,22 +1,30 @@ /* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ -import { ICommandArguments, ICommandHandler, IHandlerParameters } from "../../../../../cmd"; +import { + ICommandArguments, + ICommandHandler, + IHandlerParameters, +} from "../../../../../cmd"; import { Config, ConfigConstants, ConfigSchema } from "../../../../../config"; import { ConfigProfiles } from "../../../../../config/src/api"; import { ConfigAutoStore } from "../../../../../config/src/ConfigAutoStore"; import { ConfigUtils } from "../../../../../config/src/ConfigUtils"; import { ImperativeError } from "../../../../../error"; import { Logger } from "../../../../../logger"; -import { ConnectionPropsForSessCfg, ISession, Session } from "../../../../../rest"; +import { + ConnectionPropsForSessCfg, + ISession, + Session, +} from "../../../../../rest"; import { ImperativeConfig } from "../../../../../utilities"; export default class SecureHandler implements ICommandHandler { @@ -44,37 +52,60 @@ export default class SecureHandler implements ICommandHandler { const prunedFiles = config.api.secure.rmUnusedProps(); if (prunedFiles.length > 0) { await config.api.secure.directSave(); - params.response.console.log("Deleted secure properties for the following missing files:\n\t" + prunedFiles.join("\n\t") + "\n"); + params.response.console.log( + "Deleted secure properties for the following missing files:\n\t" + + prunedFiles.join("\n\t") + + "\n" + ); } } // Create the config, load the secure values, and activate the desired layer - config.api.layers.activate(params.arguments.userConfig, params.arguments.globalConfig); + config.api.layers.activate( + params.arguments.userConfig, + params.arguments.globalConfig + ); let secureProps: string[] = config.api.secure.secureFields(); if (secureProps.length === 0) { - params.response.console.log("No secure properties found in your config"); + params.response.console.log( + "No secure properties found in your config" + ); return; } - if(params.arguments.profile) - { - let filteredSecureProps = secureProps.filter(prop => config.api.profiles.getProfileNameFromPath(prop).toLowerCase() === params.arguments.profile.toLowerCase()); - if(filteredSecureProps.length === 0 && secureProps.length > 0) - { - params.response.console.log(`No secure properties from profile '${params.arguments.profile}' found.`); - } - else - { + if (params.arguments.profile) { + const filteredSecureProps = secureProps.filter( + (prop) => + config.api.profiles + .getProfileNameFromPath(prop) + .toLowerCase() === + params.arguments.profile.toLowerCase() + ); + if (filteredSecureProps.length === 0 && secureProps.length > 0) { + params.response.console.log( + `No secure properties from profile '${params.arguments.profile}' found.` + ); + } else { secureProps = filteredSecureProps; } } // Prompt for values designated as secure - for (const propName of secureProps){ + for (const propName of secureProps) { if (propName.endsWith(".tokenValue")) { - params.response.console.log(`Processing secure properties for profile: ${config.api.profiles.getProfileNameFromPath(propName)}`); - let propValue = await this.handlePromptForAuthToken(config, propName); + params.response.console.log( + `Processing secure properties for profile: ${config.api.profiles.getProfileNameFromPath( + propName + )}` + ); + let propValue = await this.handlePromptForAuthToken( + config, + propName + ); if (propValue === undefined) { - propValue = await params.response.console.prompt(`Enter ${propName} ${ConfigConstants.SKIP_PROMPT}`, {hideText: true}); + propValue = await params.response.console.prompt( + `Enter ${propName} ${ConfigConstants.SKIP_PROMPT}`, + { hideText: true } + ); } // Save the value in the config securely @@ -82,11 +113,20 @@ export default class SecureHandler implements ICommandHandler { config.set(propName, propValue, { secure: true }); } } else { - let propValue = await params.response.console.prompt(`Enter ${propName} ${ConfigConstants.SKIP_PROMPT}`, { hideText: true }); + let propValue = await params.response.console.prompt( + `Enter ${propName} ${ConfigConstants.SKIP_PROMPT}`, + { hideText: true } + ); // Save the value in the config securely if (propValue) { - propValue = ConfigUtils.coercePropValue(propValue, ConfigSchema.findPropertyType(propName, config.properties)); + propValue = ConfigUtils.coercePropValue( + propValue, + ConfigSchema.findPropertyType( + propName, + config.properties + ) + ); config.set(propName, propValue, { secure: true }); } } @@ -104,31 +144,57 @@ export default class SecureHandler implements ICommandHandler { * @param propPath JSON property path of the auth token * @returns Token value, or undefined if none was obtained */ - private async handlePromptForAuthToken(config: Config, propPath: string): Promise { + private async handlePromptForAuthToken( + config: Config, + propPath: string + ): Promise { const profilePath = propPath.slice(0, propPath.indexOf(".properties")); - const authHandlerClass = ConfigAutoStore.findAuthHandlerForProfile(profilePath, this.params.arguments); + const authHandlerClass = ConfigAutoStore.findAuthHandlerForProfile( + profilePath, + this.params.arguments + ); if (authHandlerClass != null) { const api = authHandlerClass.getAuthHandlerApi(); if (api.promptParams.serviceDescription != null) { - this.params.response.console.log(`Logging in to ${api.promptParams.serviceDescription} ${ConfigConstants.SKIP_PROMPT}`); + this.params.response.console.log( + `Logging in to ${api.promptParams.serviceDescription} ${ConfigConstants.SKIP_PROMPT}` + ); } - const profile = config.api.profiles.get(profilePath.replace(/profiles\./g, ""), false); - const sessCfg: ISession = api.createSessCfg(profile as ICommandArguments); - const sessCfgWithCreds = await ConnectionPropsForSessCfg.addPropsOrPrompt(sessCfg, profile as ICommandArguments, - { parms: this.params, doPrompting: true, requestToken: true, ...api.promptParams }); - Logger.getAppLogger().info(`Fetching ${profile.tokenType} for ${propPath}`); + const profile = config.api.profiles.get( + profilePath.replace(/profiles\./g, ""), + false + ); + const sessCfg: ISession = api.createSessCfg( + profile as ICommandArguments + ); + const sessCfgWithCreds = + await ConnectionPropsForSessCfg.addPropsOrPrompt( + sessCfg, + profile as ICommandArguments, + { + parms: this.params, + doPrompting: true, + requestToken: true, + ...api.promptParams, + } + ); + Logger.getAppLogger().info( + `Fetching ${profile.tokenType} for ${propPath}` + ); if (ConnectionPropsForSessCfg.sessHasCreds(sessCfgWithCreds)) { try { - const tokenValue = await api.sessionLogin(new Session(sessCfgWithCreds)); + const tokenValue = await api.sessionLogin( + new Session(sessCfgWithCreds) + ); this.params.response.console.log("Logged in successfully"); return tokenValue; } catch (error) { throw new ImperativeError({ msg: `Failed to fetch ${profile.tokenType} for ${propPath}: ${error.message}`, - causeErrors: error + causeErrors: error, }); } } else { @@ -139,7 +205,3 @@ export default class SecureHandler implements ICommandHandler { } } } -function getProfileNameFromPath(prop: string) { - throw new Error("Function not implemented."); -} - From 1dcb4455ad8f371ab45cef5f8ae6e1ace292383e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 17 Sep 2024 15:23:03 -0400 Subject: [PATCH 33/69] changelog Signed-off-by: jace-roell --- packages/imperative/CHANGELOG.md | 4 ++++ .../__tests__/config/cmd/secure/secure.handler.unit.test.ts | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 0a98089e66..2fd97c2b77 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Imperative package will be documented in this file. +## Recent Changes + +- Enhancement: Allows for profile specification on `zowe config secure` command to avoid prompting for other profiles + ## `8.0.0-next.202408301809` - LTS Breaking: Removed the following obsolete V1 profile classes/functions: diff --git a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts index 7ddfae33a1..c71b0595a7 100644 --- a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts +++ b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts @@ -28,7 +28,6 @@ import { SessConstants } from "../../../../../rest"; import { setupConfigToLoad } from "../../../../../../__tests__/src/TestUtil"; import { IHandlerParameters } from "../../../../../cmd"; import { EventOperator, EventUtils } from "../../../../../events"; -import { ConfigProfiles } from "@zowe/imperative/lib/config/src/api"; let readPromptSpy: any; const getIHandlerParametersObject = (): IHandlerParameters => { From 298ec8092637fc778c41f79f784d59565810c19a Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 17 Sep 2024 15:23:39 -0400 Subject: [PATCH 34/69] profile definition Signed-off-by: jace-roell --- .../src/imperative/src/config/cmd/secure/secure.definition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts b/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts index dae9e5b377..07a9e46e3e 100644 --- a/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts +++ b/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts @@ -42,7 +42,7 @@ export const secureDefinition: ICommandDefinition = { }, { name: "profile", - description: "temp", + description: "Specify the profile in which you would like to configure the secure values for", type: "string", aliases: ["pf"], defaultValue: null From 0d96e31e9bff2bd2ff1d6b13884d2d524a71623f Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 17 Sep 2024 15:39:31 -0400 Subject: [PATCH 35/69] fix Signed-off-by: jace-roell --- .../cli/src/zostso/issue/command/Command.definition.ts | 7 +++++-- packages/zostso/CHANGELOG.md | 2 ++ packages/zostso/src/constants/ZosTso.constants.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index 5f6a8667f9..4917a65386 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -34,8 +34,11 @@ export const CommandDefinition: ICommandDefinition = { ], options: ([ { - // Old API behavior will be utilized upon specifying --ssm to be false, otherwise try new API and if it fails, fallback to old API. - // Specifying --ssm to be false makes the value of --stateful have no impact on behavior since old API behavior does not utilize statefulness. + // Old API behavior will be utilized upon specifying --ssm to be false, + // otherwise try new API and if it fails, fallback to old API. + + // Specifying --ssm to be false makes the value of --stateful have no impact on + // behavior since old API behavior does not utilize statefulness. name: "suppress-startup-messages", aliases: ["ssm"], type: "boolean", diff --git a/packages/zostso/CHANGELOG.md b/packages/zostso/CHANGELOG.md index 43241a6386..5f24d5bae2 100644 --- a/packages/zostso/CHANGELOG.md +++ b/packages/zostso/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to the Zowe z/OS TSO SDK package will be documented in this - Enhancement: Deprecated `IssueTsoCommand()` function and replaced with `IssueTsoCmd()` for compatibility with z/OS version 2.4. [#2240](https://github.com/zowe/zowe-cli/pull/2240) - Enhancement: Modified `IIssueReponse` to handle z/OS 2.4 and newer TSO command response. [#2240](https://github.com/zowe/zowe-cli/pull/2240) + - Old API behavior will be utilized upon specifying --ssm to be false, otherwise try new API and if it fails, fallback to old API. + - Specifying --ssm to be false makes the value of --stateful have no impact on behavior since old API behavior does not utilize statefulness. ## `8.0.0-next.202408131445` diff --git a/packages/zostso/src/constants/ZosTso.constants.ts b/packages/zostso/src/constants/ZosTso.constants.ts index 321b2930ca..58c1e794e1 100644 --- a/packages/zostso/src/constants/ZosTso.constants.ts +++ b/packages/zostso/src/constants/ZosTso.constants.ts @@ -20,7 +20,7 @@ export class TsoProfileConstants { aliases: ["a"], description: "Your z/OS TSO/E accounting information.", type: "string", - required: true, + required: false, group: TsoProfileConstants.TSO_OPTION_GROUP }; From 185944f621b95dd0a74924573b9314d4c0ca720b Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 18 Sep 2024 10:15:15 -0400 Subject: [PATCH 36/69] consolidating tests Signed-off-by: jace-roell --- .../cmd/secure/secure.handler.unit.test.ts | 319 ++++++------------ 1 file changed, 106 insertions(+), 213 deletions(-) diff --git a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts index c71b0595a7..e4daed587d 100644 --- a/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts +++ b/packages/imperative/src/imperative/__tests__/config/cmd/secure/secure.handler.unit.test.ts @@ -792,219 +792,112 @@ describe("Configuration Secure command handler", () => { expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(0); expect(writeFileSyncSpy).toHaveBeenCalledTimes(0); }); - it("should only prompt for secure values that match the profile passed in through params", async () => { - const handler = new SecureHandler(); - const params = getIHandlerParametersObject(); - - params.arguments.userConfig = true; - params.arguments.globalConfig = true; - params.arguments.profile = "GoodProfile"; - - // Start doing fs mocks - keytarGetPasswordSpy.mockReturnValue(fakeSecureData); - keytarSetPasswordSpy.mockImplementation(); - keytarDeletePasswordSpy.mockImplementation(); - readFileSyncSpy = jest.spyOn(fs, "readFileSync"); - writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); - existsSyncSpy = jest.spyOn(fs, "existsSync"); - - const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); - eco.$schema = "./fakeapp.schema.json"; - - readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) - .mockReturnValue(false); // Only the global user config exists - writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); - await setupConfigToLoad(undefined, configOpts); // Setup the config - // Clear spies after config setup - searchSpy.mockClear(); - writeFileSyncSpy.mockClear(); - existsSyncSpy.mockClear(); - readFileSyncSpy.mockClear(); - jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue([ - "profiles.noMatchProfile.properties.tokenValue", - "profiles.GoodProfile.properties.tokenValue", - "profiles.abcdefg.properties.tokenValue", - ]); - // Mock the console prompt to return an empty string - const myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); - let caughtError; - try { - await handler.process(params); - } catch (error) { - caughtError = error; - } - // Verify that the prompt included "profiles.GoodProfile.properties.tokenValue" - expect(myPromptSpy.mock.calls[0][0].indexOf("profiles.GoodProfile.properties.tokenValue") >= 0).toBeTruthy(); - expect(myPromptSpy).toHaveBeenCalledTimes(1); - expect(myPromptSpy).toHaveBeenCalledWith( - expect.stringContaining("profiles.GoodProfile.properties.tokenValue"), - {"hideText": true} - ); - expect(caughtError).toBeUndefined(); - }); - it("should only prompt for secure values that match the profile passed in through params - nested profile", async () => { - const handler = new SecureHandler(); - const params = getIHandlerParametersObject(); - - params.arguments.userConfig = true; - params.arguments.globalConfig = true; - params.arguments.profile = "lpar1.GoodProfile"; - - // Start doing fs mocks - keytarGetPasswordSpy.mockReturnValue(fakeSecureData); - keytarSetPasswordSpy.mockImplementation(); - keytarDeletePasswordSpy.mockImplementation(); - readFileSyncSpy = jest.spyOn(fs, "readFileSync"); - writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); - existsSyncSpy = jest.spyOn(fs, "existsSync"); - - const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); - eco.$schema = "./fakeapp.schema.json"; - - readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) - .mockReturnValue(false); // Only the global user config exists - writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); - await setupConfigToLoad(undefined, configOpts); // Setup the config - // Clear spies after config setup - searchSpy.mockClear(); - writeFileSyncSpy.mockClear(); - existsSyncSpy.mockClear(); - readFileSyncSpy.mockClear(); - jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue([ - "profiles.noMatchProfile.properties.tokenValue", - "profiles.lpar1.profiles.GoodProfile.properties.tokenValue", - "profiles.abcdefg.properties.tokenValue", - ]); - // Mock the console prompt to return an empty string - const myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); - let caughtError; - try { - await handler.process(params); - } catch (error) { - caughtError = error; - } - // Verify that the prompt included "profiles.GoodProfile.properties.tokenValue" - expect(myPromptSpy.mock.calls[0][0].indexOf("profiles.GoodProfile.properties.tokenValue") >= 0).toBeTruthy(); - expect(myPromptSpy).toHaveBeenCalledTimes(1); - expect(myPromptSpy).toHaveBeenCalledWith( - expect.stringContaining("profiles.lpar1.profiles.GoodProfile.properties.tokenValue"), - {"hideText": true} - ); - expect(caughtError).toBeUndefined(); - }); - it("should only prompt for secure values that match the profile passed in through params - ignore casing", async () => { - const handler = new SecureHandler(); - const params = getIHandlerParametersObject(); - - params.arguments.userConfig = true; - params.arguments.globalConfig = true; - params.arguments.profile = "gOODpROFILE"; - - // Start doing fs mocks - keytarGetPasswordSpy.mockReturnValue(fakeSecureData); - keytarSetPasswordSpy.mockImplementation(); - keytarDeletePasswordSpy.mockImplementation(); - readFileSyncSpy = jest.spyOn(fs, "readFileSync"); - writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); - existsSyncSpy = jest.spyOn(fs, "existsSync"); - - const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); - eco.$schema = "./fakeapp.schema.json"; - - readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) - .mockReturnValue(false); // Only the global user config exists - writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); - await setupConfigToLoad(undefined, configOpts); // Setup the config - // Clear spies after config setup - searchSpy.mockClear(); - writeFileSyncSpy.mockClear(); - existsSyncSpy.mockClear(); - readFileSyncSpy.mockClear(); - jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue([ - "profiles.noMatchProfile.properties.tokenValue", - "profiles.GoodProfile.properties.tokenValue", - "profiles.abcdefg.properties.tokenValue", - ]); - // Mock the console prompt to return an empty string - const myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); - let caughtError; - try { - await handler.process(params); - } catch (error) { - caughtError = error; - } - // Verify that the prompt included "profiles.GoodProfile.properties.tokenValue" - expect(myPromptSpy.mock.calls[0][0].indexOf("profiles.GoodProfile.properties.tokenValue") >= 0).toBeTruthy(); - expect(myPromptSpy).toHaveBeenCalledTimes(1); - expect(myPromptSpy).toHaveBeenCalledWith( - expect.stringContaining("profiles.GoodProfile.properties.tokenValue"), - {"hideText": true} - ); - expect(caughtError).toBeUndefined(); - }); - it("should prompt for all secure values given a profile in which no secure profile value matches", async () => { - const handler = new SecureHandler(); - const params = getIHandlerParametersObject(); - - params.arguments.userConfig = true; - params.arguments.globalConfig = true; - params.arguments.profile = "noMatchProfile"; - - // Start doing fs mocks - keytarGetPasswordSpy.mockReturnValue(fakeSecureData); - keytarSetPasswordSpy.mockImplementation(); - keytarDeletePasswordSpy.mockImplementation(); - readFileSyncSpy = jest.spyOn(fs, "readFileSync"); - writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); - existsSyncSpy = jest.spyOn(fs, "existsSync"); - - const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); - eco.$schema = "./fakeapp.schema.json"; - - readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) - .mockReturnValue(false); // Only the global user config exists - writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); - await setupConfigToLoad(undefined, configOpts); // Setup the config - // Clear spies after config setup - searchSpy.mockClear(); - writeFileSyncSpy.mockClear(); - existsSyncSpy.mockClear(); - readFileSyncSpy.mockClear(); - jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue([ - "profiles.lpar1.profiles.test.properties.tokenValue", - "profiles.GoodProfile.properties.tokenValue", - "profiles.abcdefg.properties.tokenValue", - ]); - // Mock the console prompt to return an empty string - const myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); - let caughtError; - try { - await handler.process(params); - } catch (error) { - caughtError = error; - } - expect(myPromptSpy).toHaveBeenCalledTimes(3); - expect(myPromptSpy).toHaveBeenCalledWith( - expect.stringContaining("profiles.lpar1.profiles.test.properties.tokenValue"), - {"hideText": true} - ); - expect(myPromptSpy).toHaveBeenCalledWith( - expect.stringContaining("profiles.GoodProfile.properties.tokenValue"), - {"hideText": true} - ); - expect(myPromptSpy).toHaveBeenCalledWith( - expect.stringContaining("profiles.abcdefg.properties.tokenValue"), - {"hideText": true} - ); - expect(caughtError).toBeUndefined(); + describe("profile param tests", () => { + let handler: SecureHandler; + let params: any; + let myPromptSpy: jest.SpyInstance; + + beforeEach(() => { + handler = new SecureHandler(); + params = getIHandlerParametersObject(); + + params.arguments.userConfig = true; + params.arguments.globalConfig = true; + + // Mock the console prompt to return an empty string + myPromptSpy = jest.spyOn(params.response.console, "prompt").mockResolvedValue(""); + + // Reset spies + keytarGetPasswordSpy.mockReturnValue(fakeSecureData); + keytarSetPasswordSpy.mockImplementation(); + keytarDeletePasswordSpy.mockImplementation(); + readFileSyncSpy = jest.spyOn(fs, "readFileSync"); + writeFileSyncSpy = jest.spyOn(fs, "writeFileSync"); + existsSyncSpy = jest.spyOn(fs, "existsSync"); + writeFileSyncSpy.mockImplementation(); + }); + + const runTest = async (profile: string, secureFields: string[], expectedPromptTimes: number, expectedSecureField: string) => { + params.arguments.profile = profile; + + // Mock fs calls + const eco = lodash.cloneDeep(expectedGlobalUserConfigObject); + eco.$schema = "./fakeapp.schema.json"; + readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); + existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); + searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); + await setupConfigToLoad(undefined, configOpts); + + // Setup mock secure fields + jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue(secureFields); + + let caughtError; + try { + await handler.process(params); + } catch (error) { + caughtError = error; + } + + // Verify prompt count and inclusion of expected secure fields + expect(myPromptSpy).toHaveBeenCalledTimes(expectedPromptTimes); + if (expectedPromptTimes > 0) { + expect(myPromptSpy).toHaveBeenCalledWith(expect.stringContaining(expectedSecureField), { "hideText": true }); + } + expect(caughtError).toBeUndefined(); + }; + + it("should only prompt for secure values that match the profile passed in through params", async () => { + await runTest( + "GoodProfile", + [ + "profiles.noMatchProfile.properties.tokenValue", + "profiles.GoodProfile.properties.tokenValue", + "profiles.abcdefg.properties.tokenValue" + ], + 1, + "profiles.GoodProfile.properties.tokenValue" + ); + }); + + it("should only prompt for secure values that match the profile passed in through params - nested profile", async () => { + await runTest( + "lpar1.GoodProfile", + [ + "profiles.noMatchProfile.properties.tokenValue", + "profiles.lpar1.profiles.GoodProfile.properties.tokenValue", + "profiles.abcdefg.properties.tokenValue" + ], + 1, + "profiles.lpar1.profiles.GoodProfile.properties.tokenValue" + ); + }); + + it("should only prompt for secure values that match the profile passed in through params - ignore casing", async () => { + await runTest( + "gOODpROFILE", + [ + "profiles.noMatchProfile.properties.tokenValue", + "profiles.GoodProfile.properties.tokenValue", + "profiles.abcdefg.properties.tokenValue" + ], + 1, + "profiles.GoodProfile.properties.tokenValue" + ); + }); + + it("should prompt for all secure values given a profile in which no secure profile value matches", async () => { + await runTest( + "noMatchProfile", + [ + "profiles.lpar1.profiles.test.properties.tokenValue", + "profiles.GoodProfile.properties.tokenValue", + "profiles.abcdefg.properties.tokenValue" + ], + 3, + "profiles.lpar1.profiles.test.properties.tokenValue" + ); + }); }); + }); }); From cedf8a752c56fa6019be46638a41446967db2c86 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 18 Sep 2024 10:17:17 -0400 Subject: [PATCH 37/69] updated snapshots Signed-off-by: jace-roell --- .../command/__snapshots__/Command.definition.unit.test.ts.snap | 2 +- .../__snapshots__/AddressSpace.definition.unit.test.ts.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap index c931e9f2dd..00e0d58f5f 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap @@ -39,7 +39,7 @@ Object { "description": "Your z/OS TSO/E accounting information.", "group": "TSO ADDRESS SPACE OPTIONS", "name": "account", - "required": true, + "required": false, "type": "string", }, Object { diff --git a/packages/cli/__tests__/zostso/__unit__/start/address-space/__snapshots__/AddressSpace.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/start/address-space/__snapshots__/AddressSpace.definition.unit.test.ts.snap index 84fa3ed18b..6a320fdce3 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/address-space/__snapshots__/AddressSpace.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/start/address-space/__snapshots__/AddressSpace.definition.unit.test.ts.snap @@ -29,7 +29,7 @@ Object { "description": "Your z/OS TSO/E accounting information.", "group": "TSO ADDRESS SPACE OPTIONS", "name": "account", - "required": true, + "required": false, "type": "string", }, Object { From a284a7a1f5c14b6b1bd52f242952472f0524144e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 18 Sep 2024 10:27:08 -0400 Subject: [PATCH 38/69] revert change Signed-off-by: jace-roell --- packages/zostso/src/constants/ZosTso.constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zostso/src/constants/ZosTso.constants.ts b/packages/zostso/src/constants/ZosTso.constants.ts index 58c1e794e1..321b2930ca 100644 --- a/packages/zostso/src/constants/ZosTso.constants.ts +++ b/packages/zostso/src/constants/ZosTso.constants.ts @@ -20,7 +20,7 @@ export class TsoProfileConstants { aliases: ["a"], description: "Your z/OS TSO/E accounting information.", type: "string", - required: false, + required: true, group: TsoProfileConstants.TSO_OPTION_GROUP }; From 250d0932da1e33e9adfee525fdc67718dad7eacb Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 18 Sep 2024 10:28:54 -0400 Subject: [PATCH 39/69] snapshot Signed-off-by: jace-roell --- .../command/__snapshots__/Command.definition.unit.test.ts.snap | 2 +- .../__snapshots__/AddressSpace.definition.unit.test.ts.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap index 00e0d58f5f..c931e9f2dd 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap @@ -39,7 +39,7 @@ Object { "description": "Your z/OS TSO/E accounting information.", "group": "TSO ADDRESS SPACE OPTIONS", "name": "account", - "required": false, + "required": true, "type": "string", }, Object { diff --git a/packages/cli/__tests__/zostso/__unit__/start/address-space/__snapshots__/AddressSpace.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/start/address-space/__snapshots__/AddressSpace.definition.unit.test.ts.snap index 6a320fdce3..84fa3ed18b 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/address-space/__snapshots__/AddressSpace.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/start/address-space/__snapshots__/AddressSpace.definition.unit.test.ts.snap @@ -29,7 +29,7 @@ Object { "description": "Your z/OS TSO/E accounting information.", "group": "TSO ADDRESS SPACE OPTIONS", "name": "account", - "required": false, + "required": true, "type": "string", }, Object { From 484a7bfe19c8851cc4085b657fc94a8b15f69341 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 18 Sep 2024 10:50:57 -0400 Subject: [PATCH 40/69] unused import Signed-off-by: jace-roell --- .../src/imperative/src/config/cmd/secure/secure.handler.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts b/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts index 67ea80943c..dde80d4f02 100644 --- a/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts +++ b/packages/imperative/src/imperative/src/config/cmd/secure/secure.handler.ts @@ -15,7 +15,6 @@ import { IHandlerParameters, } from "../../../../../cmd"; import { Config, ConfigConstants, ConfigSchema } from "../../../../../config"; -import { ConfigProfiles } from "../../../../../config/src/api"; import { ConfigAutoStore } from "../../../../../config/src/ConfigAutoStore"; import { ConfigUtils } from "../../../../../config/src/ConfigUtils"; import { ImperativeError } from "../../../../../error"; From e5cbacca69340b4dc96a699490ca5367f49a6295 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 18 Sep 2024 11:49:14 -0400 Subject: [PATCH 41/69] fixes Signed-off-by: jace-roell --- .../command/Command.handler.unit.test.ts | 6 +- .../Command.handler.unit.test.ts.snap | 62 ++++--------------- .../zostso/issue/command/Command.handler.ts | 2 +- .../__tests__/__unit__/IssueTso.unit.test.ts | 10 +-- packages/zostso/src/IssueTso.ts | 2 +- .../zostso/src/doc/input/IIssueTsoCmdOpts.ts | 2 +- 6 files changed, 23 insertions(+), 61 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index 019a458699..bfce7e1798 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -36,9 +36,9 @@ describe("issue command handler tests", () => { it("should issue command", async () => { /* eslint-disable-next-line */ - const response = IssueTso.issueTsoCmd = jest.fn((session, cmd, undefined) => { - expect(response).toBeDefined(); - expect(response).toMatchSnapshot(); + IssueTso.issueTsoCmd = jest.fn((session, cmd) => { + expect(session).toBeDefined(); + expect(session.ISession).toMatchSnapshot(); return StartTsoData.SAMPLE_ISSUE_RESPONSE_WITH_MSG; }); const handler = new Command.default(); diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap index 88bd085302..1975c48fc9 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.handler.unit.test.ts.snap @@ -6,56 +6,18 @@ with an active z/OS application session." `; exports[`issue command handler tests should issue command 1`] = ` -[MockFunction] { - "calls": Array [ - Array [ - Session { - "mISession": Object { - "base64EncodedAuth": "c29tZW9uZTpmYWtl", - "basePath": "", - "hostname": "somewhere.com", - "password": "fake", - "port": "43443", - "protocol": "https", - "rejectUnauthorized": true, - "secureProtocol": "SSLv23_method", - "strictSSL": true, - "type": "basic", - "user": "someone", - }, - "mLog": Logger { - "category": "imperative", - "initStatus": false, - "mJsLogger": Logger { - "callStackSkipIndex": 0, - "category": "imperative", - "context": Object {}, - "parseCallStack": [Function], - }, - }, - }, - undefined, - Object { - "addressSpaceOptions": Object { - "account": "fake", - "characterSet": undefined, - "codePage": undefined, - "columns": undefined, - "logonProcedure": undefined, - "regionSize": undefined, - "rows": undefined, - }, - "isStateful": undefined, - "suppressStartupMessage": undefined, - }, - ], - ], - "results": Array [ - Object { - "type": "incomplete", - "value": undefined, - }, - ], +Object { + "base64EncodedAuth": "c29tZW9uZTpmYWtl", + "basePath": "", + "hostname": "somewhere.com", + "password": "fake", + "port": "43443", + "protocol": "https", + "rejectUnauthorized": true, + "secureProtocol": "SSLv23_method", + "strictSSL": true, + "type": "basic", + "user": "someone", } `; diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index d1b9790875..9facb94604 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -30,7 +30,7 @@ export default class Handler extends ZosTsoBaseHandler { params.arguments.commandText, { isStateful: params.arguments.stateful, - suppressStartupMessage: + suppressStartupMessages: params.arguments.suppressStartupMessages, addressSpaceOptions: this.mTsoStart } diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index dfdedf814c..01f8c3ae24 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -342,7 +342,7 @@ describe("all tests", () => { "command", { isStateful: true, - suppressStartupMessage: false, + suppressStartupMessages: false, } ); } catch (thrownError) { @@ -376,7 +376,7 @@ describe("all tests", () => { response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", { addressSpaceOptions: null, isStateful: true, - suppressStartupMessage: true, + suppressStartupMessages: true, }); } catch (thrownError) { error = thrownError; @@ -401,7 +401,7 @@ describe("all tests", () => { response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "TIME", { addressSpaceOptions: null, isStateful: true, - suppressStartupMessage: true, + suppressStartupMessages: true, }); } catch (thrownError) { error = thrownError; @@ -426,7 +426,7 @@ describe("all tests", () => { "fake_command", { isStateful: true, - suppressStartupMessage: false, + suppressStartupMessages: false, } ); } catch (thrownError) { @@ -451,7 +451,7 @@ describe("all tests", () => { try { response = await IssueTso.issueTsoCmd(PRETEND_SESSION, "", { isStateful: true, - suppressStartupMessage: false, + suppressStartupMessages: false, }); } catch (thrownError) { error = thrownError; diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 0ad775d1d1..371c6ffe21 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -42,7 +42,7 @@ export class IssueTso { session, ZosmfConstants.VERSIONS.V2R4 ) && - (opts.suppressStartupMessage ?? true); + (opts.suppressStartupMessages ?? true); if (useNewApi) { command = commandInfo; version = "v1"; diff --git a/packages/zostso/src/doc/input/IIssueTsoCmdOpts.ts b/packages/zostso/src/doc/input/IIssueTsoCmdOpts.ts index 15784e33ff..55597a07b7 100644 --- a/packages/zostso/src/doc/input/IIssueTsoCmdOpts.ts +++ b/packages/zostso/src/doc/input/IIssueTsoCmdOpts.ts @@ -36,5 +36,5 @@ export interface IIssueTsoCmdOpts { * @type {boolean} * @memberof IIssueTsoCmdOpts */ - suppressStartupMessage?: boolean; + suppressStartupMessages?: boolean; } From 1b077d2c88fbf3c0b43b36c9731b3b3464587958 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 19 Sep 2024 11:23:38 -0400 Subject: [PATCH 42/69] isZosVersionGreaterThan() renamed to isZosVersionAtLeast() and formatting Signed-off-by: jace-roell --- .../issue/command/Command.handler.unit.test.ts | 1 - .../Command.definition.unit.test.ts.snap | 2 +- .../src/zostso/issue/command/Command.definition.ts | 2 +- packages/zosmf/CHANGELOG.md | 2 +- packages/zosmf/src/CheckStatus.ts | 2 +- .../__tests__/__unit__/IssueTso.unit.test.ts | 14 +++++++------- packages/zostso/src/IssueTso.ts | 2 +- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index bfce7e1798..b7153e6ba0 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -35,7 +35,6 @@ describe("issue command handler tests", () => { }); it("should issue command", async () => { - /* eslint-disable-next-line */ IssueTso.issueTsoCmd = jest.fn((session, cmd) => { expect(session).toBeDefined(); expect(session.ISession).toMatchSnapshot(); diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap index c931e9f2dd..59cd98c3d3 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap @@ -18,7 +18,7 @@ Object { "aliases": Array [ "ssm", ], - "defaultValue": true, + "defaultValue": false, "description": "Suppress console messages from start of address space.", "name": "suppress-startup-messages", "type": "boolean", diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index 4917a65386..d500b812a1 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -43,7 +43,7 @@ export const CommandDefinition: ICommandDefinition = { aliases: ["ssm"], type: "boolean", description: "Suppress console messages from start of address space.", - defaultValue: true + defaultValue: false }, { // --stateful has no impact if --suppress-startup-messages is set to false. diff --git a/packages/zosmf/CHANGELOG.md b/packages/zosmf/CHANGELOG.md index bab12469d6..38b92f41ad 100644 --- a/packages/zosmf/CHANGELOG.md +++ b/packages/zosmf/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe z/OSMF SDK package will be documented in this fi ## Recent Changes -- Enhancement: Created `isZosVersionsGreaterThan()` function to allow for dynamic behavior based on z/OS version. [#2240](https://github.com/zowe/zowe-cli/pull/2240) +- Enhancement: Created `isZosVersionAtLeast()` function to allow for dynamic behavior based on z/OS version. [#2240](https://github.com/zowe/zowe-cli/pull/2240) ## `8.0.0-next.202408131445` diff --git a/packages/zosmf/src/CheckStatus.ts b/packages/zosmf/src/CheckStatus.ts index c46687ed74..b9198d905c 100644 --- a/packages/zosmf/src/CheckStatus.ts +++ b/packages/zosmf/src/CheckStatus.ts @@ -36,7 +36,7 @@ export class CheckStatus { return ZosmfRestClient.getExpectJSON(session, infoEndpoint); } - public static async isZosVersionGreaterThan(session: AbstractSession, version: string): Promise { + public static async isZosVersionAtLeast(session: AbstractSession, version: string): Promise { return (await CheckStatus.getZosmfInfo(session)).zosmf_version >= version; } diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index 01f8c3ae24..c381883e53 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -140,7 +140,7 @@ describe("all tests", () => { expect(error).toBeDefined(); }); it("should fail when StartTSO fails", async () => { - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + jest.spyOn(CheckStatus, "isZosVersionAtLeast").mockReturnValue( Promise.resolve(false) ); let error: ImperativeError; @@ -173,7 +173,7 @@ describe("all tests", () => { describe("TsoIssue issueTsoCommand - Deprecated API", () => { it("should succeed", async () => { - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + jest.spyOn(CheckStatus, "isZosVersionAtLeast").mockReturnValue( Promise.resolve(false) ); (StartTso.start as any) = jest.fn(() => { @@ -302,7 +302,7 @@ describe("all tests", () => { jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValueOnce( Promise.resolve(zosmfResponse) ); - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + jest.spyOn(CheckStatus, "isZosVersionAtLeast").mockReturnValue( Promise.resolve(true) ); try { @@ -321,7 +321,7 @@ describe("all tests", () => { // Mock the CheckStatus to simulate Z/OS version check jest.spyOn( CheckStatus, - "isZosVersionGreaterThan" + "isZosVersionAtLeast" ).mockReturnValueOnce(Promise.resolve(true)); const zosmfResponse = { cmdResponse: [ @@ -369,7 +369,7 @@ describe("all tests", () => { ); let error: ImperativeError; let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + jest.spyOn(CheckStatus, "isZosVersionAtLeast").mockReturnValue( Promise.resolve(true) ); try { @@ -417,7 +417,7 @@ describe("all tests", () => { it("should fail for null command text", async () => { let error: ImperativeError; let response: ISendResponse; - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + jest.spyOn(CheckStatus, "isZosVersionAtLeast").mockReturnValue( Promise.resolve(true) ); try { @@ -445,7 +445,7 @@ describe("all tests", () => { msg: "status 403", }) ); - jest.spyOn(CheckStatus, "isZosVersionGreaterThan").mockReturnValue( + jest.spyOn(CheckStatus, "isZosVersionAtLeast").mockReturnValue( Promise.resolve(true) ); try { diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 371c6ffe21..e3358c4287 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -38,7 +38,7 @@ export class IssueTso { opts = opts || {}; let useNewApi = opts.addressSpaceOptions == null || - await CheckStatus.isZosVersionGreaterThan( + await CheckStatus.isZosVersionAtLeast( session, ZosmfConstants.VERSIONS.V2R4 ) && From f5a544beebd2a3ac41a64bc332eaec3825d13c0d Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 19 Sep 2024 12:47:39 -0400 Subject: [PATCH 43/69] changelog Signed-off-by: jace-roell --- packages/imperative/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 2fd97c2b77..7dd0c265c6 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Imperative package will be documented in this file. ## Recent Changes -- Enhancement: Allows for profile specification on `zowe config secure` command to avoid prompting for other profiles +- Enhancement: Allows for profile specification on `zowe config secure` command to allow for exclusively prompting for a single profile's secure values. [#1890] https://github.com/zowe/zowe-cli/issues/1890 ## `8.0.0-next.202408301809` From bc1866fb5f244dc28af56f39d777ed020923a068 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 19 Sep 2024 13:28:38 -0400 Subject: [PATCH 44/69] removed unneccessary interface Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 9 +---- .../zostso/src/doc/input/IIssueTsoCmdParms.ts | 33 ------------------- packages/zostso/src/index.ts | 1 - 3 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 packages/zostso/src/doc/input/IIssueTsoCmdParms.ts diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index e3358c4287..83bba95163 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -21,7 +21,6 @@ import { IIssueTsoParms } from "./doc/input/IIssueTsoParms"; import { CheckStatus, ZosmfConstants } from "@zowe/zosmf-for-zowe-sdk"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { IIssueTsoCmdResponse } from "./doc/IIssueTsoCmdResponse"; -import { IIssueTsoCmdParms } from "./doc/input/IIssueTsoCmdParms"; import { IIssueTsoCmdOpts } from "./doc/input/IIssueTsoCmdOpts"; /** * Class to handle issue command to TSO @@ -30,10 +29,9 @@ import { IIssueTsoCmdOpts } from "./doc/input/IIssueTsoCmdOpts"; export class IssueTso { public static async issueTsoCmd( session: AbstractSession, - commandInfo: string | IIssueTsoCmdParms, + command: string, opts?: IIssueTsoCmdOpts ): Promise { - let command: string | IIssueTsoCmdParms; let version: string; opts = opts || {}; let useNewApi = @@ -44,7 +42,6 @@ export class IssueTso { ) && (opts.suppressStartupMessages ?? true); if (useNewApi) { - command = commandInfo; version = "v1"; try { const endpoint = `${TsoConstants.RESOURCE}/${version}/${TsoConstants.RES_START_TSO}`; @@ -77,10 +74,6 @@ export class IssueTso { } // Deprecated API Behavior [former issueTsoCommand() behavior] if (opts.addressSpaceOptions != null || !useNewApi) { - command = - typeof commandInfo === "string" - ? commandInfo - : commandInfo.command; TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( opts.addressSpaceOptions?.account, diff --git a/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts b/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts deleted file mode 100644 index 1a9850102a..0000000000 --- a/packages/zostso/src/doc/input/IIssueTsoCmdParms.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ - -export interface IIssueTsoCmdParms { - /** - * command being ran on TSO address space - * @type {string} - * @memberof IIssueTsoCmdParms - */ - command: string; - - /** - * z/OS >2.4 TSO Command statefulness of address space - * @type {boolean} - * @memberof IIssueTsoCmdParms - */ - isStateful?: boolean; - - /** - * current version of z/OS connection - * @type {string} - * @memberof IIssueTsoCmdParms - */ - version?: string; -} diff --git a/packages/zostso/src/index.ts b/packages/zostso/src/index.ts index a9592a8893..576da8ddd6 100644 --- a/packages/zostso/src/index.ts +++ b/packages/zostso/src/index.ts @@ -12,7 +12,6 @@ export * from "./constants/ZosTso.constants"; export * from "./constants/ZosTso.profile"; -export * from "./doc/input/IIssueTsoCmdParms"; export * from "./doc/input/IIssueTsoParms"; export * from "./doc/input/ISendTsoParms"; export * from "./doc/input/IStartTsoParms"; From f59fc0beb9fc025489acfca419b74b781bf1ad2b Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 19 Sep 2024 15:33:50 -0400 Subject: [PATCH 45/69] snapshot Signed-off-by: jace-roell --- .../cli.zos-tso.issue.cmd.integration.test.ts.snap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap index 5a9876216d..b8bca955a7 100644 --- a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap @@ -34,7 +34,7 @@ exports[`zos-tso issue command should display the help 1`] = ` Suppress console messages from start of address space. - Default value: true + Default value: false --stateful | --sf (boolean) @@ -193,8 +193,8 @@ exports[`zos-tso issue command should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: command.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: true\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO Command.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO Command.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: true\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO Command.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO Command.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" }" `; From 79afe99fb9bfa829497e577ca7b7869f08301db9 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 19 Sep 2024 16:16:52 -0400 Subject: [PATCH 46/69] definition warning Signed-off-by: jace-roell --- .../src/imperative/src/config/cmd/secure/secure.definition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts b/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts index 07a9e46e3e..a89816cbfc 100644 --- a/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts +++ b/packages/imperative/src/imperative/src/config/cmd/secure/secure.definition.ts @@ -42,7 +42,7 @@ export const secureDefinition: ICommandDefinition = { }, { name: "profile", - description: "Specify the profile in which you would like to configure the secure values for", + description: "Specify the profile for which you want to configure secure values.", type: "string", aliases: ["pf"], defaultValue: null From 20eb2ddc7f9b0b9bf2bd6ffb275b17e7414f34a7 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 19 Sep 2024 16:19:14 -0400 Subject: [PATCH 47/69] changelog Signed-off-by: jace-roell --- packages/imperative/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index ed934aea6a..0cc1504115 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Imperative package will be documented in this file. ## Recent Changes -- Enhancement: Allows for profile specification on `zowe config secure` command to allow for exclusively prompting for a single profile's secure values. [#1890] https://github.com/zowe/zowe-cli/issues/1890 +- Enhancement: Added the ability to specify a profile with the `zowe config secure command`. This allows the user to prompt for the secure values of the specified profile. [#1890] https://github.com/zowe/zowe-cli/issues/1890 ## `8.0.0-next.202409191615` From e8f4e52dd85454bc1cfe233f0e27d9748ac9d5d1 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 20 Sep 2024 12:23:05 -0400 Subject: [PATCH 48/69] default values and printing servlet key Signed-off-by: jace-roell --- packages/cli/src/zostso/issue/command/Command.handler.ts | 5 ++++- packages/zostso/src/IssueTso.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/zostso/issue/command/Command.handler.ts b/packages/cli/src/zostso/issue/command/Command.handler.ts index 9facb94604..61d907093a 100644 --- a/packages/cli/src/zostso/issue/command/Command.handler.ts +++ b/packages/cli/src/zostso/issue/command/Command.handler.ts @@ -15,6 +15,7 @@ import { IssueTso, ZosTsoBaseHandler, } from "@zowe/zos-tso-for-zowe-sdk"; +import chalk = require("chalk"); /** * Handler to issue command to TSO address space * @export @@ -43,8 +44,10 @@ export default class Handler extends ZosTsoBaseHandler { ) { this.console.log(response.startResponse.messages); } - this.console.log(response.commandResponse); + if(response. zosmfResponse?.[0]?.servletKey) + this.console.log(`${chalk.yellow("Servlet Key: ")}${response.zosmfResponse[0].servletKey}`); + this.console.log(response.commandResponse); // Return as an object when using --response-format-json this.data.setObj(response); } diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 83bba95163..737feb3bc4 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -40,7 +40,7 @@ export class IssueTso { session, ZosmfConstants.VERSIONS.V2R4 ) && - (opts.suppressStartupMessages ?? true); + (opts.suppressStartupMessages ?? false); if (useNewApi) { version = "v1"; try { @@ -61,7 +61,7 @@ export class IssueTso { apiResponse.cmdResponse[ apiResponse.cmdResponse.length - 1 ].message.trim() === "READY", - zosmfResponse: apiResponse as any, + zosmfResponse: [apiResponse as any], commandResponse: apiResponse.cmdResponse .map((item) => item.message) .join("\n"), From 5653ff50a555742fdcfb843d838683042e946182 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 20 Sep 2024 12:32:49 -0400 Subject: [PATCH 49/69] stateful definition Signed-off-by: jace-roell --- packages/cli/src/zostso/issue/command/Command.definition.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index d500b812a1..d758d2613c 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -50,7 +50,8 @@ export const CommandDefinition: ICommandDefinition = { name: "stateful", aliases: ["sf"], type: "boolean", - description: "Statefulness of address space created for TSO Command.", + description:"Statefulness of address space created for TSO command." + + "This option is not supported when --suppress-startup-messages is set to false.", defaultValue: false } ] as ICommandOptionDefinition[]).concat(TsoProfileConstants.TSO_PROFILE_OPTIONS), From c16d5404b426723c5437ad2baba8dc347864b46f Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 20 Sep 2024 13:00:42 -0400 Subject: [PATCH 50/69] changelog Signed-off-by: jace-roell --- packages/imperative/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 123c054369..3a547e1c60 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Imperative package will be documented in this file. ## Recent Changes -- Enhancement: Added the ability to specify a profile with the `zowe config secure command`. This allows the user to prompt for the secure values of the specified profile. [#1890] https://github.com/zowe/zowe-cli/issues/1890 +- Enhancement: Added the ability to specify a profile with the `zowe config secure` command. This allows the user to prompt for the secure values of the specified profile. [#1890] https://github.com/zowe/zowe-cli/issues/1890 ## `8.0.0` From 3c8c92859301e09e29e5787606296955d3b31657 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 20 Sep 2024 14:04:06 -0400 Subject: [PATCH 51/69] snapshot Signed-off-by: jace-roell --- .../cli.zos-tso.issue.cmd.integration.test.ts.snap | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap index b8bca955a7..b143372b58 100644 --- a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap @@ -38,7 +38,8 @@ exports[`zos-tso issue command should display the help 1`] = ` --stateful | --sf (boolean) - Statefulness of address space created for TSO Command. + Statefulness of address space created for TSO command.This option is not + supported when --suppress-startup-messages is set to false. Default value: false @@ -193,8 +194,8 @@ exports[`zos-tso issue command should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: command.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO Command.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command.This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO Command.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command.This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" }" `; From b4aa112ce3c07a65e909033118bb6b4f568cf654 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 20 Sep 2024 14:49:24 -0400 Subject: [PATCH 52/69] snapshot Signed-off-by: jace-roell --- .../command/__snapshots__/Command.definition.unit.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap index 59cd98c3d3..dc3a1f2f71 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap @@ -28,7 +28,7 @@ Object { "sf", ], "defaultValue": false, - "description": "Statefulness of address space created for TSO Command.", + "description": "Statefulness of address space created for TSO command.This option is not supported when --suppress-startup-messages is set to false.", "name": "stateful", "type": "boolean", }, From 6513228f9d4a34c40c2bb7e6d0c4c021543d4029 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 20 Sep 2024 15:41:56 -0400 Subject: [PATCH 53/69] spacing Signed-off-by: jace-roell --- packages/cli/src/zostso/issue/command/Command.definition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index d758d2613c..0e2870e28d 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -51,7 +51,7 @@ export const CommandDefinition: ICommandDefinition = { aliases: ["sf"], type: "boolean", description:"Statefulness of address space created for TSO command." + - "This option is not supported when --suppress-startup-messages is set to false.", + " This option is not supported when --suppress-startup-messages is set to false.", defaultValue: false } ] as ICommandOptionDefinition[]).concat(TsoProfileConstants.TSO_PROFILE_OPTIONS), From 096ed913eb1da1cd89c96cf760041b76e74b1f27 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 20 Sep 2024 16:02:10 -0400 Subject: [PATCH 54/69] snapshot Signed-off-by: jace-roell --- .../command/__snapshots__/Command.definition.unit.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap index dc3a1f2f71..f1c0ae6f9a 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap @@ -28,7 +28,7 @@ Object { "sf", ], "defaultValue": false, - "description": "Statefulness of address space created for TSO command.This option is not supported when --suppress-startup-messages is set to false.", + "description": "Statefulness of address space created for TSO command. This option is not supported when --suppress-startup-messages is set to false.", "name": "stateful", "type": "boolean", }, From b19696b0c3d7f1e6e1f20a13c823fe74fa37eba4 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 23 Sep 2024 10:36:35 -0400 Subject: [PATCH 55/69] snapshot Signed-off-by: jace-roell --- .../cli.zos-tso.issue.cmd.integration.test.ts.snap | 6 +++--- packages/cli/src/zostso/issue/command/Command.definition.ts | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap index b143372b58..8b33220ad7 100644 --- a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap @@ -38,7 +38,7 @@ exports[`zos-tso issue command should display the help 1`] = ` --stateful | --sf (boolean) - Statefulness of address space created for TSO command.This option is not + Statefulness of address space created for TSO command. This option is not supported when --suppress-startup-messages is set to false. Default value: false @@ -194,8 +194,8 @@ exports[`zos-tso issue command should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: command.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command.This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command. This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command.This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command. This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" }" `; diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index 0e2870e28d..4227a80d44 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -50,8 +50,7 @@ export const CommandDefinition: ICommandDefinition = { name: "stateful", aliases: ["sf"], type: "boolean", - description:"Statefulness of address space created for TSO command." + - " This option is not supported when --suppress-startup-messages is set to false.", + description:"Statefulness of address space created for TSO command. This option is not supported when --suppress-startup-messages is set to false.", defaultValue: false } ] as ICommandOptionDefinition[]).concat(TsoProfileConstants.TSO_PROFILE_OPTIONS), From 20c2db7df35a60e1ae25a512b3f16bf5c5139fee Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 23 Sep 2024 11:36:46 -0400 Subject: [PATCH 56/69] codecov Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 737feb3bc4..19081a5305 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -36,11 +36,7 @@ export class IssueTso { opts = opts || {}; let useNewApi = opts.addressSpaceOptions == null || - await CheckStatus.isZosVersionAtLeast( - session, - ZosmfConstants.VERSIONS.V2R4 - ) && - (opts.suppressStartupMessages ?? false); + await CheckStatus.isZosVersionAtLeast(session,ZosmfConstants.VERSIONS.V2R4) && (opts.suppressStartupMessages ?? false); if (useNewApi) { version = "v1"; try { From 514ba27dc739eac0d6cc698c1b24c27fd1c0b5d2 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 23 Sep 2024 12:03:01 -0400 Subject: [PATCH 57/69] default value Signed-off-by: jace-roell --- packages/cli/src/zostso/issue/command/Command.definition.ts | 2 +- packages/zostso/src/IssueTso.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index 4227a80d44..0c943110c5 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -43,7 +43,7 @@ export const CommandDefinition: ICommandDefinition = { aliases: ["ssm"], type: "boolean", description: "Suppress console messages from start of address space.", - defaultValue: false + defaultValue: true }, { // --stateful has no impact if --suppress-startup-messages is set to false. diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 19081a5305..33eb0e17d1 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -36,7 +36,7 @@ export class IssueTso { opts = opts || {}; let useNewApi = opts.addressSpaceOptions == null || - await CheckStatus.isZosVersionAtLeast(session,ZosmfConstants.VERSIONS.V2R4) && (opts.suppressStartupMessages ?? false); + await CheckStatus.isZosVersionAtLeast(session,ZosmfConstants.VERSIONS.V2R4) && (opts.suppressStartupMessages ?? true); if (useNewApi) { version = "v1"; try { @@ -135,7 +135,7 @@ export class IssueTso { command: string, startParams?: IStartTsoParms ): Promise { - return await IssueTso.issueTsoCmd(session, command, { addressSpaceOptions: {...startParams, account: accountNumber}}); + return await IssueTso.issueTsoCmd(session, command, { suppressStartupMessages: false, addressSpaceOptions: {...startParams, account: accountNumber } }); } /** From 2c41dc532a8c8e2b7d349de474ef31b742270b68 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 23 Sep 2024 13:04:24 -0400 Subject: [PATCH 58/69] snaps Signed-off-by: jace-roell --- .../cli.zos-tso.issue.cmd.integration.test.ts.snap | 6 +++--- .../__snapshots__/Command.definition.unit.test.ts.snap | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap index 8b33220ad7..da99f287ba 100644 --- a/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/issue/__snapshots__/cli.zos-tso.issue.cmd.integration.test.ts.snap @@ -34,7 +34,7 @@ exports[`zos-tso issue command should display the help 1`] = ` Suppress console messages from start of address space. - Default value: false + Default value: true --stateful | --sf (boolean) @@ -194,8 +194,8 @@ exports[`zos-tso issue command should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: command.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command. This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: true\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command. This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: false\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command. This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n command | cmd\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Creates a TSO address space, issues a TSO command through the newly created\\\\n address space, waits for the READY prompt to print the response, and terminates\\\\n the TSO address space. All response data are returned to the user up to (but not\\\\n including) the TSO 'READY' prompt.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso issue command [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n commandText\\\\t\\\\t (string)\\\\n\\\\n The TSO command to issue.\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --suppress-startup-messages | --ssm (boolean)\\\\n\\\\n Suppress console messages from start of address space.\\\\n\\\\n Default value: true\\\\n\\\\n --stateful | --sf (boolean)\\\\n\\\\n Statefulness of address space created for TSO command. This option is not\\\\n supported when --suppress-startup-messages is set to false.\\\\n\\\\n Default value: false\\\\n\\\\n TSO ADDRESS SPACE OPTIONS\\\\n -------------------------\\\\n\\\\n --account | -a (string)\\\\n\\\\n Your z/OS TSO/E accounting information.\\\\n\\\\n --character-set | --cs (string)\\\\n\\\\n Character set for address space to convert messages and responses from UTF-8 to\\\\n EBCDIC.\\\\n\\\\n Default value: 697\\\\n\\\\n --code-page | --cp (string)\\\\n\\\\n Codepage value for TSO/E address space to convert messages and responses from\\\\n UTF-8 to EBCDIC.\\\\n\\\\n Default value: 1047\\\\n\\\\n --columns | --cols (number)\\\\n\\\\n The number of columns on a screen.\\\\n\\\\n Default value: 80\\\\n\\\\n --logon-procedure | -l (string)\\\\n\\\\n The logon procedure to use when creating TSO procedures on your behalf.\\\\n\\\\n Default value: IZUFPROC\\\\n\\\\n --region-size | --rs (number)\\\\n\\\\n Region size for the TSO/E address space.\\\\n\\\\n Default value: 4096\\\\n\\\\n --rows (number)\\\\n\\\\n The number of rows on a screen.\\\\n\\\\n Default value: 24\\\\n\\\\n ZOSMF CONNECTION OPTIONS\\\\n ------------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n The z/OSMF server host name.\\\\n\\\\n --port | -P (number)\\\\n\\\\n The z/OSMF server port.\\\\n\\\\n Default value: 443\\\\n\\\\n --user | -u (string)\\\\n\\\\n Mainframe (z/OSMF) user name, which can be the same as your TSO login.\\\\n\\\\n --password | --pass | --pw (string)\\\\n\\\\n Mainframe (z/OSMF) password, which can be the same as your TSO password.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n --base-path | --bp (string)\\\\n\\\\n The base path for your API mediation layer instance. Specify this option to\\\\n prepend the base path to all z/OSMF resources when making REST requests. Do not\\\\n specify this option if you are not using an API mediation layer.\\\\n\\\\n --protocol (string)\\\\n\\\\n The protocol used (HTTP or HTTPS)\\\\n\\\\n Default value: https\\\\n Allowed values: http, https\\\\n\\\\n --cert-file (local file path)\\\\n\\\\n The file path to a certificate file to use for authentication\\\\n\\\\n --cert-key-file (local file path)\\\\n\\\\n The file path to a certificate key file to use for authentication\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --zosmf-profile | --zosmf-p (string)\\\\n\\\\n The name of a (zosmf) profile to load for this command execution.\\\\n\\\\n --tso-profile | --tso-p (string)\\\\n\\\\n The name of a (tso) profile to load for this command execution.\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Issue the TSO command \\\\\\"status\\\\\\" to display information about\\\\n jobs for your user ID.:\\\\n\\\\n $ zowe zos-tso issue command \\\\\\"status\\\\\\"\\\\n\\\\n\\" }" `; diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap index f1c0ae6f9a..80cef8874f 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/__snapshots__/Command.definition.unit.test.ts.snap @@ -18,7 +18,7 @@ Object { "aliases": Array [ "ssm", ], - "defaultValue": false, + "defaultValue": true, "description": "Suppress console messages from start of address space.", "name": "suppress-startup-messages", "type": "boolean", From 1f2facce7e9732062d03b6f8d426fd994466d98a Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 23 Sep 2024 14:11:21 -0400 Subject: [PATCH 59/69] codecov Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 33eb0e17d1..f961638263 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -34,9 +34,8 @@ export class IssueTso { ): Promise { let version: string; opts = opts || {}; - let useNewApi = - opts.addressSpaceOptions == null || - await CheckStatus.isZosVersionAtLeast(session,ZosmfConstants.VERSIONS.V2R4) && (opts.suppressStartupMessages ?? true); + let zosVersionCheck = await CheckStatus.isZosVersionAtLeast(session,ZosmfConstants.VERSIONS.V2R4); + let useNewApi = opts.addressSpaceOptions == null || zosVersionCheck && (opts.suppressStartupMessages ?? true); if (useNewApi) { version = "v1"; try { From 1f2ca229de82d1ff4257f2ee6f8b98e45f7cbfc3 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 24 Sep 2024 08:39:37 -0400 Subject: [PATCH 60/69] linting codecov Signed-off-by: jace-roell --- .../command/Command.handler.unit.test.ts | 2 +- .../issue/command/Command.definition.ts | 3 +- packages/zostso/src/IssueTso.ts | 45 +++++++++++-------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index b7153e6ba0..b93aef6aa9 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -25,7 +25,7 @@ const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ ...UNIT_TEST_TSO_PROF_OPTS }, positionals: ["zos-tso", "issue", "address-space"], - definition: CommandDefinition + definition: CommandDefinition, }); describe("issue command handler tests", () => { diff --git a/packages/cli/src/zostso/issue/command/Command.definition.ts b/packages/cli/src/zostso/issue/command/Command.definition.ts index 0c943110c5..b65d43932d 100644 --- a/packages/cli/src/zostso/issue/command/Command.definition.ts +++ b/packages/cli/src/zostso/issue/command/Command.definition.ts @@ -50,7 +50,8 @@ export const CommandDefinition: ICommandDefinition = { name: "stateful", aliases: ["sf"], type: "boolean", - description:"Statefulness of address space created for TSO command. This option is not supported when --suppress-startup-messages is set to false.", + description:"Statefulness of address space created for TSO command." + + " This option is not supported when --suppress-startup-messages is set to false.", defaultValue: false } ] as ICommandOptionDefinition[]).concat(TsoProfileConstants.TSO_PROFILE_OPTIONS), diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index f961638263..0d8199f276 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -1,13 +1,13 @@ /* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v2.0 which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-v20.html + * + * SPDX-License-Identifier: EPL-2.0 + * + * Copyright Contributors to the Zowe Project. + * + */ import { AbstractSession, Headers, ImperativeError } from "@zowe/imperative"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; @@ -34,8 +34,10 @@ export class IssueTso { ): Promise { let version: string; opts = opts || {}; - let zosVersionCheck = await CheckStatus.isZosVersionAtLeast(session,ZosmfConstants.VERSIONS.V2R4); - let useNewApi = opts.addressSpaceOptions == null || zosVersionCheck && (opts.suppressStartupMessages ?? true); + opts.suppressStartupMessages = opts.suppressStartupMessages ?? true; + const versionCheck = await CheckStatus.isZosVersionAtLeast(session,ZosmfConstants.VERSIONS.V2R4); + let useNewApi = opts.addressSpaceOptions == null || versionCheck && opts.suppressStartupMessages; + if (useNewApi) { version = "v1"; try { @@ -47,7 +49,9 @@ export class IssueTso { [Headers.APPLICATION_JSON], { tsoCmd: command, - cmdState: opts.isStateful ? "stateful" : "stateless", + cmdState: opts.isStateful + ? "stateful" + : "stateless", } ); const response: IIssueResponse = { @@ -81,9 +85,7 @@ export class IssueTso { const response: IIssueResponse = { success: false, - startResponse: await StartTso.start( - session, - opts.addressSpaceOptions?.account, + startResponse: await StartTso.start(session,opts.addressSpaceOptions?.account, opts.addressSpaceOptions || {} ), startReady: false, @@ -134,7 +136,10 @@ export class IssueTso { command: string, startParams?: IStartTsoParms ): Promise { - return await IssueTso.issueTsoCmd(session, command, { suppressStartupMessages: false, addressSpaceOptions: {...startParams, account: accountNumber } }); + return await IssueTso.issueTsoCmd(session, command, { + suppressStartupMessages: false, + addressSpaceOptions: { ...startParams, account: accountNumber }, + }); } /** @@ -149,7 +154,11 @@ export class IssueTso { session: AbstractSession, commandParms: IIssueTsoParms ): Promise { - return await IssueTso.issueTsoCmd(session, commandParms.command, - { addressSpaceOptions: {...commandParms.startParams,account: commandParms.accountNumber}}); + return await IssueTso.issueTsoCmd(session, commandParms.command, { + addressSpaceOptions: { + ...commandParms.startParams, + account: commandParms.accountNumber, + }, + }); } } From 69005a5c7fa7d9526a1126a11c315b8c29eba2be Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 25 Sep 2024 09:58:57 -0400 Subject: [PATCH 61/69] added suppressStartupMessages: false to issueTsoCommandCommon Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 0d8199f276..df747de6d4 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -155,6 +155,7 @@ export class IssueTso { commandParms: IIssueTsoParms ): Promise { return await IssueTso.issueTsoCmd(session, commandParms.command, { + suppressStartupMessages: false, addressSpaceOptions: { ...commandParms.startParams, account: commandParms.accountNumber, From 041ee9f562cf7ba4bac99bcf66f098d5bbc86e60 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 25 Sep 2024 11:02:32 -0400 Subject: [PATCH 62/69] codeQL fix Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index df747de6d4..662911be5b 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -72,7 +72,7 @@ export class IssueTso { } } // Deprecated API Behavior [former issueTsoCommand() behavior] - if (opts.addressSpaceOptions != null || !useNewApi) { + if (!useNewApi) { TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( opts.addressSpaceOptions?.account, From 48f7d53cf49f8123940292dd5aefaa618af68eb9 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 25 Sep 2024 12:57:23 -0400 Subject: [PATCH 63/69] codeQL Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index 662911be5b..b55f2f7bc4 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -35,8 +35,13 @@ export class IssueTso { let version: string; opts = opts || {}; opts.suppressStartupMessages = opts.suppressStartupMessages ?? true; - const versionCheck = await CheckStatus.isZosVersionAtLeast(session,ZosmfConstants.VERSIONS.V2R4); - let useNewApi = opts.addressSpaceOptions == null || versionCheck && opts.suppressStartupMessages; + const versionCheck = await CheckStatus.isZosVersionAtLeast( + session, + ZosmfConstants.VERSIONS.V2R4 + ); + let useNewApi = + opts.addressSpaceOptions == null || + (versionCheck && opts.suppressStartupMessages); if (useNewApi) { version = "v1"; @@ -67,8 +72,13 @@ export class IssueTso { }; return response; } catch (e) { - if (!e.mMessage.includes("status 404")) throw e; - useNewApi = false; + if (e.mMessage.includes("status 404")) { + // Set useNewApi to false to handle fallback logic + useNewApi = false; + } else { + // Re-throw for other exceptions + throw e; + } } } // Deprecated API Behavior [former issueTsoCommand() behavior] @@ -85,7 +95,9 @@ export class IssueTso { const response: IIssueResponse = { success: false, - startResponse: await StartTso.start(session,opts.addressSpaceOptions?.account, + startResponse: await StartTso.start( + session, + opts.addressSpaceOptions?.account, opts.addressSpaceOptions || {} ), startReady: false, From 4027ec4d5109d7d13da5fca79fc00adca830da8e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 25 Sep 2024 13:08:34 -0400 Subject: [PATCH 64/69] lint Signed-off-by: jace-roell --- packages/zostso/src/IssueTso.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zostso/src/IssueTso.ts b/packages/zostso/src/IssueTso.ts index b55f2f7bc4..5300781cec 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -41,7 +41,7 @@ export class IssueTso { ); let useNewApi = opts.addressSpaceOptions == null || - (versionCheck && opts.suppressStartupMessages); + versionCheck && opts.suppressStartupMessages; if (useNewApi) { version = "v1"; From 77dda1b955fb13d3a7a1ff712aa580cbc5ec664e Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Thu, 26 Sep 2024 16:01:10 -0400 Subject: [PATCH 65/69] Remove Secrets SDK requirement when Imperative is a bundled dep Signed-off-by: Timothy Johnson --- packages/imperative/CHANGELOG.md | 4 ++++ packages/imperative/src/config/src/ConvertV1Profiles.ts | 2 +- .../imperative/src/security/src/DefaultCredentialManager.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 357a55819b..87cb2bb7a2 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Imperative package will be documented in this file. +## Recent Changes + +- BugFix: Removed Secrets SDK requirement when Imperative is a bundled dependency. [#2276](https://github.com/zowe/zowe-cli/issues/2276) + ## `8.0.0` - MAJOR: v8.0.0 Release diff --git a/packages/imperative/src/config/src/ConvertV1Profiles.ts b/packages/imperative/src/config/src/ConvertV1Profiles.ts index 4669d2f8dd..7fcc7e1bd5 100644 --- a/packages/imperative/src/config/src/ConvertV1Profiles.ts +++ b/packages/imperative/src/config/src/ConvertV1Profiles.ts @@ -20,7 +20,7 @@ import { IConfig } from "./doc/IConfig"; import { CredentialManagerFactory } from "../../security"; import { IConvertV1ProfOpts, ConvertMsg, ConvertMsgFmt, IConvertV1ProfResult } from "./doc/IConvertV1Profiles"; import { IImperativeOverrides } from "../../imperative/src/doc/IImperativeOverrides"; -import { keyring } from "@zowe/secrets-for-zowe-sdk"; +import type { keyring } from "@zowe/secrets-for-zowe-sdk"; import { AppSettings } from "../../settings"; import { ISettingsFile } from "../../settings/src/doc/ISettingsFile"; import { ImperativeConfig } from "../../utilities"; diff --git a/packages/imperative/src/security/src/DefaultCredentialManager.ts b/packages/imperative/src/security/src/DefaultCredentialManager.ts index a89669c448..23b1da384d 100644 --- a/packages/imperative/src/security/src/DefaultCredentialManager.ts +++ b/packages/imperative/src/security/src/DefaultCredentialManager.ts @@ -13,7 +13,7 @@ import { AbstractCredentialManager, SecureCredential } from "./abstract/Abstract import { ImperativeError } from "../../error"; import { Logger } from "../../logger"; -import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; // Used for typing purposes only +import type { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; // Used for typing purposes only /** * Default Credential Manager is our implementation of the Imperative Credential Manager. This manager invokes methods From 8cff1858653c3c939ea96976f9db306b32ed3a4c Mon Sep 17 00:00:00 2001 From: Timothy Johnson Date: Thu, 26 Sep 2024 17:31:30 -0400 Subject: [PATCH 66/69] Update release.config.js to allow V3 patch release Signed-off-by: Timothy Johnson --- release.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.config.js b/release.config.js index d4552123aa..5583506c73 100644 --- a/release.config.js +++ b/release.config.js @@ -8,7 +8,7 @@ module.exports = { }, { name: "master", - level: "none", + level: "patch", channel: "zowe-v3-lts" } ], From 464226ed2d5cc490870a2572b455ae9dbf0dbca3 Mon Sep 17 00:00:00 2001 From: zowe-robot Date: Fri, 27 Sep 2024 14:13:10 +0000 Subject: [PATCH 67/69] Bump version to 8.0.1 [ci skip] Signed-off-by: zowe-robot --- .../__packages__/cli-test-utils/package.json | 4 +- lerna.json | 2 +- npm-shrinkwrap.json | 116 +++++++++--------- packages/cli/package.json | 26 ++-- packages/core/package.json | 6 +- packages/imperative/CHANGELOG.md | 2 +- packages/imperative/package.json | 2 +- packages/provisioning/package.json | 8 +- packages/workflows/package.json | 10 +- packages/zosconsole/package.json | 8 +- packages/zosfiles/package.json | 10 +- packages/zosjobs/package.json | 10 +- packages/zoslogs/package.json | 8 +- packages/zosmf/package.json | 8 +- packages/zostso/package.json | 10 +- packages/zosuss/package.json | 6 +- 16 files changed, 118 insertions(+), 118 deletions(-) diff --git a/__tests__/__packages__/cli-test-utils/package.json b/__tests__/__packages__/cli-test-utils/package.json index 988e3ac98c..12459a1f92 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.0.0", + "version": "8.0.1", "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.0.0" + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/imperative": "^8.0.0-next" diff --git a/lerna.json b/lerna.json index 4ac911a05e..8033a82366 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "8.0.0", + "version": "8.0.1", "command": { "publish": { "ignoreChanges": [ diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 8b1363c474..0925f9cf7d 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.0.0", + "version": "8.0.1", "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.0.0" + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/imperative": "^8.0.0-next" @@ -16267,21 +16267,21 @@ }, "packages/cli": { "name": "@zowe/cli", - "version": "8.0.0", + "version": "8.0.1", "hasInstallScript": true, "license": "EPL-2.0", "dependencies": { - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0", - "@zowe/provisioning-for-zowe-sdk": "8.0.0", - "@zowe/zos-console-for-zowe-sdk": "8.0.0", - "@zowe/zos-files-for-zowe-sdk": "8.0.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.0.0", - "@zowe/zos-logs-for-zowe-sdk": "8.0.0", - "@zowe/zos-tso-for-zowe-sdk": "8.0.0", - "@zowe/zos-uss-for-zowe-sdk": "8.0.0", - "@zowe/zos-workflows-for-zowe-sdk": "8.0.0", - "@zowe/zosmf-for-zowe-sdk": "8.0.0", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1", + "@zowe/provisioning-for-zowe-sdk": "8.0.1", + "@zowe/zos-console-for-zowe-sdk": "8.0.1", + "@zowe/zos-files-for-zowe-sdk": "8.0.1", + "@zowe/zos-jobs-for-zowe-sdk": "8.0.1", + "@zowe/zos-logs-for-zowe-sdk": "8.0.1", + "@zowe/zos-tso-for-zowe-sdk": "8.0.1", + "@zowe/zos-uss-for-zowe-sdk": "8.0.1", + "@zowe/zos-workflows-for-zowe-sdk": "8.0.1", + "@zowe/zosmf-for-zowe-sdk": "8.0.1", "find-process": "1.4.7", "lodash": "4.17.21", "minimatch": "9.0.5", @@ -16294,7 +16294,7 @@ "@types/diff": "^5.0.9", "@types/lodash": "^4.17.6", "@types/tar": "^6.1.11", - "@zowe/cli-test-utils": "8.0.0", + "@zowe/cli-test-utils": "8.0.1", "comment-json": "^4.2.3", "strip-ansi": "^6.0.1", "which": "^4.0.0" @@ -16350,15 +16350,15 @@ }, "packages/core": { "name": "@zowe/core-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "dependencies": { "comment-json": "~4.2.3", "string-width": "^4.2.3" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16369,7 +16369,7 @@ }, "packages/imperative": { "name": "@zowe/imperative", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "dependencies": { "@types/yargs": "^17.0.32", @@ -16563,16 +16563,16 @@ }, "packages/provisioning": { "name": "@zowe/provisioning-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "dependencies": { "js-yaml": "^4.1.0" }, "devDependencies": { "@types/js-yaml": "^4.0.9", - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16597,15 +16597,15 @@ }, "packages/workflows": { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.0.0" + "@zowe/zos-files-for-zowe-sdk": "8.0.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16617,12 +16617,12 @@ }, "packages/zosconsole": { "name": "@zowe/zos-console-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16634,16 +16634,16 @@ }, "packages/zosfiles": { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "dependencies": { "minimatch": "^9.0.5" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0", - "@zowe/zos-uss-for-zowe-sdk": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1", + "@zowe/zos-uss-for-zowe-sdk": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16675,15 +16675,15 @@ }, "packages/zosjobs": { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.0.0" + "@zowe/zos-files-for-zowe-sdk": "8.0.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16695,12 +16695,12 @@ }, "packages/zoslogs": { "name": "@zowe/zos-logs-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16712,12 +16712,12 @@ }, "packages/zosmf": { "name": "@zowe/zosmf-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16729,15 +16729,15 @@ }, "packages/zostso": { "name": "@zowe/zos-tso-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "dependencies": { - "@zowe/zosmf-for-zowe-sdk": "8.0.0" + "@zowe/zosmf-for-zowe-sdk": "8.0.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" @@ -16749,15 +16749,15 @@ }, "packages/zosuss": { "name": "@zowe/zos-uss-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "license": "EPL-2.0", "dependencies": { "ssh2": "^1.15.0" }, "devDependencies": { "@types/ssh2": "^1.11.19", - "@zowe/cli-test-utils": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/imperative": "8.0.1" }, "engines": { "node": ">=18.12.0" diff --git a/packages/cli/package.json b/packages/cli/package.json index bad08f2942..1084a502d9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cli", - "version": "8.0.0", + "version": "8.0.1", "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.0.0", - "@zowe/imperative": "8.0.0", - "@zowe/provisioning-for-zowe-sdk": "8.0.0", - "@zowe/zos-console-for-zowe-sdk": "8.0.0", - "@zowe/zos-files-for-zowe-sdk": "8.0.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.0.0", - "@zowe/zos-logs-for-zowe-sdk": "8.0.0", - "@zowe/zos-tso-for-zowe-sdk": "8.0.0", - "@zowe/zos-uss-for-zowe-sdk": "8.0.0", - "@zowe/zos-workflows-for-zowe-sdk": "8.0.0", - "@zowe/zosmf-for-zowe-sdk": "8.0.0", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1", + "@zowe/provisioning-for-zowe-sdk": "8.0.1", + "@zowe/zos-console-for-zowe-sdk": "8.0.1", + "@zowe/zos-files-for-zowe-sdk": "8.0.1", + "@zowe/zos-jobs-for-zowe-sdk": "8.0.1", + "@zowe/zos-logs-for-zowe-sdk": "8.0.1", + "@zowe/zos-tso-for-zowe-sdk": "8.0.1", + "@zowe/zos-uss-for-zowe-sdk": "8.0.1", + "@zowe/zos-workflows-for-zowe-sdk": "8.0.1", + "@zowe/zosmf-for-zowe-sdk": "8.0.1", "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.0.0", + "@zowe/cli-test-utils": "8.0.1", "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 ca25f38371..bcfeb6dc98 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/core-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/imperative": "^8.0.0-next" diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 87cb2bb7a2..1046acf5f1 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Imperative package will be documented in this file. -## Recent Changes +## `8.0.1` - BugFix: Removed Secrets SDK requirement when Imperative is a bundled dependency. [#2276](https://github.com/zowe/zowe-cli/issues/2276) diff --git a/packages/imperative/package.json b/packages/imperative/package.json index e67baa4109..d9fe7a3068 100644 --- a/packages/imperative/package.json +++ b/packages/imperative/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/imperative", - "version": "8.0.0", + "version": "8.0.1", "description": "framework for building configurable CLIs", "author": "Zowe", "license": "EPL-2.0", diff --git a/packages/provisioning/package.json b/packages/provisioning/package.json index 8dfa2b2b6d..be3814bc4b 100644 --- a/packages/provisioning/package.json +++ b/packages/provisioning/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/provisioning-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0-next", diff --git a/packages/workflows/package.json b/packages/workflows/package.json index 34d2dcd2d9..369884b4c6 100644 --- a/packages/workflows/package.json +++ b/packages/workflows/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0" + "@zowe/zos-files-for-zowe-sdk": "8.0.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0-next", diff --git a/packages/zosconsole/package.json b/packages/zosconsole/package.json index ed68b3e5b1..5e43ef36b6 100644 --- a/packages/zosconsole/package.json +++ b/packages/zosconsole/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-console-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0-next", diff --git a/packages/zosfiles/package.json b/packages/zosfiles/package.json index e7c0f555d9..d437229aa1 100644 --- a/packages/zosfiles/package.json +++ b/packages/zosfiles/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "description": "Zowe SDK to interact with files and data sets on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -49,10 +49,10 @@ "minimatch": "^9.0.5" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0", - "@zowe/zos-uss-for-zowe-sdk": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1", + "@zowe/zos-uss-for-zowe-sdk": "8.0.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0-next", diff --git a/packages/zosjobs/package.json b/packages/zosjobs/package.json index 0bf61c145b..2ebfaed552 100644 --- a/packages/zosjobs/package.json +++ b/packages/zosjobs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0" + "@zowe/zos-files-for-zowe-sdk": "8.0.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0-next", diff --git a/packages/zoslogs/package.json b/packages/zoslogs/package.json index c605806a1a..56cdd828b6 100644 --- a/packages/zoslogs/package.json +++ b/packages/zoslogs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-logs-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0-next", diff --git a/packages/zosmf/package.json b/packages/zosmf/package.json index 4ab009d7f9..d38e2c9785 100644 --- a/packages/zosmf/package.json +++ b/packages/zosmf/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zosmf-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0-next", diff --git a/packages/zostso/package.json b/packages/zostso/package.json index fcba1700d4..6a24425eb9 100644 --- a/packages/zostso/package.json +++ b/packages/zostso/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-tso-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0" + "@zowe/zosmf-for-zowe-sdk": "8.0.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.0.0", - "@zowe/core-for-zowe-sdk": "8.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/core-for-zowe-sdk": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0-next", diff --git a/packages/zosuss/package.json b/packages/zosuss/package.json index 522a06b499..d4143d92c1 100644 --- a/packages/zosuss/package.json +++ b/packages/zosuss/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-uss-for-zowe-sdk", - "version": "8.0.0", + "version": "8.0.1", "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.0.0", - "@zowe/imperative": "8.0.0" + "@zowe/cli-test-utils": "8.0.1", + "@zowe/imperative": "8.0.1" }, "peerDependencies": { "@zowe/imperative": "^8.0.0-next" From 0b3a57cec32af76eb9af0807cf840cad420e4c2f Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Tue, 1 Oct 2024 14:53:22 -0400 Subject: [PATCH 68/69] doc: Document rare case for Webpack & Imperative/Secrets SDK Signed-off-by: Trae Yelovich --- packages/secrets/src/keyring/EXTENDERS.md | 43 +++++++++++++++++------ 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/packages/secrets/src/keyring/EXTENDERS.md b/packages/secrets/src/keyring/EXTENDERS.md index d2f5511045..898fa37347 100644 --- a/packages/secrets/src/keyring/EXTENDERS.md +++ b/packages/secrets/src/keyring/EXTENDERS.md @@ -33,12 +33,12 @@ After the desired functions are imported, feel free to use them in the same fash ```ts getPassword("TestService", "AccountA") -.then((pw) => { + .then((pw) => { console.log("The password for TestService/AccountA is:", pw); -}) -.catch((err) => { + }) + .catch((err) => { console.error("An error occurred!", err.message); -}); + }); ``` **Examples:** @@ -63,6 +63,18 @@ await keyring.deletePassword("TestService", "AccountA"); ## Webpacking/bundling alongside your project +**Note for Webpack users:** If you do **_not_** want to use the Secrets SDK, but have Imperative modules imported that reference it (such as `ConvertV1Profiles` or `DefaultCredentialManager`), you must define the `@zowe/secrets-for-zowe-sdk` package in the `externals` section of your Webpack config: + +```json +"externals": { + "@zowe/secrets-for-zowe-sdk": "commonjs @zowe/secrets-for-zowe-sdk" +} +``` + +This will prevent Webpack from trying to dynamically resolve the Secrets SDK during compile time. This does not affect the majority of developers, as Webpack will omit any unused Imperative modules during the bundling phase. + +--- + Some projects leverage a JavaScript bundler, such as Webpack or Vite, to minify and compress their Node.js packages. While the Secrets SDK does support Webpack, developers who want to bundle the Secrets SDK alongside their package should set up a `prebuilds` folder alongside their package root. @@ -78,7 +90,8 @@ your-pkg/ │ └── (node binaries for Secrets SDK) ``` -If you are using ESbuild or Webpack, consider using a copy plugin to copy the `prebuilds` folder from the Secrets SDK *node_modules* folder: +If you are using ESbuild or Webpack, consider using a copy plugin to copy the `prebuilds` folder from the Secrets SDK _node_modules_ folder: + - ESbuild: [esbuild-copy-static-files](https://www.npmjs.com/package/esbuild-copy-static-files) - Webpack: [copy-webpack-plugin](https://www.npmjs.com/package/copy-webpack-plugin) @@ -86,9 +99,14 @@ Otherwise, use the Node.js script below (**requires Node 16.7.0 and above**). It ```js const { cpSync } = require("fs"); -cpSync("/path/to/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds", "prebuilds", {force: true, recursive: true}); +cpSync( + "/path/to/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds", + "prebuilds", + { force: true, recursive: true } +); ``` -**Note:** The first argument for `cpSync` will vary, depending on where the *node_modules* folder is located in your environment. + +**Note:** The first argument for `cpSync` will vary, depending on where the _node_modules_ folder is located in your environment. We recommend that developers add this logic to a `prepare` script in their `package.json` to guarantee the binaries are up-to-date after installing dependencies. Save the above script as a JavaScript file (e.g., `scripts/copyKeyringBinaries.js`), and execute the script: @@ -102,7 +120,8 @@ Save the above script as a JavaScript file (e.g., `scripts/copyKeyringBinaries.j ``` If you are bundling a VSCode extension, and are using a `.vscodeignore` file, you must allow the prebuilds folder to be packaged in the VSIX. -Add the following line to your `.vscodeignore` file: +Add the following line to your `.vscodeignore` file: + ``` !prebuilds/** ``` @@ -113,14 +132,16 @@ Some extenders might import `keytar` directly as a dependency. In these cases, e **Take caution when importing** as the import process is slightly different than `node-keytar`: -Before: +Before: + ```js const keytar = require("node-keytar"); // ES6 import: import * as keytar from "node-keytar"; ``` -After: +After: + ```js const { keyring } = require("@zowe/secrets-for-zowe-sdk"); // ES6 import: @@ -137,4 +158,4 @@ import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; // Existing code, such as the example below, can remain unchanged with this import alias: keytar.setPassword("Hello", "World", "ExamplePassword"); -``` \ No newline at end of file +``` From fdd531dd92ff0d1edfa487777907aaa29dc2c0d4 Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Wed, 2 Oct 2024 08:19:38 -0400 Subject: [PATCH 69/69] doc: Address feedback in Extenders.md Signed-off-by: Trae Yelovich --- packages/secrets/src/keyring/EXTENDERS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/secrets/src/keyring/EXTENDERS.md b/packages/secrets/src/keyring/EXTENDERS.md index 898fa37347..a611962403 100644 --- a/packages/secrets/src/keyring/EXTENDERS.md +++ b/packages/secrets/src/keyring/EXTENDERS.md @@ -71,7 +71,7 @@ await keyring.deletePassword("TestService", "AccountA"); } ``` -This will prevent Webpack from trying to dynamically resolve the Secrets SDK during compile time. This does not affect the majority of developers, as Webpack will omit any unused Imperative modules during the bundling phase. +This will prevent Webpack from trying to dynamically resolve the Secrets SDK during compile time. This does not affect the majority of developers, as Webpack omits any unused Imperative modules during the bundling phase. --- @@ -90,7 +90,7 @@ your-pkg/ │ └── (node binaries for Secrets SDK) ``` -If you are using ESbuild or Webpack, consider using a copy plugin to copy the `prebuilds` folder from the Secrets SDK _node_modules_ folder: +If you are using ESbuild or Webpack, consider using a copy plug-in to copy the `prebuilds` folder from the Secrets SDK _node_modules_ folder: - ESbuild: [esbuild-copy-static-files](https://www.npmjs.com/package/esbuild-copy-static-files) - Webpack: [copy-webpack-plugin](https://www.npmjs.com/package/copy-webpack-plugin)