From 450d26bb5897ce1fb4cf102c9c0f5983ab6716ac Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 30 Sep 2024 11:19:56 -0400 Subject: [PATCH 001/106] initial commit Signed-off-by: jace-roell --- .../cli/src/zostso/start/Start.definition.ts | 5 +- .../address-space/StartASApp.definition.ts | 48 +++++++++++++++++++ .../start/address-space/StartASApp.handler.ts | 28 +++++++++++ packages/zostso/src/StartTsoApp.ts | 44 +++++++++++++++++ .../zostso/src/doc/IStartASAppResponse.ts | 31 ++++++++++++ 5 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 packages/cli/src/zostso/start/address-space/StartASApp.definition.ts create mode 100644 packages/cli/src/zostso/start/address-space/StartASApp.handler.ts create mode 100644 packages/zostso/src/StartTsoApp.ts create mode 100644 packages/zostso/src/doc/IStartASAppResponse.ts diff --git a/packages/cli/src/zostso/start/Start.definition.ts b/packages/cli/src/zostso/start/Start.definition.ts index e8fac1f28f..adda1f014a 100644 --- a/packages/cli/src/zostso/start/Start.definition.ts +++ b/packages/cli/src/zostso/start/Start.definition.ts @@ -11,6 +11,7 @@ import { ICommandDefinition } from "@zowe/imperative"; import { AddressSpaceDefinition } from "./address-space/AddressSpace.definition"; +import { StartASApp } from "./address-space/StartASApp.definition"; export const StartCommand: ICommandDefinition = { name: "start", @@ -19,6 +20,6 @@ export const StartCommand: ICommandDefinition = { summary: "Start TSO/E address space", description: "Start TSO/E address space.", children: [ - AddressSpaceDefinition - ] + AddressSpaceDefinition, StartASApp + ], }; diff --git a/packages/cli/src/zostso/start/address-space/StartASApp.definition.ts b/packages/cli/src/zostso/start/address-space/StartASApp.definition.ts new file mode 100644 index 0000000000..9cc5c59648 --- /dev/null +++ b/packages/cli/src/zostso/start/address-space/StartASApp.definition.ts @@ -0,0 +1,48 @@ +/* +* 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 { ICommandDefinition } from "@zowe/imperative"; +import { TsoProfileConstants } from "@zowe/zos-tso-for-zowe-sdk"; + +export const StartASApp: ICommandDefinition = { + name: "app", + aliases: ["a"], + summary: "Start application at TSO address space", + description: "Start application at TSO address space,", + type: "command", + handler: __dirname + "/StartASApp.handler", + profile: { + optional: ["zosmf", "tso"] + }, + options: TsoProfileConstants.TSO_PROFILE_OPTIONS.concat([ + { + name: "app-key", aliases: ["ak"], + description: "App Key", + type: "string" + }, + { + name: "startup", aliases: ["s"], + description: "Startup", + type: "string" + }, + { + name: "queue-id", aliases: ["qi"], + description: "Queue ID", + type: "string" + }, + { + name: "servlet-key", aliases: ["sk"], + description: "Servlet Key", + type: "string" + } + ]), + examples: [] +}; diff --git a/packages/cli/src/zostso/start/address-space/StartASApp.handler.ts b/packages/cli/src/zostso/start/address-space/StartASApp.handler.ts new file mode 100644 index 0000000000..6ce5f0237a --- /dev/null +++ b/packages/cli/src/zostso/start/address-space/StartASApp.handler.ts @@ -0,0 +1,28 @@ +/* +* 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, ImperativeError } from "@zowe/imperative"; +import { StartTso, ZosTsoBaseHandler } from "@zowe/zos-tso-for-zowe-sdk"; +import { StartASApp } from "./StartASApp.definition"; +import { StartTsoApp } from "../../../../../zostso/src/StartTsoApp" +/** + * Handler to start app at an address space + * @export + * @class Handler + * @implements {ICommandHandler} + */ +export default class Handler extends ZosTsoBaseHandler { + + // Process the command and produce the start response (returns servlet) + public async processCmd(commandParameters: IHandlerParameters) { + const response = await StartTsoApp.start(this.mSession, this.mArguments.account, this.mTsoStart); + } +} diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts new file mode 100644 index 0000000000..daa6e64338 --- /dev/null +++ b/packages/zostso/src/StartTsoApp.ts @@ -0,0 +1,44 @@ +/* +* 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 } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { SendTso } from "./SendTso"; +import { IStartStopResponses } from "./doc/IStartStopResponses"; +import { IStartTsoParms } from "./doc/input/IStartTsoParms"; +import { IZosmfTsoResponse } from "./doc/zosmf/IZosmfTsoResponse"; +import { TsoValidator } from "./TsoValidator"; +import { noAccountNumber, TsoConstants } from "./TsoConstants"; +import { TsoResponseService } from "./TsoResponseService"; +import { IStartASAppResponse } from "./doc/IStartASAppResponse"; +/** + * Start TSO address space and receive servlet key + * @export + * @class StartTsoApp + */ +export class StartTsoApp { + /** + * Start TSO application at address space with provided parameters. + * @static + * @param {AbstractSession} session - z/OSMF connection info + * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. + * @param {IStartTsoParms} parms - optional object with required parameters, @see {IStartTsoParms} + * @returns {Promise} command response on resolve, @see {IStartASAppResponse} + * @memberof StartTso + */ + public static async start(session: AbstractSession, accountNumber: string, parms?: IStartTsoParms): Promise { + + return ""; + + + } +} + diff --git a/packages/zostso/src/doc/IStartASAppResponse.ts b/packages/zostso/src/doc/IStartASAppResponse.ts new file mode 100644 index 0000000000..95fd601f1c --- /dev/null +++ b/packages/zostso/src/doc/IStartASAppResponse.ts @@ -0,0 +1,31 @@ +/* +* 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 IStartASAppResponse { + /** + * True if the command was issued and the responses were collected. + * @type {boolean} + * @memberof IStartASAppResponse + */ + success: boolean; + /** + * Servlet key from IZosmfTsoResponse + * @type {string} + * @memberof IStartASAppResponse + */ + servletKey?: string; + /** + * Servlet key from IZosmfTsoResponse + * @type {string} + * @memberof IStartASAppResponse + */ + queueID?: string; +} From 7d736ca82957becb7bad1269a7d135cf04dbfac7 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 30 Sep 2024 16:30:05 -0400 Subject: [PATCH 002/106] poc work Signed-off-by: jace-roell --- .../cli/src/zostso/start/Start.definition.ts | 2 +- .../StartASApp.definition.ts | 30 +++++++++---- .../StartASApp.handler.ts | 19 ++++++-- packages/zostso/src/StartTsoApp.ts | 21 ++++++--- .../zostso/src/doc/input/IStartTsoAppParms.ts | 43 +++++++++++++++++++ packages/zostso/src/index.ts | 1 + 6 files changed, 97 insertions(+), 19 deletions(-) rename packages/cli/src/zostso/start/{address-space => as-app}/StartASApp.definition.ts (58%) rename packages/cli/src/zostso/start/{address-space => as-app}/StartASApp.handler.ts (56%) create mode 100644 packages/zostso/src/doc/input/IStartTsoAppParms.ts diff --git a/packages/cli/src/zostso/start/Start.definition.ts b/packages/cli/src/zostso/start/Start.definition.ts index adda1f014a..2b8afbf44c 100644 --- a/packages/cli/src/zostso/start/Start.definition.ts +++ b/packages/cli/src/zostso/start/Start.definition.ts @@ -11,7 +11,7 @@ import { ICommandDefinition } from "@zowe/imperative"; import { AddressSpaceDefinition } from "./address-space/AddressSpace.definition"; -import { StartASApp } from "./address-space/StartASApp.definition"; +import { StartASApp } from "./as-app/StartASApp.definition"; export const StartCommand: ICommandDefinition = { name: "start", diff --git a/packages/cli/src/zostso/start/address-space/StartASApp.definition.ts b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts similarity index 58% rename from packages/cli/src/zostso/start/address-space/StartASApp.definition.ts rename to packages/cli/src/zostso/start/as-app/StartASApp.definition.ts index 9cc5c59648..f525ebce49 100644 --- a/packages/cli/src/zostso/start/address-space/StartASApp.definition.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts @@ -9,7 +9,7 @@ * */ -import { ICommandDefinition } from "@zowe/imperative"; +import { ICommandDefinition, ICommandOptionDefinition } from "@zowe/imperative"; import { TsoProfileConstants } from "@zowe/zos-tso-for-zowe-sdk"; export const StartASApp: ICommandDefinition = { @@ -24,25 +24,37 @@ export const StartASApp: ICommandDefinition = { }, options: TsoProfileConstants.TSO_PROFILE_OPTIONS.concat([ { - name: "app-key", aliases: ["ak"], + name: "app-key", + aliases: ["ak"], description: "App Key", - type: "string" + type: "string", + required: true }, { - name: "startup", aliases: ["s"], + name: "startup", + aliases: ["s"], description: "Startup", - type: "string" + type: "string", + required: true }, { - name: "queue-id", aliases: ["qi"], + name: "queue-id", + aliases: ["qi"], description: "Queue ID", type: "string" }, { - name: "servlet-key", aliases: ["sk"], + name: "servlet-key", + aliases: ["sk"], description: "Servlet Key", type: "string" } - ]), - examples: [] + ] as ICommandOptionDefinition[]), + examples: [], + check: (argv: { [key: string]: any }) => { + if ((argv["queue-id"] && !argv["servlet-key"]) || (!argv["queue-id"] && argv["servlet-key"])) { + throw new Error("Both queue-id and servlet-key must be defined together."); + } + return true; + } }; diff --git a/packages/cli/src/zostso/start/address-space/StartASApp.handler.ts b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts similarity index 56% rename from packages/cli/src/zostso/start/address-space/StartASApp.handler.ts rename to packages/cli/src/zostso/start/as-app/StartASApp.handler.ts index 6ce5f0237a..74b6a49141 100644 --- a/packages/cli/src/zostso/start/address-space/StartASApp.handler.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts @@ -11,8 +11,9 @@ import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import { StartTso, ZosTsoBaseHandler } from "@zowe/zos-tso-for-zowe-sdk"; -import { StartASApp } from "./StartASApp.definition"; -import { StartTsoApp } from "../../../../../zostso/src/StartTsoApp" +import { StartTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { IStartTsoAppParms } from "@zowe/zos-tso-for-zowe-sdk/lib/doc/input/IStartTsoAppParms"; + /** * Handler to start app at an address space * @export @@ -20,9 +21,19 @@ import { StartTsoApp } from "../../../../../zostso/src/StartTsoApp" * @implements {ICommandHandler} */ export default class Handler extends ZosTsoBaseHandler { - // Process the command and produce the start response (returns servlet) + public async processCmd(commandParameters: IHandlerParameters) { - const response = await StartTsoApp.start(this.mSession, this.mArguments.account, this.mTsoStart); + const response = await StartTsoApp.start( + this.mSession, + this.mArguments.account, + { + startupCommand: commandParameters.arguments.startup, + appKey: commandParameters.arguments.appKey, + servletKey: commandParameters.arguments.servletKey, + queueID: commandParameters.arguments.queueId, + }, + this.mTsoStart + ); } } diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index daa6e64338..89b6f31fac 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -19,6 +19,7 @@ import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { TsoResponseService } from "./TsoResponseService"; import { IStartASAppResponse } from "./doc/IStartASAppResponse"; +import { IStartTsoAppParms } from "./doc/input/IStartTsoAppParms"; /** * Start TSO address space and receive servlet key * @export @@ -34,11 +35,21 @@ export class StartTsoApp { * @returns {Promise} command response on resolve, @see {IStartASAppResponse} * @memberof StartTso */ - public static async start(session: AbstractSession, accountNumber: string, parms?: IStartTsoParms): Promise { - - return ""; - - + public static async start(session: AbstractSession, accountNumber: string, params: IStartTsoAppParms, parms?: IStartTsoParms): Promise { + // Address space is not known + TsoValidator.validateSession(session); + TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); + if(!params.queueID || !params.servletKey) + { + console.log("NEEDS IMPLEMENTATION"); + return undefined; + } + // Address space is known + else + { + const response: string; + return undefined; + } } } diff --git a/packages/zostso/src/doc/input/IStartTsoAppParms.ts b/packages/zostso/src/doc/input/IStartTsoAppParms.ts new file mode 100644 index 0000000000..6dc643306e --- /dev/null +++ b/packages/zostso/src/doc/input/IStartTsoAppParms.ts @@ -0,0 +1,43 @@ +/* +* 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. +* +*/ + +/** + * Interface for starting an app on a TSO Address Space + * @export + * @interface IStartTsoAppParms + */ +export interface IStartTsoAppParms { + + /** + * Startup command to run at TSO address space + * @type {string} + * @memberof IStartTsoAppParms + */ + startupCommand: string; + /** + * App Key of application to be started at a TSO address space + * @type {string} + * @memberof IStartTsoAppParms + */ + appKey: string; + /** + * Queue ID of an active address space + * @type {string} + * @memberof IStartTsoAppParms + */ + queueID?: string; + /** + * Servlet key of an active address space + * @type {string} + * @memberof IStartTsoAppParms + */ + servletKey?: string; +} diff --git a/packages/zostso/src/index.ts b/packages/zostso/src/index.ts index cd43f1a60a..4bbd7b9fe8 100644 --- a/packages/zostso/src/index.ts +++ b/packages/zostso/src/index.ts @@ -38,6 +38,7 @@ export * from "./IssueTso"; export * from "./PingTso"; export * from "./SendTso"; export * from "./StartTso"; +export * from "./StartTsoApp"; export * from "./StopTso"; export * from "./TsoConstants"; export * from "./TsoResponseService"; From 75126e6e21ad73f3ab15add7511456f1c5795b3e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 1 Oct 2024 11:04:47 -0400 Subject: [PATCH 003/106] basic application starting poc Signed-off-by: jace-roell --- .../zostso/start/as-app/StartASApp.handler.ts | 1 + packages/zostso/src/StartTsoApp.ts | 12 ++++++++-- .../zostso/src/doc/IStartASAppResponse.ts | 22 +++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts index 74b6a49141..d0d97ebfd1 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts @@ -35,5 +35,6 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); + console.log(response); } } diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index 89b6f31fac..2fc80bfee8 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -47,8 +47,16 @@ export class StartTsoApp { // Address space is known else { - const response: string; - return undefined; + const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; + const apiResponse = await ZosmfRestClient.postExpectJSON( + session, + endpoint, + [Headers.APPLICATION_JSON], + { + "startcmd": `${params.startupCommand} '&1 &2 ${params.queueID}'` + } + ); + return apiResponse; } } } diff --git a/packages/zostso/src/doc/IStartASAppResponse.ts b/packages/zostso/src/doc/IStartASAppResponse.ts index 95fd601f1c..875eeb3cf1 100644 --- a/packages/zostso/src/doc/IStartASAppResponse.ts +++ b/packages/zostso/src/doc/IStartASAppResponse.ts @@ -11,11 +11,29 @@ export interface IStartASAppResponse { /** - * True if the command was issued and the responses were collected. + * Version in response * @type {boolean} * @memberof IStartASAppResponse */ - success: boolean; + version: string + /** + * Data from response + * @type {boolean} + * @memberof IStartASAppResponse + */ + tsoData: string[] + /** + * Reused boolean + * @type {boolean} + * @memberof IStartASAppResponse + */ + reused: boolean + /** + * Data from response + * @type {boolean} + * @memberof IStartASAppResponse + */ + timeout: boolean /** * Servlet key from IZosmfTsoResponse * @type {string} From b1b8130f5737d772f1e8bfef76ef5f3a8c41cd35 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 1 Oct 2024 11:43:43 -0400 Subject: [PATCH 004/106] start command POC Signed-off-by: jace-roell --- packages/zostso/src/StartTsoApp.ts | 67 ++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index 2fc80bfee8..494f946ba2 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.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 } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; @@ -20,6 +20,8 @@ import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { TsoResponseService } from "./TsoResponseService"; import { IStartASAppResponse } from "./doc/IStartASAppResponse"; import { IStartTsoAppParms } from "./doc/input/IStartTsoAppParms"; +import { StartTso } from "./StartTso"; +import { IIssueResponse } from "../lib"; /** * Start TSO address space and receive servlet key * @export @@ -35,29 +37,48 @@ export class StartTsoApp { * @returns {Promise} command response on resolve, @see {IStartASAppResponse} * @memberof StartTso */ - public static async start(session: AbstractSession, accountNumber: string, params: IStartTsoAppParms, parms?: IStartTsoParms): Promise { + public static async start( + session: AbstractSession, + accountNumber: string, + params: IStartTsoAppParms, + startParms: IStartTsoParms + ): Promise { // Address space is not known TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); - if(!params.queueID || !params.servletKey) - { - console.log("NEEDS IMPLEMENTATION"); - return undefined; + TsoValidator.validateNotEmptyString( + accountNumber, + noAccountNumber.message + ); + if (!params.queueID || !params.servletKey) { + const response: IIssueResponse = { + success: false, + startResponse: await StartTso.start( + session, + accountNumber, + startParms + ), + startReady: false, + zosmfResponse: null, + commandResponse: null, + stopResponse: null, + }; + params.servletKey = + response.startResponse.zosmfTsoResponse.servletKey; + params.queueID = response.startResponse.zosmfTsoResponse.queueID; } // Address space is known - else - { - const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const apiResponse = await ZosmfRestClient.postExpectJSON( + const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; + const apiResponse = + await ZosmfRestClient.postExpectJSON( session, endpoint, [Headers.APPLICATION_JSON], { - "startcmd": `${params.startupCommand} '&1 &2 ${params.queueID}'` + startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, } ); - return apiResponse; - } + apiResponse.queueID = params.queueID; + apiResponse.servletKey = params.servletKey; + return apiResponse; } } - From 607a7bd2c73e17199148fa490b26d324369ca469 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 1 Oct 2024 12:05:17 -0400 Subject: [PATCH 005/106] implications Signed-off-by: jace-roell --- .../src/zostso/start/as-app/StartASApp.definition.ts | 12 ++++-------- packages/zostso/src/StartTsoApp.ts | 11 +++++------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts index f525ebce49..240da3bad6 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts @@ -41,20 +41,16 @@ export const StartASApp: ICommandDefinition = { name: "queue-id", aliases: ["qi"], description: "Queue ID", - type: "string" + type: "string", + implies: ["servlet-key"] }, { name: "servlet-key", aliases: ["sk"], description: "Servlet Key", - type: "string" + type: "string", + implies: ["queue-id"] } ] as ICommandOptionDefinition[]), examples: [], - check: (argv: { [key: string]: any }) => { - if ((argv["queue-id"] && !argv["servlet-key"]) || (!argv["queue-id"] && argv["servlet-key"])) { - throw new Error("Both queue-id and servlet-key must be defined together."); - } - return true; - } }; diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index 494f946ba2..abe23b71b3 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -11,13 +11,9 @@ import { AbstractSession, Headers } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { SendTso } from "./SendTso"; -import { IStartStopResponses } from "./doc/IStartStopResponses"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; -import { IZosmfTsoResponse } from "./doc/zosmf/IZosmfTsoResponse"; import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; -import { TsoResponseService } from "./TsoResponseService"; import { IStartASAppResponse } from "./doc/IStartASAppResponse"; import { IStartTsoAppParms } from "./doc/input/IStartTsoAppParms"; import { StartTso } from "./StartTso"; @@ -43,12 +39,13 @@ export class StartTsoApp { params: IStartTsoAppParms, startParms: IStartTsoParms ): Promise { - // Address space is not known + TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( accountNumber, noAccountNumber.message ); + // Address space is not known and must be created if (!params.queueID || !params.servletKey) { const response: IIssueResponse = { success: false, @@ -62,11 +59,12 @@ export class StartTsoApp { commandResponse: null, stopResponse: null, }; + // Reassigning servletKey and queueID so the application can be started at the correct location params.servletKey = response.startResponse.zosmfTsoResponse.servletKey; params.queueID = response.startResponse.zosmfTsoResponse.queueID; } - // Address space is known + // Address space application starting const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; const apiResponse = await ZosmfRestClient.postExpectJSON( @@ -77,6 +75,7 @@ export class StartTsoApp { startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, } ); + // Add newly created queueID and servletKey information to return object. apiResponse.queueID = params.queueID; apiResponse.servletKey = params.servletKey; return apiResponse; From ccc423f37dd96399afd4996a3af6735c2a04a11e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 1 Oct 2024 12:09:43 -0400 Subject: [PATCH 006/106] linting Signed-off-by: jace-roell --- packages/cli/src/zostso/start/as-app/StartASApp.handler.ts | 6 ++---- packages/zostso/src/StartTsoApp.ts | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts index d0d97ebfd1..f7f4fb9b64 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts @@ -9,10 +9,9 @@ * */ -import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; -import { StartTso, ZosTsoBaseHandler } from "@zowe/zos-tso-for-zowe-sdk"; +import { IHandlerParameters } from "@zowe/imperative"; +import { ZosTsoBaseHandler } from "@zowe/zos-tso-for-zowe-sdk"; import { StartTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; -import { IStartTsoAppParms } from "@zowe/zos-tso-for-zowe-sdk/lib/doc/input/IStartTsoAppParms"; /** * Handler to start app at an address space @@ -22,7 +21,6 @@ import { IStartTsoAppParms } from "@zowe/zos-tso-for-zowe-sdk/lib/doc/input/ISta */ export default class Handler extends ZosTsoBaseHandler { // Process the command and produce the start response (returns servlet) - public async processCmd(commandParameters: IHandlerParameters) { const response = await StartTsoApp.start( this.mSession, diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index abe23b71b3..8f5caaf897 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -39,12 +39,12 @@ export class StartTsoApp { params: IStartTsoAppParms, startParms: IStartTsoParms ): Promise { - TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( accountNumber, noAccountNumber.message ); + // Address space is not known and must be created if (!params.queueID || !params.servletKey) { const response: IIssueResponse = { @@ -64,6 +64,7 @@ export class StartTsoApp { response.startResponse.zosmfTsoResponse.servletKey; params.queueID = response.startResponse.zosmfTsoResponse.queueID; } + // Address space application starting const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; const apiResponse = @@ -78,6 +79,7 @@ export class StartTsoApp { // Add newly created queueID and servletKey information to return object. apiResponse.queueID = params.queueID; apiResponse.servletKey = params.servletKey; + return apiResponse; } } From 7d4051e5283832a8743f60a75d7b6645aa5a46fe Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 1 Oct 2024 12:12:46 -0400 Subject: [PATCH 007/106] formatting Signed-off-by: jace-roell --- packages/cli/src/zostso/start/as-app/StartASApp.definition.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts index 240da3bad6..18c362a13f 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts @@ -31,8 +31,8 @@ export const StartASApp: ICommandDefinition = { required: true }, { - name: "startup", - aliases: ["s"], + name: "startup-command", + aliases: ["sc"], description: "Startup", type: "string", required: true From fd721b859dd79e25e81d3f86f8d6acdf7cc483de Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 1 Oct 2024 14:37:29 -0400 Subject: [PATCH 008/106] send POC Signed-off-by: jace-roell --- .../cli/src/zostso/send/Send.definition.ts | 3 +- .../as-app/as-app/SendASApp.definition.ts | 49 ++++++++++++++++ .../send/as-app/as-app/SendASApp.handler.ts | 36 ++++++++++++ .../start/as-app/StartASApp.definition.ts | 2 +- packages/zostso/src/SendTsoApp.ts | 57 +++++++++++++++++++ .../zostso/src/doc/input/ISendTsoAppParms.ts | 37 ++++++++++++ packages/zostso/src/index.ts | 1 + 7 files changed, 183 insertions(+), 2 deletions(-) create mode 100644 packages/cli/src/zostso/send/as-app/as-app/SendASApp.definition.ts create mode 100644 packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts create mode 100644 packages/zostso/src/SendTsoApp.ts create mode 100644 packages/zostso/src/doc/input/ISendTsoAppParms.ts diff --git a/packages/cli/src/zostso/send/Send.definition.ts b/packages/cli/src/zostso/send/Send.definition.ts index c5997f6b9d..205e1c4d8c 100644 --- a/packages/cli/src/zostso/send/Send.definition.ts +++ b/packages/cli/src/zostso/send/Send.definition.ts @@ -13,6 +13,7 @@ import { ICommandDefinition } from "@zowe/imperative"; import { SendToAddressSpaceCommandDefinition } from "./address_space/SendToAddressSpace.definition"; +import { SendASApp } from "./as-app/as-app/SendASApp.definition"; export const SendCommand: ICommandDefinition = { name: "send", @@ -21,6 +22,6 @@ export const SendCommand: ICommandDefinition = { summary: "Send data to TSO", description: "Send data to TSO and collect responses until the prompt is reached.", children: [ - SendToAddressSpaceCommandDefinition + SendToAddressSpaceCommandDefinition, SendASApp ] }; diff --git a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.definition.ts b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.definition.ts new file mode 100644 index 0000000000..170f572cf4 --- /dev/null +++ b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.definition.ts @@ -0,0 +1,49 @@ +/* +* 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 { ICommandDefinition, ICommandOptionDefinition } from "@zowe/imperative"; +import { TsoProfileConstants } from "@zowe/zos-tso-for-zowe-sdk"; + +export const SendASApp: ICommandDefinition = { + name: "app", + aliases: ["a"], + summary: "Send message to an application at a TSO address space", + description: "Send message to an application at a TSO address space,", + type: "command", + handler: __dirname + "/SendASApp.handler", + profile: { + optional: ["zosmf", "tso"] + }, + options: TsoProfileConstants.TSO_PROFILE_OPTIONS.concat([ + { + name: "app-key", + aliases: ["ak"], + description: "App Key", + type: "string", + required: true + }, + { + name: "servlet-key", + aliases: ["sk"], + description: "Servlet Key", + type: "string", + required: true + }, + { + name: "message", + aliases: ["msg"], + description: "Message", + type: "string", + required: true + } + ] as ICommandOptionDefinition[]), + examples: [], +}; diff --git a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts new file mode 100644 index 0000000000..318904c584 --- /dev/null +++ b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts @@ -0,0 +1,36 @@ +/* +* 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 { ZosTsoBaseHandler, SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; + +/** + * Handler to send a message to address space + * @export + * @class Handler + * @implements {ICommandHandler} + */ +export default class Handler extends ZosTsoBaseHandler { + // Process the command and transmit a message to an app running at a TSO address space + public async processCmd(commandParameters: IHandlerParameters) { + const response = await SendTsoApp.send( + this.mSession, + this.mArguments.account, + { + appKey: commandParameters.arguments.appKey, + servletKey: commandParameters.arguments.servletKey, + message: commandParameters.arguments.message, + }, + this.mTsoStart + ); + console.log(response); + } +} diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts index 18c362a13f..263706f47f 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts @@ -31,7 +31,7 @@ export const StartASApp: ICommandDefinition = { required: true }, { - name: "startup-command", + name: "startup", aliases: ["sc"], description: "Startup", type: "string", diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts new file mode 100644 index 0000000000..0df17d353f --- /dev/null +++ b/packages/zostso/src/SendTsoApp.ts @@ -0,0 +1,57 @@ +/* + * 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 } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { IStartTsoParms } from "./doc/input/IStartTsoParms"; +import { TsoValidator } from "./TsoValidator"; +import { noAccountNumber, TsoConstants } from "./TsoConstants"; +import { IStartASAppResponse } from "./doc/IStartASAppResponse"; +import { ISendTsoAppParms } from "./doc/input/ISendTsoAppParms"; +/** + * Send message to TSO App running at an address space + * @export + * @class SendTsoApp + */ +export class SendTsoApp { + /** + * Start TSO application at address space with provided parameters. + * @static + * @param {AbstractSession} session - z/OSMF connection info + * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. + * @param {IStartTsoParms} parms - optional object with required parameters, @see {IStartTsoParms} + * @returns {Promise} command response on resolve, @see {IStartASAppResponse} + * @memberof StartTso + */ + public static async send( + session: AbstractSession, + accountNumber: string, + params: ISendTsoAppParms, + startParms: IStartTsoParms + ): Promise { + TsoValidator.validateSession(session); + TsoValidator.validateNotEmptyString( + accountNumber, + noAccountNumber.message + ); + + const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; + const apiResponse = + await ZosmfRestClient.putExpectJSON( + session, + endpoint, + [Headers.CONTENT_TYPE, "text/plain"], + params.message + ); + + return apiResponse + } +} diff --git a/packages/zostso/src/doc/input/ISendTsoAppParms.ts b/packages/zostso/src/doc/input/ISendTsoAppParms.ts new file mode 100644 index 0000000000..326ebd809b --- /dev/null +++ b/packages/zostso/src/doc/input/ISendTsoAppParms.ts @@ -0,0 +1,37 @@ +/* +* 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. +* +*/ + +/** + * Interface for starting an app on a TSO Address Space + * @export + * @interface ISendTsoAppParms + */ +export interface ISendTsoAppParms { + + /** + * Body contents being sent to TSO address space app + * @type {string} + * @memberof ISendTsoAppParms + */ + message: string; + /** + * App Key of application to be started at a TSO address space + * @type {string} + * @memberof ISendTsoAppParms + */ + appKey: string; + /** + * Servlet key of an active address space + * @type {string} + * @memberof ISendTsoAppParms + */ + servletKey: string; +} diff --git a/packages/zostso/src/index.ts b/packages/zostso/src/index.ts index 518570a379..046b47d866 100644 --- a/packages/zostso/src/index.ts +++ b/packages/zostso/src/index.ts @@ -40,6 +40,7 @@ export * from "./PingTso"; export * from "./SendTso"; export * from "./StartTso"; export * from "./StartTsoApp"; +export * from "./SendTsoApp"; export * from "./StopTso"; export * from "./TsoConstants"; export * from "./TsoResponseService"; From efdc5017cca6ba5665945c21a6e0cb9252187a11 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 1 Oct 2024 16:41:36 -0400 Subject: [PATCH 009/106] complete POC Signed-off-by: jace-roell --- packages/cli/src/zostso/ZosTso.definition.ts | 3 +- .../src/zostso/receive/Receive.definition.ts | 24 +++++++++ .../address-space/ReceiveASApp.definition.ts | 42 +++++++++++++++ .../address-space/ReceiveASApp.handler.ts | 34 ++++++++++++ packages/zostso/src/ReceiveTsoApp.ts | 53 +++++++++++++++++++ packages/zostso/src/SendTsoApp.ts | 6 +-- packages/zostso/src/StartTsoApp.ts | 2 +- ...pParms.ts => ITsoAppCommunicationParms.ts} | 12 ++--- packages/zostso/src/index.ts | 1 + 9 files changed, 166 insertions(+), 11 deletions(-) create mode 100644 packages/cli/src/zostso/receive/Receive.definition.ts create mode 100644 packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts create mode 100644 packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts create mode 100644 packages/zostso/src/ReceiveTsoApp.ts rename packages/zostso/src/doc/input/{ISendTsoAppParms.ts => ITsoAppCommunicationParms.ts} (75%) diff --git a/packages/cli/src/zostso/ZosTso.definition.ts b/packages/cli/src/zostso/ZosTso.definition.ts index 04e4ded6de..7700b4f1a7 100644 --- a/packages/cli/src/zostso/ZosTso.definition.ts +++ b/packages/cli/src/zostso/ZosTso.definition.ts @@ -16,6 +16,7 @@ import { StopCommand } from "./stop/Stop.definition"; import { PingCommand } from "./ping/Ping.definition"; import { IssueCommand } from "./issue/Issue.definition"; import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk"; +import { ReceiveCommand } from "./receive/Receive.definition"; export const definition: ICommandDefinition = { name: "zos-tso", @@ -24,7 +25,7 @@ export const definition: ICommandDefinition = { summary: "Interact with TSO", description: "Issue TSO commands and interact with TSO address spaces.", children: [ - SendCommand, StartCommand, PingCommand, StopCommand, IssueCommand + SendCommand, StartCommand, PingCommand, StopCommand, IssueCommand, ReceiveCommand ], passOn: [{ property: "options", diff --git a/packages/cli/src/zostso/receive/Receive.definition.ts b/packages/cli/src/zostso/receive/Receive.definition.ts new file mode 100644 index 0000000000..269cc24e64 --- /dev/null +++ b/packages/cli/src/zostso/receive/Receive.definition.ts @@ -0,0 +1,24 @@ +/* +* 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 { ICommandDefinition } from "@zowe/imperative"; +import { ReceiveASApp } from "./address-space/ReceiveASApp.definition"; + +export const ReceiveCommand: ICommandDefinition = { + name: "receieve", + aliases: ["r"], + type: "group", + summary: "Receieve message from TSO address space app", + description: "Receieve message from TSO address space app", + children: [ + ReceiveASApp + ], +}; diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts new file mode 100644 index 0000000000..c34644859e --- /dev/null +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts @@ -0,0 +1,42 @@ +/* +* 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 { ICommandDefinition, ICommandOptionDefinition } from "@zowe/imperative"; +import { TsoProfileConstants } from "@zowe/zos-tso-for-zowe-sdk"; + +export const ReceiveASApp: ICommandDefinition = { + name: "app", + aliases: ["a"], + summary: "Receive message from TSO address space app", + description: "Receive message from TSO address space app,", + type: "command", + handler: __dirname + "/ReceiveASApp.handler", + profile: { + optional: ["zosmf", "tso"] + }, + options: TsoProfileConstants.TSO_PROFILE_OPTIONS.concat([ + { + name: "app-key", + aliases: ["ak"], + description: "App Key", + type: "string", + required: true + }, + { + name: "servlet-key", + aliases: ["sk"], + description: "Servlet Key", + type: "string", + required: true + } + ] as ICommandOptionDefinition[]), + examples: [], +}; diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts new file mode 100644 index 0000000000..e3b47ee8e7 --- /dev/null +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts @@ -0,0 +1,34 @@ +/* +* 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 { ZosTsoBaseHandler, ReceiveTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; + +/** + * Handler to receieve message from an app at an address space + * @export + * @class Handler + * @implements {ICommandHandler} + */ +export default class Handler extends ZosTsoBaseHandler { + // Process the command and produce the start response (returns servlet) + public async processCmd(commandParameters: IHandlerParameters) { + const response = await ReceiveTsoApp.receive( + this.mSession, + this.mArguments.account, + { + appKey: commandParameters.arguments.appKey, + servletKey: commandParameters.arguments.servletKey, + }, + ); + console.log(response); + } +} diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts new file mode 100644 index 0000000000..7d6b163c95 --- /dev/null +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -0,0 +1,53 @@ +/* + * 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 } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { TsoValidator } from "./TsoValidator"; +import { noAccountNumber, TsoConstants } from "./TsoConstants"; +import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; + +/** + * Send message to TSO App running at an address space + * @export + * @class RecieveTsoApp + */ +export class ReceiveTsoApp { + /** + * Start TSO application at address space with provided parameters. + * @static + * @param {AbstractSession} session - z/OSMF connection info + * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. + * @param {IStartTsoParms} params - optional object with required parameters, @see {IStartTsoParms} + * @returns {Promise} command response on resolve, @see {IStartASAppResponse} + * @memberof StartTso + */ + public static async receive( + session: AbstractSession, + accountNumber: string, + params: ITsoAppCommunicationParms, + ): Promise { + TsoValidator.validateSession(session); + TsoValidator.validateNotEmptyString( + accountNumber, + noAccountNumber.message + ); + + const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; + const apiResponse = + await ZosmfRestClient.getExpectString( + session, + endpoint, + ); + + return apiResponse; + } +} diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index 0df17d353f..a4c6915bff 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -15,7 +15,7 @@ import { IStartTsoParms } from "./doc/input/IStartTsoParms"; import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { IStartASAppResponse } from "./doc/IStartASAppResponse"; -import { ISendTsoAppParms } from "./doc/input/ISendTsoAppParms"; +import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; /** * Send message to TSO App running at an address space * @export @@ -34,7 +34,7 @@ export class SendTsoApp { public static async send( session: AbstractSession, accountNumber: string, - params: ISendTsoAppParms, + params: ITsoAppCommunicationParms, startParms: IStartTsoParms ): Promise { TsoValidator.validateSession(session); @@ -52,6 +52,6 @@ export class SendTsoApp { params.message ); - return apiResponse + return apiResponse; } } diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index 8f5caaf897..23e35668d2 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -17,7 +17,7 @@ import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { IStartASAppResponse } from "./doc/IStartASAppResponse"; import { IStartTsoAppParms } from "./doc/input/IStartTsoAppParms"; import { StartTso } from "./StartTso"; -import { IIssueResponse } from "../lib"; +import { IIssueResponse } from "../src"; /** * Start TSO address space and receive servlet key * @export diff --git a/packages/zostso/src/doc/input/ISendTsoAppParms.ts b/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts similarity index 75% rename from packages/zostso/src/doc/input/ISendTsoAppParms.ts rename to packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts index 326ebd809b..21074ac7d2 100644 --- a/packages/zostso/src/doc/input/ISendTsoAppParms.ts +++ b/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts @@ -12,26 +12,26 @@ /** * Interface for starting an app on a TSO Address Space * @export - * @interface ISendTsoAppParms + * @interface ITsoAppCommunicationParms */ -export interface ISendTsoAppParms { +export interface ITsoAppCommunicationParms { /** * Body contents being sent to TSO address space app * @type {string} - * @memberof ISendTsoAppParms + * @memberof ITsoAppCommunicationParms */ - message: string; + message?: string; /** * App Key of application to be started at a TSO address space * @type {string} - * @memberof ISendTsoAppParms + * @memberof ITsoAppCommunicationParms */ appKey: string; /** * Servlet key of an active address space * @type {string} - * @memberof ISendTsoAppParms + * @memberof ITsoAppCommunicationParms */ servletKey: string; } diff --git a/packages/zostso/src/index.ts b/packages/zostso/src/index.ts index 046b47d866..14ce39eadf 100644 --- a/packages/zostso/src/index.ts +++ b/packages/zostso/src/index.ts @@ -41,6 +41,7 @@ export * from "./SendTso"; export * from "./StartTso"; export * from "./StartTsoApp"; export * from "./SendTsoApp"; +export * from "./ReceiveTsoApp"; export * from "./StopTso"; export * from "./TsoConstants"; export * from "./TsoResponseService"; From 0a7286b2744394529cfc50236bd966c0956b79ab Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 2 Oct 2024 10:28:45 -0400 Subject: [PATCH 010/106] linting Signed-off-by: jace-roell --- .../src/zostso/receive/address-space/ReceiveASApp.handler.ts | 2 +- packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts | 2 +- packages/cli/src/zostso/start/as-app/StartASApp.handler.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts index e3b47ee8e7..de934aa519 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts @@ -29,6 +29,6 @@ export default class Handler extends ZosTsoBaseHandler { servletKey: commandParameters.arguments.servletKey, }, ); - console.log(response); + commandParameters.response.console.log(response); } } diff --git a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts index 318904c584..13b9cd1fe4 100644 --- a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts +++ b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts @@ -31,6 +31,6 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); - console.log(response); + commandParameters.response.console.log(response); } } diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts index f7f4fb9b64..bc6edbce49 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts @@ -33,6 +33,6 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); - console.log(response); + commandParameters.response.console.log(response as any); } } From 5ef22e045c16f7587e85effeaea677012084b5f7 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 3 Oct 2024 10:59:58 -0400 Subject: [PATCH 011/106] linting Signed-off-by: jace-roell --- .../send/as-app/as-app/SendASApp.handler.ts | 2 +- .../zostso/start/as-app/StartASApp.handler.ts | 2 +- .../cmd/secure/secure.handler.unit.test.ts | 651 +++++++++++++----- packages/zostso/src/StartTsoApp.ts | 33 +- .../zostso/src/doc/IStartASAppResponse.ts | 4 +- 5 files changed, 490 insertions(+), 202 deletions(-) diff --git a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts index 13b9cd1fe4..1598cc1c03 100644 --- a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts +++ b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts @@ -31,6 +31,6 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); - commandParameters.response.console.log(response); + commandParameters.response.console.log(JSON.stringify(response)); } } diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts index bc6edbce49..67ca0171a8 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts @@ -33,6 +33,6 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); - commandParameters.response.console.log(response as any); + commandParameters.response.console.log(JSON.stringify(response)); } } 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 e4daed587d..73fef6d05e 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 @@ -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 { Logger } from "../../../../../logger"; import { Config } from "../../../../../config"; @@ -16,8 +16,12 @@ import { ImperativeConfig } from "../../../../../utilities"; import { IImperativeConfig } from "../../../../src/doc/IImperativeConfig"; import { ICredentialManagerInit } from "../../../../../security/src/doc/ICredentialManagerInit"; import { CredentialManagerFactory } from "../../../../../security"; -import { expectedGlobalConfigObject, expectedGlobalUserConfigObject, expectedProjectConfigObject, expectedProjectUserConfigObject } from - "../../../../../../__tests__/__integration__/imperative/__tests__/__integration__/cli/config/__resources__/expectedObjects"; +import { + expectedGlobalConfigObject, + expectedGlobalUserConfigObject, + expectedProjectConfigObject, + expectedProjectUserConfigObject, +} from "../../../../../../__tests__/__integration__/imperative/__tests__/__integration__/cli/config/__resources__/expectedObjects"; import SecureHandler from "../../../../src/config/cmd/secure/secure.handler"; import * as config from "../../../../../../__tests__/__integration__/imperative/src/imperative"; import { keyring as keytar } from "@zowe/secrets-for-zowe-sdk"; @@ -39,7 +43,7 @@ const getIHandlerParametersObject = (): IHandlerParameters => { }), setObj: jest.fn((setObjArgs) => { // Nothing - }) + }), }, console: { log: jest.fn((logs) => { @@ -49,11 +53,11 @@ const getIHandlerParametersObject = (): IHandlerParameters => { // Nothing }), errorHeader: jest.fn(() => undefined), - prompt: readPromptSpy - } + prompt: readPromptSpy, + }, }, arguments: {}, - definition: {} + definition: {}, }; return x as IHandlerParameters; }; @@ -61,7 +65,7 @@ const getIHandlerParametersObject = (): IHandlerParameters => { const credentialManager: ICredentialManagerInit = { service: "Zowe", displayName: "imperativeTestCredentialManager", - invalidOnFailure: false + invalidOnFailure: false, }; const fakeConfig = config as IImperativeConfig; @@ -69,16 +73,32 @@ const fakeProjPath = path.join(__dirname, "fakeapp.config.json"); const fakeSchemaPath = path.join(__dirname, "fakeapp.schema.json"); const fakeProjUserPath = path.join(__dirname, "fakeapp.config.user.json"); const fakeGblProjPath = path.join(__dirname, ".fakeapp", "fakeapp.config.json"); -const fakeGblSchemaPath = path.join(__dirname, ".fakeapp", "fakeapp.schema.json"); -const fakeGblProjUserPath = path.join(__dirname, ".fakeapp", "fakeapp.config.user.json"); +const fakeGblSchemaPath = path.join( + __dirname, + ".fakeapp", + "fakeapp.schema.json" +); +const fakeGblProjUserPath = path.join( + __dirname, + ".fakeapp", + "fakeapp.config.user.json" +); const fakeUnrelatedPath = path.join(__dirname, "fakeapp.unrelated.config.json"); const fakeSecureDataJson: any = {}; -fakeSecureDataJson[fakeProjPath] = {"profiles.project_base.properties.secure": "fakeSecureValue"}; -fakeSecureDataJson[fakeGblProjPath] = {"profiles.global_base.properties.secure": "fakeSecureValue"}; -fakeSecureDataJson[fakeUnrelatedPath] = {"profiles.project_base.properties.secure": "anotherFakeSecureValue"}; +fakeSecureDataJson[fakeProjPath] = { + "profiles.project_base.properties.secure": "fakeSecureValue", +}; +fakeSecureDataJson[fakeGblProjPath] = { + "profiles.global_base.properties.secure": "fakeSecureValue", +}; +fakeSecureDataJson[fakeUnrelatedPath] = { + "profiles.project_base.properties.secure": "anotherFakeSecureValue", +}; -const fakeSecureData = Buffer.from(JSON.stringify(fakeSecureDataJson)).toString("base64"); +const fakeSecureData = Buffer.from(JSON.stringify(fakeSecureDataJson)).toString( + "base64" +); describe("Configuration Secure command handler", () => { let readFileSyncSpy: any; @@ -98,11 +118,11 @@ describe("Configuration Secure command handler", () => { }, save: (k: string, v: any): Promise => { return CredentialManagerFactory.manager.save(k, v); - } - } + }, + }, }; - beforeAll( async() => { + beforeAll(async () => { keytarGetPasswordSpy = jest.spyOn(keytar, "getPassword"); keytarSetPasswordSpy = jest.spyOn(keytar, "setPassword"); keytarDeletePasswordSpy = jest.spyOn(keytar, "deletePassword"); @@ -116,7 +136,7 @@ describe("Configuration Secure command handler", () => { await CredentialManagerFactory.initialize(credentialManager); // Prepare config setup }); - beforeEach( async () => { + beforeEach(async () => { ImperativeConfig.instance.loadedConfig = lodash.cloneDeep(fakeConfig); searchSpy = jest.spyOn(Config, "search"); @@ -126,10 +146,12 @@ describe("Configuration Secure command handler", () => { readPromptSpy.mockClear(); jest.spyOn(EventUtils, "validateAppName").mockImplementation(jest.fn()); - jest.spyOn(EventOperator, "getZoweProcessor").mockReturnValue({emitZoweEvent: jest.fn()} as any); + jest.spyOn(EventOperator, "getZoweProcessor").mockReturnValue({ + emitZoweEvent: jest.fn(), + } as any); }); - afterEach( () => { + afterEach(() => { jest.restoreAllMocks(); }); @@ -153,9 +175,14 @@ describe("Configuration Secure command handler", () => { eco.$schema = "./fakeapp.schema.json"; readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); // Only the project config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the project config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config @@ -165,17 +192,25 @@ describe("Configuration Secure command handler", () => { existsSyncSpy.mockClear(); readFileSyncSpy.mockClear(); - setSchemaSpy = jest.spyOn(ImperativeConfig.instance.config, "setSchema"); - (params.response.console as any).prompt = jest.fn(() => "fakePromptingData"); + setSchemaSpy = jest.spyOn( + ImperativeConfig.instance.config, + "setSchema" + ); + (params.response.console as any).prompt = jest.fn( + () => "fakePromptingData" + ); await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); delete fakeSecureDataExpectedJson[fakeProjPath]; fakeSecureDataExpectedJson[fakeProjPath] = { - "profiles.project_base.properties.secret": "fakePromptingData" + "profiles.project_base.properties.secret": "fakePromptingData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON @@ -190,9 +225,17 @@ describe("Configuration Secure command handler", () => { } expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeProjPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should attempt to secure the project user configuration", async () => { @@ -217,7 +260,9 @@ describe("Configuration Secure command handler", () => { readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); existsSyncSpy.mockReturnValueOnce(true).mockReturnValue(false); // Only the user config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config @@ -227,15 +272,21 @@ describe("Configuration Secure command handler", () => { existsSyncSpy.mockClear(); readFileSyncSpy.mockClear(); - setSchemaSpy = jest.spyOn(ImperativeConfig.instance.config, "setSchema"); + setSchemaSpy = jest.spyOn( + ImperativeConfig.instance.config, + "setSchema" + ); await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); fakeSecureDataExpectedJson[fakeProjUserPath] = { - "profiles.project_base.properties.secret": "fakePromptingData" + "profiles.project_base.properties.secret": "fakePromptingData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON @@ -250,9 +301,17 @@ describe("Configuration Secure command handler", () => { } expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjUserPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeProjUserPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should attempt to secure the global configuration", async () => { @@ -275,10 +334,16 @@ describe("Configuration Secure command handler", () => { eco.$schema = "./fakeapp.schema.json"; readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(false) - .mockReturnValueOnce(true).mockReturnValue(false); // Only the global config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(false) + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the global config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeGblProjUserPath).mockReturnValueOnce(fakeGblProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeGblProjUserPath) + .mockReturnValueOnce(fakeGblProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config @@ -288,16 +353,22 @@ describe("Configuration Secure command handler", () => { existsSyncSpy.mockClear(); readFileSyncSpy.mockClear(); - setSchemaSpy = jest.spyOn(ImperativeConfig.instance.config, "setSchema"); + setSchemaSpy = jest.spyOn( + ImperativeConfig.instance.config, + "setSchema" + ); await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); delete fakeSecureDataExpectedJson[fakeGblProjPath]; fakeSecureDataExpectedJson[fakeGblProjPath] = { - "profiles.global_base.properties.secret": "fakePromptingData" + "profiles.global_base.properties.secret": "fakePromptingData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON @@ -312,9 +383,17 @@ describe("Configuration Secure command handler", () => { } expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeGblProjPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeGblProjPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should attempt to secure the global user configuration", async () => { @@ -337,10 +416,15 @@ describe("Configuration Secure command handler", () => { eco.$schema = "./fakeapp.schema.json"; readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) + 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); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config @@ -350,16 +434,22 @@ describe("Configuration Secure command handler", () => { existsSyncSpy.mockClear(); readFileSyncSpy.mockClear(); - setSchemaSpy = jest.spyOn(ImperativeConfig.instance.config, "setSchema"); + setSchemaSpy = jest.spyOn( + ImperativeConfig.instance.config, + "setSchema" + ); await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); delete fakeSecureDataExpectedJson[fakeGblProjUserPath]; fakeSecureDataExpectedJson[fakeGblProjUserPath] = { - "profiles.global_base.properties.secret": "fakePromptingData" + "profiles.global_base.properties.secret": "fakePromptingData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON @@ -374,9 +464,17 @@ describe("Configuration Secure command handler", () => { } expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeGblProjUserPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeGblProjUserPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should fail to secure the project configuration if there is no project configuration", async () => { @@ -399,10 +497,15 @@ describe("Configuration Secure command handler", () => { eco.$schema = "./fakeapp.schema.json"; readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(false).mockReturnValueOnce(true) + 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); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config @@ -412,7 +515,10 @@ describe("Configuration Secure command handler", () => { existsSyncSpy.mockClear(); readFileSyncSpy.mockClear(); - setSchemaSpy = jest.spyOn(ImperativeConfig.instance.config, "setSchema"); + setSchemaSpy = jest.spyOn( + ImperativeConfig.instance.config, + "setSchema" + ); await handler.process(params); @@ -420,7 +526,9 @@ describe("Configuration Secure command handler", () => { expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(0); expect(writeFileSyncSpy).toHaveBeenCalledTimes(0); - expect(ImperativeConfig.instance.config.api.secure.secureFields().length).toEqual(0); + expect( + ImperativeConfig.instance.config.api.secure.secureFields().length + ).toEqual(0); }); it("should secure the project configuration and prune unused properties", async () => { @@ -444,9 +552,14 @@ describe("Configuration Secure command handler", () => { eco.$schema = "./fakeapp.schema.json"; readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); // Only the project config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the project config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config @@ -456,16 +569,21 @@ describe("Configuration Secure command handler", () => { existsSyncSpy.mockClear(); readFileSyncSpy.mockClear(); - setSchemaSpy = jest.spyOn(ImperativeConfig.instance.config, "setSchema"); + setSchemaSpy = jest.spyOn( + ImperativeConfig.instance.config, + "setSchema" + ); await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = { + const fakeSecureDataExpectedJson: { [key: string]: any } = { [fakeProjPath]: { - "profiles.project_base.properties.secret": "fakePromptingData" - } + "profiles.project_base.properties.secret": "fakePromptingData", + }, }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON @@ -480,9 +598,17 @@ describe("Configuration Secure command handler", () => { } expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(2); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeProjPath, + JSON.stringify(compObj, null, 4) + ); // Config }); describe("special prompting for auth token", () => { @@ -491,11 +617,9 @@ describe("Configuration Secure command handler", () => { properties: { host: "example.com", port: 443, - tokenType: SessConstants.TOKEN_TYPE_JWT + tokenType: SessConstants.TOKEN_TYPE_JWT, }, - secure: [ - "tokenValue" - ] + secure: ["tokenValue"], }; const expectedProjConfigObjectWithToken: IConfig = { @@ -504,31 +628,39 @@ describe("Configuration Secure command handler", () => { project_base: baseProfile, }, defaults: { - base: "project_base" - } + base: "project_base", + }, }; - const authHandlerPath = __dirname + "/../../../../src/auth/handlers/AbstractAuthHandler"; + const authHandlerPath = + __dirname + "/../../../../src/auth/handlers/AbstractAuthHandler"; const handler = new SecureHandler(); const params = getIHandlerParametersObject(); let mockAuthHandlerApi: any; beforeAll(() => { mockAuthHandlerApi = { - promptParams: { defaultTokenType: SessConstants.TOKEN_TYPE_JWT }, - createSessCfg: jest.fn(x => x), - sessionLogin: jest.fn().mockResolvedValue("fakeLoginData") + promptParams: { + defaultTokenType: SessConstants.TOKEN_TYPE_JWT, + }, + createSessCfg: jest.fn((x) => x), + sessionLogin: jest.fn().mockResolvedValue("fakeLoginData"), }; jest.doMock(authHandlerPath, () => { - const { AbstractAuthHandler } = jest.requireActual(authHandlerPath); + const { AbstractAuthHandler } = + jest.requireActual(authHandlerPath); return { default: jest.fn(() => { - const handler = Object.create(AbstractAuthHandler.prototype); + const handler = Object.create( + AbstractAuthHandler.prototype + ); return Object.assign(handler, { - getAuthHandlerApi: jest.fn().mockReturnValue(mockAuthHandlerApi) + getAuthHandlerApi: jest + .fn() + .mockReturnValue(mockAuthHandlerApi), }); - }) + }), }; }); }); @@ -559,50 +691,76 @@ describe("Configuration Secure command handler", () => { // Create another base profile and mock the loggers to test multiple login operations in a single config-secure eco.profiles["base2"] = baseProfile; - const dummyLogger: any = {debug: jest.fn(), info: jest.fn()}; - jest.spyOn(Logger, "getImperativeLogger").mockReturnValue(dummyLogger); + const dummyLogger: any = { debug: jest.fn(), info: jest.fn() }; + jest.spyOn(Logger, "getImperativeLogger").mockReturnValue( + dummyLogger + ); jest.spyOn(Logger, "getAppLogger").mockReturnValue(dummyLogger); readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); // Only the project config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the project config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config - jest.spyOn(ImperativeConfig.instance, "loadedConfig", "get").mockReturnValue({ + jest.spyOn( + ImperativeConfig.instance, + "loadedConfig", + "get" + ).mockReturnValue({ ...fakeConfig, - profiles: [{ - type: "base", - authConfig: [{ handler: authHandlerPath } as any] - } as any] + profiles: [ + { + type: "base", + authConfig: [{ handler: authHandlerPath } as any], + } as any, + ], }); await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); delete fakeSecureDataExpectedJson[fakeProjPath]; fakeSecureDataExpectedJson[fakeProjPath] = { "profiles.project_base.properties.tokenValue": "fakeLoginData", - "profiles.base2.properties.tokenValue": "fakeLoginData" + "profiles.base2.properties.tokenValue": "fakeLoginData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON compObj.$schema = "./fakeapp.schema.json"; // Fill in the name of the schema file, and make it first lodash.merge(compObj, ImperativeConfig.instance.config.properties); // Add the properties from the config - delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret - delete compObj.profiles.base2.properties.tokenValue; // Delete the secret + delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret + delete compObj.profiles.base2.properties.tokenValue; // Delete the secret - expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes(process.platform === "win32" ? 4 : 3); + expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes( + process.platform === "win32" ? 4 : 3 + ); expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); expect(mockAuthHandlerApi.createSessCfg).toHaveBeenCalledTimes(2); expect(mockAuthHandlerApi.sessionLogin).toHaveBeenCalledTimes(2); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeProjPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should not invoke auth handler if profile type is undefined", async () => { @@ -610,33 +768,52 @@ describe("Configuration Secure command handler", () => { delete eco.profiles.project_base.type; readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); // Only the project config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the project config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); delete fakeSecureDataExpectedJson[fakeProjPath]; fakeSecureDataExpectedJson[fakeProjPath] = { - "profiles.project_base.properties.tokenValue": "fakePromptingData" + "profiles.project_base.properties.tokenValue": + "fakePromptingData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON compObj.$schema = "./fakeapp.schema.json"; // Fill in the name of the schema file, and make it first lodash.merge(compObj, ImperativeConfig.instance.config.properties); // Add the properties from the config - delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret + delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret - expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes(process.platform === "win32" ? 4 : 3); + expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes( + process.platform === "win32" ? 4 : 3 + ); expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); expect(mockAuthHandlerApi.sessionLogin).toHaveBeenCalledTimes(0); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeProjPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should not invoke auth handler if profile token type is undefined", async () => { @@ -644,139 +821,223 @@ describe("Configuration Secure command handler", () => { delete eco.profiles.project_base.properties.tokenType; readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); // Only the project config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the project config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); delete fakeSecureDataExpectedJson[fakeProjPath]; fakeSecureDataExpectedJson[fakeProjPath] = { - "profiles.project_base.properties.tokenValue": "fakePromptingData" + "profiles.project_base.properties.tokenValue": + "fakePromptingData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON compObj.$schema = "./fakeapp.schema.json"; // Fill in the name of the schema file, and make it first lodash.merge(compObj, ImperativeConfig.instance.config.properties); // Add the properties from the config - delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret + delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret - expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes(process.platform === "win32" ? 4 : 3); + expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes( + process.platform === "win32" ? 4 : 3 + ); expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); expect(readPromptSpy).toHaveBeenCalledTimes(1); expect(mockAuthHandlerApi.sessionLogin).toHaveBeenCalledTimes(0); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeProjPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should not invoke auth handler if no matching auth config is found", async () => { const eco = lodash.cloneDeep(expectedProjConfigObjectWithToken); readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); // Only the project config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the project config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config - jest.spyOn(ImperativeConfig.instance, "loadedConfig", "get").mockReturnValueOnce({ - profiles: [{ - type: "not-base", - authConfig: [{ handler: authHandlerPath } as any] - } as any] + jest.spyOn( + ImperativeConfig.instance, + "loadedConfig", + "get" + ).mockReturnValueOnce({ + profiles: [ + { + type: "not-base", + authConfig: [{ handler: authHandlerPath } as any], + } as any, + ], }); await handler.process(params); - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); delete fakeSecureDataExpectedJson[fakeProjPath]; fakeSecureDataExpectedJson[fakeProjPath] = { - "profiles.project_base.properties.tokenValue": "fakePromptingData" + "profiles.project_base.properties.tokenValue": + "fakePromptingData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON compObj.$schema = "./fakeapp.schema.json"; // Fill in the name of the schema file, and make it first lodash.merge(compObj, ImperativeConfig.instance.config.properties); // Add the properties from the config - delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret + delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret - expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes(process.platform === "win32" ? 4 : 3); + expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes( + process.platform === "win32" ? 4 : 3 + ); expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); expect(readPromptSpy).toHaveBeenCalledTimes(1); expect(mockAuthHandlerApi.sessionLogin).toHaveBeenCalledTimes(0); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeProjPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should not invoke auth handler if auth handler is for different token type", async () => { const eco = lodash.cloneDeep(expectedProjConfigObjectWithToken); readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); // Only the project config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the project config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config - jest.spyOn(ImperativeConfig.instance, "loadedConfig", "get").mockReturnValueOnce({ - profiles: [{ - type: "base", - authConfig: [{ handler: authHandlerPath } as any] - } as any] + jest.spyOn( + ImperativeConfig.instance, + "loadedConfig", + "get" + ).mockReturnValueOnce({ + profiles: [ + { + type: "base", + authConfig: [{ handler: authHandlerPath } as any], + } as any, + ], }); - mockAuthHandlerApi.promptParams.defaultTokenType = SessConstants.TOKEN_TYPE_LTPA; + mockAuthHandlerApi.promptParams.defaultTokenType = + SessConstants.TOKEN_TYPE_LTPA; await handler.process(params); - mockAuthHandlerApi.promptParams.defaultTokenType = SessConstants.TOKEN_TYPE_JWT; + mockAuthHandlerApi.promptParams.defaultTokenType = + SessConstants.TOKEN_TYPE_JWT; - const fakeSecureDataExpectedJson: { [key: string]: any} = lodash.cloneDeep(fakeSecureDataJson); + const fakeSecureDataExpectedJson: { [key: string]: any } = + lodash.cloneDeep(fakeSecureDataJson); delete fakeSecureDataExpectedJson[fakeProjPath]; fakeSecureDataExpectedJson[fakeProjPath] = { - "profiles.project_base.properties.tokenValue": "fakePromptingData" + "profiles.project_base.properties.tokenValue": + "fakePromptingData", }; - const fakeSecureDataExpected = Buffer.from(JSON.stringify(fakeSecureDataExpectedJson)).toString("base64"); + const fakeSecureDataExpected = Buffer.from( + JSON.stringify(fakeSecureDataExpectedJson) + ).toString("base64"); const compObj: any = {}; // Make changes to satisfy what would be stored on the JSON compObj.$schema = "./fakeapp.schema.json"; // Fill in the name of the schema file, and make it first lodash.merge(compObj, ImperativeConfig.instance.config.properties); // Add the properties from the config - delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret + delete compObj.profiles.project_base.properties.tokenValue; // Delete the secret - expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes(process.platform === "win32" ? 4 : 3); + expect(keytarDeletePasswordSpy).toHaveBeenCalledTimes( + process.platform === "win32" ? 4 : 3 + ); expect(keytarGetPasswordSpy).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(1); expect(readPromptSpy).toHaveBeenCalledTimes(1); expect(mockAuthHandlerApi.sessionLogin).toHaveBeenCalledTimes(0); - expect(keytarSetPasswordSpy).toHaveBeenCalledWith("Zowe", "secure_config_props", fakeSecureDataExpected); + expect(keytarSetPasswordSpy).toHaveBeenCalledWith( + "Zowe", + "secure_config_props", + fakeSecureDataExpected + ); expect(writeFileSyncSpy).toHaveBeenCalledTimes(1); - expect(writeFileSyncSpy).toHaveBeenNthCalledWith(1, fakeProjPath, JSON.stringify(compObj, null, 4)); // Config + expect(writeFileSyncSpy).toHaveBeenNthCalledWith( + 1, + fakeProjPath, + JSON.stringify(compObj, null, 4) + ); // Config }); it("should only prompt for profiles that matched profile param", async () => { const eco = lodash.cloneDeep(expectedProjConfigObjectWithToken); readFileSyncSpy.mockReturnValueOnce(JSON.stringify(eco)); - existsSyncSpy.mockReturnValueOnce(false).mockReturnValueOnce(true).mockReturnValue(false); // Only the project config exists + existsSyncSpy + .mockReturnValueOnce(false) + .mockReturnValueOnce(true) + .mockReturnValue(false); // Only the project config exists writeFileSyncSpy.mockImplementation(); - searchSpy.mockReturnValueOnce(fakeProjUserPath).mockReturnValueOnce(fakeProjPath); // Give search something to return + searchSpy + .mockReturnValueOnce(fakeProjUserPath) + .mockReturnValueOnce(fakeProjPath); // Give search something to return await setupConfigToLoad(undefined, configOpts); // Setup the config - jest.spyOn(ImperativeConfig.instance, "loadedConfig", "get").mockReturnValueOnce({ - profiles: [{ - type: "base", - authConfig: [{ handler: authHandlerPath } as any] - } as any] + jest.spyOn( + ImperativeConfig.instance, + "loadedConfig", + "get" + ).mockReturnValueOnce({ + profiles: [ + { + type: "base", + authConfig: [{ handler: authHandlerPath } as any], + } as any, + ], }); - mockAuthHandlerApi.sessionLogin.mockRejectedValueOnce(new Error("bad handler")); + mockAuthHandlerApi.sessionLogin.mockRejectedValueOnce( + new Error("bad handler") + ); let caughtError; try { @@ -787,7 +1048,7 @@ describe("Configuration Secure command handler", () => { expect(caughtError).toBeDefined(); expect(caughtError.message).toContain("Failed to fetch jwtToken"); - expect(readPromptSpy).toHaveBeenCalledTimes(2); // User and password + expect(readPromptSpy).toHaveBeenCalledTimes(2); // User and password expect(mockAuthHandlerApi.sessionLogin).toHaveBeenCalledTimes(1); expect(keytarSetPasswordSpy).toHaveBeenCalledTimes(0); expect(writeFileSyncSpy).toHaveBeenCalledTimes(0); @@ -796,17 +1057,19 @@ describe("Configuration Secure command handler", () => { 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(""); - + myPromptSpy = jest + .spyOn(params.response.console, "prompt") + .mockResolvedValue(""); + // Reset spies keytarGetPasswordSpy.mockReturnValue(fakeSecureData); keytarSetPasswordSpy.mockImplementation(); @@ -816,88 +1079,104 @@ describe("Configuration Secure command handler", () => { existsSyncSpy = jest.spyOn(fs, "existsSync"); writeFileSyncSpy.mockImplementation(); }); - - const runTest = async (profile: string, secureFields: string[], expectedPromptTimes: number, expectedSecureField: string) => { + + 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); + 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); - + 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(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" + "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" + "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" + "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" + "profiles.abcdefg.properties.tokenValue", ], 3, "profiles.lpar1.profiles.test.properties.tokenValue" ); }); }); - }); }); diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index 23e35668d2..9287a1a77b 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -67,19 +67,26 @@ export class StartTsoApp { // Address space application starting const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const apiResponse = - await ZosmfRestClient.postExpectJSON( - session, - endpoint, - [Headers.APPLICATION_JSON], - { - startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, - } - ); - // Add newly created queueID and servletKey information to return object. - apiResponse.queueID = params.queueID; - apiResponse.servletKey = params.servletKey; + const apiResponse = await ZosmfRestClient.postExpectJSON( + session, + endpoint, + [Headers.APPLICATION_JSON], + { + startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, + } + ); + const formattedApiResponse: IStartASAppResponse = { + version: apiResponse.ver, + reused: apiResponse.reused, + timeout: apiResponse.timeout, + servletKey: apiResponse.servletKey ?? null, + queueID: apiResponse.queueID ?? null, + tsoData: apiResponse.tsoData.map((message: any) => ({ + VERSION: message["TSO MESSAGE"].VERSION, + DATA: message["TSO MESSAGE"].DATA, + })), + }; - return apiResponse; + return formattedApiResponse; } } diff --git a/packages/zostso/src/doc/IStartASAppResponse.ts b/packages/zostso/src/doc/IStartASAppResponse.ts index 875eeb3cf1..f308f8efbb 100644 --- a/packages/zostso/src/doc/IStartASAppResponse.ts +++ b/packages/zostso/src/doc/IStartASAppResponse.ts @@ -9,6 +9,8 @@ * */ +import { ITsoMessage } from "../../lib"; + export interface IStartASAppResponse { /** * Version in response @@ -21,7 +23,7 @@ export interface IStartASAppResponse { * @type {boolean} * @memberof IStartASAppResponse */ - tsoData: string[] + tsoData: ITsoMessage[] /** * Reused boolean * @type {boolean} From f87566b606da5aeaa61b98c095c538821e929b28 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 3 Oct 2024 15:12:39 -0400 Subject: [PATCH 012/106] renamed interface and implementations Signed-off-by: jace-roell --- packages/zostso/src/ReceiveTsoApp.ts | 2 +- packages/zostso/src/SendTsoApp.ts | 8 ++++---- packages/zostso/src/StartTsoApp.ts | 8 ++++---- .../{IStartASAppResponse.ts => IASAppResponse.ts} | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) rename packages/zostso/src/doc/{IStartASAppResponse.ts => IASAppResponse.ts} (77%) diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index 7d6b163c95..9f4a8e7b5b 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -27,7 +27,7 @@ export class ReceiveTsoApp { * @param {AbstractSession} session - z/OSMF connection info * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. * @param {IStartTsoParms} params - optional object with required parameters, @see {IStartTsoParms} - * @returns {Promise} command response on resolve, @see {IStartASAppResponse} + * @returns {Promise} command response on resolve, @see {IASAppResponse} * @memberof StartTso */ public static async receive( diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index a4c6915bff..c90d67733b 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -14,7 +14,7 @@ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; -import { IStartASAppResponse } from "./doc/IStartASAppResponse"; +import { IASAppResponse } from "./doc/IASAppResponse"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; /** * Send message to TSO App running at an address space @@ -28,7 +28,7 @@ export class SendTsoApp { * @param {AbstractSession} session - z/OSMF connection info * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. * @param {IStartTsoParms} parms - optional object with required parameters, @see {IStartTsoParms} - * @returns {Promise} command response on resolve, @see {IStartASAppResponse} + * @returns {Promise} command response on resolve, @see {IASAppResponse} * @memberof StartTso */ public static async send( @@ -36,7 +36,7 @@ export class SendTsoApp { accountNumber: string, params: ITsoAppCommunicationParms, startParms: IStartTsoParms - ): Promise { + ): Promise { TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( accountNumber, @@ -45,7 +45,7 @@ export class SendTsoApp { const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; const apiResponse = - await ZosmfRestClient.putExpectJSON( + await ZosmfRestClient.putExpectJSON( session, endpoint, [Headers.CONTENT_TYPE, "text/plain"], diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index 9287a1a77b..0d7f2743fc 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -14,7 +14,7 @@ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { IStartTsoParms } from "./doc/input/IStartTsoParms"; import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; -import { IStartASAppResponse } from "./doc/IStartASAppResponse"; +import { IASAppResponse } from "./doc/IASAppResponse"; import { IStartTsoAppParms } from "./doc/input/IStartTsoAppParms"; import { StartTso } from "./StartTso"; import { IIssueResponse } from "../src"; @@ -30,7 +30,7 @@ export class StartTsoApp { * @param {AbstractSession} session - z/OSMF connection info * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. * @param {IStartTsoParms} parms - optional object with required parameters, @see {IStartTsoParms} - * @returns {Promise} command response on resolve, @see {IStartASAppResponse} + * @returns {Promise} command response on resolve, @see {IASAppResponse} * @memberof StartTso */ public static async start( @@ -38,7 +38,7 @@ export class StartTsoApp { accountNumber: string, params: IStartTsoAppParms, startParms: IStartTsoParms - ): Promise { + ): Promise { TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( accountNumber, @@ -75,7 +75,7 @@ export class StartTsoApp { startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, } ); - const formattedApiResponse: IStartASAppResponse = { + const formattedApiResponse: IASAppResponse = { version: apiResponse.ver, reused: apiResponse.reused, timeout: apiResponse.timeout, diff --git a/packages/zostso/src/doc/IStartASAppResponse.ts b/packages/zostso/src/doc/IASAppResponse.ts similarity index 77% rename from packages/zostso/src/doc/IStartASAppResponse.ts rename to packages/zostso/src/doc/IASAppResponse.ts index f308f8efbb..7165f81cae 100644 --- a/packages/zostso/src/doc/IStartASAppResponse.ts +++ b/packages/zostso/src/doc/IASAppResponse.ts @@ -11,41 +11,41 @@ import { ITsoMessage } from "../../lib"; -export interface IStartASAppResponse { +export interface IASAppResponse { /** * Version in response * @type {boolean} - * @memberof IStartASAppResponse + * @memberof IASAppResponse */ version: string /** * Data from response * @type {boolean} - * @memberof IStartASAppResponse + * @memberof IASAppResponse */ tsoData: ITsoMessage[] /** * Reused boolean * @type {boolean} - * @memberof IStartASAppResponse + * @memberof IASAppResponse */ reused: boolean /** * Data from response * @type {boolean} - * @memberof IStartASAppResponse + * @memberof IASAppResponse */ timeout: boolean /** * Servlet key from IZosmfTsoResponse * @type {string} - * @memberof IStartASAppResponse + * @memberof IASAppResponse */ servletKey?: string; /** * Servlet key from IZosmfTsoResponse * @type {string} - * @memberof IStartASAppResponse + * @memberof IASAppResponse */ queueID?: string; } From 31dae02109da01ac2ad95ae4d7ce7b91dee82a22 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 8 Oct 2024 10:51:28 -0400 Subject: [PATCH 013/106] receive until flag and optimizations Signed-off-by: jace-roell --- .../address-space/ReceiveASApp.definition.ts | 8 ++++ .../address-space/ReceiveASApp.handler.ts | 3 +- packages/zostso/src/ReceiveTsoApp.ts | 46 +++++++++++++++---- packages/zostso/src/SendTsoApp.ts | 16 +++++-- packages/zostso/src/StartTsoApp.ts | 13 ++++-- packages/zostso/src/doc/IASAppResponse.ts | 2 +- .../doc/input/ITsoAppCommunicationParms.ts | 7 ++- 7 files changed, 76 insertions(+), 19 deletions(-) diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts index c34644859e..5a5782bd0f 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts @@ -36,6 +36,14 @@ export const ReceiveASApp: ICommandDefinition = { description: "Servlet Key", type: "string", required: true + }, + { + name: "recieveUntil", + aliases: ["ru"], + description: "Recieves data until keyword is received or timeout", + type: "boolean", + required: false, + defaultValue: false } ] as ICommandOptionDefinition[]), examples: [], diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts index de934aa519..39911088b6 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts @@ -27,8 +27,9 @@ export default class Handler extends ZosTsoBaseHandler { { appKey: commandParameters.arguments.appKey, servletKey: commandParameters.arguments.servletKey, + receiveUntil: commandParameters.arguments.receiveUntil }, ); - commandParameters.response.console.log(response); + console.log(JSON.stringify(response)); } } diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index 9f4a8e7b5b..2041a4726b 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -14,7 +14,7 @@ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; - +import { IASAppResponse } from "./doc/IASAppResponse"; /** * Send message to TSO App running at an address space * @export @@ -33,8 +33,8 @@ export class ReceiveTsoApp { public static async receive( session: AbstractSession, accountNumber: string, - params: ITsoAppCommunicationParms, - ): Promise { + params: ITsoAppCommunicationParms + ): Promise { TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString( accountNumber, @@ -42,12 +42,42 @@ export class ReceiveTsoApp { ); const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const apiResponse = - await ZosmfRestClient.getExpectString( - session, - endpoint, + let combinedResponse: IASAppResponse | null = null; + + let endKeyword: boolean = false; + do { + const apiResponse = await ZosmfRestClient.getExpectJSON< + IASAppResponse & { ver: string } + >(session, endpoint); + + const formattedApiResponse: IASAppResponse = { + version: apiResponse.ver, + reused: apiResponse.reused, + timeout: apiResponse.timeout, + servletKey: apiResponse.servletKey ?? null, + queueID: apiResponse.queueID ?? null, + tsoData: apiResponse.tsoData.map((message: any) => { + const messageKey = message["TSO MESSAGE"] + ? "TSO MESSAGE" + : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }), + }; + + if (combinedResponse === null) { + combinedResponse = formattedApiResponse; + } else { + combinedResponse.tsoData.push(...formattedApiResponse.tsoData); + } + + endKeyword = formattedApiResponse.tsoData.some( + (data) => data.DATA.trim() === "READY" ); + } while (!endKeyword && params.receiveUntil); - return apiResponse; + return combinedResponse!; } } diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index c90d67733b..29b6eccf28 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -45,13 +45,23 @@ export class SendTsoApp { const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; const apiResponse = - await ZosmfRestClient.putExpectJSON( + await ZosmfRestClient.putExpectJSON( session, endpoint, [Headers.CONTENT_TYPE, "text/plain"], params.message ); - - return apiResponse; + const formattedApiResponse: IASAppResponse = { + version: apiResponse.ver, + reused: apiResponse.reused, + timeout: apiResponse.timeout, + servletKey: apiResponse.servletKey ?? null, + queueID: apiResponse.queueID ?? null, + tsoData: apiResponse.tsoData.map((message: any) => ({ + VERSION: message["TSO MESSAGE"].VERSION, + DATA: message["TSO MESSAGE"].DATA, + })), + }; + return formattedApiResponse; } } diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index 0d7f2743fc..ccb95172e0 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -67,7 +67,7 @@ export class StartTsoApp { // Address space application starting const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const apiResponse = await ZosmfRestClient.postExpectJSON( + const apiResponse = await ZosmfRestClient.postExpectJSON( session, endpoint, [Headers.APPLICATION_JSON], @@ -81,10 +81,13 @@ export class StartTsoApp { timeout: apiResponse.timeout, servletKey: apiResponse.servletKey ?? null, queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData.map((message: any) => ({ - VERSION: message["TSO MESSAGE"].VERSION, - DATA: message["TSO MESSAGE"].DATA, - })), + tsoData: apiResponse.tsoData.map((message: any) => { + const messageKey = message["TSO MESSAGE"] ? "TSO MESSAGE" : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }), }; return formattedApiResponse; diff --git a/packages/zostso/src/doc/IASAppResponse.ts b/packages/zostso/src/doc/IASAppResponse.ts index 7165f81cae..d474e0edeb 100644 --- a/packages/zostso/src/doc/IASAppResponse.ts +++ b/packages/zostso/src/doc/IASAppResponse.ts @@ -9,7 +9,7 @@ * */ -import { ITsoMessage } from "../../lib"; +import { ITsoMessage } from "../../src"; export interface IASAppResponse { /** diff --git a/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts b/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts index 21074ac7d2..cadf4af416 100644 --- a/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts +++ b/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts @@ -15,7 +15,6 @@ * @interface ITsoAppCommunicationParms */ export interface ITsoAppCommunicationParms { - /** * Body contents being sent to TSO address space app * @type {string} @@ -34,4 +33,10 @@ export interface ITsoAppCommunicationParms { * @memberof ITsoAppCommunicationParms */ servletKey: string; + /** + * Keep receiving until end keyword is found. + * @type {boolean} + * @memberof ITsoAppCommunicationParms + */ + receiveUntil?: boolean; } From a60b1dd008a984b7c1acdcd59a838ba080d8e5c5 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 8 Oct 2024 14:25:08 -0400 Subject: [PATCH 014/106] receive until ready Signed-off-by: jace-roell --- .../zostso/receive/address-space/ReceiveASApp.definition.ts | 6 +++--- .../zostso/receive/address-space/ReceiveASApp.handler.ts | 2 +- packages/zostso/src/ReceiveTsoApp.ts | 2 +- packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts index 5a5782bd0f..3593263589 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts @@ -38,9 +38,9 @@ export const ReceiveASApp: ICommandDefinition = { required: true }, { - name: "recieveUntil", - aliases: ["ru"], - description: "Recieves data until keyword is received or timeout", + name: "receive-until-ready", + aliases: ["rur"], + description: "Receives data until keyword is received or timeout", type: "boolean", required: false, defaultValue: false diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts index 39911088b6..1325a66a21 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts @@ -27,7 +27,7 @@ export default class Handler extends ZosTsoBaseHandler { { appKey: commandParameters.arguments.appKey, servletKey: commandParameters.arguments.servletKey, - receiveUntil: commandParameters.arguments.receiveUntil + receiveUntilReady: commandParameters.arguments.receiveUntilReady }, ); console.log(JSON.stringify(response)); diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index 2041a4726b..bfc85a26d3 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -76,7 +76,7 @@ export class ReceiveTsoApp { endKeyword = formattedApiResponse.tsoData.some( (data) => data.DATA.trim() === "READY" ); - } while (!endKeyword && params.receiveUntil); + } while (!endKeyword && params.receiveUntilReady); return combinedResponse!; } diff --git a/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts b/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts index cadf4af416..f93865f111 100644 --- a/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts +++ b/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts @@ -38,5 +38,5 @@ export interface ITsoAppCommunicationParms { * @type {boolean} * @memberof ITsoAppCommunicationParms */ - receiveUntil?: boolean; + receiveUntilReady?: boolean; } From cd5856219422209659403a31c9188323e4b0cc42 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 9 Oct 2024 14:10:47 -0400 Subject: [PATCH 015/106] added 600 second timeout and loading spinner Signed-off-by: jace-roell --- .../address-space/ReceiveASApp.handler.ts | 9 +- packages/zostso/src/ReceiveTsoApp.ts | 119 +++++++++++------- 2 files changed, 83 insertions(+), 45 deletions(-) diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts index 1325a66a21..d446cf563c 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts @@ -30,6 +30,13 @@ export default class Handler extends ZosTsoBaseHandler { receiveUntilReady: commandParameters.arguments.receiveUntilReady }, ); - console.log(JSON.stringify(response)); + response.tsoData.forEach((data) => { + if(typeof data === 'string') { + commandParameters.response.console.log(data); + } else if (data && data.DATA) { + commandParameters.response.console.log(data.DATA); + } + }); + commandParameters.response.data.setObj(response); } } diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index bfc85a26d3..fbbb69076b 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -8,28 +8,16 @@ * Copyright Contributors to the Zowe Project. * */ - import { AbstractSession } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; import { IASAppResponse } from "./doc/IASAppResponse"; -/** - * Send message to TSO App running at an address space - * @export - * @class RecieveTsoApp - */ + +const TIMEOUT_SECONDS = 600; + export class ReceiveTsoApp { - /** - * Start TSO application at address space with provided parameters. - * @static - * @param {AbstractSession} session - z/OSMF connection info - * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. - * @param {IStartTsoParms} params - optional object with required parameters, @see {IStartTsoParms} - * @returns {Promise} command response on resolve, @see {IASAppResponse} - * @memberof StartTso - */ public static async receive( session: AbstractSession, accountNumber: string, @@ -41,42 +29,85 @@ export class ReceiveTsoApp { noAccountNumber.message ); + const spinnerChars = ["|", "/", "-", "\\"]; + let spinnerIndex = 0; + + const spinner = setInterval(() => { + process.stdout.write(`\rReceiving response... ${spinnerChars[spinnerIndex]}`); + spinnerIndex = (spinnerIndex + 1) % spinnerChars.length; + }, 100); + const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; let combinedResponse: IASAppResponse | null = null; + let endKeyword = false; + const startTime = Date.now(); + let timeoutReached = false; + + try { + do { + if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { + timeoutReached = true; + break; + } - let endKeyword: boolean = false; - do { - const apiResponse = await ZosmfRestClient.getExpectJSON< - IASAppResponse & { ver: string } - >(session, endpoint); + try { + const apiResponse = await ZosmfRestClient.getExpectJSON< + IASAppResponse & { ver: string; appData?: any } + >(session, endpoint); - const formattedApiResponse: IASAppResponse = { - version: apiResponse.ver, - reused: apiResponse.reused, - timeout: apiResponse.timeout, - servletKey: apiResponse.servletKey ?? null, - queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData.map((message: any) => { - const messageKey = message["TSO MESSAGE"] - ? "TSO MESSAGE" - : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, + const response = apiResponse as IASAppResponse & { + ver: string; + appData?: any; }; - }), - }; + const formattedApiResponse: IASAppResponse = { + version: response.ver, + reused: response.reused, + timeout: response.timeout, + servletKey: response.servletKey ?? null, + queueID: response.queueID ?? null, + tsoData: response.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] + ? "TSO MESSAGE" + : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }) || [response.appData], + }; + + if (combinedResponse === null) { + combinedResponse = formattedApiResponse; + } else { + combinedResponse.tsoData.push( + ...formattedApiResponse.tsoData + ); + } - if (combinedResponse === null) { - combinedResponse = formattedApiResponse; - } else { - combinedResponse.tsoData.push(...formattedApiResponse.tsoData); - } + endKeyword = formattedApiResponse.tsoData.some((data: any) => + typeof data === "string" + ? data.trim() === "READY" + : data.DATA.trim() === "READY" + ); + } catch (error) { + if (combinedResponse) { + return combinedResponse; + } + throw error; + } + } while (!endKeyword && params.receiveUntilReady && !timeoutReached); + } finally { + // Stop the spinner + clearInterval(spinner); + process.stdout.write("\r"); // Clear the spinner line + } - endKeyword = formattedApiResponse.tsoData.some( - (data) => data.DATA.trim() === "READY" - ); - } while (!endKeyword && params.receiveUntilReady); + // Display final status + if (timeoutReached) { + console.log("Timeout reached."); + } else { + console.log("Received response successfully."); + } return combinedResponse!; } From cefa92d93a5aed3a85123f8b3b97ef9bc6bf3eb6 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 9 Oct 2024 14:23:04 -0400 Subject: [PATCH 016/106] linting Signed-off-by: jace-roell --- packages/zostso/src/ReceiveTsoApp.ts | 14 +++-------- packages/zostso/src/SendTsoApp.ts | 37 ++++++++++++++-------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index fbbb69076b..77441a569e 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -35,7 +35,7 @@ export class ReceiveTsoApp { const spinner = setInterval(() => { process.stdout.write(`\rReceiving response... ${spinnerChars[spinnerIndex]}`); spinnerIndex = (spinnerIndex + 1) % spinnerChars.length; - }, 100); + }, 100); // 100ms delay const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; let combinedResponse: IASAppResponse | null = null; @@ -45,14 +45,15 @@ export class ReceiveTsoApp { try { do { - if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { + // Seconds to milliseconds + if (Date.now() - startTime > TIMEOUT_SECONDS * 1000){ timeoutReached = true; break; } try { const apiResponse = await ZosmfRestClient.getExpectJSON< - IASAppResponse & { ver: string; appData?: any } + IASAppResponse & { ver: string; appData?: any } >(session, endpoint); const response = apiResponse as IASAppResponse & { @@ -102,13 +103,6 @@ export class ReceiveTsoApp { process.stdout.write("\r"); // Clear the spinner line } - // Display final status - if (timeoutReached) { - console.log("Timeout reached."); - } else { - console.log("Received response successfully."); - } - return combinedResponse!; } } diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index 29b6eccf28..35f259ddcb 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -44,24 +44,25 @@ export class SendTsoApp { ); const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const apiResponse = - await ZosmfRestClient.putExpectJSON( - session, - endpoint, - [Headers.CONTENT_TYPE, "text/plain"], - params.message - ); - const formattedApiResponse: IASAppResponse = { - version: apiResponse.ver, - reused: apiResponse.reused, - timeout: apiResponse.timeout, - servletKey: apiResponse.servletKey ?? null, - queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData.map((message: any) => ({ - VERSION: message["TSO MESSAGE"].VERSION, - DATA: message["TSO MESSAGE"].DATA, - })), - }; + const apiResponse = await ZosmfRestClient.putExpectJSON< + IASAppResponse & { ver: string } + >( + session, + endpoint, + [Headers.CONTENT_TYPE, "text/plain"], + params.message + ); + const formattedApiResponse: IASAppResponse = { + version: apiResponse.ver, + reused: apiResponse.reused, + timeout: apiResponse.timeout, + servletKey: apiResponse.servletKey ?? null, + queueID: apiResponse.queueID ?? null, + tsoData: apiResponse.tsoData.map((message: any) => ({ + VERSION: message["TSO MESSAGE"].VERSION, + DATA: message["TSO MESSAGE"].DATA, + })), + }; return formattedApiResponse; } } From b684de5285eeb0e1432df11e039a07d6ba6d88f5 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 9 Oct 2024 15:40:20 -0400 Subject: [PATCH 017/106] formatting Signed-off-by: jace-roell --- .../address-space/ReceiveASApp.handler.ts | 1 + .../send/as-app/as-app/SendASApp.handler.ts | 2 +- .../zostso/start/as-app/StartASApp.handler.ts | 2 +- packages/zostso/src/ReceiveTsoApp.ts | 8 +++----- packages/zostso/src/StartTsoApp.ts | 18 ++++++++++-------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts index d446cf563c..14f51e41d9 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts @@ -30,6 +30,7 @@ export default class Handler extends ZosTsoBaseHandler { receiveUntilReady: commandParameters.arguments.receiveUntilReady }, ); + commandParameters.response.console.log("\n"); response.tsoData.forEach((data) => { if(typeof data === 'string') { commandParameters.response.console.log(data); diff --git a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts index 1598cc1c03..f644013e70 100644 --- a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts +++ b/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts @@ -31,6 +31,6 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); - commandParameters.response.console.log(JSON.stringify(response)); + commandParameters.response.console.log(JSON.stringify(response,null,2)); } } diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts index 67ca0171a8..757cb9e558 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts @@ -33,6 +33,6 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); - commandParameters.response.console.log(JSON.stringify(response)); + commandParameters.response.console.log(JSON.stringify(response,null,2)); } } diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index 77441a569e..c60667894e 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -35,7 +35,7 @@ export class ReceiveTsoApp { const spinner = setInterval(() => { process.stdout.write(`\rReceiving response... ${spinnerChars[spinnerIndex]}`); spinnerIndex = (spinnerIndex + 1) % spinnerChars.length; - }, 100); // 100ms delay + }, 100); const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; let combinedResponse: IASAppResponse | null = null; @@ -45,7 +45,6 @@ export class ReceiveTsoApp { try { do { - // Seconds to milliseconds if (Date.now() - startTime > TIMEOUT_SECONDS * 1000){ timeoutReached = true; break; @@ -53,7 +52,7 @@ export class ReceiveTsoApp { try { const apiResponse = await ZosmfRestClient.getExpectJSON< - IASAppResponse & { ver: string; appData?: any } + IASAppResponse & { ver: string; appData?: any } >(session, endpoint); const response = apiResponse as IASAppResponse & { @@ -98,9 +97,8 @@ export class ReceiveTsoApp { } } while (!endKeyword && params.receiveUntilReady && !timeoutReached); } finally { - // Stop the spinner clearInterval(spinner); - process.stdout.write("\r"); // Clear the spinner line + process.stdout.write("\r"); } return combinedResponse!; diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index ccb95172e0..4c117b5444 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.ts @@ -67,7 +67,7 @@ export class StartTsoApp { // Address space application starting const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const apiResponse = await ZosmfRestClient.postExpectJSON( + const response = await ZosmfRestClient.postExpectJSON( session, endpoint, [Headers.APPLICATION_JSON], @@ -76,13 +76,15 @@ export class StartTsoApp { } ); const formattedApiResponse: IASAppResponse = { - version: apiResponse.ver, - reused: apiResponse.reused, - timeout: apiResponse.timeout, - servletKey: apiResponse.servletKey ?? null, - queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData.map((message: any) => { - const messageKey = message["TSO MESSAGE"] ? "TSO MESSAGE" : "TSO PROMPT"; + version: response.ver, + reused: response.reused, + timeout: response.timeout, + servletKey: params.servletKey ?? null, + queueID: params.queueID ?? null, + tsoData: response.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] + ? "TSO MESSAGE" + : "TSO PROMPT"; return { VERSION: message[messageKey].VERSION, DATA: message[messageKey].DATA, From 0236fc740e7b2d865cb8da0ca50878355eda5788 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 9 Oct 2024 16:02:01 -0400 Subject: [PATCH 018/106] send tso fail case Signed-off-by: jace-roell --- packages/zostso/src/SendTsoApp.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index 35f259ddcb..ba901fc592 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -49,7 +49,7 @@ export class SendTsoApp { >( session, endpoint, - [Headers.CONTENT_TYPE, "text/plain"], + [Headers.APPLICATION_JSON], params.message ); const formattedApiResponse: IASAppResponse = { @@ -58,10 +58,10 @@ export class SendTsoApp { timeout: apiResponse.timeout, servletKey: apiResponse.servletKey ?? null, queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData.map((message: any) => ({ + tsoData: apiResponse.tsoData?.map((message: any) => ({ VERSION: message["TSO MESSAGE"].VERSION, DATA: message["TSO MESSAGE"].DATA, - })), + })) ?? null, }; return formattedApiResponse; } From 699c2839907d86fb7672900e5d94fb514e8a596c Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 9 Oct 2024 16:25:16 -0400 Subject: [PATCH 019/106] formatting Signed-off-by: jace-roell --- packages/zostso/src/SendTsoApp.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index ba901fc592..35f259ddcb 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -49,7 +49,7 @@ export class SendTsoApp { >( session, endpoint, - [Headers.APPLICATION_JSON], + [Headers.CONTENT_TYPE, "text/plain"], params.message ); const formattedApiResponse: IASAppResponse = { @@ -58,10 +58,10 @@ export class SendTsoApp { timeout: apiResponse.timeout, servletKey: apiResponse.servletKey ?? null, queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData?.map((message: any) => ({ + tsoData: apiResponse.tsoData.map((message: any) => ({ VERSION: message["TSO MESSAGE"].VERSION, DATA: message["TSO MESSAGE"].DATA, - })) ?? null, + })), }; return formattedApiResponse; } From 3a9b6a551c4c81c3c3cf7d2e5a25e21e6a5486f1 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 10 Oct 2024 13:40:40 -0400 Subject: [PATCH 020/106] format Signed-off-by: jace-roell --- packages/zostso/src/SendTsoApp.ts | 37 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index 35f259ddcb..29b6eccf28 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -44,25 +44,24 @@ export class SendTsoApp { ); const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const apiResponse = await ZosmfRestClient.putExpectJSON< - IASAppResponse & { ver: string } - >( - session, - endpoint, - [Headers.CONTENT_TYPE, "text/plain"], - params.message - ); - const formattedApiResponse: IASAppResponse = { - version: apiResponse.ver, - reused: apiResponse.reused, - timeout: apiResponse.timeout, - servletKey: apiResponse.servletKey ?? null, - queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData.map((message: any) => ({ - VERSION: message["TSO MESSAGE"].VERSION, - DATA: message["TSO MESSAGE"].DATA, - })), - }; + const apiResponse = + await ZosmfRestClient.putExpectJSON( + session, + endpoint, + [Headers.CONTENT_TYPE, "text/plain"], + params.message + ); + const formattedApiResponse: IASAppResponse = { + version: apiResponse.ver, + reused: apiResponse.reused, + timeout: apiResponse.timeout, + servletKey: apiResponse.servletKey ?? null, + queueID: apiResponse.queueID ?? null, + tsoData: apiResponse.tsoData.map((message: any) => ({ + VERSION: message["TSO MESSAGE"].VERSION, + DATA: message["TSO MESSAGE"].DATA, + })), + }; return formattedApiResponse; } } From 006da4aaf5a8ddb7a6f9a53bc860269dc2e69cd7 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 11 Oct 2024 15:49:33 -0400 Subject: [PATCH 021/106] spinner fixes, timeout as param on receive Signed-off-by: jace-roell --- .../address-space/ReceiveASApp.definition.ts | 8 +++ .../address-space/ReceiveASApp.handler.ts | 3 +- .../__unit__/StartTsoApp.unit.test.ts | 50 +++++++++++++++++++ packages/zostso/src/ReceiveTsoApp.ts | 38 ++++---------- packages/zostso/src/SendTsoApp.ts | 39 +++++++++++---- .../doc/input/ITsoAppCommunicationParms.ts | 6 +++ 6 files changed, 105 insertions(+), 39 deletions(-) create mode 100644 packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts index 3593263589..a63a3b4af7 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts @@ -44,6 +44,14 @@ export const ReceiveASApp: ICommandDefinition = { type: "boolean", required: false, defaultValue: false + }, + { + name: "timeout", + aliases: ["t"], + description: "Timeout length in seconds, all data at the time of timeout will be returned to user", + type: "number", + required: false, + defaultValue: 600 } ] as ICommandOptionDefinition[]), examples: [], diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts index 14f51e41d9..de147dace8 100644 --- a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts @@ -27,7 +27,8 @@ export default class Handler extends ZosTsoBaseHandler { { appKey: commandParameters.arguments.appKey, servletKey: commandParameters.arguments.servletKey, - receiveUntilReady: commandParameters.arguments.receiveUntilReady + receiveUntilReady: commandParameters.arguments.receiveUntilReady, + timeout: commandParameters.arguments.timeout }, ); commandParameters.response.console.log("\n"); diff --git a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts new file mode 100644 index 0000000000..94ee7e6c34 --- /dev/null +++ b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts @@ -0,0 +1,50 @@ +// /* +// * 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("../../../../../../zosmf/lib/ListDefinedSystems"); +// import { IASAppResponse } from "../../src/doc/IASAppResponse"; + +// const goodCmdParms: IHandlerParameters = mockHandlerParameters({ +// arguments: UNIT_TEST_ZOSMF_PROF_OPTS, +// positionals: ["zosmf", "check", "status"], +// definition: cmdDef.SystemsDefinition, +// profiles: UNIT_TEST_PROFILES_ZOSMF +// }); + + +// const response: IASAppResponse = { +// version: "0100", +// reused: false, +// timeout: false, +// servletKey: "JR897694-116-aabwaaak", +// queueID: "983068", +// tsoData: [ +// { VERSION: "0100", DATA: "HELLOW exec processing has started." }, +// { VERSION: "0100", DATA: "UNIX message queue id = 983068" }, +// { VERSION: "0100", DATA: "Input message type = 32772" }, +// { VERSION: "0100", DATA: "Output message type = 4" }, +// { VERSION: "0100", DATA: "Reading application input from the UNIX message queue." } +// ] +// }; + + +// describe("List systems behavior", () => { +// beforeEach(() => { +// }); + +// afterEach(() => { +// jest.resetAllMocks(); +// }); + +// it("", async () => { + +// }); +// }); diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index c60667894e..9edb63211c 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -15,8 +15,6 @@ import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; import { IASAppResponse } from "./doc/IASAppResponse"; -const TIMEOUT_SECONDS = 600; - export class ReceiveTsoApp { public static async receive( session: AbstractSession, @@ -24,14 +22,12 @@ export class ReceiveTsoApp { params: ITsoAppCommunicationParms ): Promise { TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString( - accountNumber, - noAccountNumber.message - ); - + TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); + const TIMEOUT_SECONDS: number = params.timeout; const spinnerChars = ["|", "/", "-", "\\"]; let spinnerIndex = 0; + // Start the spinner const spinner = setInterval(() => { process.stdout.write(`\rReceiving response... ${spinnerChars[spinnerIndex]}`); spinnerIndex = (spinnerIndex + 1) % spinnerChars.length; @@ -45,20 +41,14 @@ export class ReceiveTsoApp { try { do { - if (Date.now() - startTime > TIMEOUT_SECONDS * 1000){ + if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { timeoutReached = true; break; } try { - const apiResponse = await ZosmfRestClient.getExpectJSON< - IASAppResponse & { ver: string; appData?: any } - >(session, endpoint); - - const response = apiResponse as IASAppResponse & { - ver: string; - appData?: any; - }; + const apiResponse = await ZosmfRestClient.getExpectJSON(session, endpoint); + const response = apiResponse as IASAppResponse & { ver: string; appData?: any }; const formattedApiResponse: IASAppResponse = { version: response.ver, reused: response.reused, @@ -66,9 +56,7 @@ export class ReceiveTsoApp { servletKey: response.servletKey ?? null, queueID: response.queueID ?? null, tsoData: response.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] - ? "TSO MESSAGE" - : "TSO PROMPT"; + const messageKey = message["TSO MESSAGE"] ? "TSO MESSAGE" : "TSO PROMPT"; return { VERSION: message[messageKey].VERSION, DATA: message[messageKey].DATA, @@ -79,15 +67,11 @@ export class ReceiveTsoApp { if (combinedResponse === null) { combinedResponse = formattedApiResponse; } else { - combinedResponse.tsoData.push( - ...formattedApiResponse.tsoData - ); + combinedResponse.tsoData.push(...formattedApiResponse.tsoData); } endKeyword = formattedApiResponse.tsoData.some((data: any) => - typeof data === "string" - ? data.trim() === "READY" - : data.DATA.trim() === "READY" + typeof data === "string" ? data.trim() === "READY" : data.DATA.trim() === "READY" ); } catch (error) { if (combinedResponse) { @@ -97,8 +81,8 @@ export class ReceiveTsoApp { } } while (!endKeyword && params.receiveUntilReady && !timeoutReached); } finally { - clearInterval(spinner); - process.stdout.write("\r"); + clearInterval(spinner); // Stop the spinner + process.stdout.write("\r\x1b[K"); // Clear the line with spinner text } return combinedResponse!; diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index 29b6eccf28..ee3b98d74d 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -16,6 +16,7 @@ import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { IASAppResponse } from "./doc/IASAppResponse"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; + /** * Send message to TSO App running at an address space * @export @@ -38,30 +39,46 @@ export class SendTsoApp { startParms: IStartTsoParms ): Promise { TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString( - accountNumber, - noAccountNumber.message - ); + TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); + + const spinnerChars = ["|", "/", "-", "\\"]; + let spinnerIndex = 0; + + // Start the spinner + const spinner = setInterval(() => { + process.stdout.write(`\rSending request... ${spinnerChars[spinnerIndex]}`); + spinnerIndex = (spinnerIndex + 1) % spinnerChars.length; + }, 100); const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const apiResponse = - await ZosmfRestClient.putExpectJSON( + + try { + const apiResponse = await ZosmfRestClient.putExpectJSON( session, endpoint, [Headers.CONTENT_TYPE, "text/plain"], params.message ); + const formattedApiResponse: IASAppResponse = { version: apiResponse.ver, reused: apiResponse.reused, timeout: apiResponse.timeout, servletKey: apiResponse.servletKey ?? null, queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData.map((message: any) => ({ - VERSION: message["TSO MESSAGE"].VERSION, - DATA: message["TSO MESSAGE"].DATA, - })), + tsoData: apiResponse.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] ? "TSO MESSAGE" : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }), }; - return formattedApiResponse; + + return formattedApiResponse; + } finally { + clearInterval(spinner); // Stop the spinner + process.stdout.write("\r\x1b[K"); // Clear the line with spinner text + } } } diff --git a/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts b/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts index f93865f111..bf187b724c 100644 --- a/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts +++ b/packages/zostso/src/doc/input/ITsoAppCommunicationParms.ts @@ -39,4 +39,10 @@ export interface ITsoAppCommunicationParms { * @memberof ITsoAppCommunicationParms */ receiveUntilReady?: boolean; + /** + * Timeout duration in seconds + * @type {boolean} + * @memberof ITsoAppCommunicationParms + */ + timeout?: number; } From 33cef4d3689d61340a7196882bb7dcec1846eb0b Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 14 Oct 2024 14:49:03 -0400 Subject: [PATCH 022/106] start command unit tests Signed-off-by: jace-roell --- .../__unit__/StartTsoApp.unit.test.ts | 155 ++++++++++++------ 1 file changed, 105 insertions(+), 50 deletions(-) diff --git a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts index 94ee7e6c34..23ba08e274 100644 --- a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts @@ -1,50 +1,105 @@ -// /* -// * 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("../../../../../../zosmf/lib/ListDefinedSystems"); -// import { IASAppResponse } from "../../src/doc/IASAppResponse"; - -// const goodCmdParms: IHandlerParameters = mockHandlerParameters({ -// arguments: UNIT_TEST_ZOSMF_PROF_OPTS, -// positionals: ["zosmf", "check", "status"], -// definition: cmdDef.SystemsDefinition, -// profiles: UNIT_TEST_PROFILES_ZOSMF -// }); - - -// const response: IASAppResponse = { -// version: "0100", -// reused: false, -// timeout: false, -// servletKey: "JR897694-116-aabwaaak", -// queueID: "983068", -// tsoData: [ -// { VERSION: "0100", DATA: "HELLOW exec processing has started." }, -// { VERSION: "0100", DATA: "UNIX message queue id = 983068" }, -// { VERSION: "0100", DATA: "Input message type = 32772" }, -// { VERSION: "0100", DATA: "Output message type = 4" }, -// { VERSION: "0100", DATA: "Reading application input from the UNIX message queue." } -// ] -// }; - - -// describe("List systems behavior", () => { -// beforeEach(() => { -// }); - -// afterEach(() => { -// jest.resetAllMocks(); -// }); - -// it("", async () => { - -// }); -// }); +import { Session } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { StartTsoApp } from "../../src"; +import { StartTso } from "../../src"; +import { IStartStopResponses } from "../../src"; + +const PRETEND_SESSION = new Session({ + user: "usr", + password: "pasword", + hostname: "host.com", + port: 443, + type: "basic", + rejectUnauthorized: false +}); +const MOCK_RESPONSE: Promise = Promise.resolve({ + version: "0100", + reused: false, + timeout: false, + servletKey: "JR897694-123-aaaaaa", + queueID: "983068", + tsoData: [ + { "TSO MESSAGE": { VERSION: "0100", DATA: "HELLOW exec processing has started." } }, + { "TSO MESSAGE": { VERSION: "0100", DATA: "UNIX message queue id = 983068" } }, + { "TSO MESSAGE": { VERSION: "0100", DATA: "Input message type = 32772" } }, + { "TSO MESSAGE": { VERSION: "0100", DATA: "Output message type = 4" } }, + { "TSO MESSAGE": { VERSION: "0100", DATA: "Reading application input from the UNIX message queue." } } + ] +}); + +const MOCK_START_RESPONSE: Promise = Promise.resolve({ + collectedResponses: [], + messages: "IKJ56455I JR897694 LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", + servletKey: "JR897694-123-aaaaaa", + success: true, + zosmfTsoResponse: { + ver: "0100", + queueID: "983068", + reused: false, + servletKey: "JR897694-123-aaaaaa", + sessionID: "0x00", + timeout: false, + tsoData: [{}] + } +}); + +describe("StartTsoApp behavior", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it("should issue a TSO address space and start an application at that address space", async () => { + jest.spyOn(StartTso, "start").mockReturnValue(MOCK_START_RESPONSE); + jest.spyOn(ZosmfRestClient, "postExpectJSON").mockReturnValue(MOCK_RESPONSE); + + const response = await StartTsoApp.start(PRETEND_SESSION, "izuacct", { + startupCommand: "EXEC 'TEST.EXEC(THISSCRIPTDOESNOTEXIST)'", + appKey: "testappkey", + }, null); + + expect(StartTso.start).toHaveBeenCalled(); + expect(ZosmfRestClient.postExpectJSON).toHaveBeenCalledWith( + PRETEND_SESSION, + expect.stringContaining("/app/"), + expect.any(Array), + expect.objectContaining({ + startcmd: expect.stringContaining("THISSCRIPTDOESNOTEXIST") + }) + ); + expect(response).toMatchObject({ + servletKey: "JR897694-123-aaaaaa", + queueID: "983068", + tsoData: expect.arrayContaining([ + expect.objectContaining({ DATA: "HELLOW exec processing has started." }) + ]) + }); + }); + it("should start an application at a specified existing TSO address space", async () => { + jest.spyOn(StartTso, "start").mockReturnValue(MOCK_START_RESPONSE); + jest.spyOn(ZosmfRestClient, "postExpectJSON").mockReturnValue(MOCK_RESPONSE); + + const response = await StartTsoApp.start(PRETEND_SESSION, "izuacct", { + startupCommand: "EXEC 'TEST.EXEC(THISSCRIPTDOESNOTEXIST)'", + appKey: "testappkey", + queueID: "12345", + servletKey: "JR897694-123-aaaaaaaa" + }, null); + + expect(StartTso.start).not.toHaveBeenCalled(); + expect(ZosmfRestClient.postExpectJSON).toHaveBeenCalledWith( + PRETEND_SESSION, + expect.stringContaining("/app/"), + expect.any(Array), + expect.objectContaining({ + startcmd: expect.stringContaining("THISSCRIPTDOESNOTEXIST") + }) + ); + expect(response).toMatchObject({ + servletKey: "JR897694-123-aaaaaaaa", + queueID: "12345", + tsoData: expect.arrayContaining([ + expect.objectContaining({ DATA: "HELLOW exec processing has started." }) + ]) + }); + }); +}); From 7408f2c6e83dff645a3477b173e0d45aff7ef0c8 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 15 Oct 2024 08:40:22 -0400 Subject: [PATCH 023/106] send unit test Signed-off-by: jace-roell --- .../__unit__/SendTsoApp.unit.test.ts | 89 +++++++++++++++++++ .../__unit__/StartTsoApp.unit.test.ts | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts diff --git a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts new file mode 100644 index 0000000000..9d7b4e2830 --- /dev/null +++ b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts @@ -0,0 +1,89 @@ +/* + * 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 { Session } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { SendTsoApp } from "../../src"; +import { ITsoAppCommunicationParms } from "../../src/doc/input/ITsoAppCommunicationParms"; + +const PRETEND_SESSION = new Session({ + user: "usr", + password: "pasword", + hostname: "host.com", + port: 443, + type: "basic", + rejectUnauthorized: false, +}); + +const MOCK_START_RESPONSE = Promise.resolve({ + servletKey: "JR897694-127-aabeaaag", + ver: "0100", + tsoData: [ + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "HELLOW exec processing has started.", + }, + }, + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "UNIX message queue id = 1048608", + }, + }, + ], + reused: false, + timeout: false, +}); + +describe("SendTsoApp behavior", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it("should send a TSO application message and receive a response", async () => { + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue(MOCK_START_RESPONSE); + + const params: ITsoAppCommunicationParms = { + servletKey: "JR897694-127-aabeaaag", + appKey: "someAppKey", + message: "Test message", + }; + + const response = await SendTsoApp.send(PRETEND_SESSION, "123456", params, null); + + expect(ZosmfRestClient.putExpectJSON).toHaveBeenCalledWith( + PRETEND_SESSION, + `/zosmf/tsoApp/app/${params.servletKey}/${params.appKey}`, + [expect.any(String), "text/plain"], + params.message + ); + + expect(response).toEqual({ + version: "0100", + reused: false, + timeout: false, + servletKey: "JR897694-127-aabeaaag", + queueID: null, + tsoData: [ + { + VERSION: "0100", + DATA: "HELLOW exec processing has started.", + }, + { + VERSION: "0100", + DATA: "UNIX message queue id = 1048608", + }, + ], + }); + }); +}); diff --git a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts index 23ba08e274..f2e612ece7 100644 --- a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts @@ -12,7 +12,7 @@ const PRETEND_SESSION = new Session({ type: "basic", rejectUnauthorized: false }); -const MOCK_RESPONSE: Promise = Promise.resolve({ +const MOCK_RESPONSE = Promise.resolve({ version: "0100", reused: false, timeout: false, From 689be51ae9427271ab01d186cf58bd60eca98e4a Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 15 Oct 2024 09:30:19 -0400 Subject: [PATCH 024/106] receiveTsoApp unit tests Signed-off-by: jace-roell --- .../__unit__/ReceiveTsoApp.unit.test.ts | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts diff --git a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts new file mode 100644 index 0000000000..75cf4fdf82 --- /dev/null +++ b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts @@ -0,0 +1,155 @@ +/* + * 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 { Session } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { ReceiveTsoApp } from "../../src"; +import { ITsoAppCommunicationParms } from "../../src/doc/input/ITsoAppCommunicationParms"; +import { IASAppResponse } from "../../src/doc/IASAppResponse"; + +const PRETEND_SESSION = new Session({ + user: "usr", + password: "pasword", + hostname: "host.com", + port: 443, + type: "basic", + rejectUnauthorized: false, +}); + +const MOCK_RECEIVE_RESPONSE: any = { + version: undefined, + reused: false, + timeout: false, + servletKey: "JR897694-127-aabeaaag", + queueID: null, + tsoData: [ + { + "TSO MESSAGE": { VERSION: "0100", DATA: "Processing started." }, + }, + { + "TSO MESSAGE": { VERSION: "0100", DATA: "READY" }, + }, + ], +}; + +const MOCK_TIMEOUT_RESPONSE: any = { + version: undefined, + reused: false, + timeout: true, + servletKey: "JR897694-127-aabeaaag", + queueID: null, + tsoData: [], +}; + +describe("ReceiveTsoApp behavior", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it("should format a successful response to match expected syntax", async () => { + jest.spyOn(ZosmfRestClient, "getExpectJSON").mockResolvedValueOnce( + MOCK_RECEIVE_RESPONSE + ); + + const params: ITsoAppCommunicationParms = { + servletKey: "JR897694-127-aabeaaag", + appKey: "someAppKey", + timeout: 10, + receiveUntilReady: true, + }; + + const response = await ReceiveTsoApp.receive( + PRETEND_SESSION, + "123456", + params + ); + + expect(ZosmfRestClient.getExpectJSON).toHaveBeenCalledWith( + PRETEND_SESSION, + `/zosmf/tsoApp/app/${params.servletKey}/${params.appKey}` + ); + + expect(response).toEqual({ + version: undefined, + reused: false, + timeout: false, + servletKey: "JR897694-127-aabeaaag", + queueID: null, + tsoData: [ + { VERSION: "0100", DATA: "Processing started." }, + { VERSION: "0100", DATA: "READY" }, + ], + }); + }); + + it("should stop receiving when 'READY' keyword is detected", async () => { + jest.spyOn(ZosmfRestClient, "getExpectJSON").mockResolvedValueOnce( + MOCK_RECEIVE_RESPONSE + ); + + const params: ITsoAppCommunicationParms = { + servletKey: "JR897694-127-aabeaaag", + appKey: "someAppKey", + timeout: 10, + receiveUntilReady: true, + }; + + const response = await ReceiveTsoApp.receive( + PRETEND_SESSION, + "123456", + params + ); + + expect(ZosmfRestClient.getExpectJSON).toHaveBeenCalledTimes(1); // Should only call once + expect( + response.tsoData.some((data) => data.DATA === "READY") + ).toBeTruthy(); + }); + + it("should handle timeout by returning a partial response if timeout occurs", async () => { + jest.spyOn(ZosmfRestClient, "getExpectJSON").mockResolvedValueOnce( + MOCK_TIMEOUT_RESPONSE + ); + + const params: ITsoAppCommunicationParms = { + servletKey: "JR897694-127-aabeaaag", + appKey: "someAppKey", + timeout: 1, + receiveUntilReady: true, + }; + + const response = await ReceiveTsoApp.receive( + PRETEND_SESSION, + "123456", + params + ); + + expect(response).toEqual(MOCK_TIMEOUT_RESPONSE); + expect(response.timeout).toBe(true); + }); + + it("should throw an error if an error occurs and no partial response is available", async () => { + jest.spyOn(ZosmfRestClient, "getExpectJSON").mockRejectedValueOnce( + new Error("Network error") + ); + + const params: ITsoAppCommunicationParms = { + servletKey: "JR897694-127-aabeaaag", + appKey: "someAppKey", + timeout: 10, + receiveUntilReady: true, + }; + + await expect( + ReceiveTsoApp.receive(PRETEND_SESSION, "123456", params) + ).rejects.toThrow("Network error"); + }); +}); From 11b1209f4e681f8c9ac545dd14094f4bd78ea3dc Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 15 Oct 2024 09:58:30 -0400 Subject: [PATCH 025/106] receive test for code coverage Signed-off-by: jace-roell --- .../__unit__/ReceiveTsoApp.unit.test.ts | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts index 75cf4fdf82..6162b4f641 100644 --- a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts @@ -152,4 +152,54 @@ describe("ReceiveTsoApp behavior", () => { ReceiveTsoApp.receive(PRETEND_SESSION, "123456", params) ).rejects.toThrow("Network error"); }); + + it("should append multiple responses to combinedResponse.tsoData", async () => { + // Mock the first response without "READY" to simulate multiple API calls + const mockResponse1: any = { + version: "0100", + reused: false, + timeout: false, + servletKey: "JR897694-127-aabeaaag", + queueID: null, + tsoData: [{"TSO MESSAGE":{ VERSION: "0100", DATA: "First response data." }}], + }; + + // Mock the second response containing "READY" to trigger stopping condition + const mockResponse2: any = { + version: "0100", + reused: false, + timeout: false, + servletKey: "JR897694-127-aabeaaag", + queueID: null, + tsoData: [ + {"TSO MESSAGE":{ VERSION: "0100", DATA: "Second response data." }}, + {"TSO MESSAGE":{ VERSION: "0100", DATA: "READY" }} + ], + }; + + // Set up mock to return these responses in sequence + jest.spyOn(ZosmfRestClient, "getExpectJSON") + .mockResolvedValueOnce(mockResponse1) // First call + .mockResolvedValueOnce(mockResponse2); // Second call + + const params: ITsoAppCommunicationParms = { + servletKey: "JR897694-127-aabeaaag", + appKey: "someAppKey", + timeout: 10, + receiveUntilReady: true, + }; + + const response = await ReceiveTsoApp.receive( + PRETEND_SESSION, + "123456", + params + ); + + expect(response.tsoData).toEqual([ + { VERSION: "0100", DATA: "First response data." }, + { VERSION: "0100", DATA: "Second response data." }, + { VERSION: "0100", DATA: "READY" }, + ]); + expect(ZosmfRestClient.getExpectJSON).toHaveBeenCalledTimes(2); // Two calls due to no "READY" in the first response + }); }); From 92fce343670181f8b6a95d43484d9f04910d5ff5 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 15 Oct 2024 15:47:27 -0400 Subject: [PATCH 026/106] receive test folder and definition, handler test files, receive test file, revisions Signed-off-by: jace-roell --- .../receive/Receive.definition.unit.test.ts | 22 ++++ .../Receive.definition.unit.test.ts.snap | 13 +++ .../app/ReceiveASApp.handler.unit.test.ts | 86 +++++++++++++++ .../send/app/SendASApp.handler.unit.test.ts | 92 ++++++++++++++++ .../start/app/StartASApp.handler.test.ts | 101 ++++++++++++++++++ .../__unit__/ReceiveTsoApp.unit.test.ts | 1 - .../__unit__/SendTsoApp.unit.test.ts | 14 ++- 7 files changed, 324 insertions(+), 5 deletions(-) create mode 100644 packages/cli/__tests__/zostso/__unit__/receive/Receive.definition.unit.test.ts create mode 100644 packages/cli/__tests__/zostso/__unit__/receive/__snapshots__/Receive.definition.unit.test.ts.snap create mode 100644 packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts create mode 100644 packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts create mode 100644 packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.test.ts diff --git a/packages/cli/__tests__/zostso/__unit__/receive/Receive.definition.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/Receive.definition.unit.test.ts new file mode 100644 index 0000000000..633ed85317 --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/receive/Receive.definition.unit.test.ts @@ -0,0 +1,22 @@ +/* +* 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 { ICommandDefinition } from "@zowe/imperative"; + +describe("zos-tso receieve group definition", () => { + it("should not have changed", () => { + const definition: ICommandDefinition = require("../../../../src/zostso/receive/Receive.definition").ReceiveCommand; + expect(definition).toBeDefined(); + expect(definition.children.length).toBe(1); + delete definition.children; + expect(definition).toMatchSnapshot(); + }); +}); diff --git a/packages/cli/__tests__/zostso/__unit__/receive/__snapshots__/Receive.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/receive/__snapshots__/Receive.definition.unit.test.ts.snap new file mode 100644 index 0000000000..ec88ec58a0 --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/receive/__snapshots__/Receive.definition.unit.test.ts.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`zos-tso receieve group definition should not have changed 1`] = ` +Object { + "aliases": Array [ + "r", + ], + "description": "Receieve message from TSO address space app", + "name": "receieve", + "summary": "Receieve message from TSO address space app", + "type": "group", +} +`; diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts new file mode 100644 index 0000000000..3b12bd3238 --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts @@ -0,0 +1,86 @@ +/* + * 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 { Session } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { IASAppResponse } from "@zowe/zos-tso-for-zowe-sdk/src/doc/IASAppResponse"; +import { ReceiveTsoApp, SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { ITsoAppCommunicationParms } from "@zowe/zos-tso-for-zowe-sdk/src/doc/input/ITsoAppCommunicationParms"; + +const PRETEND_SESSION = new Session({ + user: "usr", + password: "pasword", + hostname: "host.com", + port: 443, + type: "basic", + rejectUnauthorized: false, +}); + +const MOCK_RECEIVE_RESPONSE: any = { + version: undefined, + reused: false, + timeout: false, + servletKey: "JR897694-127-aabeaaag", + queueID: null, + tsoData: [ + { + "TSO MESSAGE": { VERSION: "0100", DATA: "Processing started." }, + }, + { + "TSO MESSAGE": { VERSION: "0100", DATA: "READY" }, + }, + ], +}; + +const params: ITsoAppCommunicationParms = { + servletKey: "JR897694-127-aabeaaag", + appKey: "someAppKey", + message: "Test message", +}; + +describe("receive TSO app handler behavior", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it("should properly receive and parse data from receive TSO response", async () => { + jest.spyOn(ZosmfRestClient, "getExpectJSON").mockResolvedValueOnce( + MOCK_RECEIVE_RESPONSE + ); + let response = undefined; + let error = undefined; + try{ + response = await ReceiveTsoApp.receive( + PRETEND_SESSION, + "123456", + params + ); + } + catch(e) + { + error = e; + } + expect(error).toBeUndefined(); + expect(response).toBeDefined(); + expect(response.tsoData.length).toEqual(2); + }); +}); diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts new file mode 100644 index 0000000000..f31383027f --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts @@ -0,0 +1,92 @@ +/* + * 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 { Session } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { IASAppResponse } from "@zowe/zos-tso-for-zowe-sdk/src/doc/IASAppResponse"; +import { SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { ITsoAppCommunicationParms } from "@zowe/zos-tso-for-zowe-sdk/src/doc/input/ITsoAppCommunicationParms"; + +const PRETEND_SESSION = new Session({ + user: "usr", + password: "pasword", + hostname: "host.com", + port: 443, + type: "basic", + rejectUnauthorized: false, +}); + +const MOCK_SEND_RESPONSE = Promise.resolve({ + servletKey: "JR897694-127-aabeaaag", + ver: "0100", + tsoData: [ + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "HELLOW exec processing has started.", + }, + }, + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "UNIX message queue id = 1048608", + }, + }, + ], + reused: false, + timeout: false, +}); + +const params: ITsoAppCommunicationParms = { + servletKey: "JR897694-127-aabeaaag", + appKey: "someAppKey", + message: "Test message", +}; + +describe("send TSO app handler behavior", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it("should properly receive and parse data from send TSO response", async () => { + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue( + MOCK_SEND_RESPONSE + ); + let response = undefined; + let error = undefined; + try{ + response = await SendTsoApp.send( + PRETEND_SESSION, + "123456", + params, + null + ); + } + catch(e) + { + error = e; + } + expect(error).toBeUndefined(); + expect(response).toBeDefined(); + expect(response.tsoData.length).toEqual(2); + }); +}); diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.test.ts b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.test.ts new file mode 100644 index 0000000000..ffa32623ee --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.test.ts @@ -0,0 +1,101 @@ +/* + * 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 { Session } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { StartTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { IASAppResponse } from "@zowe/zos-tso-for-zowe-sdk/src/doc/IASAppResponse"; + +const PRETEND_SESSION = new Session({ + user: "usr", + password: "pasword", + hostname: "host.com", + port: 443, + type: "basic", + rejectUnauthorized: false, +}); + +const MOCK_RESPONSE = Promise.resolve({ + version: "0100", + reused: false, + timeout: false, + servletKey: "JR897694-123-aaaaaa", + queueID: "983068", + tsoData: [ + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "HELLOW exec processing has started.", + }, + }, + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "UNIX message queue id = 983068", + }, + }, + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "Input message type = 32772", + }, + }, + { "TSO MESSAGE": { VERSION: "0100", DATA: "Output message type = 4" } }, + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "Reading application input from the UNIX message queue.", + }, + }, + ], +}); +describe("start TSO app handler behavior", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it("should return mocked value and validate tso data", async () => { + jest.spyOn(ZosmfRestClient, "postExpectJSON").mockReturnValue( + MOCK_RESPONSE + ); + let response = undefined; + let error = undefined; + try { + response = await StartTsoApp.start( + PRETEND_SESSION, + "izuacct", + { + startupCommand: "EXEC 'TEST.EXEC(THISSCRIPTDOESNOTEXIST)'", + appKey: "testappkey", + queueID: "12345", + servletKey: "JR897694-123-aaaaaaaa", + }, + null + ); + } catch (e) { + error = e; + } + expect(error).toBeUndefined(); + expect(response).toBeDefined(); + expect(response.tsoData.length).toEqual(5); + }); +}); diff --git a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts index 6162b4f641..2bbe4d5c79 100644 --- a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts @@ -13,7 +13,6 @@ import { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { ReceiveTsoApp } from "../../src"; import { ITsoAppCommunicationParms } from "../../src/doc/input/ITsoAppCommunicationParms"; -import { IASAppResponse } from "../../src/doc/IASAppResponse"; const PRETEND_SESSION = new Session({ user: "usr", diff --git a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts index 9d7b4e2830..fef87fcbc1 100644 --- a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts @@ -9,7 +9,6 @@ * */ - import { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { SendTsoApp } from "../../src"; @@ -24,7 +23,7 @@ const PRETEND_SESSION = new Session({ rejectUnauthorized: false, }); -const MOCK_START_RESPONSE = Promise.resolve({ +const MOCK_SEND_RESPONSE = Promise.resolve({ servletKey: "JR897694-127-aabeaaag", ver: "0100", tsoData: [ @@ -51,7 +50,9 @@ describe("SendTsoApp behavior", () => { }); it("should send a TSO application message and receive a response", async () => { - jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue(MOCK_START_RESPONSE); + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue( + MOCK_SEND_RESPONSE + ); const params: ITsoAppCommunicationParms = { servletKey: "JR897694-127-aabeaaag", @@ -59,7 +60,12 @@ describe("SendTsoApp behavior", () => { message: "Test message", }; - const response = await SendTsoApp.send(PRETEND_SESSION, "123456", params, null); + const response = await SendTsoApp.send( + PRETEND_SESSION, + "123456", + params, + null + ); expect(ZosmfRestClient.putExpectJSON).toHaveBeenCalledWith( PRETEND_SESSION, From 2ee9f93c23aa1fd4e2f803ad74883d5d0ba86483 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 16 Oct 2024 10:10:34 -0400 Subject: [PATCH 027/106] fixed handler tests, command group related unit tests Signed-off-by: jace-roell --- .../__unit__/ZosTso.definition.unit.test.ts | 2 +- .../app/ReceiveASApp.handler.unit.test.ts | 55 ++---- .../ReceiveASApp.handler.unit.test.ts.snap | 30 ++++ .../send/Send.definition.unit.test.ts | 2 +- .../send/app/SendASApp.handler.unit.test.ts | 58 ++----- .../SendASApp.handler.unit.test.ts.snap | 21 +++ .../start/Start.definition.unit.test.ts | 2 +- .../start/app/StartASApp.handler.test.ts | 101 ------------ .../start/app/StartASApp.handler.unit.test.ts | 156 ++++++++++++++++++ .../StartASApp.handler.unit.test.ts.snap | 63 +++++++ .../src/zostso/receive/Receive.definition.ts | 2 +- .../ReceiveASApp.definition.ts | 0 .../ReceiveASApp.handler.ts | 0 .../cli/src/zostso/send/Send.definition.ts | 2 +- .../{as-app => }/SendASApp.definition.ts | 0 .../as-app/{as-app => }/SendASApp.handler.ts | 22 +-- 16 files changed, 322 insertions(+), 194 deletions(-) create mode 100644 packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap create mode 100644 packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap delete mode 100644 packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.test.ts create mode 100644 packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts create mode 100644 packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap rename packages/cli/src/zostso/receive/{address-space => app}/ReceiveASApp.definition.ts (100%) rename packages/cli/src/zostso/receive/{address-space => app}/ReceiveASApp.handler.ts (100%) rename packages/cli/src/zostso/send/as-app/{as-app => }/SendASApp.definition.ts (100%) rename packages/cli/src/zostso/send/as-app/{as-app => }/SendASApp.handler.ts (66%) diff --git a/packages/cli/__tests__/zostso/__unit__/ZosTso.definition.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/ZosTso.definition.unit.test.ts index a6f099ca60..80dcbc0034 100644 --- a/packages/cli/__tests__/zostso/__unit__/ZosTso.definition.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/ZosTso.definition.unit.test.ts @@ -13,7 +13,7 @@ import { ICommandDefinition } from "@zowe/imperative"; describe("zos-tso group definition", () => { it("should not have changed", () => { - const CHILDREN = 5; + const CHILDREN = 6; const definition: ICommandDefinition = require("../../../src/zostso/ZosTso.definition"); expect(definition).toBeDefined(); expect(definition.children.length).toBe(CHILDREN); diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts index 3b12bd3238..fd9193da57 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts @@ -9,37 +9,24 @@ * */ -/* - * 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 { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { IASAppResponse } from "@zowe/zos-tso-for-zowe-sdk/src/doc/IASAppResponse"; -import { ReceiveTsoApp, SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; -import { ITsoAppCommunicationParms } from "@zowe/zos-tso-for-zowe-sdk/src/doc/input/ITsoAppCommunicationParms"; +import { ReceiveTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import * as ReceiveASAppHandler from "../../../../../src/zostso/receive/app/ReceiveASApp.handler"; +import * as ReceiveASAppDefinition from "../../../../../src/zostso/receive/app/ReceiveASApp.definition"; +import { IHandlerParameters } from "@zowe/imperative"; +import { mockHandlerParameters } from "@zowe/cli-test-utils"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; -const PRETEND_SESSION = new Session({ - user: "usr", - password: "pasword", - hostname: "host.com", - port: 443, - type: "basic", - rejectUnauthorized: false, +const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ + arguments: UNIT_TEST_ZOSMF_PROF_OPTS, + positionals: ["zos-tso","r","app"], + definition: ReceiveASAppDefinition.ReceiveASApp }); - const MOCK_RECEIVE_RESPONSE: any = { version: undefined, reused: false, timeout: false, - servletKey: "JR897694-127-aabeaaag", + servletKey: "JR897694-122-aabyaaaj", queueID: null, tsoData: [ { @@ -51,12 +38,6 @@ const MOCK_RECEIVE_RESPONSE: any = { ], }; -const params: ITsoAppCommunicationParms = { - servletKey: "JR897694-127-aabeaaag", - appKey: "someAppKey", - message: "Test message", -}; - describe("receive TSO app handler behavior", () => { beforeEach(() => { jest.clearAllMocks(); @@ -66,21 +47,19 @@ describe("receive TSO app handler behavior", () => { jest.spyOn(ZosmfRestClient, "getExpectJSON").mockResolvedValueOnce( MOCK_RECEIVE_RESPONSE ); - let response = undefined; + const receiveSpy = jest.spyOn(ReceiveTsoApp,"receive"); + const handler = new ReceiveASAppHandler.default(); + const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); let error = undefined; + params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "JR897694-122-aabyaaaj", runUntilReady: true}; try{ - response = await ReceiveTsoApp.receive( - PRETEND_SESSION, - "123456", - params - ); + await handler.process(params); } catch(e) { error = e; } expect(error).toBeUndefined(); - expect(response).toBeDefined(); - expect(response.tsoData.length).toEqual(2); + expect(receiveSpy).toHaveBeenCalledTimes(1); }); }); diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap new file mode 100644 index 0000000000..660ac20308 --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap @@ -0,0 +1,30 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 1`] = ` +" +" +`; + +exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 2`] = `"Processing started."`; + +exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 3`] = `"READY"`; + +exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 4`] = ` +Object { + "queueID": null, + "reused": false, + "servletKey": "JR897694-122-aabyaaaj", + "timeout": false, + "tsoData": Array [ + Object { + "DATA": "Processing started.", + "VERSION": "0100", + }, + Object { + "DATA": "READY", + "VERSION": "0100", + }, + ], + "version": undefined, +} +`; diff --git a/packages/cli/__tests__/zostso/__unit__/send/Send.definition.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/send/Send.definition.unit.test.ts index 9272a3ec33..119a5ff9b8 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/Send.definition.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/send/Send.definition.unit.test.ts @@ -15,7 +15,7 @@ describe("zos-tso send group definition", () => { it("should not have changed", () => { const definition: ICommandDefinition = require("../../../../src/zostso/send/Send.definition").SendCommand; expect(definition).toBeDefined(); - expect(definition.children.length).toBe(1); + expect(definition.children.length).toBe(2); delete definition.children; expect(definition).toMatchSnapshot(); }); diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts index f31383027f..574c38378b 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts @@ -9,32 +9,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. - * - */ - -import { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { IASAppResponse } from "@zowe/zos-tso-for-zowe-sdk/src/doc/IASAppResponse"; import { SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; -import { ITsoAppCommunicationParms } from "@zowe/zos-tso-for-zowe-sdk/src/doc/input/ITsoAppCommunicationParms"; +import * as SendASAppHandler from "../../../../../src/zostso/send/as-app/SendASApp.handler"; +import * as SendASAppDefinition from "../../../../../src/zostso/send/as-app/SendASApp.definition"; +import { IHandlerParameters } from "@zowe/imperative"; +import { mockHandlerParameters } from "@zowe/cli-test-utils"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; -const PRETEND_SESSION = new Session({ - user: "usr", - password: "pasword", - hostname: "host.com", - port: 443, - type: "basic", - rejectUnauthorized: false, +const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ + arguments: UNIT_TEST_ZOSMF_PROF_OPTS, + positionals: ["zos-tso","send","app","--app-key","test2"], + definition: SendASAppDefinition.SendASApp }); - const MOCK_SEND_RESPONSE = Promise.resolve({ servletKey: "JR897694-127-aabeaaag", ver: "0100", @@ -56,37 +43,28 @@ const MOCK_SEND_RESPONSE = Promise.resolve({ timeout: false, }); -const params: ITsoAppCommunicationParms = { - servletKey: "JR897694-127-aabeaaag", - appKey: "someAppKey", - message: "Test message", -}; - -describe("send TSO app handler behavior", () => { +describe("receive TSO app handler behavior", () => { beforeEach(() => { jest.clearAllMocks(); }); - it("should properly receive and parse data from send TSO response", async () => { - jest.spyOn(ZosmfRestClient, "putExpectJSON").mockReturnValue( + it("should properly receive and parse data from receive TSO response", async () => { + jest.spyOn(ZosmfRestClient, "putExpectJSON").mockResolvedValueOnce( MOCK_SEND_RESPONSE ); - let response = undefined; + const sendSpy = jest.spyOn(SendTsoApp,"send"); + const handler = new SendASAppHandler.default(); + const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); let error = undefined; + params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "JR897694-129-aaceaaap", message: "LONG 100"}; try{ - response = await SendTsoApp.send( - PRETEND_SESSION, - "123456", - params, - null - ); + await handler.process(params); } catch(e) { error = e; } expect(error).toBeUndefined(); - expect(response).toBeDefined(); - expect(response.tsoData.length).toEqual(2); + expect(sendSpy).toHaveBeenCalledTimes(1); }); }); diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap new file mode 100644 index 0000000000..364a1bf59d --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`receive TSO app handler behavior should properly receive and parse data from receive TSO response 1`] = ` +"{ + \\"version\\": \\"0100\\", + \\"reused\\": false, + \\"timeout\\": false, + \\"servletKey\\": \\"JR897694-127-aabeaaag\\", + \\"queueID\\": null, + \\"tsoData\\": [ + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"HELLOW exec processing has started.\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"UNIX message queue id = 1048608\\" + } + ] +}" +`; diff --git a/packages/cli/__tests__/zostso/__unit__/start/Start.definition.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/start/Start.definition.unit.test.ts index 8e62ed0856..e0ce1f037e 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/Start.definition.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/start/Start.definition.unit.test.ts @@ -15,7 +15,7 @@ describe("zos-tso start group definition", () => { it("should not have changed", () => { const definition: ICommandDefinition = require("../../../../src/zostso/start/Start.definition").StartCommand; expect(definition).toBeDefined(); - expect(definition.children.length).toBe(1); + expect(definition.children.length).toBe(2); delete definition.children; expect(definition).toMatchSnapshot(); }); diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.test.ts b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.test.ts deleted file mode 100644 index ffa32623ee..0000000000 --- a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.test.ts +++ /dev/null @@ -1,101 +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. - * - */ - -/* - * 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 { Session } from "@zowe/imperative"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { StartTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; -import { IASAppResponse } from "@zowe/zos-tso-for-zowe-sdk/src/doc/IASAppResponse"; - -const PRETEND_SESSION = new Session({ - user: "usr", - password: "pasword", - hostname: "host.com", - port: 443, - type: "basic", - rejectUnauthorized: false, -}); - -const MOCK_RESPONSE = Promise.resolve({ - version: "0100", - reused: false, - timeout: false, - servletKey: "JR897694-123-aaaaaa", - queueID: "983068", - tsoData: [ - { - "TSO MESSAGE": { - VERSION: "0100", - DATA: "HELLOW exec processing has started.", - }, - }, - { - "TSO MESSAGE": { - VERSION: "0100", - DATA: "UNIX message queue id = 983068", - }, - }, - { - "TSO MESSAGE": { - VERSION: "0100", - DATA: "Input message type = 32772", - }, - }, - { "TSO MESSAGE": { VERSION: "0100", DATA: "Output message type = 4" } }, - { - "TSO MESSAGE": { - VERSION: "0100", - DATA: "Reading application input from the UNIX message queue.", - }, - }, - ], -}); -describe("start TSO app handler behavior", () => { - beforeEach(() => { - jest.clearAllMocks(); - }); - - it("should return mocked value and validate tso data", async () => { - jest.spyOn(ZosmfRestClient, "postExpectJSON").mockReturnValue( - MOCK_RESPONSE - ); - let response = undefined; - let error = undefined; - try { - response = await StartTsoApp.start( - PRETEND_SESSION, - "izuacct", - { - startupCommand: "EXEC 'TEST.EXEC(THISSCRIPTDOESNOTEXIST)'", - appKey: "testappkey", - queueID: "12345", - servletKey: "JR897694-123-aaaaaaaa", - }, - null - ); - } catch (e) { - error = e; - } - expect(error).toBeUndefined(); - expect(response).toBeDefined(); - expect(response.tsoData.length).toEqual(5); - }); -}); diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts new file mode 100644 index 0000000000..20424a1e50 --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts @@ -0,0 +1,156 @@ +/* + * 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 { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { StartTso, StartTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import * as StartASAppHandler from "../../../../../src/zostso/start/as-app/StartASApp.handler"; +import * as StartASAppDefinition from "../../../../../src/zostso/start/as-app/StartASApp.definition"; +import { IHandlerParameters } from "@zowe/imperative"; +import { mockHandlerParameters } from "@zowe/cli-test-utils"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; +import { IStartStopResponses } from "@zowe/zos-tso-for-zowe-sdk"; + +const NEW_AS_SPACE_PARAMS: IHandlerParameters = mockHandlerParameters({ + arguments: UNIT_TEST_ZOSMF_PROF_OPTS, + positionals: ["zos-tso", "start", "app"], + definition: StartASAppDefinition.StartASApp, +}); +const EXISTING_AS_SPACE_PARAMS: IHandlerParameters = mockHandlerParameters({ + arguments: UNIT_TEST_ZOSMF_PROF_OPTS, + positionals: ["zos-tso", "start", "app"], + definition: StartASAppDefinition.StartASApp, +}); +const MOCK_RESPONSE = Promise.resolve({ + version: "0100", + reused: false, + timeout: false, + servletKey: "JR897694-123-aaaaaa", + queueID: "983068", + tsoData: [ + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "HELLOW exec processing has started.", + }, + }, + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "UNIX message queue id = 983068", + }, + }, + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "Input message type = 32772", + }, + }, + { "TSO MESSAGE": { VERSION: "0100", DATA: "Output message type = 4" } }, + { + "TSO MESSAGE": { + VERSION: "0100", + DATA: "Reading application input from the UNIX message queue.", + }, + }, + ], +}); + +const MOCK_START_RESPONSE: Promise = Promise.resolve({ + collectedResponses: [], + messages: + "IKJ56455I JR897694 LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", + servletKey: "JR897694-123-aaaaaa", + success: true, + zosmfTsoResponse: { + ver: "0100", + queueID: "983068", + reused: false, + servletKey: "JR897694-123-aaaaaa", + sessionID: "0x00", + timeout: false, + tsoData: [{}], + }, +}); +describe("receive TSO app handler behavior", () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it("should properly start TSO address space and run an application at the created address space", async () => { + jest.spyOn(StartTso, "start").mockReturnValue(MOCK_START_RESPONSE); + jest.spyOn(ZosmfRestClient, "postExpectJSON").mockReturnValue( + MOCK_RESPONSE + ); + + const startSpy = jest.spyOn(StartTsoApp, "start"); + const startASSpaceSpy = jest.spyOn(StartTso, "start"); + const zosmfSpy = jest.spyOn(ZosmfRestClient, "postExpectJSON"); + const handler = new StartASAppHandler.default(); + const params = Object.assign({}, ...[NEW_AS_SPACE_PARAMS]); + let error = undefined; + params.arguments = { + ...params.arguments, + account: "izuacct", + startup: "EXEC 'CUST009.PUBLIC.REXX(VAREXX)'", + appKey: "test2", + }; + try { + await handler.process(params); + } catch (e) { + error = e; + } + expect(error).toBeUndefined(); + expect(startSpy).toHaveBeenCalledTimes(1); + expect(startASSpaceSpy).toHaveBeenCalledTimes(1); + expect(zosmfSpy).toHaveBeenCalledTimes(1); + }); + it("should properly start TSO address space at an existing TSO address space", async () => { + jest.spyOn(StartTso, "start").mockReturnValue(MOCK_START_RESPONSE); + jest.spyOn(ZosmfRestClient, "postExpectJSON").mockReturnValue( + MOCK_RESPONSE + ); + + const startSpy = jest.spyOn(StartTsoApp, "start"); + const startASSpaceSpy = jest.spyOn(StartTso, "start"); + const zosmfSpy = jest.spyOn(ZosmfRestClient, "postExpectJSON"); + const handler = new StartASAppHandler.default(); + const params = Object.assign({}, ...[EXISTING_AS_SPACE_PARAMS]); + let error = undefined; + params.arguments = { + ...params.arguments, + account: "izuacct", + startup: "EXEC 'CUST009.PUBLIC.REXX(VAREXX)'", + queueId: "983068", + servletKey: "JR897694-123-aaaaaa", + appKey: "test2", + }; + try { + await handler.process(params); + } catch (e) { + error = e; + } + expect(error).toBeUndefined(); + expect(startSpy).toHaveBeenCalledTimes(1); + expect(startASSpaceSpy).toHaveBeenCalledTimes(0); + expect(zosmfSpy).toHaveBeenCalledTimes(1); + }); +}); diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap new file mode 100644 index 0000000000..e41de0a8af --- /dev/null +++ b/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap @@ -0,0 +1,63 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`receive TSO app handler behavior should properly start TSO address space and run an application at the created address space 1`] = ` +"{ + \\"reused\\": false, + \\"timeout\\": false, + \\"servletKey\\": \\"JR897694-123-aaaaaa\\", + \\"queueID\\": \\"983068\\", + \\"tsoData\\": [ + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"HELLOW exec processing has started.\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"UNIX message queue id = 983068\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"Input message type = 32772\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"Output message type = 4\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"Reading application input from the UNIX message queue.\\" + } + ] +}" +`; + +exports[`receive TSO app handler behavior should properly start TSO address space at an existing TSO address space 1`] = ` +"{ + \\"reused\\": false, + \\"timeout\\": false, + \\"servletKey\\": \\"JR897694-123-aaaaaa\\", + \\"queueID\\": \\"983068\\", + \\"tsoData\\": [ + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"HELLOW exec processing has started.\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"UNIX message queue id = 983068\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"Input message type = 32772\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"Output message type = 4\\" + }, + { + \\"VERSION\\": \\"0100\\", + \\"DATA\\": \\"Reading application input from the UNIX message queue.\\" + } + ] +}" +`; diff --git a/packages/cli/src/zostso/receive/Receive.definition.ts b/packages/cli/src/zostso/receive/Receive.definition.ts index 269cc24e64..de01532863 100644 --- a/packages/cli/src/zostso/receive/Receive.definition.ts +++ b/packages/cli/src/zostso/receive/Receive.definition.ts @@ -10,7 +10,7 @@ */ import { ICommandDefinition } from "@zowe/imperative"; -import { ReceiveASApp } from "./address-space/ReceiveASApp.definition"; +import { ReceiveASApp } from "./app/ReceiveASApp.definition"; export const ReceiveCommand: ICommandDefinition = { name: "receieve", diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts b/packages/cli/src/zostso/receive/app/ReceiveASApp.definition.ts similarity index 100% rename from packages/cli/src/zostso/receive/address-space/ReceiveASApp.definition.ts rename to packages/cli/src/zostso/receive/app/ReceiveASApp.definition.ts diff --git a/packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts similarity index 100% rename from packages/cli/src/zostso/receive/address-space/ReceiveASApp.handler.ts rename to packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts diff --git a/packages/cli/src/zostso/send/Send.definition.ts b/packages/cli/src/zostso/send/Send.definition.ts index 205e1c4d8c..f521ab605c 100644 --- a/packages/cli/src/zostso/send/Send.definition.ts +++ b/packages/cli/src/zostso/send/Send.definition.ts @@ -13,7 +13,7 @@ import { ICommandDefinition } from "@zowe/imperative"; import { SendToAddressSpaceCommandDefinition } from "./address_space/SendToAddressSpace.definition"; -import { SendASApp } from "./as-app/as-app/SendASApp.definition"; +import { SendASApp } from "./as-app/SendASApp.definition"; export const SendCommand: ICommandDefinition = { name: "send", diff --git a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.definition.ts b/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts similarity index 100% rename from packages/cli/src/zostso/send/as-app/as-app/SendASApp.definition.ts rename to packages/cli/src/zostso/send/as-app/SendASApp.definition.ts diff --git a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts similarity index 66% rename from packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts rename to packages/cli/src/zostso/send/as-app/SendASApp.handler.ts index f644013e70..27befd7b8b 100644 --- a/packages/cli/src/zostso/send/as-app/as-app/SendASApp.handler.ts +++ b/packages/cli/src/zostso/send/as-app/SendASApp.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 { ZosTsoBaseHandler, SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; @@ -31,6 +31,8 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); - commandParameters.response.console.log(JSON.stringify(response,null,2)); + commandParameters.response.console.log( + JSON.stringify(response, null, 2) + ); } } From d96d688a3b8af00d17fbe667085fdc665b8ea78d Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 16 Oct 2024 11:43:10 -0400 Subject: [PATCH 028/106] integration test updates Signed-off-by: jace-roell --- .../cli.zos-tso.integration.test.ts.snap | 15 ++++++++------- .../root/cli.zos-tso.integration.test.ts | 2 +- .../cli.zos-tso.send.integration.test.ts.snap | 7 ++++--- .../cli.zos-tso.start.integration.test.ts.snap | 7 ++++--- .../start/cli.zos-tso.start.integration.test.ts | 4 ++-- packages/zostso/src/ReceiveTsoApp.ts | 1 - 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/cli/__tests__/zostso/__integration__/root/__snapshots__/cli.zos-tso.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/root/__snapshots__/cli.zos-tso.integration.test.ts.snap index be8a0738b8..11230b5709 100644 --- a/packages/cli/__tests__/zostso/__integration__/root/__snapshots__/cli.zos-tso.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/root/__snapshots__/cli.zos-tso.integration.test.ts.snap @@ -17,11 +17,12 @@ exports[`zos-tso should display the help 1`] = ` GROUPS ------ - issue Issue TSO commands - ping Ping a TSO address space - send Send data to TSO - start | st Start TSO/E address space - stop | sp Stop TSO/E address space + issue Issue TSO commands + ping Ping a TSO address space + receieve | r Receieve message from TSO address space app + send Send data to TSO + start | st Start TSO/E address space + stop | sp Stop TSO/E address space GLOBAL OPTIONS -------------- @@ -46,8 +47,8 @@ exports[`zos-tso should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: zos-tso.\\", - \\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso \\\\n\\\\n Where is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n send Send data to TSO \\\\n start | st Start TSO/E address space\\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\", + \\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso \\\\n\\\\n Where is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n receieve | r Receieve message from TSO address space app\\\\n send Send data to TSO \\\\n start | st Start TSO/E address space \\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso \\\\n\\\\n Where is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n send Send data to TSO \\\\n start | st Start TSO/E address space\\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\" + \\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso \\\\n\\\\n Where is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n receieve | r Receieve message from TSO address space app\\\\n send Send data to TSO \\\\n start | st Start TSO/E address space \\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\" }" `; diff --git a/packages/cli/__tests__/zostso/__integration__/root/cli.zos-tso.integration.test.ts b/packages/cli/__tests__/zostso/__integration__/root/cli.zos-tso.integration.test.ts index 75a1fb62dc..9bb895c171 100644 --- a/packages/cli/__tests__/zostso/__integration__/root/cli.zos-tso.integration.test.ts +++ b/packages/cli/__tests__/zostso/__integration__/root/cli.zos-tso.integration.test.ts @@ -50,7 +50,7 @@ describe("zos-tso", () => { expect(response.stdout.toString()).toBe(""); expect(response.stderr.toString()).toContain('Unknown arguments: not-valid-option, notValidOption'); expect(response.stderr.toString()).toContain('Command failed due to improper syntax'); - expect(response.stderr.toString()).toContain('Did you mean: zos-tso start'); + expect(response.stderr.toString()).toContain('Did you mean: zos-tso send app'); expect(response.stderr.toString()).toContain('Command entered: "zos-tso --not-valid-option"'); expect(response.stderr.toString()).toContain('Use "zowe zos-tso --help" to view groups, commands, and options.'); }); diff --git a/packages/cli/__tests__/zostso/__integration__/send/__snapshots__/cli.zos-tso.send.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/send/__snapshots__/cli.zos-tso.send.integration.test.ts.snap index 5ec94b307f..583114ba18 100644 --- a/packages/cli/__tests__/zostso/__integration__/send/__snapshots__/cli.zos-tso.send.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/send/__snapshots__/cli.zos-tso.send.integration.test.ts.snap @@ -17,7 +17,8 @@ exports[`zos-tso send should display the help 1`] = ` COMMANDS -------- - address-space | as Send data to a TSO address space + address-space | as Send data to a TSO address space + app | a Send message to an application at a TSO address space GLOBAL OPTIONS -------------- @@ -42,8 +43,8 @@ exports[`zos-tso send should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: send.\\", - \\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Send data to TSO and collect responses until the prompt is reached.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso send \\\\n\\\\n Where is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Send data to a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\", + \\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Send data to TSO and collect responses until the prompt is reached.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso send \\\\n\\\\n Where is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Send data to a TSO address space \\\\n app | a Send message to an application at a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Send data to TSO and collect responses until the prompt is reached.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso send \\\\n\\\\n Where is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Send data to a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\" + \\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Send data to TSO and collect responses until the prompt is reached.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso send \\\\n\\\\n Where is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Send data to a TSO address space \\\\n app | a Send message to an application at a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\" }" `; diff --git a/packages/cli/__tests__/zostso/__integration__/start/__snapshots__/cli.zos-tso.start.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/start/__snapshots__/cli.zos-tso.start.integration.test.ts.snap index 1f08304a7a..ed2a55c2d9 100644 --- a/packages/cli/__tests__/zostso/__integration__/start/__snapshots__/cli.zos-tso.start.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/start/__snapshots__/cli.zos-tso.start.integration.test.ts.snap @@ -17,7 +17,8 @@ exports[`zos-tso start should display the help 1`] = ` COMMANDS -------- - address-space | as Start a TSO address space + address-space | as Start a TSO address space + app | a Start application at TSO address space GLOBAL OPTIONS -------------- @@ -42,8 +43,8 @@ exports[`zos-tso start should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: start.\\", - \\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Start TSO/E address space.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso start \\\\n\\\\n Where is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Start a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\", + \\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Start TSO/E address space.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso start \\\\n\\\\n Where is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Start a TSO address space \\\\n app | a Start application at TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Start TSO/E address space.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso start \\\\n\\\\n Where is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Start a TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\" + \\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Start TSO/E address space.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso start \\\\n\\\\n Where is one of the following:\\\\n\\\\n COMMANDS\\\\n --------\\\\n\\\\n address-space | as Start a TSO address space \\\\n app | a Start application at TSO address space\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\" }" `; diff --git a/packages/cli/__tests__/zostso/__integration__/start/cli.zos-tso.start.integration.test.ts b/packages/cli/__tests__/zostso/__integration__/start/cli.zos-tso.start.integration.test.ts index c0a244761a..93b34e7e15 100644 --- a/packages/cli/__tests__/zostso/__integration__/start/cli.zos-tso.start.integration.test.ts +++ b/packages/cli/__tests__/zostso/__integration__/start/cli.zos-tso.start.integration.test.ts @@ -41,7 +41,7 @@ describe("zos-tso start", () => { expect(response.stderr.toString()).toContain('Command failed due to improper syntax'); expect(response.stderr.toString()).toContain('Did you mean: zos-tso start'); expect(response.stderr.toString()).toContain('Command entered: "zos-tso start foobar"'); - expect(response.stderr.toString()).toContain('Available commands are "address-space".'); + expect(response.stderr.toString()).toContain('Available commands are "address-space, app".'); expect(response.stderr.toString()).toContain('Use "zowe zos-tso start --help" to view groups, commands, and options.'); expect(response.stderr.toString()).toContain('Error: Unknown argument: foobar'); }); @@ -53,7 +53,7 @@ describe("zos-tso start", () => { expect(response.stderr.toString()).toContain('Unknown arguments: foo-bar, fooBar'); expect(response.stderr.toString()).toContain('Command failed due to improper syntax'); expect(response.stderr.toString()).toContain('Command entered: "zos-tso start --foo-bar"'); - expect(response.stderr.toString()).toContain('Available commands are "address-space".'); + expect(response.stderr.toString()).toContain('Available commands are "address-space, app".'); expect(response.stderr.toString()).toContain('Use "zowe zos-tso start --help" to view groups, commands, and options.'); expect(response.stderr.toString()).toContain('Error: Unknown arguments: foo-bar, fooBar'); }); diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index 9edb63211c..5355a40d08 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -69,7 +69,6 @@ export class ReceiveTsoApp { } else { combinedResponse.tsoData.push(...formattedApiResponse.tsoData); } - endKeyword = formattedApiResponse.tsoData.some((data: any) => typeof data === "string" ? data.trim() === "READY" : data.DATA.trim() === "READY" ); From f366eb951c7084baef5e71b7471e0651d1365d9c Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 18 Oct 2024 12:03:27 -0400 Subject: [PATCH 029/106] linting and system tests Signed-off-by: jace-roell --- .../cli.zos-tso.integration.test.ts.snap | 16 +- .../receive/Receive.definition.unit.test.ts | 2 +- .../Receive.definition.unit.test.ts.snap | 8 +- .../src/zostso/receive/Receive.definition.ts | 6 +- .../receive/app/ReceiveASApp.handler.ts | 2 +- .../send/as-app/SendASApp.definition.ts | 2 +- .../imperative/src/config/src/ProfileInfo.ts | 3 +- .../cmd/secure/secure.handler.unit.test.ts | 1 - .../__scripts__/receive/receive_tso_app.sh | 13 + .../__scripts__/send/send_tso_app.sh | 22 ++ .../start/start_app_existing_as.sh | 11 + .../__scripts__/start/start_app_new_as.sh | 9 + .../__system__/api.TsoASApp.system.test.ts | 289 ++++++++++++++++++ 13 files changed, 364 insertions(+), 20 deletions(-) create mode 100755 packages/zostso/__tests__/__system__/__scripts__/receive/receive_tso_app.sh create mode 100755 packages/zostso/__tests__/__system__/__scripts__/send/send_tso_app.sh create mode 100755 packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh create mode 100755 packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh create mode 100644 packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts diff --git a/packages/cli/__tests__/zostso/__integration__/root/__snapshots__/cli.zos-tso.integration.test.ts.snap b/packages/cli/__tests__/zostso/__integration__/root/__snapshots__/cli.zos-tso.integration.test.ts.snap index 11230b5709..6878be1a6d 100644 --- a/packages/cli/__tests__/zostso/__integration__/root/__snapshots__/cli.zos-tso.integration.test.ts.snap +++ b/packages/cli/__tests__/zostso/__integration__/root/__snapshots__/cli.zos-tso.integration.test.ts.snap @@ -17,12 +17,12 @@ exports[`zos-tso should display the help 1`] = ` GROUPS ------ - issue Issue TSO commands - ping Ping a TSO address space - receieve | r Receieve message from TSO address space app - send Send data to TSO - start | st Start TSO/E address space - stop | sp Stop TSO/E address space + issue Issue TSO commands + ping Ping a TSO address space + receive | r Receive message from TSO address space app + send Send data to TSO + start | st Start TSO/E address space + stop | sp Stop TSO/E address space GLOBAL OPTIONS -------------- @@ -47,8 +47,8 @@ exports[`zos-tso should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: zos-tso.\\", - \\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso \\\\n\\\\n Where is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n receieve | r Receieve message from TSO address space app\\\\n send Send data to TSO \\\\n start | st Start TSO/E address space \\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\", + \\"stdout\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso \\\\n\\\\n Where is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n receive | r Receive message from TSO address space app\\\\n send Send data to TSO \\\\n start | st Start TSO/E address space \\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso \\\\n\\\\n Where is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n receieve | r Receieve message from TSO address space app\\\\n send Send data to TSO \\\\n start | st Start TSO/E address space \\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\" + \\"data\\": \\"\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Issue TSO commands and interact with TSO address spaces.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-tso \\\\n\\\\n Where is one of the following:\\\\n\\\\n GROUPS\\\\n ------\\\\n\\\\n issue Issue TSO commands \\\\n ping Ping a TSO address space \\\\n receive | r Receive message from TSO address space app\\\\n send Send data to TSO \\\\n start | st Start TSO/E address space \\\\n stop | sp Stop TSO/E address space \\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --help-examples (boolean)\\\\n\\\\n Display examples for all the commands in a group\\\\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\\" }" `; diff --git a/packages/cli/__tests__/zostso/__unit__/receive/Receive.definition.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/Receive.definition.unit.test.ts index 633ed85317..7b950ce791 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/Receive.definition.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/receive/Receive.definition.unit.test.ts @@ -11,7 +11,7 @@ import { ICommandDefinition } from "@zowe/imperative"; -describe("zos-tso receieve group definition", () => { +describe("zos-tso receive group definition", () => { it("should not have changed", () => { const definition: ICommandDefinition = require("../../../../src/zostso/receive/Receive.definition").ReceiveCommand; expect(definition).toBeDefined(); diff --git a/packages/cli/__tests__/zostso/__unit__/receive/__snapshots__/Receive.definition.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/receive/__snapshots__/Receive.definition.unit.test.ts.snap index ec88ec58a0..7be0203f57 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/__snapshots__/Receive.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/receive/__snapshots__/Receive.definition.unit.test.ts.snap @@ -1,13 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`zos-tso receieve group definition should not have changed 1`] = ` +exports[`zos-tso receive group definition should not have changed 1`] = ` Object { "aliases": Array [ "r", ], - "description": "Receieve message from TSO address space app", - "name": "receieve", - "summary": "Receieve message from TSO address space app", + "description": "Receive message from TSO address space app", + "name": "receive", + "summary": "Receive message from TSO address space app", "type": "group", } `; diff --git a/packages/cli/src/zostso/receive/Receive.definition.ts b/packages/cli/src/zostso/receive/Receive.definition.ts index de01532863..30c8e7e2fb 100644 --- a/packages/cli/src/zostso/receive/Receive.definition.ts +++ b/packages/cli/src/zostso/receive/Receive.definition.ts @@ -13,11 +13,11 @@ import { ICommandDefinition } from "@zowe/imperative"; import { ReceiveASApp } from "./app/ReceiveASApp.definition"; export const ReceiveCommand: ICommandDefinition = { - name: "receieve", + name: "receive", aliases: ["r"], type: "group", - summary: "Receieve message from TSO address space app", - description: "Receieve message from TSO address space app", + summary: "Receive message from TSO address space app", + description: "Receive message from TSO address space app", children: [ ReceiveASApp ], diff --git a/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts index de147dace8..b07c6ff164 100644 --- a/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts @@ -13,7 +13,7 @@ import { IHandlerParameters } from "@zowe/imperative"; import { ZosTsoBaseHandler, ReceiveTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; /** - * Handler to receieve message from an app at an address space + * Handler to receive message from an app at an address space * @export * @class Handler * @implements {ICommandHandler} diff --git a/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts b/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts index 170f572cf4..b07757b0ef 100644 --- a/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts +++ b/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts @@ -39,7 +39,7 @@ export const SendASApp: ICommandDefinition = { }, { name: "message", - aliases: ["msg"], + aliases: ["m"], description: "Message", type: "string", required: true diff --git a/packages/imperative/src/config/src/ProfileInfo.ts b/packages/imperative/src/config/src/ProfileInfo.ts index b5d812260c..48820e3eaa 100644 --- a/packages/imperative/src/config/src/ProfileInfo.ts +++ b/packages/imperative/src/config/src/ProfileInfo.ts @@ -180,7 +180,8 @@ export class ProfileInfo { } /** - * Checks if a JSON web token is used for authenticating the given profile name. If so, it will decode the token to determine whether it has expired. + * Checks if a JSON web token is used for authenticating the given profile name. + * If so, it will decode the token to determine whether it has expired. * * @param {string | IProfileLoaded} profile - The name of the profile or the profile object to check the JSON web token for * @returns {boolean} Whether the token has expired for the given profile. Returns `false` if a token value is not set or the token type is LTPA2. 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 e6f0f9263e..466bb78590 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 @@ -1104,7 +1104,6 @@ describe("Configuration Secure command handler", () => { ImperativeConfig.instance.config.api.secure, "secureFields" ).mockReturnValue(secureFields); - jest.spyOn(ImperativeConfig.instance.config.api.secure, "secureFields").mockReturnValue(secureFields); let caughtError; diff --git a/packages/zostso/__tests__/__system__/__scripts__/receive/receive_tso_app.sh b/packages/zostso/__tests__/__system__/__scripts__/receive/receive_tso_app.sh new file mode 100755 index 0000000000..7066cf6185 --- /dev/null +++ b/packages/zostso/__tests__/__system__/__scripts__/receive/receive_tso_app.sh @@ -0,0 +1,13 @@ +#!/bin/bash +account=$1 +host=$2 +port=$3 +user=$4 +password=$5 +ru=$6 +servletKey=$7 +appKey=$8 +rur=$9 + +zowe zos-tso r app --app-key $appKey --servlet-key "$servletKey" --rur $rur --account $account --host $host --port $port --user $user --password $password --ru $ru +exit $? diff --git a/packages/zostso/__tests__/__system__/__scripts__/send/send_tso_app.sh b/packages/zostso/__tests__/__system__/__scripts__/send/send_tso_app.sh new file mode 100755 index 0000000000..6e0c52e805 --- /dev/null +++ b/packages/zostso/__tests__/__system__/__scripts__/send/send_tso_app.sh @@ -0,0 +1,22 @@ +#!/bin/bash +account=$1 +host=$2 +port=$3 +user=$4 +password=$5 +ru=$6 +servletKey=$7 +message=$8 +appKey=$9 + +echo "Account: $account" +echo "Host: $host" +echo "Port: $port" +echo "User: $user" +echo "Password: $password" +echo "RU: $ru" +echo "ServletKey: $servletKey" +echo "Message: $message" + +zowe zos-tso send app --ak "$appKey" --sk "$servletKey" --message "$message" --account $account --host $host --port $port --user $user --password $password --ru $ru +exit $? diff --git a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh new file mode 100755 index 0000000000..101037d3c6 --- /dev/null +++ b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh @@ -0,0 +1,11 @@ +#!/bin/bash +account=$1 +host=$2 +port=$3 +user=$4 +password=$5 +ru=$6 +servletKey=$7 +queueID=$8 +zowe zos-tso start app --app-key "test2" --startup "EXEC 'RIJFE01.PUBLIC.REXX.EXEC(TESTADRS)'" --servlet-key $servletKey --queue-id $queueID --account $account --host $host --port $port --user $user --password $password --ru $ru +exit $? diff --git a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh new file mode 100755 index 0000000000..7d9f42e1f3 --- /dev/null +++ b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh @@ -0,0 +1,9 @@ +#!/bin/bash +account=$1 +host=$2 +port=$3 +user=$4 +password=$5 +ru=$6 +zowe zos-tso start app --app-key "test2" --startup "EXEC 'RIJFE01.PUBLIC.REXX.EXEC(TESTADRS)'" --account $account --host $host --port $port --user $user --password $password --ru $ru +exit $? diff --git a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts new file mode 100644 index 0000000000..1c99ac79a6 --- /dev/null +++ b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts @@ -0,0 +1,289 @@ +/* + * 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 { ImperativeError, Session } from "@zowe/imperative"; +import { IIssueResponse, StartTso, StopTso } from "../../src"; +import { ITestEnvironment } from "@zowe/cli-test-utils"; +import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; +import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; +import { runCliScript } from "@zowe/cli-test-utils"; + +let testEnvironment: ITestEnvironment; +let systemProperties: ITestPropertiesSchema; +let REAL_SESSION: Session; +let ACCOUNT_NUMBER: string; +let defaultSystem: ITestPropertiesSchema; + +describe("All test", () => { + beforeAll(async () => { + testEnvironment = await TestEnvironment.setUp({ + testName: "zos_tso_as_app", + }); + systemProperties = testEnvironment.systemTestProperties; + REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); + ACCOUNT_NUMBER = systemProperties.tso.account; + defaultSystem = testEnvironment.systemTestProperties; + }); + + afterAll(async () => { + await TestEnvironment.cleanUp(testEnvironment); + }); + + describe("Start TSO app tests", () => { + it("should create TSO address space and run an application instance at the created AS", async () => { + let error: ImperativeError; + + const response = await runCliScript( + __dirname + "/__scripts__/start/start_app_new_as.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + ] + ); + + expect(response.stdout.toString()).toBeDefined(); + expect(response.stdout.toString()).toContain( + "HELLOW exec processing has started" + ); + expect(response.stdout.toString()).toContain( + "UNIX message queue id = " + ); + expect(response.stdout.toString()).toContain( + "Input message type = " + ); + expect(response.stdout.toString()).toContain( + "Output message type = " + ); + expect(response.stdout.toString()).toContain( + "Reading application input from the UNIX message queue." + ); + expect(error).toBeUndefined(); + await StopTso.stop( + REAL_SESSION, + JSON.parse(response.stdout.toString()).servletKey + ); + }); + it("should create TSO application instance on existing address space", async () => { + const startResponse: IIssueResponse = { + success: false, + startResponse: await StartTso.start( + REAL_SESSION, + ACCOUNT_NUMBER + ), + startReady: false, + zosmfResponse: null, + commandResponse: null, + stopResponse: null, + }; + + const response = await runCliScript( + __dirname + "/__scripts__/start/start_app_existing_as.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + startResponse.startResponse.zosmfTsoResponse.servletKey, + startResponse.startResponse.zosmfTsoResponse.queueID, + ] + ); + expect(response.stdout.toString()).toBeDefined(); + expect(response.stdout.toString()).toContain( + "HELLOW exec processing has started" + ); + expect(response.stdout.toString()).toContain( + "UNIX message queue id = " + ); + expect(response.stdout.toString()).toContain( + "Input message type = " + ); + expect(response.stdout.toString()).toContain( + "Output message type = " + ); + expect(response.stdout.toString()).toContain( + "Reading application input from the UNIX message queue." + ); + + //Clean up test + await StopTso.stop( + REAL_SESSION, + startResponse.startResponse.zosmfTsoResponse.servletKey + ); + }); + }); + describe("Send TSO app tests", () => { + it("Should send message to TSO address space app", async () => { + const startResponse = await runCliScript( + __dirname + "/__scripts__/start/start_app_new_as.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + ] + ); + const startServletkey = JSON.parse( + startResponse.stdout.toString() + ).servletKey; + const response = await runCliScript( + __dirname + "/__scripts__/send/send_tso_app.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + startServletkey, + "LONG 100", + "test2", + ] + ); + + expect(response.stdout.toString()).toBeDefined(); + expect(response.stdout.toString()).toContain( + "Application input = LONG 100" + ); + expect(response.stdout.toString()).toContain("servletKey"); + expect(response.stdout.toString()).toContain("READY "); + + //Clean up test + await StopTso.stop(REAL_SESSION, startServletkey); + }); + }); + describe("Receive TSO app tests", () => { + it("should pull from message queue but not reach the end (--no-rur)", async () => { + const startResponse = await runCliScript( + __dirname + "/__scripts__/start/start_app_new_as.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + ] + ); + const startServletkey = JSON.parse( + startResponse.stdout.toString() + ).servletKey; + await runCliScript( + __dirname + "/__scripts__/send/send_tso_app.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + startServletkey, + "LONG 4000", // Greater than 1000 such that receive will contain data. + "test2", + ] + ); + const response = await runCliScript( + __dirname + "/__scripts__/receive/receive_tso_app.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + startServletkey, + "test2", + "false", + ] + ); + expect(response.stdout.toString()).toContain("999"); + expect(response.stdout.toString()).toContain("1000"); + expect(response.stdout.toString()).toContain("1001"); + expect(response.stdout.toString()).not.toContain("4000"); + + //Clean up test + await StopTso.stop(REAL_SESSION, startServletkey); + }); + it("should empty message queue using --rur flag", async () => { + const startResponse = await runCliScript( + __dirname + "/__scripts__/start/start_app_new_as.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + ] + ); + const startServletkey = JSON.parse( + startResponse.stdout.toString() + ).servletKey; + await runCliScript( + __dirname + "/__scripts__/send/send_tso_app.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + startServletkey, + "LONG 4000", // Greater than 1000 such that receive will contain data. + "test2", + ] + ); + const response = await runCliScript( + __dirname + "/__scripts__/receive/receive_tso_app.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + startServletkey, + "test2", + "true", + ] + ); + + expect(response.stdout.toString()).toContain("1000"); + expect(response.stdout.toString()).toContain("2000"); + expect(response.stdout.toString()).toContain("3000"); + expect(response.stdout.toString()).toContain("4000"); + expect(response.stdout.toString()).toContain( + "HELLOW exec processing is complete with rc = 0." + ); + expect(response.stdout.toString()).toContain("READY"); + + //Clean up test + await StopTso.stop(REAL_SESSION, startServletkey); + }); + }); +}); From 0eed919285298332b14b5c913e05a1709f06fd92 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 18 Oct 2024 12:22:00 -0400 Subject: [PATCH 030/106] changelog Signed-off-by: jace-roell --- packages/zostso/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/zostso/CHANGELOG.md b/packages/zostso/CHANGELOG.md index f5a53aa697..bd58aa7a70 100644 --- a/packages/zostso/CHANGELOG.md +++ b/packages/zostso/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the Zowe z/OS TSO SDK package will be documented in this file. +## Recent Changes + +- Enhancement: Created app command under zos-tso start/send and new receieve command group, + this allows for starting applications at TSO address spaces aswell as message transmission/reception [#2280] (https://github.com/zowe/zowe-cli/pull/2280) + ## `8.1.1` - BugFix: Updated peer dependencies to `^8.0.0`, dropping support for versions tagged `next`. [#2287](https://github.com/zowe/zowe-cli/pull/2287) From 376ecfcce9c6b711d47bce5882f0f3e023d3d17e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 18 Oct 2024 12:24:55 -0400 Subject: [PATCH 031/106] temp changelog Signed-off-by: jace-roell --- packages/imperative/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 9893f8b278..538bdb0c5b 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 + +- I fixed random linting warnings here and I want to appease the changelog check, idk what to put here + ## `8.2.0` - Enhancement: Use the new SDK method `ConfigUtils.hasTokenExpired` to check whether a given JSON web token has expired. [#2298](https://github.com/zowe/zowe-cli/pull/2298) From e3a69fffadfee23c031de02404432147de930b7e Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 18 Oct 2024 12:27:13 -0400 Subject: [PATCH 032/106] revert linting Signed-off-by: jace-roell --- packages/imperative/CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 538bdb0c5b..9893f8b278 100644 --- a/packages/imperative/CHANGELOG.md +++ b/packages/imperative/CHANGELOG.md @@ -2,10 +2,6 @@ All notable changes to the Imperative package will be documented in this file. -## Recent Changes - -- I fixed random linting warnings here and I want to appease the changelog check, idk what to put here - ## `8.2.0` - Enhancement: Use the new SDK method `ConfigUtils.hasTokenExpired` to check whether a given JSON web token has expired. [#2298](https://github.com/zowe/zowe-cli/pull/2298) From 3af43f170b7ab84321d1fd98fce0d56a87c7edd7 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 18 Oct 2024 12:30:18 -0400 Subject: [PATCH 033/106] remove echo from shell Signed-off-by: jace-roell --- .../__system__/__scripts__/send/send_tso_app.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/zostso/__tests__/__system__/__scripts__/send/send_tso_app.sh b/packages/zostso/__tests__/__system__/__scripts__/send/send_tso_app.sh index 6e0c52e805..633d9e3353 100755 --- a/packages/zostso/__tests__/__system__/__scripts__/send/send_tso_app.sh +++ b/packages/zostso/__tests__/__system__/__scripts__/send/send_tso_app.sh @@ -9,14 +9,5 @@ servletKey=$7 message=$8 appKey=$9 -echo "Account: $account" -echo "Host: $host" -echo "Port: $port" -echo "User: $user" -echo "Password: $password" -echo "RU: $ru" -echo "ServletKey: $servletKey" -echo "Message: $message" - zowe zos-tso send app --ak "$appKey" --sk "$servletKey" --message "$message" --account $account --host $host --port $port --user $user --password $password --ru $ru exit $? From 00acdf7e2da06ddbffb2cc303de0381ba2009eae Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 21 Oct 2024 11:04:50 -0400 Subject: [PATCH 034/106] small documentation fix Signed-off-by: jace-roell --- packages/zostso/src/doc/IASAppResponse.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zostso/src/doc/IASAppResponse.ts b/packages/zostso/src/doc/IASAppResponse.ts index d474e0edeb..5b43b31526 100644 --- a/packages/zostso/src/doc/IASAppResponse.ts +++ b/packages/zostso/src/doc/IASAppResponse.ts @@ -20,7 +20,7 @@ export interface IASAppResponse { version: string /** * Data from response - * @type {boolean} + * @type {ITsoMessage[]} * @memberof IASAppResponse */ tsoData: ITsoMessage[] @@ -31,7 +31,7 @@ export interface IASAppResponse { */ reused: boolean /** - * Data from response + * Timeout boolean response * @type {boolean} * @memberof IASAppResponse */ @@ -43,7 +43,7 @@ export interface IASAppResponse { */ servletKey?: string; /** - * Servlet key from IZosmfTsoResponse + * QueueID from created address space * @type {string} * @memberof IASAppResponse */ From 52cb3f1fb17d4a36ca0f1436c886b6bce15496a0 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 23 Oct 2024 10:05:52 -0400 Subject: [PATCH 035/106] poc Signed-off-by: jace-roell --- .../FileToUSS.definition.unit.test.ts.snap | 11 +++ .../upload/ftu/FileToUSS.definition.ts | 3 +- .../zosfiles/upload/ftu/FileToUSS.handler.ts | 91 +++++++++++++++---- .../zosfiles/src/methods/upload/Upload.ts | 10 +- 4 files changed, 89 insertions(+), 26 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.definition.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.definition.unit.test.ts.snap index c701260de3..985f225221 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.definition.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.definition.unit.test.ts.snap @@ -18,6 +18,17 @@ Array [ "name": "encoding", "type": "string", }, + Object { + "aliases": Array [ + "attrs", + ], + "conflictsWith": Array [ + "ascii-files, binary-files", + ], + "description": "Path of an attributes file to control how files are uploaded.", + "name": "attributes", + "type": "string", + }, ] `; diff --git a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.definition.ts b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.definition.ts index 1cd07d4b82..ea80d10433 100644 --- a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.definition.ts +++ b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.definition.ts @@ -48,7 +48,8 @@ export const FileToUSSDefinition: ICommandDefinition = { ], options: [ UploadOptions.binary, - UploadOptions.encoding + UploadOptions.encoding, + UploadOptions.attributes ], examples: [ { diff --git a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts index 2efe480004..d0f386ff10 100644 --- a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts @@ -1,42 +1,93 @@ /* -* 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, IHandlerParameters, ITaskWithStatus, TaskStage, TextUtils } from "@zowe/imperative"; +import { + AbstractSession, + IHandlerParameters, + ITaskWithStatus, + TaskStage, + TextUtils, +} from "@zowe/imperative"; import { Upload, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; +import { IUploadOptions } from "@zowe/zos-files-for-zowe-sdk"; +import { ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; +import { IUploadMap } from "@zowe/zos-files-for-zowe-sdk"; /** * Handler to upload content from a local file to a USS file * @export */ export default class FileToUSSHandler extends ZosFilesBaseHandler { - public async processWithSession(commandParameters: IHandlerParameters, - session: AbstractSession): Promise { + public async processWithSession( + commandParameters: IHandlerParameters, + session: AbstractSession + ): Promise { const task: ITaskWithStatus = { percentComplete: 0, statusMessage: "Uploading USS file", - stageName: TaskStage.IN_PROGRESS + stageName: TaskStage.IN_PROGRESS, }; commandParameters.response.progress.startBar({ task }); - const response = await Upload.fileToUssFile(session, commandParameters.arguments.inputfile, - commandParameters.arguments.USSFileName, { - binary: commandParameters.arguments.binary, - encoding: commandParameters.arguments.encoding, - task, - responseTimeout: commandParameters.arguments.responseTimeout - }); + const uploadOptions: IUploadOptions = { + binary: commandParameters.arguments.binary, + maxConcurrentRequests: + commandParameters.arguments.maxConcurrentRequests, + task: task, + responseTimeout: commandParameters.arguments.responseTimeout, + includeHidden: commandParameters.arguments.includeHidden, + }; + + const attributes = ZosFilesAttributes.loadFromFile( + commandParameters.arguments.attributes, + commandParameters.arguments.inputDir + ); + if (attributes != null) { + uploadOptions.attributes = attributes; + } else { + uploadOptions.filesMap = this.buildFilesMap(commandParameters); + } + + const response = await Upload.uploadFile( + session, + commandParameters.arguments.inputfile, + commandParameters.arguments.USSFileName, + uploadOptions + ); const formatMessage = TextUtils.prettyJson(response.apiResponse); commandParameters.response.console.log(formatMessage); return response; } + private buildFilesMap(commandParameters: IHandlerParameters) { + let filesMap: IUploadMap = null; + + // checking if binary-files or ascii-files are used, and update filesMap argument + if (commandParameters.arguments.binaryFiles) { + filesMap = { + binary: true, + fileNames: commandParameters.arguments.binaryFiles + .split(",") + .map((fileName: string) => fileName.trim()), + }; + } + if (commandParameters.arguments.asciiFiles) { + filesMap = { + binary: false, + fileNames: commandParameters.arguments.asciiFiles + .split(",") + .map((fileName: string) => fileName.trim()), + }; + } + return filesMap; + } } diff --git a/packages/zosfiles/src/methods/upload/Upload.ts b/packages/zosfiles/src/methods/upload/Upload.ts index 985cf0455c..1387a8c850 100644 --- a/packages/zosfiles/src/methods/upload/Upload.ts +++ b/packages/zosfiles/src/methods/upload/Upload.ts @@ -678,7 +678,7 @@ export class Upload { } const fileName = path.normalize(path.join(inputDirectory, file.fileName)); const ussFilePath = path.posix.join(ussname, file.fileName); - return this.uploadFile(fileName, ussFilePath, session, + return this.uploadFile(session,fileName, ussFilePath, { ...options, binary: file.binary }); }; @@ -831,7 +831,7 @@ export class Upload { } const filePath = path.normalize(path.join(inputDirectory, file.fileName)); const ussFilePath = path.posix.join(ussname, file.fileName); - return this.uploadFile(filePath, ussFilePath, session, + return this.uploadFile(session, filePath, ussFilePath, { ...options, binary: file.binary }); }; if (maxConcurrentRequests === 0) { @@ -854,8 +854,8 @@ export class Upload { }; } - private static async uploadFile(localPath: string, ussPath: string, - session: AbstractSession, options: IUploadOptions) { + public static async uploadFile(session: AbstractSession, localPath: string, ussPath: string, + options: IUploadOptions) { const tempOptions: Partial = {}; if (options.attributes) { @@ -882,7 +882,7 @@ export class Upload { } } - await this.fileToUssFile(session, localPath, ussPath, tempOptions); + return await this.fileToUssFile(session, localPath, ussPath, tempOptions); } /** From 3b4ca49229dd19ba347f31872b3d93ce980d44af Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 23 Oct 2024 10:15:04 -0400 Subject: [PATCH 036/106] header and spelling mistake Signed-off-by: jace-roell --- .../app/ReceiveASApp.handler.unit.test.ts | 18 +++++++++--------- .../send/app/SendASApp.handler.unit.test.ts | 18 +++++++++--------- .../start/app/StartASApp.handler.unit.test.ts | 18 +++++++++--------- .../zostso/send/as-app/SendASApp.handler.ts | 18 +++++++++--------- .../cmd/secure/secure.handler.unit.test.ts | 18 +++++++++--------- packages/zostso/CHANGELOG.md | 2 +- .../__system__/api.TsoASApp.system.test.ts | 18 +++++++++--------- .../__unit__/ReceiveTsoApp.unit.test.ts | 18 +++++++++--------- .../__unit__/SendTsoApp.unit.test.ts | 18 +++++++++--------- .../__unit__/StartTsoApp.unit.test.ts | 11 +++++++++++ packages/zostso/src/ReceiveTsoApp.ts | 19 ++++++++++--------- packages/zostso/src/SendTsoApp.ts | 18 +++++++++--------- packages/zostso/src/StartTsoApp.ts | 18 +++++++++--------- 13 files changed, 112 insertions(+), 100 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts index fd9193da57..bfb3e8b2f1 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.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. +* +*/ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { ReceiveTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts index 574c38378b..f56c1963c3 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.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. +* +*/ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts index 20424a1e50..cb0259dbd3 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.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. +* +*/ /* * This program and the accompanying materials are made available under the terms of the diff --git a/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts index 27befd7b8b..78bf795f62 100644 --- a/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts +++ b/packages/cli/src/zostso/send/as-app/SendASApp.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 { ZosTsoBaseHandler, SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; 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 466bb78590..3228c6089e 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 @@ -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 { Logger } from "../../../../../logger"; import { Config } from "../../../../../config"; diff --git a/packages/zostso/CHANGELOG.md b/packages/zostso/CHANGELOG.md index bd58aa7a70..9c041daebf 100644 --- a/packages/zostso/CHANGELOG.md +++ b/packages/zostso/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe z/OS TSO SDK package will be documented in this ## Recent Changes -- Enhancement: Created app command under zos-tso start/send and new receieve command group, +- Enhancement: Created app command under zos-tso start/send and new receive command group, this allows for starting applications at TSO address spaces aswell as message transmission/reception [#2280] (https://github.com/zowe/zowe-cli/pull/2280) ## `8.1.1` diff --git a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts index 1c99ac79a6..7aff5ae812 100644 --- a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoASApp.system.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. +* +*/ import { ImperativeError, Session } from "@zowe/imperative"; import { IIssueResponse, StartTso, StopTso } from "../../src"; diff --git a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts index 2bbe4d5c79..0d7faa1ba0 100644 --- a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.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. +* +*/ import { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; diff --git a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts index fef87fcbc1..11385b42ec 100644 --- a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/SendTsoApp.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. +* +*/ import { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; diff --git a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts index f2e612ece7..8d354f683e 100644 --- a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts @@ -1,3 +1,14 @@ +/* +* 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 { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { StartTsoApp } from "../../src"; diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index 5355a40d08..088853022e 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -1,13 +1,14 @@ /* - * 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 } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { TsoValidator } from "./TsoValidator"; diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index ee3b98d74d..e00a246a0b 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.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 } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts index 4c117b5444..23c931ec73 100644 --- a/packages/zostso/src/StartTsoApp.ts +++ b/packages/zostso/src/StartTsoApp.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 } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; From 9d4540664850b1f98f97783fde28e941105294d0 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 23 Oct 2024 11:05:21 -0400 Subject: [PATCH 037/106] start unit test Signed-off-by: jace-roell --- .../__unit__/methods/upload/Upload.unit.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts b/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts index 9f232a790e..c8e537a0ff 100644 --- a/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts +++ b/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts @@ -2106,6 +2106,21 @@ describe("z/OS Files - Upload", () => { error = err; } + expect(USSresponse).toBeUndefined(); + expect(error).toBeDefined(); + expect(error.message).toContain(ZosFilesMessages.missingInputFile.message); + lstatSpy.mockClear(); + }); + it("should throw an error if local file name is not a valid file path", async () => { + lstatSpy.mockImplementationOnce((somePath, callback: any) => { + callback(null, {isFile: () => false}); + }); + try { + USSresponse = await Upload.fileToUssFile(dummySession, undefined, "file"); + } catch (err) { + error = err; + } + expect(USSresponse).toBeUndefined(); expect(error).toBeDefined(); expect(error.message).toContain(ZosFilesMessages.missingInputFile.message); From f49728341d9b48392e4ae54e53b25044e7f68679 Mon Sep 17 00:00:00 2001 From: Pujal Date: Wed, 23 Oct 2024 14:54:24 -0400 Subject: [PATCH 038/106] code implementation plus tests Signed-off-by: Pujal --- .../__resources__/api/GetJobsData.ts | 6 ++ .../__tests__/__unit__/GetJobs.unit.test.ts | 21 +++++-- .../__snapshots__/GetJobs.unit.test.ts.snap | 58 +++++++++++++++++++ packages/zosjobs/src/GetJobs.ts | 1 + packages/zosjobs/src/doc/response/IJob.ts | 14 +++++ 5 files changed, 95 insertions(+), 5 deletions(-) diff --git a/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts b/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts index 645c347331..6ff94b39b9 100644 --- a/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts +++ b/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts @@ -29,6 +29,8 @@ export class GetJobsData { public static readonly SAMPLE_COMPLETE_JOB: IJob = { "jobid": "TSUxxx", "jobname": "IBMUSER$", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', "subsystem": "JES2", "owner": "IBMUSER", "status": "OUTPUT", @@ -51,6 +53,8 @@ export class GetJobsData { public static readonly SAMPLE_COMPLETE_JOB_AGAIN: IJob = { "jobid": "JOBxxx", "jobname": "CAUSER$", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', "subsystem": "JES2", "owner": "CAUSER", "status": "OUTPUT", @@ -81,6 +85,8 @@ export class GetJobsData { public static readonly SAMPLE_ACTIVE_JOB: IJob = { "retcode": null, "jobname": "IBMUSER$", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', "status": "INPUT", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "class": "A", diff --git a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts index f8a0e3138d..232d1b984f 100644 --- a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts @@ -596,21 +596,28 @@ describe("GetJobs tests", () => { owner: 'zowe', status: 'active', type: 't', class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', - phase: 1, 'phase-name': 'name', 'reason-not-running': 'no' + phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', + 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-ended': '2024-01-02T15:58:00.600Z' }, { jobid: '2', jobname: 'b', subsystem: 'sub', owner: 'zowe', status: 'Output', type: 't', class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', - phase: 1, 'phase-name': 'name', 'reason-not-running': 'no' + phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', + 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-ended': '2024-01-02T15:58:00.600Z' }, { jobid: '3', jobname: 'c', subsystem: 'sub', owner: 'kri', status: 'Output', type: 't', class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', - phase: 1, 'phase-name': 'name', 'reason-not-running': 'no' + phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', + 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-ended': '2024-01-02T15:58:00.600Z' + } ]; const expectedJobs = [ @@ -619,14 +626,18 @@ describe("GetJobs tests", () => { owner: 'zowe', status: 'Output', type: 't', class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', - phase: 1, 'phase-name': 'name', 'reason-not-running': 'no' + phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', + 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-ended': '2024-01-02T15:58:00.600Z' }, { jobid: '3', jobname: 'c', subsystem: 'sub', owner: 'kri', status: 'Output', type: 't', class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', - phase: 1, 'phase-name': 'name', 'reason-not-running': 'no' + phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', + 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-ended': '2024-01-02T15:58:00.600Z' } ]; const filteredResults = GetJobs['filterResultsByStatuses'](jobs, { status: 'OUTPUT', owner: 'zowe' }); diff --git a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap index a8c7fff252..707755244a 100644 --- a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap +++ b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap @@ -14,6 +14,8 @@ exports[`GetJobs tests getJobs APIs should allow getting jobs by common method w Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -29,6 +31,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -49,6 +53,8 @@ exports[`GetJobs tests getJobs APIs should allow getting jobs by common method w Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -64,6 +70,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -84,6 +92,8 @@ exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobs and g Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -99,6 +109,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -119,6 +131,8 @@ exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobs and g Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -134,6 +148,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -154,6 +170,8 @@ exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobsCommon Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -169,6 +187,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -189,6 +209,8 @@ exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobsCommon Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -204,6 +226,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -224,6 +248,8 @@ exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobsCommon Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -239,6 +265,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -259,6 +287,8 @@ exports[`GetJobs tests getJobs APIs should get a list of jobs from getJobsCommon Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -274,6 +304,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -294,6 +326,8 @@ exports[`GetJobs tests getJobs APIs should get jobs by owner 1`] = ` Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -309,6 +343,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -329,6 +365,8 @@ exports[`GetJobs tests getJobs APIs should get jobs by owner and prefix 1`] = ` Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -344,6 +382,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -364,6 +404,8 @@ exports[`GetJobs tests getJobs APIs should get jobs by prefix 1`] = ` Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -379,6 +421,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -416,6 +460,8 @@ exports[`GetJobs tests getJobs APIs should have proper URI when using status 1`] exports[`GetJobs tests getJobs APIs should locate a job by jobid 1`] = ` Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -445,6 +491,8 @@ exports[`GetJobs tests getJobsByParameters should get jobs even when no params a Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -460,6 +508,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -480,6 +530,8 @@ exports[`GetJobs tests getJobsByParameters should get jobs when any of the valid Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -495,6 +547,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -693,6 +747,8 @@ exports[`GetJobs tests getSpoolFiles APIs should have proper URI when getting sp exports[`GetJobs tests getStatus APIs should get a job via getStatus and getStatusCommon 1`] = ` Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -711,6 +767,8 @@ Object { exports[`GetJobs tests getStatus APIs should get a job via getStatus and getStatusCommon 2`] = ` Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 5cefdfc953..42e52589fd 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -153,6 +153,7 @@ export class GetJobs { Logger.getAppLogger().trace("GetJobs.getJobsCommon()"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); let query = JobsConstants.QUERY_ID; + params.execData = true; // always returning start and end time data if (params) { if (params.owner) { diff --git a/packages/zosjobs/src/doc/response/IJob.ts b/packages/zosjobs/src/doc/response/IJob.ts index 46e00be949..5ddfdf0bcf 100644 --- a/packages/zosjobs/src/doc/response/IJob.ts +++ b/packages/zosjobs/src/doc/response/IJob.ts @@ -34,6 +34,20 @@ export interface IJob { */ jobname: string; + /** + * start date of the job + * @type {Date} + * @memberof IJob + */ + "exec-started": string; + + /** + * end date of the job + * @type {Date} + * @memberof IJob + */ + "exec-ended": string; + /** * The primary or secondary JES subsystem. * If this value is null, the job was processed by the primary subsystem. From 1925533dc3961e7691fc886bad742b6d25ab7fc8 Mon Sep 17 00:00:00 2001 From: Pujal Date: Wed, 23 Oct 2024 15:51:42 -0400 Subject: [PATCH 039/106] updated the changelog Signed-off-by: Pujal --- packages/zosjobs/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/zosjobs/CHANGELOG.md b/packages/zosjobs/CHANGELOG.md index 899dbad608..19a20c38ec 100644 --- a/packages/zosjobs/CHANGELOG.md +++ b/packages/zosjobs/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to the Zowe z/OS jobs SDK package will be documented in this file. +## Recent Changes +- Enhancement: Added "exec-started" and "exec-ended" to IJob return data from GetJobs.getJob [#2320](https://github.com/zowe/zowe-cli/pull/2320) + ## `8.1.1` - BugFix: Updated peer dependencies to `^8.0.0`, dropping support for versions tagged `next`. [#2287](https://github.com/zowe/zowe-cli/pull/2287) From e2f2b254efd4bbc2eeca4fc7accdb4110448904a Mon Sep 17 00:00:00 2001 From: Pujal Date: Wed, 23 Oct 2024 15:55:59 -0400 Subject: [PATCH 040/106] linting issues fixed Signed-off-by: Pujal --- .../__tests__/__resources__/api/GetJobsData.ts | 6 +++--- .../zosjobs/__tests__/__unit__/GetJobs.unit.test.ts | 12 ++++++------ packages/zosjobs/src/GetJobs.ts | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts b/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts index 6ff94b39b9..a9cf78e74c 100644 --- a/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts +++ b/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts @@ -29,7 +29,7 @@ export class GetJobsData { public static readonly SAMPLE_COMPLETE_JOB: IJob = { "jobid": "TSUxxx", "jobname": "IBMUSER$", - "exec-started": '2024-01-02T15:57:58.350Z', + "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', "subsystem": "JES2", "owner": "IBMUSER", @@ -53,7 +53,7 @@ export class GetJobsData { public static readonly SAMPLE_COMPLETE_JOB_AGAIN: IJob = { "jobid": "JOBxxx", "jobname": "CAUSER$", - "exec-started": '2024-01-02T15:57:58.350Z', + "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', "subsystem": "JES2", "owner": "CAUSER", @@ -85,7 +85,7 @@ export class GetJobsData { public static readonly SAMPLE_ACTIVE_JOB: IJob = { "retcode": null, "jobname": "IBMUSER$", - "exec-started": '2024-01-02T15:57:58.350Z', + "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', "status": "INPUT", "job-correlator": "J0003781USILDAMDD3CE8146.......:", diff --git a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts index 232d1b984f..1c8b941cb1 100644 --- a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts @@ -597,7 +597,7 @@ describe("GetJobs tests", () => { class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', - 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-started': '2024-01-02T15:57:58.350Z', 'exec-ended': '2024-01-02T15:58:00.600Z' }, { @@ -605,8 +605,8 @@ describe("GetJobs tests", () => { owner: 'zowe', status: 'Output', type: 't', class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', - phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', - 'exec-started': '2024-01-02T15:57:58.350Z', + phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', + 'exec-started': '2024-01-02T15:57:58.350Z', 'exec-ended': '2024-01-02T15:58:00.600Z' }, { @@ -615,7 +615,7 @@ describe("GetJobs tests", () => { class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', - 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-started': '2024-01-02T15:57:58.350Z', 'exec-ended': '2024-01-02T15:58:00.600Z' } @@ -627,7 +627,7 @@ describe("GetJobs tests", () => { class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', - 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-started': '2024-01-02T15:57:58.350Z', 'exec-ended': '2024-01-02T15:58:00.600Z' }, { @@ -636,7 +636,7 @@ describe("GetJobs tests", () => { class: 'c', retcode: 'r', url: '', 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', - 'exec-started': '2024-01-02T15:57:58.350Z', + 'exec-started': '2024-01-02T15:57:58.350Z', 'exec-ended': '2024-01-02T15:58:00.600Z' } ]; diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 42e52589fd..ff20d355c6 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -153,7 +153,7 @@ export class GetJobs { Logger.getAppLogger().trace("GetJobs.getJobsCommon()"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); let query = JobsConstants.QUERY_ID; - params.execData = true; // always returning start and end time data + params.execData = true; // always returning start and end time data if (params) { if (params.owner) { From dc7028a1331facfd4fc96f7efb7a42fe25caddd1 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 23 Oct 2024 16:05:33 -0400 Subject: [PATCH 041/106] changelog, fixed existing unit tests Signed-off-by: jace-roell --- .../upload/ftu/FileToUSS.handler.unit.test.ts | 13 +++-- .../FileToUSS.handler.unit.test.ts.snap | 54 +++++++++++++++++++ packages/zosfiles/CHANGELOG.md | 4 ++ .../methods/upload/Upload.unit.test.ts | 15 ------ 4 files changed, 66 insertions(+), 20 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts index c4eedd2bd4..507a7e69a7 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts @@ -29,7 +29,7 @@ describe("Upload file-to-uss handler", () => { let fakeSession = null; // Mock the submit JCL function - Upload.fileToUssFile = jest.fn(async (session, file, name, options = {}) => { + Upload.uploadFile = jest.fn(async (session, file, name, options = {}) => { fakeSession = session; return { success: true, @@ -79,20 +79,23 @@ describe("Upload file-to-uss handler", () => { } expect(error).toBeUndefined(); - expect(Upload.fileToUssFile).toHaveBeenCalledTimes(1); - expect(Upload.fileToUssFile).toHaveBeenCalledWith(fakeSession, inputfile, USSFileName, { + expect(Upload.uploadFile).toHaveBeenCalledTimes(1); + expect(Upload.uploadFile).toHaveBeenCalledWith(fakeSession, inputfile, USSFileName, { binary: undefined, encoding: undefined, task: { percentComplete: 0, stageName: 0, statusMessage: "Uploading USS file" - } + }, + filesMap: null, + includeHidden: undefined, + maxConcurrentRequests: undefined, + responseTimeout: undefined }); expect(jsonObj).toMatchSnapshot(); expect(apiMessage).toMatchSnapshot(); expect(logMessage).toMatchSnapshot(); }); - }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap index 463337181f..86e6283ffe 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap @@ -1,5 +1,32 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Upload file-to-uss handler process method should upload a file to a uss if requested - zosattributes 1`] = ` +Object { + "apiResponse": Array [ + Object { + "from": "test-file", + "success": true, + "to": "testing", + }, + ], + "commandResponse": "uploaded", + "success": true, +} +`; + +exports[`Upload file-to-uss handler process method should upload a file to a uss if requested - zosattributes 2`] = `""`; + +exports[`Upload file-to-uss handler process method should upload a file to a uss if requested - zosattributes 3`] = ` +" +-  + success: true + from:  test-file + to:  testing + + +uploaded" +`; + exports[`Upload file-to-uss handler process method should upload a file to a uss if requested 1`] = ` Object { "apiResponse": Array [ @@ -26,3 +53,30 @@ exports[`Upload file-to-uss handler process method should upload a file to a uss uploaded" `; + +exports[`Upload file-to-uss handler process method should upload a file to a uss if requested 4`] = ` +Object { + "apiResponse": Array [ + Object { + "from": "test-file", + "success": true, + "to": "testing", + }, + ], + "commandResponse": "uploaded", + "success": true, +} +`; + +exports[`Upload file-to-uss handler process method should upload a file to a uss if requested 5`] = `""`; + +exports[`Upload file-to-uss handler process method should upload a file to a uss if requested 6`] = ` +" +-  + success: true + from:  test-file + to:  testing + + +uploaded" +`; diff --git a/packages/zosfiles/CHANGELOG.md b/packages/zosfiles/CHANGELOG.md index c34ceeb4fe..4c819c988a 100644 --- a/packages/zosfiles/CHANGELOG.md +++ b/packages/zosfiles/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe z/OS files SDK package will be documented in this file. +## Recent Changes + +- Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319] (https://github.com/zowe/zowe-cli/pull/2319) + ## `8.2.0` - Enhancement: Added an optional `continueSearch` function to the `ISearchOptions` interface. After a data set listing is completed, the new function is called with the list of data sets about to be searched. This allows the extender or end users to continue with the search or cancel it. [#2300](https://github.com/zowe/zowe-cli/pull/2300) diff --git a/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts b/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts index c8e537a0ff..9f232a790e 100644 --- a/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts +++ b/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts @@ -2106,21 +2106,6 @@ describe("z/OS Files - Upload", () => { error = err; } - expect(USSresponse).toBeUndefined(); - expect(error).toBeDefined(); - expect(error.message).toContain(ZosFilesMessages.missingInputFile.message); - lstatSpy.mockClear(); - }); - it("should throw an error if local file name is not a valid file path", async () => { - lstatSpy.mockImplementationOnce((somePath, callback: any) => { - callback(null, {isFile: () => false}); - }); - try { - USSresponse = await Upload.fileToUssFile(dummySession, undefined, "file"); - } catch (err) { - error = err; - } - expect(USSresponse).toBeUndefined(); expect(error).toBeDefined(); expect(error.message).toContain(ZosFilesMessages.missingInputFile.message); From 9ac3e768a197d369ecd7cca9b40538ae38ec24f8 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 23 Oct 2024 16:17:58 -0400 Subject: [PATCH 042/106] changelog Signed-off-by: jace-roell --- packages/cli/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index b249587912..a8c0a33f4a 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe CLI package will be documented in this file. +## Recent Changes + +- Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319] (https://github.com/zowe/zowe-cli/pull/2319) + ## `8.3.0` - Enhancement: Issue the `zowe files search data-sets` command with the new `encoding` option to use a different code page when searching data set contents. [#2161](https://github.com/zowe/zowe-cli/issues/2161) From 4b291d68fe292d05dbd3672948c23a82643cc4ee Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 24 Oct 2024 09:37:56 -0400 Subject: [PATCH 043/106] unit test and snapshot Signed-off-by: jace-roell --- .../upload/ftu/FileToUSS.handler.unit.test.ts | 91 +++++++++++++++++++ .../FileToUSS.handler.unit.test.ts.snap | 33 +------ 2 files changed, 94 insertions(+), 30 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts index 507a7e69a7..e495566285 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts @@ -11,6 +11,7 @@ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; +import { ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; describe("Upload file-to-uss handler", () => { describe("process method", () => { @@ -97,5 +98,95 @@ describe("Upload file-to-uss handler", () => { expect(apiMessage).toMatchSnapshot(); expect(logMessage).toMatchSnapshot(); }); + it("should upload a file to a USS if requested - zosattributes file", async () => { + // Require the handler and create a new instance + const handlerReq = require("../../../../../src/zosfiles/upload/ftu/FileToUSS.handler"); + const handler = new handlerReq.default(); + const inputfile = "test-file"; + const USSFileName = "testing"; + let zosAttributes: any; + + let error; + let apiMessage = ""; + let jsonObj; + let logMessage = ""; + let fakeSession = null; + + jest.spyOn(ZosFilesAttributes, "loadFromFile").mockImplementation(() => { + zosAttributes = Object.create(ZosFilesAttributes.prototype); + zosAttributes.attributes = new Map([ + ['*.json', { ignore: true }], + ['*.bin', { ignore: false, localEncoding: 'binary', remoteEncoding: 'binary' }], + ['*.jcl', { ignore: false, localEncoding: 'IBM-1047', remoteEncoding: 'IBM-1047' }], + ['*.md', { ignore: false, localEncoding: 'UTF-8', remoteEncoding: 'UTF-8' }], + ['*.txt', { ignore: false, localEncoding: 'UTF-8', remoteEncoding: 'IBM-1047' }] + ]); + zosAttributes.basePath = undefined; + return zosAttributes; + }); + Upload.uploadFile = jest.fn(async (session, file, name, options = {}) => { + fakeSession = session; + return { + success: true, + commandResponse: "uploaded", + apiResponse: [ + { success: true, from: inputfile, to: USSFileName } + ] + }; + }); + try { + await handler.process({ + arguments: { + $0: "fake", + _: ["fake"], + inputfile, + USSFileName, + ...UNIT_TEST_ZOSMF_PROF_OPTS + }, + response: { + data: { + setMessage: jest.fn((setMsgArgs) => { + apiMessage = setMsgArgs; + }), + setObj: jest.fn((setObjArgs) => { + jsonObj = setObjArgs; + }) + }, + console: { + log: jest.fn((logArgs) => { + logMessage += "\n" + logArgs; + }) + }, + progress: { + startBar: jest.fn(() => { + // do nothing + }), + endBar: jest.fn(() => { + // do nothing + }) + } + } + } as any); + } catch (e) { + error = e; + } + expect(error).toBeUndefined(); + expect(Upload.uploadFile).toHaveBeenCalledTimes(1); + expect(Upload.uploadFile).toHaveBeenCalledWith(fakeSession, inputfile, USSFileName, { + attributes: zosAttributes, + binary: undefined, + includeHidden: undefined, + maxConcurrentRequests: undefined, + responseTimeout: undefined, + task: { + percentComplete: 0, + stageName: 0, + statusMessage: "Uploading USS file" + } + }); + expect(jsonObj).toMatchSnapshot(); + expect(apiMessage).toMatchSnapshot(); + expect(logMessage).toMatchSnapshot(); + }); }); }); diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap index 86e6283ffe..f13e49cc22 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Upload file-to-uss handler process method should upload a file to a uss if requested - zosattributes 1`] = ` +exports[`Upload file-to-uss handler process method should upload a file to a USS if requested - zosattributes file 1`] = ` Object { "apiResponse": Array [ Object { @@ -14,9 +14,9 @@ Object { } `; -exports[`Upload file-to-uss handler process method should upload a file to a uss if requested - zosattributes 2`] = `""`; +exports[`Upload file-to-uss handler process method should upload a file to a USS if requested - zosattributes file 2`] = `""`; -exports[`Upload file-to-uss handler process method should upload a file to a uss if requested - zosattributes 3`] = ` +exports[`Upload file-to-uss handler process method should upload a file to a USS if requested - zosattributes file 3`] = ` " -  success: true @@ -53,30 +53,3 @@ exports[`Upload file-to-uss handler process method should upload a file to a uss uploaded" `; - -exports[`Upload file-to-uss handler process method should upload a file to a uss if requested 4`] = ` -Object { - "apiResponse": Array [ - Object { - "from": "test-file", - "success": true, - "to": "testing", - }, - ], - "commandResponse": "uploaded", - "success": true, -} -`; - -exports[`Upload file-to-uss handler process method should upload a file to a uss if requested 5`] = `""`; - -exports[`Upload file-to-uss handler process method should upload a file to a uss if requested 6`] = ` -" --  - success: true - from:  test-file - to:  testing - - -uploaded" -`; From ad419118beabe1fa391648b31e7d5090bbee3422 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 24 Oct 2024 09:45:35 -0400 Subject: [PATCH 044/106] snapshot Signed-off-by: jace-roell --- .../cli.files.upload.ftu.integration.test.ts.snap | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__integration__/upload/ftu/__snapshots__/cli.files.upload.ftu.integration.test.ts.snap b/packages/cli/__tests__/zosfiles/__integration__/upload/ftu/__snapshots__/cli.files.upload.ftu.integration.test.ts.snap index 8d37ccd150..de432abd19 100644 --- a/packages/cli/__tests__/zosfiles/__integration__/upload/ftu/__snapshots__/cli.files.upload.ftu.integration.test.ts.snap +++ b/packages/cli/__tests__/zosfiles/__integration__/upload/ftu/__snapshots__/cli.files.upload.ftu.integration.test.ts.snap @@ -43,6 +43,10 @@ exports[`Upload uss file should display the help 1`] = ` Data content in encoding mode, which means that data conversion is performed according to the encoding specified. + --attributes | --attrs (string) + + Path of an attributes file to control how files are uploaded. + --response-timeout | --rto (number) The maximum amount of time in seconds the z/OSMF Files TSO servlet should run @@ -152,8 +156,8 @@ exports[`Upload uss file should display the help 1`] = ` \\"success\\": true, \\"exitCode\\": 0, \\"message\\": \\"The help was constructed for command: file-to-uss.\\", - \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n file-to-uss | ftu\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Upload content to a USS file from local file.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files upload file-to-uss [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n inputfile\\\\t\\\\t (string)\\\\n\\\\n The local file that you want to upload to a USS file\\\\n\\\\n USSFileName\\\\t\\\\t (string)\\\\n\\\\n The name of the USS file to which you want to upload the file\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --binary | -b (boolean)\\\\n\\\\n Data content in binary mode, which means that no data conversion is performed.\\\\n The data transfer process returns each record as-is, without translation. No\\\\n delimiters are added between records.\\\\n\\\\n --encoding | --ec (string)\\\\n\\\\n Data content in encoding mode, which means that data conversion is performed\\\\n according to the encoding specified.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\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 --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 - Upload to the USS file \\\\\\"/a/ibmuser/my_text.txt\\\\\\" from the\\\\n file \\\\\\"file.txt\\\\\\":\\\\n\\\\n $ zowe zos-files upload file-to-uss \\\\\\"file.txt\\\\\\" \\\\\\"/a/ibmuser/my_text.txt\\\\\\"\\\\n\\\\n\\", + \\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n file-to-uss | ftu\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Upload content to a USS file from local file.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files upload file-to-uss [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n inputfile\\\\t\\\\t (string)\\\\n\\\\n The local file that you want to upload to a USS file\\\\n\\\\n USSFileName\\\\t\\\\t (string)\\\\n\\\\n The name of the USS file to which you want to upload the file\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --binary | -b (boolean)\\\\n\\\\n Data content in binary mode, which means that no data conversion is performed.\\\\n The data transfer process returns each record as-is, without translation. No\\\\n delimiters are added between records.\\\\n\\\\n --encoding | --ec (string)\\\\n\\\\n Data content in encoding mode, which means that data conversion is performed\\\\n according to the encoding specified.\\\\n\\\\n --attributes | --attrs (string)\\\\n\\\\n Path of an attributes file to control how files are uploaded.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\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 --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 - Upload to the USS file \\\\\\"/a/ibmuser/my_text.txt\\\\\\" from the\\\\n file \\\\\\"file.txt\\\\\\":\\\\n\\\\n $ zowe zos-files upload file-to-uss \\\\\\"file.txt\\\\\\" \\\\\\"/a/ibmuser/my_text.txt\\\\\\"\\\\n\\\\n\\", \\"stderr\\": \\"\\", - \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n file-to-uss | ftu\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Upload content to a USS file from local file.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files upload file-to-uss [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n inputfile\\\\t\\\\t (string)\\\\n\\\\n The local file that you want to upload to a USS file\\\\n\\\\n USSFileName\\\\t\\\\t (string)\\\\n\\\\n The name of the USS file to which you want to upload the file\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --binary | -b (boolean)\\\\n\\\\n Data content in binary mode, which means that no data conversion is performed.\\\\n The data transfer process returns each record as-is, without translation. No\\\\n delimiters are added between records.\\\\n\\\\n --encoding | --ec (string)\\\\n\\\\n Data content in encoding mode, which means that data conversion is performed\\\\n according to the encoding specified.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\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 --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 - Upload to the USS file \\\\\\"/a/ibmuser/my_text.txt\\\\\\" from the\\\\n file \\\\\\"file.txt\\\\\\":\\\\n\\\\n $ zowe zos-files upload file-to-uss \\\\\\"file.txt\\\\\\" \\\\\\"/a/ibmuser/my_text.txt\\\\\\"\\\\n\\\\n\\" + \\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n file-to-uss | ftu\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Upload content to a USS file from local file.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe zos-files upload file-to-uss [options]\\\\n\\\\n POSITIONAL ARGUMENTS\\\\n --------------------\\\\n\\\\n inputfile\\\\t\\\\t (string)\\\\n\\\\n The local file that you want to upload to a USS file\\\\n\\\\n USSFileName\\\\t\\\\t (string)\\\\n\\\\n The name of the USS file to which you want to upload the file\\\\n\\\\n OPTIONS\\\\n -------\\\\n\\\\n --binary | -b (boolean)\\\\n\\\\n Data content in binary mode, which means that no data conversion is performed.\\\\n The data transfer process returns each record as-is, without translation. No\\\\n delimiters are added between records.\\\\n\\\\n --encoding | --ec (string)\\\\n\\\\n Data content in encoding mode, which means that data conversion is performed\\\\n according to the encoding specified.\\\\n\\\\n --attributes | --attrs (string)\\\\n\\\\n Path of an attributes file to control how files are uploaded.\\\\n\\\\n --response-timeout | --rto (number)\\\\n\\\\n The maximum amount of time in seconds the z/OSMF Files TSO servlet should run\\\\n before returning a response. Any request exceeding this amount of time will be\\\\n terminated and return an error. Allowed values: 5 - 600\\\\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 --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 - Upload to the USS file \\\\\\"/a/ibmuser/my_text.txt\\\\\\" from the\\\\n file \\\\\\"file.txt\\\\\\":\\\\n\\\\n $ zowe zos-files upload file-to-uss \\\\\\"file.txt\\\\\\" \\\\\\"/a/ibmuser/my_text.txt\\\\\\"\\\\n\\\\n\\" }" `; From 02c08339c1d342bf01acc26b3ea46d8474e8c6ca Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 24 Oct 2024 09:58:03 -0400 Subject: [PATCH 045/106] command definition descriptions and generic user ID in tests Signed-off-by: jace-roell --- .../receive/app/ReceiveASApp.handler.unit.test.ts | 2 +- .../cli/src/zostso/receive/app/ReceiveASApp.definition.ts | 4 ++-- .../cli/src/zostso/send/as-app/SendASApp.definition.ts | 6 +++--- .../cli/src/zostso/start/as-app/StartASApp.definition.ts | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts index bfb3e8b2f1..9f48e47261 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts @@ -51,7 +51,7 @@ describe("receive TSO app handler behavior", () => { const handler = new ReceiveASAppHandler.default(); const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); let error = undefined; - params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "JR897694-122-aabyaaaj", runUntilReady: true}; + params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "CUST009-122-aabyaaaj", runUntilReady: true}; try{ await handler.process(params); } diff --git a/packages/cli/src/zostso/receive/app/ReceiveASApp.definition.ts b/packages/cli/src/zostso/receive/app/ReceiveASApp.definition.ts index a63a3b4af7..8dafae9a58 100644 --- a/packages/cli/src/zostso/receive/app/ReceiveASApp.definition.ts +++ b/packages/cli/src/zostso/receive/app/ReceiveASApp.definition.ts @@ -26,14 +26,14 @@ export const ReceiveASApp: ICommandDefinition = { { name: "app-key", aliases: ["ak"], - description: "App Key", + description: "App key of application running at TSO address space, app key should be the value established when app instance was started", type: "string", required: true }, { name: "servlet-key", aliases: ["sk"], - description: "Servlet Key", + description: "Servlet Key of TSO address space", type: "string", required: true }, diff --git a/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts b/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts index b07757b0ef..ef2d06c501 100644 --- a/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts +++ b/packages/cli/src/zostso/send/as-app/SendASApp.definition.ts @@ -26,21 +26,21 @@ export const SendASApp: ICommandDefinition = { { name: "app-key", aliases: ["ak"], - description: "App Key", + description: "App key of application running at TSO address space, app key should be the value established when app instance was started", type: "string", required: true }, { name: "servlet-key", aliases: ["sk"], - description: "Servlet Key", + description: "Servlet Key of TSO address space", type: "string", required: true }, { name: "message", aliases: ["m"], - description: "Message", + description: "Message payload to be sent to the TSO address space application", type: "string", required: true } diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts index 263706f47f..85f0a35380 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts @@ -26,28 +26,28 @@ export const StartASApp: ICommandDefinition = { { name: "app-key", aliases: ["ak"], - description: "App Key", + description: "App key of application running at TSO address space, this app key value should be referenced when sending or receiving messages from the application instance", type: "string", required: true }, { name: "startup", aliases: ["sc"], - description: "Startup", + description: "Command to be ran to start application at the TSO address space", type: "string", required: true }, { name: "queue-id", aliases: ["qi"], - description: "Queue ID", + description: "Queue ID of TSO address space", type: "string", implies: ["servlet-key"] }, { name: "servlet-key", aliases: ["sk"], - description: "Servlet Key", + description: "Servlet Key of TSO address space", type: "string", implies: ["queue-id"] } From 3441ea74fa104ae695be9d702c0b07575764c6cd Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 24 Oct 2024 10:11:30 -0400 Subject: [PATCH 046/106] generic user replacement Signed-off-by: jace-roell --- .../app/ReceiveASApp.handler.unit.test.ts | 2 +- .../ReceiveASApp.handler.unit.test.ts.snap | 2 +- .../send/app/SendASApp.handler.unit.test.ts | 4 ++-- .../SendASApp.handler.unit.test.ts.snap | 2 +- .../start/app/StartASApp.handler.unit.test.ts | 10 +++++----- .../StartASApp.handler.unit.test.ts.snap | 4 ++-- .../__unit__/ReceiveTsoApp.unit.test.ts | 20 +++++++++---------- .../__unit__/SendTsoApp.unit.test.ts | 6 +++--- .../__unit__/StartTsoApp.unit.test.ts | 14 ++++++------- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts index 9f48e47261..8690c0e506 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts @@ -26,7 +26,7 @@ const MOCK_RECEIVE_RESPONSE: any = { version: undefined, reused: false, timeout: false, - servletKey: "JR897694-122-aabyaaaj", + servletKey: "CUST009-122-aabyaaaj", queueID: null, tsoData: [ { diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap index 660ac20308..24db489a36 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap @@ -13,7 +13,7 @@ exports[`receive TSO app handler behavior should properly receive and parse data Object { "queueID": null, "reused": false, - "servletKey": "JR897694-122-aabyaaaj", + "servletKey": "CUST009-122-aabyaaaj", "timeout": false, "tsoData": Array [ Object { diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts index f56c1963c3..e3c90ed872 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts @@ -23,7 +23,7 @@ const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ definition: SendASAppDefinition.SendASApp }); const MOCK_SEND_RESPONSE = Promise.resolve({ - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", ver: "0100", tsoData: [ { @@ -56,7 +56,7 @@ describe("receive TSO app handler behavior", () => { const handler = new SendASAppHandler.default(); const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); let error = undefined; - params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "JR897694-129-aaceaaap", message: "LONG 100"}; + params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "CUST009-129-aaceaaap", message: "LONG 100"}; try{ await handler.process(params); } diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap index 364a1bf59d..2845b9254b 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap @@ -5,7 +5,7 @@ exports[`receive TSO app handler behavior should properly receive and parse data \\"version\\": \\"0100\\", \\"reused\\": false, \\"timeout\\": false, - \\"servletKey\\": \\"JR897694-127-aabeaaag\\", + \\"servletKey\\": \\"CUST009-127-aabeaaag\\", \\"queueID\\": null, \\"tsoData\\": [ { diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts index cb0259dbd3..1681461fac 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts @@ -43,7 +43,7 @@ const MOCK_RESPONSE = Promise.resolve({ version: "0100", reused: false, timeout: false, - servletKey: "JR897694-123-aaaaaa", + servletKey: "CUST009-123-aaaaaa", queueID: "983068", tsoData: [ { @@ -77,14 +77,14 @@ const MOCK_RESPONSE = Promise.resolve({ const MOCK_START_RESPONSE: Promise = Promise.resolve({ collectedResponses: [], messages: - "IKJ56455I JR897694 LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", - servletKey: "JR897694-123-aaaaaa", + "IKJ56455I CUST009 LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", + servletKey: "CUST009-123-aaaaaa", success: true, zosmfTsoResponse: { ver: "0100", queueID: "983068", reused: false, - servletKey: "JR897694-123-aaaaaa", + servletKey: "CUST009-123-aaaaaa", sessionID: "0x00", timeout: false, tsoData: [{}], @@ -140,7 +140,7 @@ describe("receive TSO app handler behavior", () => { account: "izuacct", startup: "EXEC 'CUST009.PUBLIC.REXX(VAREXX)'", queueId: "983068", - servletKey: "JR897694-123-aaaaaa", + servletKey: "CUST009-123-aaaaaa", appKey: "test2", }; try { diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap index e41de0a8af..74d74a704c 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap @@ -4,7 +4,7 @@ exports[`receive TSO app handler behavior should properly start TSO address spac "{ \\"reused\\": false, \\"timeout\\": false, - \\"servletKey\\": \\"JR897694-123-aaaaaa\\", + \\"servletKey\\": \\"CUST009-123-aaaaaa\\", \\"queueID\\": \\"983068\\", \\"tsoData\\": [ { @@ -35,7 +35,7 @@ exports[`receive TSO app handler behavior should properly start TSO address spac "{ \\"reused\\": false, \\"timeout\\": false, - \\"servletKey\\": \\"JR897694-123-aaaaaa\\", + \\"servletKey\\": \\"CUST009-123-aaaaaa\\", \\"queueID\\": \\"983068\\", \\"tsoData\\": [ { diff --git a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts index 0d7faa1ba0..6f56e6ed59 100644 --- a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts @@ -27,7 +27,7 @@ const MOCK_RECEIVE_RESPONSE: any = { version: undefined, reused: false, timeout: false, - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", queueID: null, tsoData: [ { @@ -43,7 +43,7 @@ const MOCK_TIMEOUT_RESPONSE: any = { version: undefined, reused: false, timeout: true, - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", queueID: null, tsoData: [], }; @@ -59,7 +59,7 @@ describe("ReceiveTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", appKey: "someAppKey", timeout: 10, receiveUntilReady: true, @@ -80,7 +80,7 @@ describe("ReceiveTsoApp behavior", () => { version: undefined, reused: false, timeout: false, - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", queueID: null, tsoData: [ { VERSION: "0100", DATA: "Processing started." }, @@ -95,7 +95,7 @@ describe("ReceiveTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", appKey: "someAppKey", timeout: 10, receiveUntilReady: true, @@ -119,7 +119,7 @@ describe("ReceiveTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", appKey: "someAppKey", timeout: 1, receiveUntilReady: true, @@ -141,7 +141,7 @@ describe("ReceiveTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", appKey: "someAppKey", timeout: 10, receiveUntilReady: true, @@ -158,7 +158,7 @@ describe("ReceiveTsoApp behavior", () => { version: "0100", reused: false, timeout: false, - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", queueID: null, tsoData: [{"TSO MESSAGE":{ VERSION: "0100", DATA: "First response data." }}], }; @@ -168,7 +168,7 @@ describe("ReceiveTsoApp behavior", () => { version: "0100", reused: false, timeout: false, - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", queueID: null, tsoData: [ {"TSO MESSAGE":{ VERSION: "0100", DATA: "Second response data." }}, @@ -182,7 +182,7 @@ describe("ReceiveTsoApp behavior", () => { .mockResolvedValueOnce(mockResponse2); // Second call const params: ITsoAppCommunicationParms = { - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", appKey: "someAppKey", timeout: 10, receiveUntilReady: true, diff --git a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts index 11385b42ec..e7601abd0a 100644 --- a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts @@ -24,7 +24,7 @@ const PRETEND_SESSION = new Session({ }); const MOCK_SEND_RESPONSE = Promise.resolve({ - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", ver: "0100", tsoData: [ { @@ -55,7 +55,7 @@ describe("SendTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", appKey: "someAppKey", message: "Test message", }; @@ -78,7 +78,7 @@ describe("SendTsoApp behavior", () => { version: "0100", reused: false, timeout: false, - servletKey: "JR897694-127-aabeaaag", + servletKey: "CUST009-127-aabeaaag", queueID: null, tsoData: [ { diff --git a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts index 8d354f683e..93fb532c82 100644 --- a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts @@ -27,7 +27,7 @@ const MOCK_RESPONSE = Promise.resolve({ version: "0100", reused: false, timeout: false, - servletKey: "JR897694-123-aaaaaa", + servletKey: "CUST009-123-aaaaaa", queueID: "983068", tsoData: [ { "TSO MESSAGE": { VERSION: "0100", DATA: "HELLOW exec processing has started." } }, @@ -40,14 +40,14 @@ const MOCK_RESPONSE = Promise.resolve({ const MOCK_START_RESPONSE: Promise = Promise.resolve({ collectedResponses: [], - messages: "IKJ56455I JR897694 LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", - servletKey: "JR897694-123-aaaaaa", + messages: "IKJ56455I CUST009 LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", + servletKey: "CUST009-123-aaaaaa", success: true, zosmfTsoResponse: { ver: "0100", queueID: "983068", reused: false, - servletKey: "JR897694-123-aaaaaa", + servletKey: "CUST009-123-aaaaaa", sessionID: "0x00", timeout: false, tsoData: [{}] @@ -78,7 +78,7 @@ describe("StartTsoApp behavior", () => { }) ); expect(response).toMatchObject({ - servletKey: "JR897694-123-aaaaaa", + servletKey: "CUST009-123-aaaaaa", queueID: "983068", tsoData: expect.arrayContaining([ expect.objectContaining({ DATA: "HELLOW exec processing has started." }) @@ -93,7 +93,7 @@ describe("StartTsoApp behavior", () => { startupCommand: "EXEC 'TEST.EXEC(THISSCRIPTDOESNOTEXIST)'", appKey: "testappkey", queueID: "12345", - servletKey: "JR897694-123-aaaaaaaa" + servletKey: "CUST009-123-aaaaaaaa" }, null); expect(StartTso.start).not.toHaveBeenCalled(); @@ -106,7 +106,7 @@ describe("StartTsoApp behavior", () => { }) ); expect(response).toMatchObject({ - servletKey: "JR897694-123-aaaaaaaa", + servletKey: "CUST009-123-aaaaaaaa", queueID: "12345", tsoData: expect.arrayContaining([ expect.objectContaining({ DATA: "HELLOW exec processing has started." }) From 6c08a008173e7f074cc45a092f7bc60c3c45962c Mon Sep 17 00:00:00 2001 From: Pujal Date: Thu, 24 Oct 2024 10:41:18 -0400 Subject: [PATCH 047/106] updated unit tests sample jobs Signed-off-by: Pujal --- .../zosjobs/__resources__/GetJobsData.ts | 6 ++++ .../Job.handler.unit.test.ts.snap | 4 +++ .../Job.handler.unit.test.ts.snap | 4 +++ .../OldJobs.handler.unit.test.ts.snap | 32 +++++++++++++++++++ .../Jobs.handler.unit.test.ts.snap | 24 ++++++++++++++ .../modify/job/Job.handler.unit.test.ts | 2 ++ ...JobStatusByJobid.handler.unit.test.ts.snap | 4 +++ .../__unit__/CancelJobs.unit.test.ts | 4 ++- .../__unit__/DeleteJobs.unit.test.ts | 2 ++ .../__unit__/SubmitJobs.unit.test.ts | 3 ++ packages/zosjobs/src/GetJobs.ts | 2 +- 11 files changed, 85 insertions(+), 2 deletions(-) diff --git a/packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts b/packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts index 56a1fe3f59..ac4ea88163 100644 --- a/packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts +++ b/packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts @@ -27,6 +27,8 @@ export class GetJobsData { public static readonly SAMPLE_COMPLETE_JOB: IJob = { "jobid": "TSUxxx", "jobname": "IBMUSER$", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', "subsystem": "JES2", "owner": "IBMUSER", "status": "OUTPUT", @@ -49,6 +51,8 @@ export class GetJobsData { public static readonly SAMPLE_COMPLETE_JOB_AGAIN: IJob = { "jobid": "JOBxxx", "jobname": "CAUSER$", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', "subsystem": "JES2", "owner": "CAUSER", "status": "OUTPUT", @@ -79,6 +83,8 @@ export class GetJobsData { public static readonly SAMPLE_ACTIVE_JOB: IJob = { "retcode": null, "jobname": "KELDA16$", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', "status": "INPUT", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "class": "A", diff --git a/packages/cli/__tests__/zosjobs/__unit__/cancel/job/__snapshots__/Job.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/cancel/job/__snapshots__/Job.handler.unit.test.ts.snap index a2ca50e52b..b0305e5ab1 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/cancel/job/__snapshots__/Job.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/cancel/job/__snapshots__/Job.handler.unit.test.ts.snap @@ -7,6 +7,8 @@ exports[`cancel job handler tests should be able to cancel a job by job id 2`] = exports[`cancel job handler tests should be able to cancel a job by job id 3`] = ` Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -29,6 +31,8 @@ exports[`cancel job handler tests should be able to cancel a job by job id versi exports[`cancel job handler tests should be able to cancel a job by job id version 2.0 3`] = ` Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", diff --git a/packages/cli/__tests__/zosjobs/__unit__/delete/job/__snapshots__/Job.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/delete/job/__snapshots__/Job.handler.unit.test.ts.snap index 520ed858b3..45ea1c2358 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/delete/job/__snapshots__/Job.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/delete/job/__snapshots__/Job.handler.unit.test.ts.snap @@ -7,6 +7,8 @@ exports[`delete job handler tests should be able to delete a job by job id 2`] = exports[`delete job handler tests should be able to delete a job by job id 3`] = ` Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -29,6 +31,8 @@ exports[`delete job handler tests should be able to delete a job by job id versi exports[`delete job handler tests should be able to delete a job by job id version 2.0 3`] = ` Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", diff --git a/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/__snapshots__/OldJobs.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/__snapshots__/OldJobs.handler.unit.test.ts.snap index 5a8b586a63..4cd83b11c3 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/__snapshots__/OldJobs.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/__snapshots__/OldJobs.handler.unit.test.ts.snap @@ -13,6 +13,8 @@ Object { "output": Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -28,6 +30,8 @@ Object { }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -51,6 +55,8 @@ exports[`delete old-jobs handler tests should delete all jobs using defaults in Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -66,6 +72,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -95,6 +103,8 @@ Object { "output": Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -110,6 +120,8 @@ Object { }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -133,6 +145,8 @@ exports[`delete old-jobs handler tests should delete all jobs using defaults seq Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -148,6 +162,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -177,6 +193,8 @@ Object { "output": Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -192,6 +210,8 @@ Object { }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -215,6 +235,8 @@ exports[`delete old-jobs handler tests should delete jobs with a specific prefix Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -230,6 +252,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -259,6 +283,8 @@ Object { "output": Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -274,6 +300,8 @@ Object { }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -297,6 +325,8 @@ exports[`delete old-jobs handler tests should delete jobs with modifyVersion 2.0 Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -312,6 +342,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", diff --git a/packages/cli/__tests__/zosjobs/__unit__/list/jobs/__snapshots__/Jobs.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/list/jobs/__snapshots__/Jobs.handler.unit.test.ts.snap index a1b05c64c4..1a05549051 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/list/jobs/__snapshots__/Jobs.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/list/jobs/__snapshots__/Jobs.handler.unit.test.ts.snap @@ -4,6 +4,8 @@ exports[`list jobs handler tests should be able to get a list of jobs for a spec Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -19,6 +21,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -49,6 +53,8 @@ Object { "output": Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -64,6 +70,8 @@ Object { }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -85,6 +93,8 @@ exports[`list jobs handler tests should be able to get a list of jobs for a spec Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -100,6 +110,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -130,6 +142,8 @@ Object { "output": Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -145,6 +159,8 @@ Object { }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -166,6 +182,8 @@ exports[`list jobs handler tests should be able to get a list of jobs using defa Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -181,6 +199,8 @@ Array [ }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -211,6 +231,8 @@ Object { "output": Array [ Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -226,6 +248,8 @@ Object { }, Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", diff --git a/packages/cli/__tests__/zosjobs/__unit__/modify/job/Job.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/modify/job/Job.handler.unit.test.ts index b703740e85..48f39b426a 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/modify/job/Job.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/modify/job/Job.handler.unit.test.ts @@ -39,6 +39,8 @@ const SAMPLE_COMPLETE_JOB: IJob= { "subsystem": "JES2", "type": "JOB", "url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', }; const SUCCESS_FEEDBACK: IJobFeedback = { diff --git a/packages/cli/__tests__/zosjobs/__unit__/view/job/__snapshots__/JobStatusByJobid.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/view/job/__snapshots__/JobStatusByJobid.handler.unit.test.ts.snap index c41d29f992..dc0a0152cc 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/view/job/__snapshots__/JobStatusByJobid.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/view/job/__snapshots__/JobStatusByJobid.handler.unit.test.ts.snap @@ -5,6 +5,8 @@ exports[`view job-status-by-jobid handler tests should be able respond with erro exports[`view job-status-by-jobid handler tests should be able to get a job 1`] = ` Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -33,6 +35,8 @@ Object { "format": "object", "output": Object { "class": "A", + "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-started": "2024-01-02T15:57:58.350Z", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", diff --git a/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts index 8d19923dc9..a5f134c171 100644 --- a/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts @@ -40,7 +40,9 @@ describe("Cancel Jobs unit tests", () => { "files-url": "myfakeurl.com/files/records", "phase": 2, "phase-name": "OUTPUT", - "job-correlator": "mycorrelator" + "job-correlator": "mycorrelator", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', }; describe("Positive tests", () => { it("should allow users to call cancelJob with correct parameters", async () => { diff --git a/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts index c28a5c0015..761d14f0d6 100644 --- a/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts @@ -31,6 +31,8 @@ describe("Delete Jobs unit tests", () => { const fakeJob: IJob = { "jobid": "JOB00001", "jobname": "MYJOB1", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', "retcode": "CC 0000", "owner": "dummy", "subsystem": "JES2", diff --git a/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts index 55d6257d1c..74c5a8c189 100644 --- a/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts @@ -27,6 +27,7 @@ const expectedMockSpoolContent = "Hello! This is my spool content."; const jobFiles: IJobFile[] = [{ "jobid": fakeJobID, "jobname": fakeJobName, + "id": 0, "recfm": "FB", "lrecl": 80, @@ -44,6 +45,8 @@ const sampleJob: IJob = { "jobid": fakeJobID, "jobname": fakeJobName, "subsystem": "JES2", + "exec-started": '2024-01-02T15:57:58.350Z', + "exec-ended": '2024-01-02T15:58:00.600Z', "owner": "IBMUSER", "status": "OUTPUT", "type": "job", diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index ff20d355c6..172f6770f0 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -153,7 +153,7 @@ export class GetJobs { Logger.getAppLogger().trace("GetJobs.getJobsCommon()"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); let query = JobsConstants.QUERY_ID; - params.execData = true; // always returning start and end time data + // params.execData = true; // always returning start and end time data if (params) { if (params.owner) { From cec51f4070935f3e2c1a23882e31fd200bc21d42 Mon Sep 17 00:00:00 2001 From: Pujal Date: Thu, 24 Oct 2024 11:58:49 -0400 Subject: [PATCH 048/106] updated code Signed-off-by: Pujal --- packages/zosjobs/src/GetJobs.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 172f6770f0..b220afb240 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -108,7 +108,7 @@ export class GetJobs { ImperativeExpect.toBeDefinedAndNonBlank(jobid, "jobid"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); const jobs = await GetJobs.getJobsCommon(session, { jobid, owner: "*" }); - + const userMsg: string = "Cannot obtain job info for job id = " + jobid; const diagInfo: string = "Protocol: " + session.ISession.protocol + @@ -153,7 +153,7 @@ export class GetJobs { Logger.getAppLogger().trace("GetJobs.getJobsCommon()"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); let query = JobsConstants.QUERY_ID; - // params.execData = true; // always returning start and end time data + let includeExecData = params?.execData != false; if (params) { if (params.owner) { @@ -181,7 +181,7 @@ export class GetJobs { } query += JobsConstants.QUERY_JOBID + encodeURIComponent(params.jobid); } - if (params.execData) { + if (includeExecData) { if (RestClient.hasQueryString(query)) { query += JobsConstants.COMBO_ID; } From fc488da6c7397fbcd1d2328b45fa5819d48c986f Mon Sep 17 00:00:00 2001 From: Pujal Date: Thu, 24 Oct 2024 12:22:43 -0400 Subject: [PATCH 049/106] fixed linting errors Signed-off-by: Pujal --- .../test_plugins/override_plugin/package.json | 2 +- .../__tests__/__unit__/SubmitJobs.unit.test.ts | 2 +- .../__snapshots__/GetJobs.unit.test.ts.snap | 18 +++++++++--------- packages/zosjobs/src/GetJobs.ts | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/override_plugin/package.json b/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/override_plugin/package.json index 8851951c26..8a0fb0e246 100644 --- a/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/override_plugin/package.json +++ b/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/override_plugin/package.json @@ -1,5 +1,5 @@ { - "name": "override-plugin", + "name": "@zowe/secrets-for-kubernetes-for-zowe-cli", "version": "1.0.1", "description": "Some description", "main": "lib/index.js", diff --git a/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts index 74c5a8c189..0b03de6bda 100644 --- a/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts @@ -27,7 +27,7 @@ const expectedMockSpoolContent = "Hello! This is my spool content."; const jobFiles: IJobFile[] = [{ "jobid": fakeJobID, "jobname": fakeJobName, - + "id": 0, "recfm": "FB", "lrecl": 80, diff --git a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap index 707755244a..2d849555e1 100644 --- a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap +++ b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap @@ -439,23 +439,23 @@ Array [ ] `; -exports[`GetJobs tests getJobs APIs should have proper URI when using all parms 1`] = `"/zosmf/restjobs/jobs?owner=fakeOwner&prefix=fakePrefix&max-jobs=2&jobid=fakeID"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using all parms 1`] = `"/zosmf/restjobs/jobs?owner=fakeOwner&prefix=fakePrefix&max-jobs=2&jobid=fakeID&exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using jobid 1`] = `"/zosmf/restjobs/jobs?jobid=fakeJobid"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using jobid 1`] = `"/zosmf/restjobs/jobs?jobid=fakeJobid&exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using jobname and jobid 1`] = `"/zosmf/restjobs/jobs?owner=someOwner&prefix=somePrefix"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using jobname and jobid 1`] = `"/zosmf/restjobs/jobs?owner=someOwner&prefix=somePrefix&exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using jobname, prefix, and jobid 1`] = `"/zosmf/restjobs/jobs?owner=someOwner&prefix=somePrefix&jobid=fakeJobid"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using jobname, prefix, and jobid 1`] = `"/zosmf/restjobs/jobs?owner=someOwner&prefix=somePrefix&jobid=fakeJobid&exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using maxjobs 1`] = `"/zosmf/restjobs/jobs?max-jobs=10"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using maxjobs 1`] = `"/zosmf/restjobs/jobs?max-jobs=10&exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using no parms 1`] = `"/zosmf/restjobs/jobs"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using no parms 1`] = `"/zosmf/restjobs/jobs?exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using owner 1`] = `"/zosmf/restjobs/jobs?owner=fakeOwner"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using owner 1`] = `"/zosmf/restjobs/jobs?owner=fakeOwner&exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using prefix 1`] = `"/zosmf/restjobs/jobs?prefix=fakePrefix"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using prefix 1`] = `"/zosmf/restjobs/jobs?prefix=fakePrefix&exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using status 1`] = `"/zosmf/restjobs/jobs?status=active"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using status 1`] = `"/zosmf/restjobs/jobs?exec-data=Y&status=active"`; exports[`GetJobs tests getJobs APIs should locate a job by jobid 1`] = ` Object { diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index b220afb240..5ff8cb142a 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -108,7 +108,7 @@ export class GetJobs { ImperativeExpect.toBeDefinedAndNonBlank(jobid, "jobid"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); const jobs = await GetJobs.getJobsCommon(session, { jobid, owner: "*" }); - + const userMsg: string = "Cannot obtain job info for job id = " + jobid; const diagInfo: string = "Protocol: " + session.ISession.protocol + @@ -153,7 +153,7 @@ export class GetJobs { Logger.getAppLogger().trace("GetJobs.getJobsCommon()"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); let query = JobsConstants.QUERY_ID; - let includeExecData = params?.execData != false; + const includeExecData = params?.execData != false; if (params) { if (params.owner) { From 6ec2809eaf16a8245eaf0c57c5fd90642376ad7d Mon Sep 17 00:00:00 2001 From: jace-roell Date: Thu, 24 Oct 2024 14:31:06 -0400 Subject: [PATCH 050/106] system tests Signed-off-by: jace-roell --- .../methods/upload/Upload.system.test.ts | 35 +++++++++++++++++++ .../upload/__resources__/.zosattributes | 5 +++ .../__resources__/upload_file_to_uss.sh | 13 +++++++ .../upload/testfiles/encodingCheck.txt | 1 + 4 files changed, 54 insertions(+) create mode 100644 packages/zosfiles/__tests__/__system__/methods/upload/__resources__/.zosattributes create mode 100755 packages/zosfiles/__tests__/__system__/methods/upload/__resources__/upload_file_to_uss.sh create mode 100644 packages/zosfiles/__tests__/__system__/methods/upload/testfiles/encodingCheck.txt diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts index e0797df365..4376ab4d9e 100644 --- a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts @@ -18,6 +18,7 @@ import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/prope import { deleteFiles, getUniqueDatasetName, stripNewLines, wait, waitTime } from "../../../../../../__tests__/__src__/TestUtils"; import * as fs from "fs"; import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; +import { runCliScript } from "../../../../../../__tests__/__packages__/cli-test-utils/src"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -25,8 +26,10 @@ let defaultSystem: ITestPropertiesSchema; let dsname: string; let ussname: string; const inputfile = __dirname + "/testfiles/upload.txt"; +const encodingCheck = __dirname + "/testfiles/encodingCheck.txt"; const testdata = "abcdefghijklmnopqrstuvwxyz"; const uploadOptions: IUploadOptions = {} as any; +let TEST_ENVIRONMENT: ITestEnvironment; describe("Upload Data Set", () => { @@ -848,6 +851,38 @@ describe("Upload USS file", () => { expect(uploadResponse.success).toBeTruthy(); expect(uploadResponse.apiResponse.etag).toBeDefined(); }); + it("should upload local file to USS using .zosattributes file", async () => { + TEST_ENVIRONMENT = await TestEnvironment.setUp({ + testName: "zos_files_file_to_uss", + }); + const systemProperties = TEST_ENVIRONMENT.systemTestProperties; + const ACCOUNT_NUMBER = systemProperties.tso.account; + let response: any; + let error; + let uploadResponse; + let getResponse; + let tagResponse; + try { + response = runCliScript(__dirname + "/__resources__/upload_file_to_uss.sh", TEST_ENVIRONMENT,[ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + __dirname + "/testfiles/encodingCheck.txt", + "/u/users/jr897694/usstest.txt", + __dirname + "/__resources__/.zosattributes", + ]); + } + catch (err) { + error = err; + Imperative.console.info("Error: " + inspect(error)); + } + expect(response.stderr.toString()).toBe(""); + expect(response.stdout.toString()).toBeDefined(); + expect(response.stdout.toString()).toContain("USS file uploaded successfully."); + }); }); }); diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/.zosattributes b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/.zosattributes new file mode 100644 index 0000000000..88a1b0f51f --- /dev/null +++ b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/.zosattributes @@ -0,0 +1,5 @@ +*.json - +*.bin binary binary +*.jcl IBM-1047 IBM-1047 +*.md UTF-8 UTF-8 +*.txt UTF-8 IBM-1047 \ No newline at end of file diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/upload_file_to_uss.sh b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/upload_file_to_uss.sh new file mode 100755 index 0000000000..ae60e4afa2 --- /dev/null +++ b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/upload_file_to_uss.sh @@ -0,0 +1,13 @@ +#!/bin/bash +account=$1 +host=$2 +port=$3 +user=$4 +password=$5 +ru=$6 +inputFile=$7 +ussName=$8 +attributes=$9 + +zowe zos-files upload file-to-uss $inputFile $ussName --attributes $attributes --host $host --port $port --user $user --password $password --ru $ru +exit $? \ No newline at end of file diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/encodingCheck.txt b/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/encodingCheck.txt new file mode 100644 index 0000000000..98ce8af41b --- /dev/null +++ b/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/encodingCheck.txt @@ -0,0 +1 @@ +á é í ó ú ñ Ç ß 12345 !@#$% \ No newline at end of file From c8cf9eedbae1c3f6e572930cf848d00252c35000 Mon Sep 17 00:00:00 2001 From: Pujal Date: Thu, 24 Oct 2024 15:51:50 -0400 Subject: [PATCH 051/106] updated code with PR comments Signed-off-by: Pujal --- .../zosjobs/__resources__/GetJobsData.ts | 9 ++ .../Job.handler.unit.test.ts.snap | 6 ++ .../Job.handler.unit.test.ts.snap | 6 ++ .../OldJobs.handler.unit.test.ts.snap | 48 ++++++++++ .../Jobs.handler.unit.test.ts.snap | 36 ++++++++ .../modify/job/Job.handler.unit.test.ts | 3 + ...JobStatusByJobid.handler.unit.test.ts.snap | 6 ++ packages/zosjobs/CHANGELOG.md | 2 +- .../__resources__/api/GetJobsData.ts | 9 ++ .../__unit__/CancelJobs.unit.test.ts | 3 + .../__unit__/DeleteJobs.unit.test.ts | 5 +- .../__tests__/__unit__/GetJobs.unit.test.ts | 25 ++++-- .../__unit__/SubmitJobs.unit.test.ts | 3 + .../__snapshots__/GetJobs.unit.test.ts.snap | 87 +++++++++++++++++++ packages/zosjobs/src/GetJobs.ts | 2 +- packages/zosjobs/src/doc/response/IJob.ts | 21 +++++ 16 files changed, 263 insertions(+), 8 deletions(-) diff --git a/packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts b/packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts index ac4ea88163..1bb395ed13 100644 --- a/packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts +++ b/packages/cli/__tests__/zosjobs/__resources__/GetJobsData.ts @@ -29,6 +29,9 @@ export class GetJobsData { "jobname": "IBMUSER$", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z', "subsystem": "JES2", "owner": "IBMUSER", "status": "OUTPUT", @@ -53,6 +56,9 @@ export class GetJobsData { "jobname": "CAUSER$", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z', "subsystem": "JES2", "owner": "CAUSER", "status": "OUTPUT", @@ -85,6 +91,9 @@ export class GetJobsData { "jobname": "KELDA16$", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z', "status": "INPUT", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "class": "A", diff --git a/packages/cli/__tests__/zosjobs/__unit__/cancel/job/__snapshots__/Job.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/cancel/job/__snapshots__/Job.handler.unit.test.ts.snap index b0305e5ab1..14675179cb 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/cancel/job/__snapshots__/Job.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/cancel/job/__snapshots__/Job.handler.unit.test.ts.snap @@ -8,7 +8,10 @@ exports[`cancel job handler tests should be able to cancel a job by job id 3`] = Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -32,7 +35,10 @@ exports[`cancel job handler tests should be able to cancel a job by job id versi Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", diff --git a/packages/cli/__tests__/zosjobs/__unit__/delete/job/__snapshots__/Job.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/delete/job/__snapshots__/Job.handler.unit.test.ts.snap index 45ea1c2358..240d19e4d6 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/delete/job/__snapshots__/Job.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/delete/job/__snapshots__/Job.handler.unit.test.ts.snap @@ -8,7 +8,10 @@ exports[`delete job handler tests should be able to delete a job by job id 3`] = Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -32,7 +35,10 @@ exports[`delete job handler tests should be able to delete a job by job id versi Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", diff --git a/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/__snapshots__/OldJobs.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/__snapshots__/OldJobs.handler.unit.test.ts.snap index 4cd83b11c3..3a0dd3c904 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/__snapshots__/OldJobs.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/__snapshots__/OldJobs.handler.unit.test.ts.snap @@ -14,7 +14,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -31,7 +34,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -56,7 +62,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -73,7 +82,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -104,7 +116,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -121,7 +136,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -146,7 +164,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -163,7 +184,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -194,7 +218,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -211,7 +238,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -236,7 +266,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -253,7 +286,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -284,7 +320,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -301,7 +340,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -326,7 +368,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -343,7 +388,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", diff --git a/packages/cli/__tests__/zosjobs/__unit__/list/jobs/__snapshots__/Jobs.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/list/jobs/__snapshots__/Jobs.handler.unit.test.ts.snap index 1a05549051..21f22a85a1 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/list/jobs/__snapshots__/Jobs.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/list/jobs/__snapshots__/Jobs.handler.unit.test.ts.snap @@ -5,7 +5,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -22,7 +25,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -54,7 +60,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -71,7 +80,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -94,7 +106,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -111,7 +126,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -143,7 +161,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -160,7 +181,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -183,7 +207,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -200,7 +227,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", @@ -232,7 +262,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -249,7 +282,10 @@ Object { Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "JOBxxx", diff --git a/packages/cli/__tests__/zosjobs/__unit__/modify/job/Job.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/modify/job/Job.handler.unit.test.ts index 48f39b426a..afe417b4ee 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/modify/job/Job.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/modify/job/Job.handler.unit.test.ts @@ -41,6 +41,9 @@ const SAMPLE_COMPLETE_JOB: IJob= { "url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z' }; const SUCCESS_FEEDBACK: IJobFeedback = { diff --git a/packages/cli/__tests__/zosjobs/__unit__/view/job/__snapshots__/JobStatusByJobid.handler.unit.test.ts.snap b/packages/cli/__tests__/zosjobs/__unit__/view/job/__snapshots__/JobStatusByJobid.handler.unit.test.ts.snap index dc0a0152cc..a9e6fb30eb 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/view/job/__snapshots__/JobStatusByJobid.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zosjobs/__unit__/view/job/__snapshots__/JobStatusByJobid.handler.unit.test.ts.snap @@ -6,7 +6,10 @@ exports[`view job-status-by-jobid handler tests should be able to get a job 1`] Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -36,7 +39,10 @@ Object { "output": Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", diff --git a/packages/zosjobs/CHANGELOG.md b/packages/zosjobs/CHANGELOG.md index 19a20c38ec..efed2c155e 100644 --- a/packages/zosjobs/CHANGELOG.md +++ b/packages/zosjobs/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to the Zowe z/OS jobs SDK package will be documented in this file. ## Recent Changes -- Enhancement: Added "exec-started" and "exec-ended" to IJob return data from GetJobs.getJob [#2320](https://github.com/zowe/zowe-cli/pull/2320) +- Enhancement: Added execData to IJob return data from GetJobs.getJob [#2320](https://github.com/zowe/zowe-cli/pull/2320) ## `8.1.1` diff --git a/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts b/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts index a9cf78e74c..fb58d21b0d 100644 --- a/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts +++ b/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts @@ -31,6 +31,9 @@ export class GetJobsData { "jobname": "IBMUSER$", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-submitted": '2024-01-02T15:58:00.600Z', + "exec-member": 'DE20', + "exec-system": 'DE20', "subsystem": "JES2", "owner": "IBMUSER", "status": "OUTPUT", @@ -55,6 +58,9 @@ export class GetJobsData { "jobname": "CAUSER$", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-submitted": '2024-01-02T15:58:00.600Z', + "exec-member": 'DE20', + "exec-system": 'DE20', "subsystem": "JES2", "owner": "CAUSER", "status": "OUTPUT", @@ -87,6 +93,9 @@ export class GetJobsData { "jobname": "IBMUSER$", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-submitted": '2024-01-02T15:58:00.600Z', + "exec-member": 'DE20', + "exec-system": 'DE20', "status": "INPUT", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "class": "A", diff --git a/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts index a5f134c171..655555e852 100644 --- a/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts @@ -43,6 +43,9 @@ describe("Cancel Jobs unit tests", () => { "job-correlator": "mycorrelator", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z' }; describe("Positive tests", () => { it("should allow users to call cancelJob with correct parameters", async () => { diff --git a/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts index 761d14f0d6..d6bf063145 100644 --- a/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts @@ -43,7 +43,10 @@ describe("Delete Jobs unit tests", () => { "files-url": "myfakeurl.com/files/records", "phase": 2, "phase-name": "OUTPUT", - "job-correlator": "mycorrelator" + "job-correlator": "mycorrelator", + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z' }; describe("Positive tests", () => { diff --git a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts index 1c8b941cb1..3f66dc74d7 100644 --- a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts @@ -598,7 +598,10 @@ describe("GetJobs tests", () => { 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', 'exec-started': '2024-01-02T15:57:58.350Z', - 'exec-ended': '2024-01-02T15:58:00.600Z' + 'exec-ended': '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z' }, { jobid: '2', jobname: 'b', subsystem: 'sub', @@ -607,7 +610,10 @@ describe("GetJobs tests", () => { 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', 'exec-started': '2024-01-02T15:57:58.350Z', - 'exec-ended': '2024-01-02T15:58:00.600Z' + 'exec-ended': '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z' }, { jobid: '3', jobname: 'c', subsystem: 'sub', @@ -616,7 +622,10 @@ describe("GetJobs tests", () => { 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', 'exec-started': '2024-01-02T15:57:58.350Z', - 'exec-ended': '2024-01-02T15:58:00.600Z' + 'exec-ended': '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z' } ]; @@ -628,7 +637,10 @@ describe("GetJobs tests", () => { 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', 'exec-started': '2024-01-02T15:57:58.350Z', - 'exec-ended': '2024-01-02T15:58:00.600Z' + 'exec-ended': '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z' }, { jobid: '3', jobname: 'c', subsystem: 'sub', @@ -637,7 +649,10 @@ describe("GetJobs tests", () => { 'files-url': '', 'job-correlator': '', phase: 1, 'phase-name': 'name', 'reason-not-running': 'no', 'exec-started': '2024-01-02T15:57:58.350Z', - 'exec-ended': '2024-01-02T15:58:00.600Z' + 'exec-ended': '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z' } ]; const filteredResults = GetJobs['filterResultsByStatuses'](jobs, { status: 'OUTPUT', owner: 'zowe' }); diff --git a/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts index 0b03de6bda..da4305381a 100644 --- a/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts @@ -47,6 +47,9 @@ const sampleJob: IJob = { "subsystem": "JES2", "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', + "exec-member": 'SYS1', + "exec-system": 'SYS1', + "exec-submitted": '2024-01-02T15:58:00.600Z', "owner": "IBMUSER", "status": "OUTPUT", "type": "job", diff --git a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap index 2d849555e1..ca74e41c93 100644 --- a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap +++ b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap @@ -15,7 +15,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -32,7 +35,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -54,7 +60,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -71,7 +80,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -93,7 +105,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -110,7 +125,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -132,7 +150,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -149,7 +170,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -171,7 +195,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -188,7 +215,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -210,7 +240,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -227,7 +260,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -249,7 +285,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -266,7 +305,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -288,7 +330,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -305,7 +350,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -327,7 +375,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -344,7 +395,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -366,7 +420,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -383,7 +440,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -405,7 +465,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -422,7 +485,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -461,7 +527,10 @@ exports[`GetJobs tests getJobs APIs should locate a job by jobid 1`] = ` Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -492,7 +561,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -509,7 +581,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -531,7 +606,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -548,7 +626,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -748,7 +829,10 @@ exports[`GetJobs tests getStatus APIs should get a job via getStatus and getStat Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -768,7 +852,10 @@ exports[`GetJobs tests getStatus APIs should get a job via getStatus and getStat Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", + "exec-member": "DE20", "exec-started": "2024-01-02T15:57:58.350Z", + "exec-submitted": "2024-01-02T15:58:00.600Z", + "exec-system": "DE20", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 5ff8cb142a..0b774bcbac 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -153,7 +153,7 @@ export class GetJobs { Logger.getAppLogger().trace("GetJobs.getJobsCommon()"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); let query = JobsConstants.QUERY_ID; - const includeExecData = params?.execData != false; + const includeExecData = params?.execData !== false; if (params) { if (params.owner) { diff --git a/packages/zosjobs/src/doc/response/IJob.ts b/packages/zosjobs/src/doc/response/IJob.ts index 5ddfdf0bcf..3963a6b783 100644 --- a/packages/zosjobs/src/doc/response/IJob.ts +++ b/packages/zosjobs/src/doc/response/IJob.ts @@ -48,6 +48,27 @@ export interface IJob { */ "exec-ended": string; + /** + * exec-member + * @type {string} + * @memberof IJob + */ + "exec-member": string; + + /** + * exec-submitted + * @type {Date} + * @memberof IJob + */ + "exec-submitted": string; + + /** + * exec-system + * @type {String} + * @memberof IJob + */ + "exec-system": string; + /** * The primary or secondary JES subsystem. * If this value is null, the job was processed by the primary subsystem. From ddbaa2074116bec3b45d08fc888a8b84e670a67c Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 09:22:53 -0400 Subject: [PATCH 052/106] system test Signed-off-by: jace-roell --- .../ussdir/__resources__/.zosattributes | 2 +- .../methods/upload/Upload.system.test.ts | 49 ++++++++++++++----- .../upload/__resources__/view_file_uss.sh | 11 +++++ 3 files changed, 49 insertions(+), 13 deletions(-) create mode 100755 packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh diff --git a/packages/cli/__tests__/zosfiles/__system__/download/ussdir/__resources__/.zosattributes b/packages/cli/__tests__/zosfiles/__system__/download/ussdir/__resources__/.zosattributes index a121e51700..1740b9eb3e 100644 --- a/packages/cli/__tests__/zosfiles/__system__/download/ussdir/__resources__/.zosattributes +++ b/packages/cli/__tests__/zosfiles/__system__/download/ussdir/__resources__/.zosattributes @@ -2,4 +2,4 @@ *.bin binary binary *.jcl IBM-1047 IBM-1047 *.md UTF-8 UTF-8 -*.txt UTF-8 IBM-1047 +*.txt UTF-8 UTF-8 diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts index 4376ab4d9e..9517d9dd86 100644 --- a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts @@ -788,7 +788,6 @@ describe("Upload USS file", () => { expect(error).toBeFalsy(); expect(getResponse).toEqual(Buffer.from(testdata)); expect(tagResponse).toBe(false); - }); it("should upload a USS file from local file in binary mode", async () => { let error; @@ -852,36 +851,62 @@ describe("Upload USS file", () => { expect(uploadResponse.apiResponse.etag).toBeDefined(); }); it("should upload local file to USS using .zosattributes file", async () => { - TEST_ENVIRONMENT = await TestEnvironment.setUp({ - testName: "zos_files_file_to_uss", - }); - const systemProperties = TEST_ENVIRONMENT.systemTestProperties; - const ACCOUNT_NUMBER = systemProperties.tso.account; let response: any; let error; - let uploadResponse; - let getResponse; - let tagResponse; + let readResponseGood: any; + let readResponseBad: any; try { - response = runCliScript(__dirname + "/__resources__/upload_file_to_uss.sh", TEST_ENVIRONMENT,[ - ACCOUNT_NUMBER, + response = runCliScript(__dirname + "/__resources__/upload_file_to_uss.sh", testEnvironment,[ + defaultSystem.tso.account, defaultSystem.zosmf.host, defaultSystem.zosmf.port, defaultSystem.zosmf.user, defaultSystem.zosmf.password, defaultSystem.zosmf.rejectUnauthorized, __dirname + "/testfiles/encodingCheck.txt", - "/u/users/jr897694/usstest.txt", + ussname, __dirname + "/__resources__/.zosattributes", ]); + // View file with matching encoding + readResponseGood = runCliScript(__dirname + "/__resources__/view_file_uss.sh", testEnvironment,[ + defaultSystem.tso.account, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + ussname, + 1047 + ]); + // View file with not matching encoding + readResponseBad = runCliScript(__dirname + "/__resources__/view_file_uss.sh", testEnvironment,[ + defaultSystem.tso.account, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + ussname, + 1147 + ]); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); } + // Get contents of file that was uploaded + const fileContents = fs.readFileSync(__dirname + "/testfiles/encodingCheck.txt").toString(); + + // Ensure upload was successful expect(response.stderr.toString()).toBe(""); expect(response.stdout.toString()).toBeDefined(); expect(response.stdout.toString()).toContain("USS file uploaded successfully."); + + // Compare file view with not matching upload and view encoding (1047 vs 1147). + expect(readResponseBad.stdout.toString()).not.toContain(fileContents); + + // Compare file view with matching upload and view encoding (1047). + expect(readResponseGood.stdout.toString()).toContain(fileContents); }); }); }); diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh new file mode 100755 index 0000000000..85c0abc375 --- /dev/null +++ b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh @@ -0,0 +1,11 @@ +#!/bin/bash +account=$1 +host=$2 +port=$3 +user=$4 +password=$5 +ru=$6 +ussName=$7 +encoding=$8 + +zowe zos-files view uf $ussName --encoding $encoding --host $host --port $port --user $user --password $password --ru $ru \ No newline at end of file From d024149601e717d223c40072f62d51166b5799fb Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 09:25:20 -0400 Subject: [PATCH 053/106] fixed unintentionally changed file Signed-off-by: jace-roell --- .../__system__/download/ussdir/__resources__/.zosattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/__tests__/zosfiles/__system__/download/ussdir/__resources__/.zosattributes b/packages/cli/__tests__/zosfiles/__system__/download/ussdir/__resources__/.zosattributes index 1740b9eb3e..a121e51700 100644 --- a/packages/cli/__tests__/zosfiles/__system__/download/ussdir/__resources__/.zosattributes +++ b/packages/cli/__tests__/zosfiles/__system__/download/ussdir/__resources__/.zosattributes @@ -2,4 +2,4 @@ *.bin binary binary *.jcl IBM-1047 IBM-1047 *.md UTF-8 UTF-8 -*.txt UTF-8 UTF-8 +*.txt UTF-8 IBM-1047 From e5cef09113905a2cf872cf594b5c0233e196f82a Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 09:31:47 -0400 Subject: [PATCH 054/106] removed unused variables in previous tests Signed-off-by: jace-roell --- .../__system__/methods/upload/Upload.system.test.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts index 9517d9dd86..a4c33cfd7e 100644 --- a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts @@ -26,10 +26,8 @@ let defaultSystem: ITestPropertiesSchema; let dsname: string; let ussname: string; const inputfile = __dirname + "/testfiles/upload.txt"; -const encodingCheck = __dirname + "/testfiles/encodingCheck.txt"; const testdata = "abcdefghijklmnopqrstuvwxyz"; const uploadOptions: IUploadOptions = {} as any; -let TEST_ENVIRONMENT: ITestEnvironment; describe("Upload Data Set", () => { @@ -772,12 +770,11 @@ describe("Upload USS file", () => { }); it("should upload a USS file from local file", async () => { let error; - let uploadResponse; let getResponse; let tagResponse; try { - uploadResponse = await Upload.fileToUssFile(REAL_SESSION, inputfile, ussname); + await Upload.fileToUssFile(REAL_SESSION, inputfile, ussname); getResponse = await Get.USSFile(REAL_SESSION, ussname); tagResponse = await Utilities.isFileTagBinOrAscii(REAL_SESSION, ussname); } catch (err) { @@ -791,12 +788,11 @@ describe("Upload USS file", () => { }); it("should upload a USS file from local file in binary mode", async () => { let error; - let uploadResponse; let getResponse; let tagResponse; try { - uploadResponse = await Upload.fileToUssFile(REAL_SESSION, inputfile, ussname, { binary: true }); + await Upload.fileToUssFile(REAL_SESSION, inputfile, ussname, { binary: true }); getResponse = await Get.USSFile(REAL_SESSION, ussname, {binary: true}); tagResponse = await Utilities.isFileTagBinOrAscii(REAL_SESSION, ussname); } catch (err) { @@ -835,11 +831,10 @@ describe("Upload USS file", () => { it("should upload a USS file and return Etag", async () => { let error; let uploadResponse; - let getResponse; try { uploadResponse = await Upload.fileToUssFile(REAL_SESSION, inputfile, ussname, {returnEtag: true}); - getResponse = await Get.USSFile(REAL_SESSION, ussname); + await Get.USSFile(REAL_SESSION, ussname); } catch (err) { error = err; Imperative.console.info("Error: " + inspect(error)); From 764d5332bc9d515cc3a991e611308c8bfdaad2b5 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 09:40:49 -0400 Subject: [PATCH 055/106] exit shell line Signed-off-by: jace-roell --- .../__system__/methods/upload/__resources__/view_file_uss.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh index 85c0abc375..a1356ff9bf 100755 --- a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh +++ b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh @@ -8,4 +8,5 @@ ru=$6 ussName=$7 encoding=$8 -zowe zos-files view uf $ussName --encoding $encoding --host $host --port $port --user $user --password $password --ru $ru \ No newline at end of file +zowe zos-files view uf $ussName --encoding $encoding --host $host --port $port --user $user --password $password --ru $ru +exit $? \ No newline at end of file From 0ac83353582c1c17c343eeb57cb14519ad318cc3 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 09:46:32 -0400 Subject: [PATCH 056/106] changelog and linting Signed-off-by: jace-roell --- packages/cli/src/zostso/start/as-app/StartASApp.definition.ts | 3 ++- packages/zostso/CHANGELOG.md | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts index 85f0a35380..efdf4946ac 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.definition.ts @@ -26,7 +26,8 @@ export const StartASApp: ICommandDefinition = { { name: "app-key", aliases: ["ak"], - description: "App key of application running at TSO address space, this app key value should be referenced when sending or receiving messages from the application instance", + description: "App key of application running at TSO address space, " + + "this app key value should be referenced when sending or receiving messages from the application instance", type: "string", required: true }, diff --git a/packages/zostso/CHANGELOG.md b/packages/zostso/CHANGELOG.md index 9c041daebf..47825c838d 100644 --- a/packages/zostso/CHANGELOG.md +++ b/packages/zostso/CHANGELOG.md @@ -4,8 +4,8 @@ All notable changes to the Zowe z/OS TSO SDK package will be documented in this ## Recent Changes -- Enhancement: Created app command under zos-tso start/send and new receive command group, - this allows for starting applications at TSO address spaces aswell as message transmission/reception [#2280] (https://github.com/zowe/zowe-cli/pull/2280) +- Enhancement: Issue app commands to better target communication with a TSO/E application. The app command is now included in the start/send command group and the new receive command group, +allowing direct interaction with an application through a z/OS message queue. [#2280] (https://github.com/zowe/zowe-cli/pull/2280) ## `8.1.1` From c595646135f99c5abf8b2a2944e42baa09757d03 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 10:28:41 -0400 Subject: [PATCH 057/106] generic data set for starting AS app in shell script Signed-off-by: jace-roell --- packages/imperative/src/cmd/src/response/CommandResponse.ts | 2 +- .../__system__/__scripts__/start/start_app_existing_as.sh | 2 +- .../__system__/__scripts__/start/start_app_new_as.sh | 2 +- packages/zostso/src/ReceiveTsoApp.ts | 3 ++- packages/zostso/src/SendTsoApp.ts | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/imperative/src/cmd/src/response/CommandResponse.ts b/packages/imperative/src/cmd/src/response/CommandResponse.ts index d35af49898..89974372ed 100644 --- a/packages/imperative/src/cmd/src/response/CommandResponse.ts +++ b/packages/imperative/src/cmd/src/response/CommandResponse.ts @@ -38,7 +38,7 @@ import { Logger } from "../../../logger"; import { LoggerUtils } from "../../../logger/src/LoggerUtils"; const DataObjectParser = require("dataobject-parser"); - +export const DEFAULT_SPINNER_CHARS = "-oO0)|(0Oo-"; /** * Command response object allocated by the command processor and used to construct the handler response object * passed to the command handlers. The response object contains all the methods necessary for a command handler (and diff --git a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh index 101037d3c6..c611e6692d 100755 --- a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh +++ b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh @@ -7,5 +7,5 @@ password=$5 ru=$6 servletKey=$7 queueID=$8 -zowe zos-tso start app --app-key "test2" --startup "EXEC 'RIJFE01.PUBLIC.REXX.EXEC(TESTADRS)'" --servlet-key $servletKey --queue-id $queueID --account $account --host $host --port $port --user $user --password $password --ru $ru +zowe zos-tso start app --app-key "test2" --startup "EXEC 'CUST009.PUBLIC.REXX(TESTADRS)'" --servlet-key $servletKey --queue-id $queueID --account $account --host $host --port $port --user $user --password $password --ru $ru exit $? diff --git a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh index 7d9f42e1f3..ac6c1546ce 100755 --- a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh +++ b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh @@ -5,5 +5,5 @@ port=$3 user=$4 password=$5 ru=$6 -zowe zos-tso start app --app-key "test2" --startup "EXEC 'RIJFE01.PUBLIC.REXX.EXEC(TESTADRS)'" --account $account --host $host --port $port --user $user --password $password --ru $ru +zowe zos-tso start app --app-key "test2" --startup "EXEC 'CUST009.PUBLIC.REXX(TESTADRS)'" --account $account --host $host --port $port --user $user --password $password --ru $ru exit $? diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index 088853022e..41c883afb8 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.ts @@ -15,6 +15,7 @@ import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; import { IASAppResponse } from "./doc/IASAppResponse"; +import { DEFAULT_SPINNER_CHARS } from "@zowe/imperative"; export class ReceiveTsoApp { public static async receive( @@ -25,7 +26,7 @@ export class ReceiveTsoApp { TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); const TIMEOUT_SECONDS: number = params.timeout; - const spinnerChars = ["|", "/", "-", "\\"]; + const spinnerChars = DEFAULT_SPINNER_CHARS.split(""); let spinnerIndex = 0; // Start the spinner diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index e00a246a0b..7f2120414e 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.ts @@ -16,7 +16,7 @@ import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { IASAppResponse } from "./doc/IASAppResponse"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; - +import { DEFAULT_SPINNER_CHARS } from "@zowe/imperative"; /** * Send message to TSO App running at an address space * @export @@ -41,7 +41,7 @@ export class SendTsoApp { TsoValidator.validateSession(session); TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); - const spinnerChars = ["|", "/", "-", "\\"]; + const spinnerChars = DEFAULT_SPINNER_CHARS.split(""); let spinnerIndex = 0; // Start the spinner From cdcb02e3f63ce52ed1588dcc502dc79e07b68f06 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 10:36:18 -0400 Subject: [PATCH 058/106] removed unused function Signed-off-by: jace-roell --- .../upload/ftu/FileToUSS.handler.unit.test.ts | 2 -- .../zosfiles/upload/ftu/FileToUSS.handler.ts | 24 ------------------- 2 files changed, 26 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts index e495566285..52cbac3cdf 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts @@ -83,13 +83,11 @@ describe("Upload file-to-uss handler", () => { expect(Upload.uploadFile).toHaveBeenCalledTimes(1); expect(Upload.uploadFile).toHaveBeenCalledWith(fakeSession, inputfile, USSFileName, { binary: undefined, - encoding: undefined, task: { percentComplete: 0, stageName: 0, statusMessage: "Uploading USS file" }, - filesMap: null, includeHidden: undefined, maxConcurrentRequests: undefined, responseTimeout: undefined diff --git a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts index d0f386ff10..306d935e46 100644 --- a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts @@ -53,8 +53,6 @@ export default class FileToUSSHandler extends ZosFilesBaseHandler { ); if (attributes != null) { uploadOptions.attributes = attributes; - } else { - uploadOptions.filesMap = this.buildFilesMap(commandParameters); } const response = await Upload.uploadFile( @@ -68,26 +66,4 @@ export default class FileToUSSHandler extends ZosFilesBaseHandler { commandParameters.response.console.log(formatMessage); return response; } - private buildFilesMap(commandParameters: IHandlerParameters) { - let filesMap: IUploadMap = null; - - // checking if binary-files or ascii-files are used, and update filesMap argument - if (commandParameters.arguments.binaryFiles) { - filesMap = { - binary: true, - fileNames: commandParameters.arguments.binaryFiles - .split(",") - .map((fileName: string) => fileName.trim()), - }; - } - if (commandParameters.arguments.asciiFiles) { - filesMap = { - binary: false, - fileNames: commandParameters.arguments.asciiFiles - .split(",") - .map((fileName: string) => fileName.trim()), - }; - } - return filesMap; - } } From eb489d7be190347d1a3aab376023bd411fff49f7 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 10:42:35 -0400 Subject: [PATCH 059/106] unused import Signed-off-by: jace-roell --- packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts index 306d935e46..ac87340da0 100644 --- a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts @@ -20,7 +20,6 @@ import { Upload, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; import { IUploadOptions } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; -import { IUploadMap } from "@zowe/zos-files-for-zowe-sdk"; /** * Handler to upload content from a local file to a USS file From e3724068fdd8518928b88a19e025028e6c15ef02 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Fri, 25 Oct 2024 11:42:54 -0400 Subject: [PATCH 060/106] changelog Signed-off-by: jace-roell --- packages/zostso/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zostso/CHANGELOG.md b/packages/zostso/CHANGELOG.md index 47825c838d..394969b008 100644 --- a/packages/zostso/CHANGELOG.md +++ b/packages/zostso/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe z/OS TSO SDK package will be documented in this ## Recent Changes -- Enhancement: Issue app commands to better target communication with a TSO/E application. The app command is now included in the start/send command group and the new receive command group, +- Enhancement: Issue `app` commands to better target communication with a TSO/E application. The `app` command is now included in the `start`/`send` command group and the new `receive` command group, allowing direct interaction with an application through a z/OS message queue. [#2280] (https://github.com/zowe/zowe-cli/pull/2280) ## `8.1.1` From 53f296a7959676372cc0762740d64316789319de Mon Sep 17 00:00:00 2001 From: Pujal Date: Fri, 25 Oct 2024 16:49:52 -0400 Subject: [PATCH 061/106] fixed getJobs() error Signed-off-by: Pujal --- .../imperative/plugins/suites/sample-plugin.json | 11 +++++++++++ .../test_plugins/override_plugin/package.json | 2 +- .../__snapshots__/GetJobs.unit.test.ts.snap | 2 +- packages/zosjobs/src/GetJobs.ts | 13 +++++++------ 4 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json diff --git a/packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json b/packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json new file mode 100644 index 0000000000..099053db9e --- /dev/null +++ b/packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json @@ -0,0 +1,11 @@ +{ + "normal-plugin": { + "package": "/Users/pujalgandhi/Documents/ZOWE/zowe-cli/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/normal_plugin", + "version": "1.0.1" + }, + "normal-plugin-2": { + "package": "/Users/pujalgandhi/Documents/ZOWE/zowe-cli/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/normal_plugin_2", + "location": "http://imperative-npm-registry:4873", + "version": "1.0.2" + } +} diff --git a/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/override_plugin/package.json b/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/override_plugin/package.json index 8a0fb0e246..8851951c26 100644 --- a/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/override_plugin/package.json +++ b/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/override_plugin/package.json @@ -1,5 +1,5 @@ { - "name": "@zowe/secrets-for-kubernetes-for-zowe-cli", + "name": "override-plugin", "version": "1.0.1", "description": "Some description", "main": "lib/index.js", diff --git a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap index ca74e41c93..bcb25df65b 100644 --- a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap +++ b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap @@ -521,7 +521,7 @@ exports[`GetJobs tests getJobs APIs should have proper URI when using owner 1`] exports[`GetJobs tests getJobs APIs should have proper URI when using prefix 1`] = `"/zosmf/restjobs/jobs?prefix=fakePrefix&exec-data=Y"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using status 1`] = `"/zosmf/restjobs/jobs?exec-data=Y&status=active"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using status 1`] = `"/zosmf/restjobs/jobs?status=active&exec-data=Y"`; exports[`GetJobs tests getJobs APIs should locate a job by jobid 1`] = ` Object { diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 0b774bcbac..6bc2d7163b 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -181,12 +181,6 @@ export class GetJobs { } query += JobsConstants.QUERY_JOBID + encodeURIComponent(params.jobid); } - if (includeExecData) { - if (RestClient.hasQueryString(query)) { - query += JobsConstants.COMBO_ID; - } - query += JobsConstants.EXEC_DATA; - } if (params.status) { if (RestClient.hasQueryString(query)) { query += JobsConstants.COMBO_ID; @@ -195,6 +189,13 @@ export class GetJobs { } } + if (includeExecData) { + if (RestClient.hasQueryString(query)) { + query += JobsConstants.COMBO_ID; + } + query += JobsConstants.EXEC_DATA; + } + let resource = JobsConstants.RESOURCE; resource += query === JobsConstants.QUERY_ID ? "" : query; Logger.getAppLogger().info("GetJobs.getJobsCommon() resource: " + resource); From a8f0cf418b58f5dbcc8dc05205344cf1c00f9b45 Mon Sep 17 00:00:00 2001 From: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:09:35 -0400 Subject: [PATCH 062/106] Delete packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json Signed-off-by: Pujal Gandhi <71276682+pujal0909@users.noreply.github.com> --- .../imperative/plugins/suites/sample-plugin.json | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json diff --git a/packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json b/packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json deleted file mode 100644 index 099053db9e..0000000000 --- a/packages/imperative/__tests__/src/packages/imperative/plugins/suites/sample-plugin.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "normal-plugin": { - "package": "/Users/pujalgandhi/Documents/ZOWE/zowe-cli/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/normal_plugin", - "version": "1.0.1" - }, - "normal-plugin-2": { - "package": "/Users/pujalgandhi/Documents/ZOWE/zowe-cli/packages/imperative/__tests__/src/packages/imperative/plugins/test_plugins/normal_plugin_2", - "location": "http://imperative-npm-registry:4873", - "version": "1.0.2" - } -} From 2f6ec41c42f10fccd7680e6514372c85d1dd40b9 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 28 Oct 2024 11:21:45 -0400 Subject: [PATCH 063/106] refactored spinner functionality to be on the commandResponse interface Signed-off-by: jace-roell --- .../cli-test-utils/src/TestUtils.ts | 4 +- .../receive/app/ReceiveASApp.handler.ts | 6 + .../zostso/send/as-app/SendASApp.handler.ts | 6 + .../api/handler/IHandlerProgressApi.ts | 12 ++ .../src/cmd/src/response/CommandResponse.ts | 26 ++++ packages/zostso/src/ReceiveTsoApp.ts | 119 +++++++++--------- packages/zostso/src/SendTsoApp.ts | 85 ++++++------- 7 files changed, 151 insertions(+), 107 deletions(-) diff --git a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts index 6952abcc7c..05a1fe5016 100644 --- a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts +++ b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts @@ -121,7 +121,9 @@ export function mockHandlerParameters(params: PartialHandlerParameters): IHandle }, progress: { startBar: jest.fn((parms) => undefined), - endBar: jest.fn(() => undefined) + endBar: jest.fn(() => undefined), + startSpinner: jest.fn(() => undefined), + stopSpinner: jest.fn(() => undefined) }, format: { output: jest.fn((parms) => { diff --git a/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts index b07c6ff164..56208471b6 100644 --- a/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts @@ -21,6 +21,9 @@ import { ZosTsoBaseHandler, ReceiveTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; export default class Handler extends ZosTsoBaseHandler { // Process the command and produce the start response (returns servlet) public async processCmd(commandParameters: IHandlerParameters) { + + commandParameters.response.progress.startSpinner("Receiving response..."); + const response = await ReceiveTsoApp.receive( this.mSession, this.mArguments.account, @@ -31,6 +34,9 @@ export default class Handler extends ZosTsoBaseHandler { timeout: commandParameters.arguments.timeout }, ); + + commandParameters.response.progress.stopSpinner("Receiving response... Done!"); + commandParameters.response.console.log("\n"); response.tsoData.forEach((data) => { if(typeof data === 'string') { diff --git a/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts index 78bf795f62..15048634fe 100644 --- a/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts +++ b/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts @@ -21,6 +21,9 @@ import { ZosTsoBaseHandler, SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; export default class Handler extends ZosTsoBaseHandler { // Process the command and transmit a message to an app running at a TSO address space public async processCmd(commandParameters: IHandlerParameters) { + + commandParameters.response.progress.startSpinner("Sending request..."); + const response = await SendTsoApp.send( this.mSession, this.mArguments.account, @@ -31,6 +34,9 @@ export default class Handler extends ZosTsoBaseHandler { }, this.mTsoStart ); + + commandParameters.response.progress.stopSpinner("Sending request... Done!"); + commandParameters.response.console.log( JSON.stringify(response, null, 2) ); diff --git a/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts b/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts index 3aeab96d61..99a3a41b52 100644 --- a/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts +++ b/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts @@ -29,4 +29,16 @@ export interface IHandlerProgressApi { * @memberof IHandlerProgressApi */ endBar(): void; + /** + * Start a spinner - displays on the users terminal + * @param {IProgressBarParms} params + * @memberof IHandlerProgressApi + */ + startSpinner(pendingText: string): void; + /** + * Stop a spinner - displays on the users terminal + * @param {IProgressBarParms} params + * @memberof IHandlerProgressApi + */ + stopSpinner(endText: string): void; } diff --git a/packages/imperative/src/cmd/src/response/CommandResponse.ts b/packages/imperative/src/cmd/src/response/CommandResponse.ts index 89974372ed..7f6842ce44 100644 --- a/packages/imperative/src/cmd/src/response/CommandResponse.ts +++ b/packages/imperative/src/cmd/src/response/CommandResponse.ts @@ -698,6 +698,32 @@ export class CommandResponse implements ICommandResponseApi { // Create an instance of the class this.mProgressApi = new class { + private spinnerIndex = 0; + private spinnerInterval: any; + + /** + * Start a spinner + */ + public startSpinner(pendingText: string): void { + if (this.spinnerInterval == null) { + this.spinnerInterval = setInterval(() => { + process.stdout.write(`\r${pendingText} ${this.mProgressBarSpinnerChars[this.spinnerIndex]}`); + this.spinnerIndex = (this.spinnerIndex + 1) % this.mProgressBarSpinnerChars.length; + }, 100); + } + } + /** + * Stop a spinner + */ + public stopSpinner(stopText: string): void { + if (this.spinnerInterval != null) { + clearInterval(this.spinnerInterval); + this.spinnerInterval = null; + process.stdout.write(`\r${stopText}\n`); + process.stdout.write("\r\x1b[K"); + } + } + private mProgressBarSpinnerIndex = 0; private mProgressTask: ITaskWithStatus; private mProgressBarPollFrequency = 65; // eslint-disable-line @typescript-eslint/no-magic-numbers diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts index 41c883afb8..c0f3e56d5f 100644 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ b/packages/zostso/src/ReceiveTsoApp.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 } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; @@ -15,8 +15,6 @@ import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; import { IASAppResponse } from "./doc/IASAppResponse"; -import { DEFAULT_SPINNER_CHARS } from "@zowe/imperative"; - export class ReceiveTsoApp { public static async receive( session: AbstractSession, @@ -24,16 +22,11 @@ export class ReceiveTsoApp { params: ITsoAppCommunicationParms ): Promise { TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); + TsoValidator.validateNotEmptyString( + accountNumber, + noAccountNumber.message + ); const TIMEOUT_SECONDS: number = params.timeout; - const spinnerChars = DEFAULT_SPINNER_CHARS.split(""); - let spinnerIndex = 0; - - // Start the spinner - const spinner = setInterval(() => { - process.stdout.write(`\rReceiving response... ${spinnerChars[spinnerIndex]}`); - spinnerIndex = (spinnerIndex + 1) % spinnerChars.length; - }, 100); const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; let combinedResponse: IASAppResponse | null = null; @@ -41,50 +34,56 @@ export class ReceiveTsoApp { const startTime = Date.now(); let timeoutReached = false; - try { - do { - if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { - timeoutReached = true; - break; - } + do { + if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { + timeoutReached = true; + break; + } - try { - const apiResponse = await ZosmfRestClient.getExpectJSON(session, endpoint); - const response = apiResponse as IASAppResponse & { ver: string; appData?: any }; - const formattedApiResponse: IASAppResponse = { - version: response.ver, - reused: response.reused, - timeout: response.timeout, - servletKey: response.servletKey ?? null, - queueID: response.queueID ?? null, - tsoData: response.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] ? "TSO MESSAGE" : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, - }; - }) || [response.appData], - }; + try { + const apiResponse = await ZosmfRestClient.getExpectJSON< + IASAppResponse & { ver: string; appData?: any } + >(session, endpoint); + const response = apiResponse as IASAppResponse & { + ver: string; + appData?: any; + }; + const formattedApiResponse: IASAppResponse = { + version: response.ver, + reused: response.reused, + timeout: response.timeout, + servletKey: response.servletKey ?? null, + queueID: response.queueID ?? null, + tsoData: response.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] + ? "TSO MESSAGE" + : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }) || [response.appData], + }; - if (combinedResponse === null) { - combinedResponse = formattedApiResponse; - } else { - combinedResponse.tsoData.push(...formattedApiResponse.tsoData); - } - endKeyword = formattedApiResponse.tsoData.some((data: any) => - typeof data === "string" ? data.trim() === "READY" : data.DATA.trim() === "READY" + if (combinedResponse === null) { + combinedResponse = formattedApiResponse; + } else { + combinedResponse.tsoData.push( + ...formattedApiResponse.tsoData ); - } catch (error) { - if (combinedResponse) { - return combinedResponse; - } - throw error; } - } while (!endKeyword && params.receiveUntilReady && !timeoutReached); - } finally { - clearInterval(spinner); // Stop the spinner - process.stdout.write("\r\x1b[K"); // Clear the line with spinner text - } + endKeyword = formattedApiResponse.tsoData.some((data: any) => + typeof data === "string" + ? data.trim() === "READY" + : data.DATA.trim() === "READY" + ); + } catch (error) { + if (combinedResponse) { + return combinedResponse; + } + throw error; + } + } while (!endKeyword && params.receiveUntilReady && !timeoutReached); return combinedResponse!; } diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts index 7f2120414e..256ad9518e 100644 --- a/packages/zostso/src/SendTsoApp.ts +++ b/packages/zostso/src/SendTsoApp.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 } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; @@ -16,7 +16,7 @@ import { TsoValidator } from "./TsoValidator"; import { noAccountNumber, TsoConstants } from "./TsoConstants"; import { IASAppResponse } from "./doc/IASAppResponse"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; -import { DEFAULT_SPINNER_CHARS } from "@zowe/imperative"; + /** * Send message to TSO App running at an address space * @export @@ -39,46 +39,39 @@ export class SendTsoApp { startParms: IStartTsoParms ): Promise { TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); - - const spinnerChars = DEFAULT_SPINNER_CHARS.split(""); - let spinnerIndex = 0; - - // Start the spinner - const spinner = setInterval(() => { - process.stdout.write(`\rSending request... ${spinnerChars[spinnerIndex]}`); - spinnerIndex = (spinnerIndex + 1) % spinnerChars.length; - }, 100); + TsoValidator.validateNotEmptyString( + accountNumber, + noAccountNumber.message + ); const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - try { - const apiResponse = await ZosmfRestClient.putExpectJSON( - session, - endpoint, - [Headers.CONTENT_TYPE, "text/plain"], - params.message - ); + const apiResponse = await ZosmfRestClient.putExpectJSON< + IASAppResponse & { ver: string } + >( + session, + endpoint, + [Headers.CONTENT_TYPE, "text/plain"], + params.message + ); - const formattedApiResponse: IASAppResponse = { - version: apiResponse.ver, - reused: apiResponse.reused, - timeout: apiResponse.timeout, - servletKey: apiResponse.servletKey ?? null, - queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] ? "TSO MESSAGE" : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, - }; - }), - }; + const formattedApiResponse: IASAppResponse = { + version: apiResponse.ver, + reused: apiResponse.reused, + timeout: apiResponse.timeout, + servletKey: apiResponse.servletKey ?? null, + queueID: apiResponse.queueID ?? null, + tsoData: apiResponse.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] + ? "TSO MESSAGE" + : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }), + }; - return formattedApiResponse; - } finally { - clearInterval(spinner); // Stop the spinner - process.stdout.write("\r\x1b[K"); // Clear the line with spinner text - } + return formattedApiResponse; } } From a0b60940a8eeff528f1857db86155f00968d6bb9 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 28 Oct 2024 11:43:30 -0400 Subject: [PATCH 064/106] refactored (start/send/receive)TsoApp.ts into a single AddressSpaceApps.ts file Signed-off-by: jace-roell --- .../app/ReceiveASApp.handler.unit.test.ts | 4 +- .../send/app/SendASApp.handler.unit.test.ts | 4 +- .../start/app/StartASApp.handler.unit.test.ts | 7 +- .../receive/app/ReceiveASApp.handler.ts | 4 +- .../zostso/send/as-app/SendASApp.handler.ts | 4 +- .../zostso/start/as-app/StartASApp.handler.ts | 5 +- .../__unit__/ReceiveTsoApp.unit.test.ts | 12 +- .../__unit__/SendTsoApp.unit.test.ts | 4 +- .../__unit__/StartTsoApp.unit.test.ts | 8 +- packages/zostso/src/AddressSpaceApps.ts | 222 ++++++++++++++++++ packages/zostso/src/ReceiveTsoApp.ts | 90 ------- packages/zostso/src/SendTsoApp.ts | 77 ------ packages/zostso/src/StartTsoApp.ts | 97 -------- packages/zostso/src/index.ts | 4 +- 14 files changed, 247 insertions(+), 295 deletions(-) create mode 100644 packages/zostso/src/AddressSpaceApps.ts delete mode 100644 packages/zostso/src/ReceiveTsoApp.ts delete mode 100644 packages/zostso/src/SendTsoApp.ts delete mode 100644 packages/zostso/src/StartTsoApp.ts diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts index 8690c0e506..ba8a540266 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { ReceiveTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { AddressSpaceApps } from "@zowe/zos-tso-for-zowe-sdk"; import * as ReceiveASAppHandler from "../../../../../src/zostso/receive/app/ReceiveASApp.handler"; import * as ReceiveASAppDefinition from "../../../../../src/zostso/receive/app/ReceiveASApp.definition"; import { IHandlerParameters } from "@zowe/imperative"; @@ -47,7 +47,7 @@ describe("receive TSO app handler behavior", () => { jest.spyOn(ZosmfRestClient, "getExpectJSON").mockResolvedValueOnce( MOCK_RECEIVE_RESPONSE ); - const receiveSpy = jest.spyOn(ReceiveTsoApp,"receive"); + const receiveSpy = jest.spyOn(AddressSpaceApps,"receive"); const handler = new ReceiveASAppHandler.default(); const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); let error = undefined; diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts index e3c90ed872..379da76816 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { AddressSpaceApps } from "@zowe/zos-tso-for-zowe-sdk"; import * as SendASAppHandler from "../../../../../src/zostso/send/as-app/SendASApp.handler"; import * as SendASAppDefinition from "../../../../../src/zostso/send/as-app/SendASApp.definition"; import { IHandlerParameters } from "@zowe/imperative"; @@ -52,7 +52,7 @@ describe("receive TSO app handler behavior", () => { jest.spyOn(ZosmfRestClient, "putExpectJSON").mockResolvedValueOnce( MOCK_SEND_RESPONSE ); - const sendSpy = jest.spyOn(SendTsoApp,"send"); + const sendSpy = jest.spyOn(AddressSpaceApps,"send"); const handler = new SendASAppHandler.default(); const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); let error = undefined; diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts index 1681461fac..4cc212678e 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts @@ -21,13 +21,12 @@ */ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { StartTso, StartTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { StartTso, AddressSpaceApps, IStartStopResponses } from "@zowe/zos-tso-for-zowe-sdk"; import * as StartASAppHandler from "../../../../../src/zostso/start/as-app/StartASApp.handler"; import * as StartASAppDefinition from "../../../../../src/zostso/start/as-app/StartASApp.definition"; import { IHandlerParameters } from "@zowe/imperative"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; -import { IStartStopResponses } from "@zowe/zos-tso-for-zowe-sdk"; const NEW_AS_SPACE_PARAMS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, @@ -101,7 +100,7 @@ describe("receive TSO app handler behavior", () => { MOCK_RESPONSE ); - const startSpy = jest.spyOn(StartTsoApp, "start"); + const startSpy = jest.spyOn(AddressSpaceApps, "start"); const startASSpaceSpy = jest.spyOn(StartTso, "start"); const zosmfSpy = jest.spyOn(ZosmfRestClient, "postExpectJSON"); const handler = new StartASAppHandler.default(); @@ -129,7 +128,7 @@ describe("receive TSO app handler behavior", () => { MOCK_RESPONSE ); - const startSpy = jest.spyOn(StartTsoApp, "start"); + const startSpy = jest.spyOn(AddressSpaceApps, "start"); const startASSpaceSpy = jest.spyOn(StartTso, "start"); const zosmfSpy = jest.spyOn(ZosmfRestClient, "postExpectJSON"); const handler = new StartASAppHandler.default(); diff --git a/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts index 56208471b6..a7025d641c 100644 --- a/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts @@ -10,7 +10,7 @@ */ import { IHandlerParameters } from "@zowe/imperative"; -import { ZosTsoBaseHandler, ReceiveTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { ZosTsoBaseHandler, AddressSpaceApps } from "@zowe/zos-tso-for-zowe-sdk"; /** * Handler to receive message from an app at an address space @@ -24,7 +24,7 @@ export default class Handler extends ZosTsoBaseHandler { commandParameters.response.progress.startSpinner("Receiving response..."); - const response = await ReceiveTsoApp.receive( + const response = await AddressSpaceApps.receive( this.mSession, this.mArguments.account, { diff --git a/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts index 15048634fe..f0db078644 100644 --- a/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts +++ b/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts @@ -10,7 +10,7 @@ */ import { IHandlerParameters } from "@zowe/imperative"; -import { ZosTsoBaseHandler, SendTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { ZosTsoBaseHandler, AddressSpaceApps } from "@zowe/zos-tso-for-zowe-sdk"; /** * Handler to send a message to address space @@ -24,7 +24,7 @@ export default class Handler extends ZosTsoBaseHandler { commandParameters.response.progress.startSpinner("Sending request..."); - const response = await SendTsoApp.send( + const response = await AddressSpaceApps.send( this.mSession, this.mArguments.account, { diff --git a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts index 757cb9e558..a5d4f4e541 100644 --- a/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts +++ b/packages/cli/src/zostso/start/as-app/StartASApp.handler.ts @@ -10,8 +10,7 @@ */ import { IHandlerParameters } from "@zowe/imperative"; -import { ZosTsoBaseHandler } from "@zowe/zos-tso-for-zowe-sdk"; -import { StartTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; +import { ZosTsoBaseHandler, AddressSpaceApps } from "@zowe/zos-tso-for-zowe-sdk"; /** * Handler to start app at an address space @@ -22,7 +21,7 @@ import { StartTsoApp } from "@zowe/zos-tso-for-zowe-sdk"; export default class Handler extends ZosTsoBaseHandler { // Process the command and produce the start response (returns servlet) public async processCmd(commandParameters: IHandlerParameters) { - const response = await StartTsoApp.start( + const response = await AddressSpaceApps.start( this.mSession, this.mArguments.account, { diff --git a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts index 6f56e6ed59..2f494f7076 100644 --- a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts @@ -11,7 +11,7 @@ import { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { ReceiveTsoApp } from "../../src"; +import { AddressSpaceApps } from "../../src"; import { ITsoAppCommunicationParms } from "../../src/doc/input/ITsoAppCommunicationParms"; const PRETEND_SESSION = new Session({ @@ -65,7 +65,7 @@ describe("ReceiveTsoApp behavior", () => { receiveUntilReady: true, }; - const response = await ReceiveTsoApp.receive( + const response = await AddressSpaceApps.receive( PRETEND_SESSION, "123456", params @@ -101,7 +101,7 @@ describe("ReceiveTsoApp behavior", () => { receiveUntilReady: true, }; - const response = await ReceiveTsoApp.receive( + const response = await AddressSpaceApps.receive( PRETEND_SESSION, "123456", params @@ -125,7 +125,7 @@ describe("ReceiveTsoApp behavior", () => { receiveUntilReady: true, }; - const response = await ReceiveTsoApp.receive( + const response = await AddressSpaceApps.receive( PRETEND_SESSION, "123456", params @@ -148,7 +148,7 @@ describe("ReceiveTsoApp behavior", () => { }; await expect( - ReceiveTsoApp.receive(PRETEND_SESSION, "123456", params) + AddressSpaceApps.receive(PRETEND_SESSION, "123456", params) ).rejects.toThrow("Network error"); }); @@ -188,7 +188,7 @@ describe("ReceiveTsoApp behavior", () => { receiveUntilReady: true, }; - const response = await ReceiveTsoApp.receive( + const response = await AddressSpaceApps.receive( PRETEND_SESSION, "123456", params diff --git a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts index e7601abd0a..f9b2381e70 100644 --- a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts @@ -11,7 +11,7 @@ import { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { SendTsoApp } from "../../src"; +import { AddressSpaceApps } from "../../src"; import { ITsoAppCommunicationParms } from "../../src/doc/input/ITsoAppCommunicationParms"; const PRETEND_SESSION = new Session({ @@ -60,7 +60,7 @@ describe("SendTsoApp behavior", () => { message: "Test message", }; - const response = await SendTsoApp.send( + const response = await AddressSpaceApps.send( PRETEND_SESSION, "123456", params, diff --git a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts index 93fb532c82..0de43fa87f 100644 --- a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts @@ -11,9 +11,7 @@ import { Session } from "@zowe/imperative"; import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { StartTsoApp } from "../../src"; -import { StartTso } from "../../src"; -import { IStartStopResponses } from "../../src"; +import { AddressSpaceApps, StartTso, IStartStopResponses } from "../../src"; const PRETEND_SESSION = new Session({ user: "usr", @@ -63,7 +61,7 @@ describe("StartTsoApp behavior", () => { jest.spyOn(StartTso, "start").mockReturnValue(MOCK_START_RESPONSE); jest.spyOn(ZosmfRestClient, "postExpectJSON").mockReturnValue(MOCK_RESPONSE); - const response = await StartTsoApp.start(PRETEND_SESSION, "izuacct", { + const response = await AddressSpaceApps.start(PRETEND_SESSION, "izuacct", { startupCommand: "EXEC 'TEST.EXEC(THISSCRIPTDOESNOTEXIST)'", appKey: "testappkey", }, null); @@ -89,7 +87,7 @@ describe("StartTsoApp behavior", () => { jest.spyOn(StartTso, "start").mockReturnValue(MOCK_START_RESPONSE); jest.spyOn(ZosmfRestClient, "postExpectJSON").mockReturnValue(MOCK_RESPONSE); - const response = await StartTsoApp.start(PRETEND_SESSION, "izuacct", { + const response = await AddressSpaceApps.start(PRETEND_SESSION, "izuacct", { startupCommand: "EXEC 'TEST.EXEC(THISSCRIPTDOESNOTEXIST)'", appKey: "testappkey", queueID: "12345", diff --git a/packages/zostso/src/AddressSpaceApps.ts b/packages/zostso/src/AddressSpaceApps.ts new file mode 100644 index 0000000000..9d28a395e8 --- /dev/null +++ b/packages/zostso/src/AddressSpaceApps.ts @@ -0,0 +1,222 @@ +/* + * 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 { noAccountNumber, TsoConstants } from "./TsoConstants"; +import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; +import { IASAppResponse } from "./doc/IASAppResponse"; +import { AbstractSession, Headers } from "@zowe/imperative"; +import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; +import { IStartTsoParms } from "./doc/input/IStartTsoParms"; +import { TsoValidator } from "./TsoValidator"; +import { IStartTsoAppParms } from "./doc/input/IStartTsoAppParms"; +import { StartTso } from "./StartTso"; +import { IIssueResponse } from "../src"; + +export class AddressSpaceApps { + /** + * Start TSO application at address space with provided parameters. + * @static + * @param {AbstractSession} session - z/OSMF connection info + * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. + * @param {IStartTsoParms} parms - optional object with required parameters, @see {IStartTsoParms} + * @returns {Promise} command response on resolve, @see {IASAppResponse} + * @memberof StartTso + */ + public static async start( + session: AbstractSession, + accountNumber: string, + params: IStartTsoAppParms, + startParms: IStartTsoParms + ): Promise { + TsoValidator.validateSession(session); + TsoValidator.validateNotEmptyString( + accountNumber, + noAccountNumber.message + ); + + // Address space is not known and must be created + if (!params.queueID || !params.servletKey) { + const response: IIssueResponse = { + success: false, + startResponse: await StartTso.start( + session, + accountNumber, + startParms + ), + startReady: false, + zosmfResponse: null, + commandResponse: null, + stopResponse: null, + }; + // Reassigning servletKey and queueID so the application can be started at the correct location + params.servletKey = + response.startResponse.zosmfTsoResponse.servletKey; + params.queueID = response.startResponse.zosmfTsoResponse.queueID; + } + + // Address space application starting + const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; + const response = await ZosmfRestClient.postExpectJSON< + IASAppResponse & { ver: string } + >(session, endpoint, [Headers.APPLICATION_JSON], { + startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, + }); + const formattedApiResponse: IASAppResponse = { + version: response.ver, + reused: response.reused, + timeout: response.timeout, + servletKey: params.servletKey ?? null, + queueID: params.queueID ?? null, + tsoData: response.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] + ? "TSO MESSAGE" + : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }), + }; + + return formattedApiResponse; + } + /** + * Send message to TSO application at address space with provided parameters. + * @static + * @param {AbstractSession} session - z/OSMF connection info + * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. + * @param {IStartTsoParms} parms - optional object with required parameters, + * @returns {Promise} command response on resolve, @see {IASAppResponse} + * @memberof SendTso + */ + public static async send( + session: AbstractSession, + accountNumber: string, + params: ITsoAppCommunicationParms, + startParms: IStartTsoParms + ): Promise { + TsoValidator.validateSession(session); + TsoValidator.validateNotEmptyString( + accountNumber, + noAccountNumber.message + ); + + const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; + + const apiResponse = await ZosmfRestClient.putExpectJSON< + IASAppResponse & { ver: string } + >( + session, + endpoint, + [Headers.CONTENT_TYPE, "text/plain"], + params.message + ); + + const formattedApiResponse: IASAppResponse = { + version: apiResponse.ver, + reused: apiResponse.reused, + timeout: apiResponse.timeout, + servletKey: apiResponse.servletKey ?? null, + queueID: apiResponse.queueID ?? null, + tsoData: apiResponse.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] + ? "TSO MESSAGE" + : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }), + }; + + return formattedApiResponse; + } + /** + * Receive message from TSO application at address space with provided parameters. + * @static + * @param {AbstractSession} session - z/OSMF connection info + * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. + * @param {IStartTsoParms} parms - optional object with required parameters, + * @returns {Promise} command response on resolve, @see {IASAppResponse} + * @memberof SendTso + */ + public static async receive( + session: AbstractSession, + accountNumber: string, + params: ITsoAppCommunicationParms + ): Promise { + TsoValidator.validateSession(session); + TsoValidator.validateNotEmptyString( + accountNumber, + noAccountNumber.message + ); + const TIMEOUT_SECONDS: number = params.timeout; + + const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; + let combinedResponse: IASAppResponse | null = null; + let endKeyword = false; + const startTime = Date.now(); + let timeoutReached = false; + + do { + if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { + timeoutReached = true; + break; + } + + try { + const apiResponse = await ZosmfRestClient.getExpectJSON< + IASAppResponse & { ver: string; appData?: any } + >(session, endpoint); + const response = apiResponse as IASAppResponse & { + ver: string; + appData?: any; + }; + const formattedApiResponse: IASAppResponse = { + version: response.ver, + reused: response.reused, + timeout: response.timeout, + servletKey: response.servletKey ?? null, + queueID: response.queueID ?? null, + tsoData: response.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] + ? "TSO MESSAGE" + : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }) || [response.appData], + }; + + if (combinedResponse === null) { + combinedResponse = formattedApiResponse; + } else { + combinedResponse.tsoData.push( + ...formattedApiResponse.tsoData + ); + } + endKeyword = formattedApiResponse.tsoData.some((data: any) => + typeof data === "string" + ? data.trim() === "READY" + : data.DATA.trim() === "READY" + ); + } catch (error) { + if (combinedResponse) { + return combinedResponse; + } + throw error; + } + } while (!endKeyword && params.receiveUntilReady && !timeoutReached); + + return combinedResponse!; + } +} diff --git a/packages/zostso/src/ReceiveTsoApp.ts b/packages/zostso/src/ReceiveTsoApp.ts deleted file mode 100644 index c0f3e56d5f..0000000000 --- a/packages/zostso/src/ReceiveTsoApp.ts +++ /dev/null @@ -1,90 +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. - * - */ - -import { AbstractSession } from "@zowe/imperative"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { TsoValidator } from "./TsoValidator"; -import { noAccountNumber, TsoConstants } from "./TsoConstants"; -import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; -import { IASAppResponse } from "./doc/IASAppResponse"; -export class ReceiveTsoApp { - public static async receive( - session: AbstractSession, - accountNumber: string, - params: ITsoAppCommunicationParms - ): Promise { - TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString( - accountNumber, - noAccountNumber.message - ); - const TIMEOUT_SECONDS: number = params.timeout; - - const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - let combinedResponse: IASAppResponse | null = null; - let endKeyword = false; - const startTime = Date.now(); - let timeoutReached = false; - - do { - if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { - timeoutReached = true; - break; - } - - try { - const apiResponse = await ZosmfRestClient.getExpectJSON< - IASAppResponse & { ver: string; appData?: any } - >(session, endpoint); - const response = apiResponse as IASAppResponse & { - ver: string; - appData?: any; - }; - const formattedApiResponse: IASAppResponse = { - version: response.ver, - reused: response.reused, - timeout: response.timeout, - servletKey: response.servletKey ?? null, - queueID: response.queueID ?? null, - tsoData: response.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] - ? "TSO MESSAGE" - : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, - }; - }) || [response.appData], - }; - - if (combinedResponse === null) { - combinedResponse = formattedApiResponse; - } else { - combinedResponse.tsoData.push( - ...formattedApiResponse.tsoData - ); - } - endKeyword = formattedApiResponse.tsoData.some((data: any) => - typeof data === "string" - ? data.trim() === "READY" - : data.DATA.trim() === "READY" - ); - } catch (error) { - if (combinedResponse) { - return combinedResponse; - } - throw error; - } - } while (!endKeyword && params.receiveUntilReady && !timeoutReached); - - return combinedResponse!; - } -} diff --git a/packages/zostso/src/SendTsoApp.ts b/packages/zostso/src/SendTsoApp.ts deleted file mode 100644 index 256ad9518e..0000000000 --- a/packages/zostso/src/SendTsoApp.ts +++ /dev/null @@ -1,77 +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. - * - */ - -import { AbstractSession, Headers } from "@zowe/imperative"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { IStartTsoParms } from "./doc/input/IStartTsoParms"; -import { TsoValidator } from "./TsoValidator"; -import { noAccountNumber, TsoConstants } from "./TsoConstants"; -import { IASAppResponse } from "./doc/IASAppResponse"; -import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; - -/** - * Send message to TSO App running at an address space - * @export - * @class SendTsoApp - */ -export class SendTsoApp { - /** - * Start TSO application at address space with provided parameters. - * @static - * @param {AbstractSession} session - z/OSMF connection info - * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. - * @param {IStartTsoParms} parms - optional object with required parameters, @see {IStartTsoParms} - * @returns {Promise} command response on resolve, @see {IASAppResponse} - * @memberof StartTso - */ - public static async send( - session: AbstractSession, - accountNumber: string, - params: ITsoAppCommunicationParms, - startParms: IStartTsoParms - ): Promise { - TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString( - accountNumber, - noAccountNumber.message - ); - - const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - - const apiResponse = await ZosmfRestClient.putExpectJSON< - IASAppResponse & { ver: string } - >( - session, - endpoint, - [Headers.CONTENT_TYPE, "text/plain"], - params.message - ); - - const formattedApiResponse: IASAppResponse = { - version: apiResponse.ver, - reused: apiResponse.reused, - timeout: apiResponse.timeout, - servletKey: apiResponse.servletKey ?? null, - queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] - ? "TSO MESSAGE" - : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, - }; - }), - }; - - return formattedApiResponse; - } -} diff --git a/packages/zostso/src/StartTsoApp.ts b/packages/zostso/src/StartTsoApp.ts deleted file mode 100644 index 23c931ec73..0000000000 --- a/packages/zostso/src/StartTsoApp.ts +++ /dev/null @@ -1,97 +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. -* -*/ - -import { AbstractSession, Headers } from "@zowe/imperative"; -import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; -import { IStartTsoParms } from "./doc/input/IStartTsoParms"; -import { TsoValidator } from "./TsoValidator"; -import { noAccountNumber, TsoConstants } from "./TsoConstants"; -import { IASAppResponse } from "./doc/IASAppResponse"; -import { IStartTsoAppParms } from "./doc/input/IStartTsoAppParms"; -import { StartTso } from "./StartTso"; -import { IIssueResponse } from "../src"; -/** - * Start TSO address space and receive servlet key - * @export - * @class StartTsoApp - */ -export class StartTsoApp { - /** - * Start TSO application at address space with provided parameters. - * @static - * @param {AbstractSession} session - z/OSMF connection info - * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. - * @param {IStartTsoParms} parms - optional object with required parameters, @see {IStartTsoParms} - * @returns {Promise} command response on resolve, @see {IASAppResponse} - * @memberof StartTso - */ - public static async start( - session: AbstractSession, - accountNumber: string, - params: IStartTsoAppParms, - startParms: IStartTsoParms - ): Promise { - TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString( - accountNumber, - noAccountNumber.message - ); - - // Address space is not known and must be created - if (!params.queueID || !params.servletKey) { - const response: IIssueResponse = { - success: false, - startResponse: await StartTso.start( - session, - accountNumber, - startParms - ), - startReady: false, - zosmfResponse: null, - commandResponse: null, - stopResponse: null, - }; - // Reassigning servletKey and queueID so the application can be started at the correct location - params.servletKey = - response.startResponse.zosmfTsoResponse.servletKey; - params.queueID = response.startResponse.zosmfTsoResponse.queueID; - } - - // Address space application starting - const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const response = await ZosmfRestClient.postExpectJSON( - session, - endpoint, - [Headers.APPLICATION_JSON], - { - startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, - } - ); - const formattedApiResponse: IASAppResponse = { - version: response.ver, - reused: response.reused, - timeout: response.timeout, - servletKey: params.servletKey ?? null, - queueID: params.queueID ?? null, - tsoData: response.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] - ? "TSO MESSAGE" - : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, - }; - }), - }; - - return formattedApiResponse; - } -} diff --git a/packages/zostso/src/index.ts b/packages/zostso/src/index.ts index 14ce39eadf..743200c6e7 100644 --- a/packages/zostso/src/index.ts +++ b/packages/zostso/src/index.ts @@ -39,9 +39,7 @@ export * from "./IssueTso"; export * from "./PingTso"; export * from "./SendTso"; export * from "./StartTso"; -export * from "./StartTsoApp"; -export * from "./SendTsoApp"; -export * from "./ReceiveTsoApp"; +export * from "./AddressSpaceApps"; export * from "./StopTso"; export * from "./TsoConstants"; export * from "./TsoResponseService"; From 7eeddb7cafc6ccec6883ea2f4f062f0ebda0e2f4 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 28 Oct 2024 11:57:38 -0400 Subject: [PATCH 065/106] expanded on encodingCheck.txt file, consolidated import lines, private -> public function signature Signed-off-by: jace-roell --- packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts | 3 +-- .../__system__/methods/upload/testfiles/encodingCheck.txt | 2 +- packages/zosfiles/src/methods/upload/Upload.ts | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts index ac87340da0..9b4450278d 100644 --- a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts @@ -18,8 +18,7 @@ import { } from "@zowe/imperative"; import { Upload, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; -import { IUploadOptions } from "@zowe/zos-files-for-zowe-sdk"; -import { ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; +import { IUploadOptions, ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; /** * Handler to upload content from a local file to a USS file diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/encodingCheck.txt b/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/encodingCheck.txt index 98ce8af41b..ae3e63ebb9 100644 --- a/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/encodingCheck.txt +++ b/packages/zosfiles/__tests__/__system__/methods/upload/testfiles/encodingCheck.txt @@ -1 +1 @@ -á é í ó ú ñ Ç ß 12345 !@#$% \ No newline at end of file +á é í ó ú ñ Ç ß 12345 !@#$% ^ [ ] $ £ € \ No newline at end of file diff --git a/packages/zosfiles/src/methods/upload/Upload.ts b/packages/zosfiles/src/methods/upload/Upload.ts index 1387a8c850..f13f4eb4bb 100644 --- a/packages/zosfiles/src/methods/upload/Upload.ts +++ b/packages/zosfiles/src/methods/upload/Upload.ts @@ -855,7 +855,7 @@ export class Upload { } public static async uploadFile(session: AbstractSession, localPath: string, ussPath: string, - options: IUploadOptions) { + options: IUploadOptions): Promise { const tempOptions: Partial = {}; if (options.attributes) { From 761d9600b9d581e645d7bee2d8988fd00cd5e7b5 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 28 Oct 2024 11:59:46 -0400 Subject: [PATCH 066/106] duplicate import lines Signed-off-by: jace-roell --- .../__unit__/upload/ftu/FileToUSS.handler.unit.test.ts | 3 +-- packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts index 52cbac3cdf..e4a6582d25 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftu/FileToUSS.handler.unit.test.ts @@ -9,9 +9,8 @@ * */ -import { Upload } from "@zowe/zos-files-for-zowe-sdk"; +import { Upload, ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; -import { ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; describe("Upload file-to-uss handler", () => { describe("process method", () => { diff --git a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts index 9b4450278d..45cfe46971 100644 --- a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts @@ -16,9 +16,8 @@ import { TaskStage, TextUtils, } from "@zowe/imperative"; -import { Upload, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; +import { Upload, IZosFilesResponse, IUploadOptions, ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; -import { IUploadOptions, ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; /** * Handler to upload content from a local file to a USS file From 7762d1636609a7588db1a8bb18cc66e96d5629ac Mon Sep 17 00:00:00 2001 From: jace-roell Date: Mon, 28 Oct 2024 12:04:20 -0400 Subject: [PATCH 067/106] linting Signed-off-by: jace-roell --- .../imperative/src/cmd/src/response/CommandResponse.ts | 2 +- packages/imperative/src/config/src/ConfigUtils.ts | 3 ++- packages/zostso/src/AddressSpaceApps.ts | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/imperative/src/cmd/src/response/CommandResponse.ts b/packages/imperative/src/cmd/src/response/CommandResponse.ts index 7f6842ce44..0732d247d1 100644 --- a/packages/imperative/src/cmd/src/response/CommandResponse.ts +++ b/packages/imperative/src/cmd/src/response/CommandResponse.ts @@ -709,7 +709,7 @@ export class CommandResponse implements ICommandResponseApi { this.spinnerInterval = setInterval(() => { process.stdout.write(`\r${pendingText} ${this.mProgressBarSpinnerChars[this.spinnerIndex]}`); this.spinnerIndex = (this.spinnerIndex + 1) % this.mProgressBarSpinnerChars.length; - }, 100); + }, 100); // eslint-disable-line } } /** diff --git a/packages/imperative/src/config/src/ConfigUtils.ts b/packages/imperative/src/config/src/ConfigUtils.ts index dc7d0a5853..8128b99032 100644 --- a/packages/imperative/src/config/src/ConfigUtils.ts +++ b/packages/imperative/src/config/src/ConfigUtils.ts @@ -300,7 +300,8 @@ export class ConfigUtils { * Checks if the given token has expired. Supports JSON web tokens only. * * @param {string} token - The JSON web token to check - * @returns {boolean} Whether the token has expired. Returns `false` if the token cannot be decoded or an expire time is not specified in the payload. + * @returns {boolean} Whether the token has expired. + * Returns `false` if the token cannot be decoded or an expire time is not specified in the payload. */ public static hasTokenExpired(token: string): boolean { // JWT format: [header].[payload].[signature] diff --git a/packages/zostso/src/AddressSpaceApps.ts b/packages/zostso/src/AddressSpaceApps.ts index 9d28a395e8..b865120260 100644 --- a/packages/zostso/src/AddressSpaceApps.ts +++ b/packages/zostso/src/AddressSpaceApps.ts @@ -65,7 +65,7 @@ export class AddressSpaceApps { // Address space application starting const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; const response = await ZosmfRestClient.postExpectJSON< - IASAppResponse & { ver: string } + IASAppResponse & { ver: string } >(session, endpoint, [Headers.APPLICATION_JSON], { startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, }); @@ -112,7 +112,7 @@ export class AddressSpaceApps { const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; const apiResponse = await ZosmfRestClient.putExpectJSON< - IASAppResponse & { ver: string } + IASAppResponse & { ver: string } >( session, endpoint, @@ -167,14 +167,14 @@ export class AddressSpaceApps { let timeoutReached = false; do { - if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { + if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { // eslint-disable-line timeoutReached = true; break; } try { const apiResponse = await ZosmfRestClient.getExpectJSON< - IASAppResponse & { ver: string; appData?: any } + IASAppResponse & { ver: string; appData?: any } >(session, endpoint); const response = apiResponse as IASAppResponse & { ver: string; From f408fc3da5ae2ac8e77770ba257bab107275b664 Mon Sep 17 00:00:00 2001 From: Pujal Date: Mon, 28 Oct 2024 12:33:51 -0400 Subject: [PATCH 068/106] updated iJob interface Signed-off-by: Pujal --- .../__tests__/__resources__/api/GetJobsData.ts | 12 ++++++------ packages/zosjobs/src/GetJobs.ts | 13 ++++++------- packages/zosjobs/src/doc/response/IJob.ts | 10 +++++----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts b/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts index fb58d21b0d..144f9b8d85 100644 --- a/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts +++ b/packages/zosjobs/__tests__/__resources__/api/GetJobsData.ts @@ -32,8 +32,8 @@ export class GetJobsData { "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', "exec-submitted": '2024-01-02T15:58:00.600Z', - "exec-member": 'DE20', - "exec-system": 'DE20', + "exec-member": 'SYS1', + "exec-system": 'SYS1', "subsystem": "JES2", "owner": "IBMUSER", "status": "OUTPUT", @@ -59,8 +59,8 @@ export class GetJobsData { "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', "exec-submitted": '2024-01-02T15:58:00.600Z', - "exec-member": 'DE20', - "exec-system": 'DE20', + "exec-member": 'SYS1', + "exec-system": 'SYS1', "subsystem": "JES2", "owner": "CAUSER", "status": "OUTPUT", @@ -94,8 +94,8 @@ export class GetJobsData { "exec-started": '2024-01-02T15:57:58.350Z', "exec-ended": '2024-01-02T15:58:00.600Z', "exec-submitted": '2024-01-02T15:58:00.600Z', - "exec-member": 'DE20', - "exec-system": 'DE20', + "exec-member": 'SYS1', + "exec-system": 'SYS1', "status": "INPUT", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "class": "A", diff --git a/packages/zosjobs/src/GetJobs.ts b/packages/zosjobs/src/GetJobs.ts index 6bc2d7163b..4e7c510f12 100644 --- a/packages/zosjobs/src/GetJobs.ts +++ b/packages/zosjobs/src/GetJobs.ts @@ -153,7 +153,6 @@ export class GetJobs { Logger.getAppLogger().trace("GetJobs.getJobsCommon()"); ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined"); let query = JobsConstants.QUERY_ID; - const includeExecData = params?.execData !== false; if (params) { if (params.owner) { @@ -181,6 +180,12 @@ export class GetJobs { } query += JobsConstants.QUERY_JOBID + encodeURIComponent(params.jobid); } + if (params.execData) { + if (RestClient.hasQueryString(query)) { + query += JobsConstants.COMBO_ID; + } + query += JobsConstants.EXEC_DATA; + } if (params.status) { if (RestClient.hasQueryString(query)) { query += JobsConstants.COMBO_ID; @@ -189,12 +194,6 @@ export class GetJobs { } } - if (includeExecData) { - if (RestClient.hasQueryString(query)) { - query += JobsConstants.COMBO_ID; - } - query += JobsConstants.EXEC_DATA; - } let resource = JobsConstants.RESOURCE; resource += query === JobsConstants.QUERY_ID ? "" : query; diff --git a/packages/zosjobs/src/doc/response/IJob.ts b/packages/zosjobs/src/doc/response/IJob.ts index 3963a6b783..d181827b77 100644 --- a/packages/zosjobs/src/doc/response/IJob.ts +++ b/packages/zosjobs/src/doc/response/IJob.ts @@ -39,35 +39,35 @@ export interface IJob { * @type {Date} * @memberof IJob */ - "exec-started": string; + "exec-started"?: string; /** * end date of the job * @type {Date} * @memberof IJob */ - "exec-ended": string; + "exec-ended"?: string; /** * exec-member * @type {string} * @memberof IJob */ - "exec-member": string; + "exec-member"?: string; /** * exec-submitted * @type {Date} * @memberof IJob */ - "exec-submitted": string; + "exec-submitted"?: string; /** * exec-system * @type {String} * @memberof IJob */ - "exec-system": string; + "exec-system"?: string; /** * The primary or secondary JES subsystem. From 11cd8aed6936649cb1b1cd983c222da428325020 Mon Sep 17 00:00:00 2001 From: Pujal Date: Mon, 28 Oct 2024 13:26:44 -0400 Subject: [PATCH 069/106] updated snapshots Signed-off-by: Pujal --- .../__snapshots__/GetJobs.unit.test.ts.snap | 134 +++++++++--------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap index bcb25df65b..f9d948a744 100644 --- a/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap +++ b/packages/zosjobs/__tests__/__unit__/__snapshots__/GetJobs.unit.test.ts.snap @@ -15,10 +15,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -35,10 +35,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -60,10 +60,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -80,10 +80,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -105,10 +105,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -125,10 +125,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -150,10 +150,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -170,10 +170,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -195,10 +195,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -215,10 +215,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -240,10 +240,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -260,10 +260,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -285,10 +285,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -305,10 +305,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -330,10 +330,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -350,10 +350,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -375,10 +375,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -395,10 +395,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -420,10 +420,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -440,10 +440,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -465,10 +465,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -485,10 +485,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -505,32 +505,32 @@ Array [ ] `; -exports[`GetJobs tests getJobs APIs should have proper URI when using all parms 1`] = `"/zosmf/restjobs/jobs?owner=fakeOwner&prefix=fakePrefix&max-jobs=2&jobid=fakeID&exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using all parms 1`] = `"/zosmf/restjobs/jobs?owner=fakeOwner&prefix=fakePrefix&max-jobs=2&jobid=fakeID"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using jobid 1`] = `"/zosmf/restjobs/jobs?jobid=fakeJobid&exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using jobid 1`] = `"/zosmf/restjobs/jobs?jobid=fakeJobid"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using jobname and jobid 1`] = `"/zosmf/restjobs/jobs?owner=someOwner&prefix=somePrefix&exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using jobname and jobid 1`] = `"/zosmf/restjobs/jobs?owner=someOwner&prefix=somePrefix"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using jobname, prefix, and jobid 1`] = `"/zosmf/restjobs/jobs?owner=someOwner&prefix=somePrefix&jobid=fakeJobid&exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using jobname, prefix, and jobid 1`] = `"/zosmf/restjobs/jobs?owner=someOwner&prefix=somePrefix&jobid=fakeJobid"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using maxjobs 1`] = `"/zosmf/restjobs/jobs?max-jobs=10&exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using maxjobs 1`] = `"/zosmf/restjobs/jobs?max-jobs=10"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using no parms 1`] = `"/zosmf/restjobs/jobs?exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using no parms 1`] = `"/zosmf/restjobs/jobs"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using owner 1`] = `"/zosmf/restjobs/jobs?owner=fakeOwner&exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using owner 1`] = `"/zosmf/restjobs/jobs?owner=fakeOwner"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using prefix 1`] = `"/zosmf/restjobs/jobs?prefix=fakePrefix&exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using prefix 1`] = `"/zosmf/restjobs/jobs?prefix=fakePrefix"`; -exports[`GetJobs tests getJobs APIs should have proper URI when using status 1`] = `"/zosmf/restjobs/jobs?status=active&exec-data=Y"`; +exports[`GetJobs tests getJobs APIs should have proper URI when using status 1`] = `"/zosmf/restjobs/jobs?status=active"`; exports[`GetJobs tests getJobs APIs should locate a job by jobid 1`] = ` Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -561,10 +561,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -581,10 +581,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -606,10 +606,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -626,10 +626,10 @@ Array [ Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "https://tso1:443/zosmf/restjobs/jobs/J0003781USILDAMDD3CE8146.......%3A/files", "job-correlator": "J0003781USILDAMDD3CE8146.......:", "jobid": "JOB03781", @@ -829,10 +829,10 @@ exports[`GetJobs tests getStatus APIs should get a job via getStatus and getStat Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", @@ -852,10 +852,10 @@ exports[`GetJobs tests getStatus APIs should get a job via getStatus and getStat Object { "class": "A", "exec-ended": "2024-01-02T15:58:00.600Z", - "exec-member": "DE20", + "exec-member": "SYS1", "exec-started": "2024-01-02T15:57:58.350Z", "exec-submitted": "2024-01-02T15:58:00.600Z", - "exec-system": "DE20", + "exec-system": "SYS1", "files-url": "www.nowhere.com/restjobs/jobs/files", "job-correlator": "123545asdfadf", "jobid": "TSUxxx", From 58fd40f2210b0aca80285f25f432d3af675a8b87 Mon Sep 17 00:00:00 2001 From: zowe-robot Date: Mon, 28 Oct 2024 19:23:20 +0000 Subject: [PATCH 070/106] Bump version to 8.4.0 [ci skip] Signed-off-by: zowe-robot --- lerna.json | 2 +- npm-shrinkwrap.json | 18 +++++++++--------- packages/cli/CHANGELOG.md | 2 +- packages/cli/package.json | 8 ++++---- packages/workflows/package.json | 4 ++-- packages/zosfiles/CHANGELOG.md | 2 +- packages/zosfiles/package.json | 2 +- packages/zosjobs/package.json | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lerna.json b/lerna.json index 6e016aa3d2..c1b0160cf8 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "8.3.1", + "version": "8.4.0", "command": { "publish": { "ignoreChanges": [ diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index dc95d5321f..42fdc41c17 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -16267,7 +16267,7 @@ }, "packages/cli": { "name": "@zowe/cli", - "version": "8.3.1", + "version": "8.4.0", "hasInstallScript": true, "license": "EPL-2.0", "dependencies": { @@ -16275,12 +16275,12 @@ "@zowe/imperative": "8.3.1", "@zowe/provisioning-for-zowe-sdk": "8.3.1", "@zowe/zos-console-for-zowe-sdk": "8.3.1", - "@zowe/zos-files-for-zowe-sdk": "8.3.1", - "@zowe/zos-jobs-for-zowe-sdk": "8.3.1", + "@zowe/zos-files-for-zowe-sdk": "8.4.0", + "@zowe/zos-jobs-for-zowe-sdk": "8.4.0", "@zowe/zos-logs-for-zowe-sdk": "8.3.1", "@zowe/zos-tso-for-zowe-sdk": "8.3.1", "@zowe/zos-uss-for-zowe-sdk": "8.3.1", - "@zowe/zos-workflows-for-zowe-sdk": "8.3.1", + "@zowe/zos-workflows-for-zowe-sdk": "8.4.0", "@zowe/zosmf-for-zowe-sdk": "8.3.1", "find-process": "1.4.7", "lodash": "4.17.21", @@ -16597,10 +16597,10 @@ }, "packages/workflows": { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.3.1", + "version": "8.4.0", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.3.1" + "@zowe/zos-files-for-zowe-sdk": "8.4.0" }, "devDependencies": { "@zowe/cli-test-utils": "8.3.1", @@ -16634,7 +16634,7 @@ }, "packages/zosfiles": { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.3.1", + "version": "8.4.0", "license": "EPL-2.0", "dependencies": { "lodash": "^4.17.21", @@ -16676,10 +16676,10 @@ }, "packages/zosjobs": { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.3.1", + "version": "8.4.0", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.3.1" + "@zowe/zos-files-for-zowe-sdk": "8.4.0" }, "devDependencies": { "@zowe/cli-test-utils": "8.3.1", diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index a8c0a33f4a..2c571c6f39 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe CLI package will be documented in this file. -## Recent Changes +## `8.4.0` - Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319] (https://github.com/zowe/zowe-cli/pull/2319) diff --git a/packages/cli/package.json b/packages/cli/package.json index 49ffdb8744..4745fc3993 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cli", - "version": "8.3.1", + "version": "8.4.0", "zoweVersion": "v3.0.0", "description": "Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.", "author": "Zowe", @@ -62,12 +62,12 @@ "@zowe/imperative": "8.3.1", "@zowe/provisioning-for-zowe-sdk": "8.3.1", "@zowe/zos-console-for-zowe-sdk": "8.3.1", - "@zowe/zos-files-for-zowe-sdk": "8.3.1", - "@zowe/zos-jobs-for-zowe-sdk": "8.3.1", + "@zowe/zos-files-for-zowe-sdk": "8.4.0", + "@zowe/zos-jobs-for-zowe-sdk": "8.4.0", "@zowe/zos-logs-for-zowe-sdk": "8.3.1", "@zowe/zos-tso-for-zowe-sdk": "8.3.1", "@zowe/zos-uss-for-zowe-sdk": "8.3.1", - "@zowe/zos-workflows-for-zowe-sdk": "8.3.1", + "@zowe/zos-workflows-for-zowe-sdk": "8.4.0", "@zowe/zosmf-for-zowe-sdk": "8.3.1", "find-process": "1.4.7", "lodash": "4.17.21", diff --git a/packages/workflows/package.json b/packages/workflows/package.json index 99c52d8a23..b9e3e3e8bd 100644 --- a/packages/workflows/package.json +++ b/packages/workflows/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.3.1", + "version": "8.4.0", "description": "Zowe SDK to interact with the z/OS workflows APIs", "author": "Zowe", "license": "EPL-2.0", @@ -45,7 +45,7 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.3.1" + "@zowe/zos-files-for-zowe-sdk": "8.4.0" }, "devDependencies": { "@zowe/cli-test-utils": "8.3.1", diff --git a/packages/zosfiles/CHANGELOG.md b/packages/zosfiles/CHANGELOG.md index 4c819c988a..3c53654b69 100644 --- a/packages/zosfiles/CHANGELOG.md +++ b/packages/zosfiles/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe z/OS files SDK package will be documented in this file. -## Recent Changes +## `8.4.0` - Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319] (https://github.com/zowe/zowe-cli/pull/2319) diff --git a/packages/zosfiles/package.json b/packages/zosfiles/package.json index 8c5f11d13a..25e8342c16 100644 --- a/packages/zosfiles/package.json +++ b/packages/zosfiles/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.3.1", + "version": "8.4.0", "description": "Zowe SDK to interact with files and data sets on z/OS", "author": "Zowe", "license": "EPL-2.0", diff --git a/packages/zosjobs/package.json b/packages/zosjobs/package.json index d1590252e3..108518dd5f 100644 --- a/packages/zosjobs/package.json +++ b/packages/zosjobs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.3.1", + "version": "8.4.0", "description": "Zowe SDK to interact with jobs on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -46,7 +46,7 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.3.1" + "@zowe/zos-files-for-zowe-sdk": "8.4.0" }, "devDependencies": { "@zowe/cli-test-utils": "8.3.1", From 4b7a19408d2f761a0a1a202aa85114838993e0d9 Mon Sep 17 00:00:00 2001 From: zowe-robot Date: Mon, 28 Oct 2024 20:58:24 +0000 Subject: [PATCH 071/106] Bump version to 8.5.0 [ci skip] Signed-off-by: zowe-robot --- lerna.json | 2 +- npm-shrinkwrap.json | 6 +++--- packages/cli/package.json | 4 ++-- packages/zosjobs/CHANGELOG.md | 2 +- packages/zosjobs/package.json | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lerna.json b/lerna.json index c1b0160cf8..e60247f527 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "8.4.0", + "version": "8.5.0", "command": { "publish": { "ignoreChanges": [ diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 42fdc41c17..e4e1c1bd9b 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -16267,7 +16267,7 @@ }, "packages/cli": { "name": "@zowe/cli", - "version": "8.4.0", + "version": "8.5.0", "hasInstallScript": true, "license": "EPL-2.0", "dependencies": { @@ -16276,7 +16276,7 @@ "@zowe/provisioning-for-zowe-sdk": "8.3.1", "@zowe/zos-console-for-zowe-sdk": "8.3.1", "@zowe/zos-files-for-zowe-sdk": "8.4.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.4.0", + "@zowe/zos-jobs-for-zowe-sdk": "8.5.0", "@zowe/zos-logs-for-zowe-sdk": "8.3.1", "@zowe/zos-tso-for-zowe-sdk": "8.3.1", "@zowe/zos-uss-for-zowe-sdk": "8.3.1", @@ -16676,7 +16676,7 @@ }, "packages/zosjobs": { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.4.0", + "version": "8.5.0", "license": "EPL-2.0", "dependencies": { "@zowe/zos-files-for-zowe-sdk": "8.4.0" diff --git a/packages/cli/package.json b/packages/cli/package.json index 4745fc3993..20051e25c5 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cli", - "version": "8.4.0", + "version": "8.5.0", "zoweVersion": "v3.0.0", "description": "Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.", "author": "Zowe", @@ -63,7 +63,7 @@ "@zowe/provisioning-for-zowe-sdk": "8.3.1", "@zowe/zos-console-for-zowe-sdk": "8.3.1", "@zowe/zos-files-for-zowe-sdk": "8.4.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.4.0", + "@zowe/zos-jobs-for-zowe-sdk": "8.5.0", "@zowe/zos-logs-for-zowe-sdk": "8.3.1", "@zowe/zos-tso-for-zowe-sdk": "8.3.1", "@zowe/zos-uss-for-zowe-sdk": "8.3.1", diff --git a/packages/zosjobs/CHANGELOG.md b/packages/zosjobs/CHANGELOG.md index efed2c155e..2f2e1eb413 100644 --- a/packages/zosjobs/CHANGELOG.md +++ b/packages/zosjobs/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe z/OS jobs SDK package will be documented in this file. -## Recent Changes +## `8.5.0` - Enhancement: Added execData to IJob return data from GetJobs.getJob [#2320](https://github.com/zowe/zowe-cli/pull/2320) ## `8.1.1` diff --git a/packages/zosjobs/package.json b/packages/zosjobs/package.json index 108518dd5f..19464cbade 100644 --- a/packages/zosjobs/package.json +++ b/packages/zosjobs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.4.0", + "version": "8.5.0", "description": "Zowe SDK to interact with jobs on z/OS", "author": "Zowe", "license": "EPL-2.0", From 6ddbd1752af7a3c9e2594933a3ad466089ecf078 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 29 Oct 2024 10:50:13 -0400 Subject: [PATCH 072/106] spinner refactorting, spinner unit tests, generic rexx script for testing now local and not system dependent Signed-off-by: jace-roell --- .../cli-test-utils/src/TestUtils.ts | 2 +- .../app/ReceiveASApp.handler.unit.test.ts | 4 +- .../ReceiveASApp.handler.unit.test.ts.snap | 2 +- .../send/app/SendASApp.handler.unit.test.ts | 4 +- .../SendASApp.handler.unit.test.ts.snap | 2 +- .../start/app/StartASApp.handler.unit.test.ts | 14 +- .../StartASApp.handler.unit.test.ts.snap | 4 +- .../receive/app/ReceiveASApp.handler.ts | 2 +- .../zostso/send/as-app/SendASApp.handler.ts | 2 +- .../response/CommandResponse.unit.test.ts | 12 +- .../api/handler/IHandlerProgressApi.ts | 2 +- .../src/cmd/src/response/CommandResponse.ts | 11 +- .../zosfiles/src/methods/upload/Upload.ts | 10 +- .../start/start_app_existing_as.sh | 3 +- .../__scripts__/start/start_app_new_as.sh | 3 +- .../__scripts__/start/test_app.rexx | 206 ++++++++++++++++++ .../__system__/api.TsoASApp.system.test.ts | 17 +- .../__unit__/ReceiveTsoApp.unit.test.ts | 20 +- .../__unit__/SendTsoApp.unit.test.ts | 6 +- .../__unit__/StartTsoApp.unit.test.ts | 14 +- packages/zostso/src/AddressSpaceApps.ts | 172 +++++---------- 21 files changed, 337 insertions(+), 175 deletions(-) create mode 100644 packages/zostso/__tests__/__system__/__scripts__/start/test_app.rexx diff --git a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts index 05a1fe5016..1c47f617c8 100644 --- a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts +++ b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts @@ -123,7 +123,7 @@ export function mockHandlerParameters(params: PartialHandlerParameters): IHandle startBar: jest.fn((parms) => undefined), endBar: jest.fn(() => undefined), startSpinner: jest.fn(() => undefined), - stopSpinner: jest.fn(() => undefined) + endSpinner: jest.fn(() => undefined) }, format: { output: jest.fn((parms) => { diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts index ba8a540266..133bc072f1 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/ReceiveASApp.handler.unit.test.ts @@ -26,7 +26,7 @@ const MOCK_RECEIVE_RESPONSE: any = { version: undefined, reused: false, timeout: false, - servletKey: "CUST009-122-aabyaaaj", + servletKey: "ZOWEUSER-122-aabyaaaj", queueID: null, tsoData: [ { @@ -51,7 +51,7 @@ describe("receive TSO app handler behavior", () => { const handler = new ReceiveASAppHandler.default(); const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); let error = undefined; - params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "CUST009-122-aabyaaaj", runUntilReady: true}; + params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "ZOWEUSER-122-aabyaaaj", runUntilReady: true}; try{ await handler.process(params); } diff --git a/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap index 24db489a36..804ca2c953 100644 --- a/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/receive/app/__snapshots__/ReceiveASApp.handler.unit.test.ts.snap @@ -13,7 +13,7 @@ exports[`receive TSO app handler behavior should properly receive and parse data Object { "queueID": null, "reused": false, - "servletKey": "CUST009-122-aabyaaaj", + "servletKey": "ZOWEUSER-122-aabyaaaj", "timeout": false, "tsoData": Array [ Object { diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts index 379da76816..6b7aa1b720 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/send/app/SendASApp.handler.unit.test.ts @@ -23,7 +23,7 @@ const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ definition: SendASAppDefinition.SendASApp }); const MOCK_SEND_RESPONSE = Promise.resolve({ - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", ver: "0100", tsoData: [ { @@ -56,7 +56,7 @@ describe("receive TSO app handler behavior", () => { const handler = new SendASAppHandler.default(); const params = Object.assign({}, ...[DEFAULT_PARAMETERS]); let error = undefined; - params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "CUST009-129-aaceaaap", message: "LONG 100"}; + params.arguments = {...params.arguments,account: "izuacct", appKey: "test2", servletKey: "ZOWEUSER-129-aaceaaap", message: "LONG 100"}; try{ await handler.process(params); } diff --git a/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap index 2845b9254b..7f6ec7a519 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/send/app/__snapshots__/SendASApp.handler.unit.test.ts.snap @@ -5,7 +5,7 @@ exports[`receive TSO app handler behavior should properly receive and parse data \\"version\\": \\"0100\\", \\"reused\\": false, \\"timeout\\": false, - \\"servletKey\\": \\"CUST009-127-aabeaaag\\", + \\"servletKey\\": \\"ZOWEUSER-127-aabeaaag\\", \\"queueID\\": null, \\"tsoData\\": [ { diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts index 4cc212678e..ddfc9cdcd3 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/start/app/StartASApp.handler.unit.test.ts @@ -42,7 +42,7 @@ const MOCK_RESPONSE = Promise.resolve({ version: "0100", reused: false, timeout: false, - servletKey: "CUST009-123-aaaaaa", + servletKey: "ZOWEUSER-123-aaaaaa", queueID: "983068", tsoData: [ { @@ -76,14 +76,14 @@ const MOCK_RESPONSE = Promise.resolve({ const MOCK_START_RESPONSE: Promise = Promise.resolve({ collectedResponses: [], messages: - "IKJ56455I CUST009 LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", - servletKey: "CUST009-123-aaaaaa", + "IKJ56455I ZOWEUSER LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", + servletKey: "ZOWEUSER-123-aaaaaa", success: true, zosmfTsoResponse: { ver: "0100", queueID: "983068", reused: false, - servletKey: "CUST009-123-aaaaaa", + servletKey: "ZOWEUSER-123-aaaaaa", sessionID: "0x00", timeout: false, tsoData: [{}], @@ -109,7 +109,7 @@ describe("receive TSO app handler behavior", () => { params.arguments = { ...params.arguments, account: "izuacct", - startup: "EXEC 'CUST009.PUBLIC.REXX(VAREXX)'", + startup: "EXEC 'ZOWEUSER.PUBLIC.REXX(VAREXX)'", appKey: "test2", }; try { @@ -137,9 +137,9 @@ describe("receive TSO app handler behavior", () => { params.arguments = { ...params.arguments, account: "izuacct", - startup: "EXEC 'CUST009.PUBLIC.REXX(VAREXX)'", + startup: "EXEC 'ZOWEUSER.PUBLIC.REXX(VAREXX)'", queueId: "983068", - servletKey: "CUST009-123-aaaaaa", + servletKey: "ZOWEUSER-123-aaaaaa", appKey: "test2", }; try { diff --git a/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap b/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap index 74d74a704c..ca5889138b 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap +++ b/packages/cli/__tests__/zostso/__unit__/start/app/__snapshots__/StartASApp.handler.unit.test.ts.snap @@ -4,7 +4,7 @@ exports[`receive TSO app handler behavior should properly start TSO address spac "{ \\"reused\\": false, \\"timeout\\": false, - \\"servletKey\\": \\"CUST009-123-aaaaaa\\", + \\"servletKey\\": \\"ZOWEUSER-123-aaaaaa\\", \\"queueID\\": \\"983068\\", \\"tsoData\\": [ { @@ -35,7 +35,7 @@ exports[`receive TSO app handler behavior should properly start TSO address spac "{ \\"reused\\": false, \\"timeout\\": false, - \\"servletKey\\": \\"CUST009-123-aaaaaa\\", + \\"servletKey\\": \\"ZOWEUSER-123-aaaaaa\\", \\"queueID\\": \\"983068\\", \\"tsoData\\": [ { diff --git a/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts index a7025d641c..03cd8e27fc 100644 --- a/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts +++ b/packages/cli/src/zostso/receive/app/ReceiveASApp.handler.ts @@ -35,7 +35,7 @@ export default class Handler extends ZosTsoBaseHandler { }, ); - commandParameters.response.progress.stopSpinner("Receiving response... Done!"); + commandParameters.response.progress.endSpinner(); commandParameters.response.console.log("\n"); response.tsoData.forEach((data) => { diff --git a/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts b/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts index f0db078644..cb14bf80a9 100644 --- a/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts +++ b/packages/cli/src/zostso/send/as-app/SendASApp.handler.ts @@ -35,7 +35,7 @@ export default class Handler extends ZosTsoBaseHandler { this.mTsoStart ); - commandParameters.response.progress.stopSpinner("Sending request... Done!"); + commandParameters.response.progress.endSpinner(); commandParameters.response.console.log( JSON.stringify(response, null, 2) diff --git a/packages/imperative/src/cmd/__tests__/response/CommandResponse.unit.test.ts b/packages/imperative/src/cmd/__tests__/response/CommandResponse.unit.test.ts index 001d0861ed..d926bdf31f 100644 --- a/packages/imperative/src/cmd/__tests__/response/CommandResponse.unit.test.ts +++ b/packages/imperative/src/cmd/__tests__/response/CommandResponse.unit.test.ts @@ -327,6 +327,17 @@ describe("Command Response", () => { expect((response.progress as any).mProgressBarInterval).not.toBeDefined(); }); + it("should start and stop a spinner", () => { + const response: CommandResponse = new CommandResponse({ + silent: false, + responseFormat: "default", + stream, + }); + response.progress.startSpinner("Test Spinner...."); + expect((response as any).progress.spinnerInterval).toBeDefined(); + response.progress.endSpinner("Done"); + expect((response as any).progress.spinnerInterval).toBe(null); + }); it("should allow us to create an instance", () => { let caughtError; try { @@ -414,7 +425,6 @@ describe("Command Response", () => { response.failed(); expect(response.buildJsonResponse()).toMatchSnapshot(); }); - it("should allow us to indicate that the command succeeded", () => { const response = new CommandResponse(); response.failed(); diff --git a/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts b/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts index 99a3a41b52..2eba57b1c2 100644 --- a/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts +++ b/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts @@ -40,5 +40,5 @@ export interface IHandlerProgressApi { * @param {IProgressBarParms} params * @memberof IHandlerProgressApi */ - stopSpinner(endText: string): void; + endSpinner(endText?: string): void; } diff --git a/packages/imperative/src/cmd/src/response/CommandResponse.ts b/packages/imperative/src/cmd/src/response/CommandResponse.ts index 0732d247d1..7ec76af47e 100644 --- a/packages/imperative/src/cmd/src/response/CommandResponse.ts +++ b/packages/imperative/src/cmd/src/response/CommandResponse.ts @@ -38,7 +38,7 @@ import { Logger } from "../../../logger"; import { LoggerUtils } from "../../../logger/src/LoggerUtils"; const DataObjectParser = require("dataobject-parser"); -export const DEFAULT_SPINNER_CHARS = "-oO0)|(0Oo-"; + /** * Command response object allocated by the command processor and used to construct the handler response object * passed to the command handlers. The response object contains all the methods necessary for a command handler (and @@ -707,7 +707,7 @@ export class CommandResponse implements ICommandResponseApi { public startSpinner(pendingText: string): void { if (this.spinnerInterval == null) { this.spinnerInterval = setInterval(() => { - process.stdout.write(`\r${pendingText} ${this.mProgressBarSpinnerChars[this.spinnerIndex]}`); + outer.writeStdout(`\r${pendingText} ${this.mProgressBarSpinnerChars[this.spinnerIndex]}`); this.spinnerIndex = (this.spinnerIndex + 1) % this.mProgressBarSpinnerChars.length; }, 100); // eslint-disable-line } @@ -715,12 +715,13 @@ export class CommandResponse implements ICommandResponseApi { /** * Stop a spinner */ - public stopSpinner(stopText: string): void { + public endSpinner(stopText?: string): void { if (this.spinnerInterval != null) { + outer.write(); clearInterval(this.spinnerInterval); this.spinnerInterval = null; - process.stdout.write(`\r${stopText}\n`); - process.stdout.write("\r\x1b[K"); + if(stopText) outer.writeStdout(`\r${stopText}\n`); + outer.writeStdout("\r\x1b[K"); } } diff --git a/packages/zosfiles/src/methods/upload/Upload.ts b/packages/zosfiles/src/methods/upload/Upload.ts index 985cf0455c..1387a8c850 100644 --- a/packages/zosfiles/src/methods/upload/Upload.ts +++ b/packages/zosfiles/src/methods/upload/Upload.ts @@ -678,7 +678,7 @@ export class Upload { } const fileName = path.normalize(path.join(inputDirectory, file.fileName)); const ussFilePath = path.posix.join(ussname, file.fileName); - return this.uploadFile(fileName, ussFilePath, session, + return this.uploadFile(session,fileName, ussFilePath, { ...options, binary: file.binary }); }; @@ -831,7 +831,7 @@ export class Upload { } const filePath = path.normalize(path.join(inputDirectory, file.fileName)); const ussFilePath = path.posix.join(ussname, file.fileName); - return this.uploadFile(filePath, ussFilePath, session, + return this.uploadFile(session, filePath, ussFilePath, { ...options, binary: file.binary }); }; if (maxConcurrentRequests === 0) { @@ -854,8 +854,8 @@ export class Upload { }; } - private static async uploadFile(localPath: string, ussPath: string, - session: AbstractSession, options: IUploadOptions) { + public static async uploadFile(session: AbstractSession, localPath: string, ussPath: string, + options: IUploadOptions) { const tempOptions: Partial = {}; if (options.attributes) { @@ -882,7 +882,7 @@ export class Upload { } } - await this.fileToUssFile(session, localPath, ussPath, tempOptions); + return await this.fileToUssFile(session, localPath, ussPath, tempOptions); } /** diff --git a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh index c611e6692d..1203459b1a 100755 --- a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh +++ b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_existing_as.sh @@ -7,5 +7,6 @@ password=$5 ru=$6 servletKey=$7 queueID=$8 -zowe zos-tso start app --app-key "test2" --startup "EXEC 'CUST009.PUBLIC.REXX(TESTADRS)'" --servlet-key $servletKey --queue-id $queueID --account $account --host $host --port $port --user $user --password $password --ru $ru +file=$9 +zowe zos-tso start app --app-key "test2" --startup "EXEC '$file'" --servlet-key $servletKey --queue-id $queueID --account $account --host $host --port $port --user $user --password $password --ru $ru exit $? diff --git a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh index ac6c1546ce..d250cc7d95 100755 --- a/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh +++ b/packages/zostso/__tests__/__system__/__scripts__/start/start_app_new_as.sh @@ -5,5 +5,6 @@ port=$3 user=$4 password=$5 ru=$6 -zowe zos-tso start app --app-key "test2" --startup "EXEC 'CUST009.PUBLIC.REXX(TESTADRS)'" --account $account --host $host --port $port --user $user --password $password --ru $ru +file=$7 +zowe zos-tso start app --app-key "test2" --startup "EXEC '$file'" --account $account --host $host --port $port --user $user --password $password --ru $ru exit $? diff --git a/packages/zostso/__tests__/__system__/__scripts__/start/test_app.rexx b/packages/zostso/__tests__/__system__/__scripts__/start/test_app.rexx new file mode 100644 index 0000000000..46e41bdb61 --- /dev/null +++ b/packages/zostso/__tests__/__system__/__scripts__/start/test_app.rexx @@ -0,0 +1,206 @@ +/* REXX hello world application */ + +mainRc=0 + +PARSE ARG oMsgType iMsgType msgQueueId . /* Pick up 3 input parms. */ + +say 'HELLOW exec processing has started.' + +say 'UNIX message queue id = 'msgQueueId +say 'Input message type = 'iMsgType +say 'Output message type = 'oMsgType +iMsgType = D2C(iMsgType, 4) +oMsgType = D2C(oMsgType, 4) + +if syscalls('ON')>3 then + do + say 'Unable to establish the UNIX SYSCALL environment.' + mainRc=-1 + end + +/* Perform a blocking read on the message queue to get the application + input. +*/ +if mainRc=0 then + do + say 'Reading application input from the UNIX message queue.' + ADDRESS SYSCALL 'msgrcv (msgQueueId) iMsg 999 0 iMsgType' + if rc<>0 then + do + say 'Error reading input. ''msgrcv'' rc = 'mainrc + mainRc=-1 + end + else + do + iMsg = atoe(iMsg) /* Convert input from ASCII to EBCDIC. */ + say 'Application input = 'iMsg + end + end + + +do while iMsg \== 'EXIT' + /* Generate the application response. */ + if mainRc=0 then + do + select + when iMsg = 'RANDOM' then + do + oMsg = randomString() + oMsg = etoa(oMsg) + ADDRESS SYSCALL 'msgsnd (msgQueueId) oMsg' length(oMsg) '0 oMsgType' + oMsg = '"READY "' + oMsg = etoa(oMsg) + ADDRESS SYSCALL 'msgsnd (msgQueueId) oMsg' length(oMsg) '0 oMsgType' + mainRc = 0 + leave + end + when SUBSTR(iMsg,1,4) = 'LONG' then + do + PARSE VAR iMsg "LONG" N + N = N+ 0 + do i = 0 to N + say i + end + + say "READY " + oMsg = '"READY "' + oMsg = etoa(oMsg) + ADDRESS SYSCALL 'msgsnd (msgQueueId) oMsg' length(oMsg) '0 oMsgType' + mainRc = 0 + leave + end + otherwise + oMsg = '"' || MVSVAR(iMsg) || '"' + end + if oMsg = '' then + oMsg = 'No information returned' + /*oMsg = '"Hello 'iMsg'!"' */ + say 'Response = 'oMsg + + /* Write the response to the UNIX message queue. */ + oMsg = etoa(oMsg) /* Convert EBCDIC to ASCII. */ + say 'Writing response to the UNIX message queue.' + ADDRESS SYSCALL 'msgsnd (msgQueueId) oMsg' length(oMsg) '0 oMsgType' + if rc<>0 then + do + say 'Error writing response to the UNIX message queue. ', + '''msgsnd'' rc = 'rc'.' + mainRc=-1 + leave + end + end + say 'Reading application input from the UNIX message queue2.' + ADDRESS SYSCALL 'msgrcv (msgQueueId) iMsg 999 0 iMsgType' + if rc<>0 then + do + say 'Error reading input. ''msgrcv'' rc = 'mainrc + mainRc=-1 + end + else + do + iMsg = atoe(iMsg) /* Convert input from ASCII to EBCDIC. */ + say 'Application input2 = 'iMsg + end +end + +say 'HELLOW exec processing is complete with rc = 'mainRc'.' + +return mainRc + + +/* Convert an ASCII string to EBCDIC. */ +atoe: + parse arg msg /* */ + msg = convertstring('ATOE' msg) /* */ + return msg /* */ +/* Convert an EBCDIC string to ASCII. */ +etoa: + parse arg msg /* */ + msg = convertstring('ETOA' msg) /* */ + return msg /* */ + +/* + Convert ASCII to EBCDIC and EBCDIC to ASCII. Use the UNIX iconv + command. Positional input parameters: + + 1 -- conversion type, either "ATOE" or "ETOA" + 2 -- string to be converted. +*/ +convertstring: + parse arg conv msg + /* Create temporary file names. */ + fn = '/tmp/' || USERID() || '.' || TIME('L') + ifn = fn || '.i' /* Name of file to contain input text. */ + ofn = fn || '.o' /* Name of file to contain output text. */ + address syscall 'creat (ifn) 700' + fd=retval + if retval=-1 then + do + say 'Error creating temporary file 'ifn'. ', + 'errno: 'errno' errnojr: 'errnojr + return -1 + end + /* Write the input text to the temporary file. */ + address syscall 'write (fd) msg' length(msg) + address syscall 'close (fd)' + /* + Call iconv to read the temp file containg intput text, and write + the converted text to the output file. + */ + select /* Which conversion was requested?*/ + when conv = 'ATOE' then /* ASCII to EBCDIC? */ + retcode=bpxwunix('iconv -f ISO8859-1 -t IBM-1047 'ifn' > 'ofn) + when conv = 'ETOA' then /* EBCDIC to ASCII? */ + retcode=bpxwunix('iconv -f IBM-1047 -t ISO8859-1 'ifn' > 'ofn) + otherwise + do + say 'Unknown conversion type: "'conv'". ', + 'Acceptable values are "ATOE" or "ETOA".' + return -1 + end + end + if retcode<>0 then + do + say conv' iconv failed with rc = 'retcode'.' + return -1 + end + /* Read the converted text from the output file. */ + address syscall 'open (ofn)' o_rdonly + fd=retval + if retval=-1 then + do + say 'Open failed for file 'ofn'. ', + 'errno: 'errno' errnojr: 'errnojr + return -1 + end + address syscall 'fstat (fd) st.' /* Get file status, to get size. */ + address syscall 'read (fd) msg' st.st_size /* Read entire file. */ + address syscall 'close (fd)' + /* Delete the temporary files. */ + address syscall 'unlink (ofn)' + address syscall 'unlink (ifn)' + return msg /* Return the converted string. */ + +longOutput: + do i = 0 to 4000 + say i + end + +randomString: + randomChars = '' + numChars = 10 + + /* Loop to generate random characters */ + DO i = 1 TO numChars + /* Generate a random number between 65 and 90 for (A-Z) */ + randomNum = RANDOM(65, 90) + + /* Convert the random character using the C2D function */ + randomChar = C2D(randomNum) + + /* Concatenate the random character to the string */ + randomChars = randomChars || randomChar + END + + /* Display the result */ + return 'Random Characters: ' randomChars diff --git a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts index 7aff5ae812..849a4ee778 100644 --- a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts @@ -15,12 +15,15 @@ import { ITestEnvironment } from "@zowe/cli-test-utils"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { runCliScript } from "@zowe/cli-test-utils"; +import { Upload, Create, CreateDataSetTypeEnum, Delete } from "../../../zosfiles/src"; +import { getUniqueDatasetName } from "../../../../__tests__/__src__/TestUtils"; let testEnvironment: ITestEnvironment; let systemProperties: ITestPropertiesSchema; let REAL_SESSION: Session; let ACCOUNT_NUMBER: string; let defaultSystem: ITestPropertiesSchema; +let dsname: string; describe("All test", () => { beforeAll(async () => { @@ -31,9 +34,12 @@ describe("All test", () => { REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); ACCOUNT_NUMBER = systemProperties.tso.account; defaultSystem = testEnvironment.systemTestProperties; + dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSTEST`); + await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname); + await Upload.fileToDataset(REAL_SESSION, __dirname + "/__scripts__/start/test_app.rexx", dsname, {}); }); - afterAll(async () => { + await Delete.dataSet(REAL_SESSION, dsname); await TestEnvironment.cleanUp(testEnvironment); }); @@ -51,6 +57,7 @@ describe("All test", () => { defaultSystem.zosmf.user, defaultSystem.zosmf.password, defaultSystem.zosmf.rejectUnauthorized, + dsname+"(TESTAPP)" ] ); @@ -77,6 +84,10 @@ describe("All test", () => { ); }); it("should create TSO application instance on existing address space", async () => { + dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSTEST`); + await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname); + await Upload.fileToDataset(REAL_SESSION, __dirname + "/__scripts__/start/test_app.rexx", dsname, {}); + const startResponse: IIssueResponse = { success: false, startResponse: await StartTso.start( @@ -101,6 +112,7 @@ describe("All test", () => { defaultSystem.zosmf.rejectUnauthorized, startResponse.startResponse.zosmfTsoResponse.servletKey, startResponse.startResponse.zosmfTsoResponse.queueID, + dsname+"(TESTAPP)" ] ); expect(response.stdout.toString()).toBeDefined(); @@ -139,6 +151,7 @@ describe("All test", () => { defaultSystem.zosmf.user, defaultSystem.zosmf.password, defaultSystem.zosmf.rejectUnauthorized, + dsname+"(TESTAPP)" ] ); const startServletkey = JSON.parse( @@ -183,6 +196,7 @@ describe("All test", () => { defaultSystem.zosmf.user, defaultSystem.zosmf.password, defaultSystem.zosmf.rejectUnauthorized, + dsname+"(TESTAPP)" ] ); const startServletkey = JSON.parse( @@ -237,6 +251,7 @@ describe("All test", () => { defaultSystem.zosmf.user, defaultSystem.zosmf.password, defaultSystem.zosmf.rejectUnauthorized, + dsname+"(TESTAPP)" ] ); const startServletkey = JSON.parse( diff --git a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts index 2f494f7076..f13ca5a131 100644 --- a/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/ReceiveTsoApp.unit.test.ts @@ -27,7 +27,7 @@ const MOCK_RECEIVE_RESPONSE: any = { version: undefined, reused: false, timeout: false, - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", queueID: null, tsoData: [ { @@ -43,7 +43,7 @@ const MOCK_TIMEOUT_RESPONSE: any = { version: undefined, reused: false, timeout: true, - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", queueID: null, tsoData: [], }; @@ -59,7 +59,7 @@ describe("ReceiveTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", appKey: "someAppKey", timeout: 10, receiveUntilReady: true, @@ -80,7 +80,7 @@ describe("ReceiveTsoApp behavior", () => { version: undefined, reused: false, timeout: false, - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", queueID: null, tsoData: [ { VERSION: "0100", DATA: "Processing started." }, @@ -95,7 +95,7 @@ describe("ReceiveTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", appKey: "someAppKey", timeout: 10, receiveUntilReady: true, @@ -119,7 +119,7 @@ describe("ReceiveTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", appKey: "someAppKey", timeout: 1, receiveUntilReady: true, @@ -141,7 +141,7 @@ describe("ReceiveTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", appKey: "someAppKey", timeout: 10, receiveUntilReady: true, @@ -158,7 +158,7 @@ describe("ReceiveTsoApp behavior", () => { version: "0100", reused: false, timeout: false, - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", queueID: null, tsoData: [{"TSO MESSAGE":{ VERSION: "0100", DATA: "First response data." }}], }; @@ -168,7 +168,7 @@ describe("ReceiveTsoApp behavior", () => { version: "0100", reused: false, timeout: false, - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", queueID: null, tsoData: [ {"TSO MESSAGE":{ VERSION: "0100", DATA: "Second response data." }}, @@ -182,7 +182,7 @@ describe("ReceiveTsoApp behavior", () => { .mockResolvedValueOnce(mockResponse2); // Second call const params: ITsoAppCommunicationParms = { - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", appKey: "someAppKey", timeout: 10, receiveUntilReady: true, diff --git a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts index f9b2381e70..3aadc54f2a 100644 --- a/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/SendTsoApp.unit.test.ts @@ -24,7 +24,7 @@ const PRETEND_SESSION = new Session({ }); const MOCK_SEND_RESPONSE = Promise.resolve({ - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", ver: "0100", tsoData: [ { @@ -55,7 +55,7 @@ describe("SendTsoApp behavior", () => { ); const params: ITsoAppCommunicationParms = { - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", appKey: "someAppKey", message: "Test message", }; @@ -78,7 +78,7 @@ describe("SendTsoApp behavior", () => { version: "0100", reused: false, timeout: false, - servletKey: "CUST009-127-aabeaaag", + servletKey: "ZOWEUSER-127-aabeaaag", queueID: null, tsoData: [ { diff --git a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts index 0de43fa87f..688347aeaa 100644 --- a/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/StartTsoApp.unit.test.ts @@ -25,7 +25,7 @@ const MOCK_RESPONSE = Promise.resolve({ version: "0100", reused: false, timeout: false, - servletKey: "CUST009-123-aaaaaa", + servletKey: "ZOWEUSER-123-aaaaaa", queueID: "983068", tsoData: [ { "TSO MESSAGE": { VERSION: "0100", DATA: "HELLOW exec processing has started." } }, @@ -38,14 +38,14 @@ const MOCK_RESPONSE = Promise.resolve({ const MOCK_START_RESPONSE: Promise = Promise.resolve({ collectedResponses: [], - messages: "IKJ56455I CUST009 LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", - servletKey: "CUST009-123-aaaaaa", + messages: "IKJ56455I ZOWEUSER LOGON IN PROGRESS AT 11:18:56 ON OCTOBER 14, 2024\nIKJ56951I NO BROADCAST MESSAGES\nREADY \n", + servletKey: "ZOWEUSER-123-aaaaaa", success: true, zosmfTsoResponse: { ver: "0100", queueID: "983068", reused: false, - servletKey: "CUST009-123-aaaaaa", + servletKey: "ZOWEUSER-123-aaaaaa", sessionID: "0x00", timeout: false, tsoData: [{}] @@ -76,7 +76,7 @@ describe("StartTsoApp behavior", () => { }) ); expect(response).toMatchObject({ - servletKey: "CUST009-123-aaaaaa", + servletKey: "ZOWEUSER-123-aaaaaa", queueID: "983068", tsoData: expect.arrayContaining([ expect.objectContaining({ DATA: "HELLOW exec processing has started." }) @@ -91,7 +91,7 @@ describe("StartTsoApp behavior", () => { startupCommand: "EXEC 'TEST.EXEC(THISSCRIPTDOESNOTEXIST)'", appKey: "testappkey", queueID: "12345", - servletKey: "CUST009-123-aaaaaaaa" + servletKey: "ZOWEUSER-123-aaaaaaaa" }, null); expect(StartTso.start).not.toHaveBeenCalled(); @@ -104,7 +104,7 @@ describe("StartTsoApp behavior", () => { }) ); expect(response).toMatchObject({ - servletKey: "CUST009-123-aaaaaaaa", + servletKey: "ZOWEUSER-123-aaaaaaaa", queueID: "12345", tsoData: expect.arrayContaining([ expect.objectContaining({ DATA: "HELLOW exec processing has started." }) diff --git a/packages/zostso/src/AddressSpaceApps.ts b/packages/zostso/src/AddressSpaceApps.ts index b865120260..c114cad049 100644 --- a/packages/zostso/src/AddressSpaceApps.ts +++ b/packages/zostso/src/AddressSpaceApps.ts @@ -22,14 +22,30 @@ import { IIssueResponse } from "../src"; export class AddressSpaceApps { /** - * Start TSO application at address space with provided parameters. + * Format API response to IASAppResponse structure. * @static - * @param {AbstractSession} session - z/OSMF connection info - * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. - * @param {IStartTsoParms} parms - optional object with required parameters, @see {IStartTsoParms} - * @returns {Promise} command response on resolve, @see {IASAppResponse} - * @memberof StartTso + * @param {any} response - Raw API response + * @param {string | null} servletKey - Servlet key if present + * @param {string | null} queueID - Queue ID if present + * @returns {IASAppResponse} Formatted API response */ + private static formatResponse(response: any, servletKey: string | null, queueID: string | null): IASAppResponse { + return { + version: response.ver, + reused: response.reused, + timeout: response.timeout, + servletKey: servletKey ?? null, + queueID: queueID ?? null, + tsoData: response.tsoData?.map((message: any) => { + const messageKey = message["TSO MESSAGE"] ? "TSO MESSAGE" : "TSO PROMPT"; + return { + VERSION: message[messageKey].VERSION, + DATA: message[messageKey].DATA, + }; + }) || [response.appData], + }; + } + public static async start( session: AbstractSession, accountNumber: string, @@ -37,66 +53,32 @@ export class AddressSpaceApps { startParms: IStartTsoParms ): Promise { TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString( - accountNumber, - noAccountNumber.message - ); + TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); - // Address space is not known and must be created if (!params.queueID || !params.servletKey) { const response: IIssueResponse = { success: false, - startResponse: await StartTso.start( - session, - accountNumber, - startParms - ), + startResponse: await StartTso.start(session, accountNumber, startParms), startReady: false, zosmfResponse: null, commandResponse: null, stopResponse: null, }; - // Reassigning servletKey and queueID so the application can be started at the correct location - params.servletKey = - response.startResponse.zosmfTsoResponse.servletKey; + params.servletKey = response.startResponse.zosmfTsoResponse.servletKey; params.queueID = response.startResponse.zosmfTsoResponse.queueID; } - // Address space application starting const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - const response = await ZosmfRestClient.postExpectJSON< - IASAppResponse & { ver: string } - >(session, endpoint, [Headers.APPLICATION_JSON], { - startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'`, - }); - const formattedApiResponse: IASAppResponse = { - version: response.ver, - reused: response.reused, - timeout: response.timeout, - servletKey: params.servletKey ?? null, - queueID: params.queueID ?? null, - tsoData: response.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] - ? "TSO MESSAGE" - : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, - }; - }), - }; + const response = await ZosmfRestClient.postExpectJSON( + session, + endpoint, + [Headers.APPLICATION_JSON], + { startcmd: `${params.startupCommand} '&1 &2 ${params.queueID}'` } + ); - return formattedApiResponse; + return AddressSpaceApps.formatResponse(response, params.servletKey, params.queueID); } - /** - * Send message to TSO application at address space with provided parameters. - * @static - * @param {AbstractSession} session - z/OSMF connection info - * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. - * @param {IStartTsoParms} parms - optional object with required parameters, - * @returns {Promise} command response on resolve, @see {IASAppResponse} - * @memberof SendTso - */ + public static async send( session: AbstractSession, accountNumber: string, @@ -104,60 +86,26 @@ export class AddressSpaceApps { startParms: IStartTsoParms ): Promise { TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString( - accountNumber, - noAccountNumber.message - ); + TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; - - const apiResponse = await ZosmfRestClient.putExpectJSON< - IASAppResponse & { ver: string } - >( + const apiResponse = await ZosmfRestClient.putExpectJSON( session, endpoint, [Headers.CONTENT_TYPE, "text/plain"], params.message ); - const formattedApiResponse: IASAppResponse = { - version: apiResponse.ver, - reused: apiResponse.reused, - timeout: apiResponse.timeout, - servletKey: apiResponse.servletKey ?? null, - queueID: apiResponse.queueID ?? null, - tsoData: apiResponse.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] - ? "TSO MESSAGE" - : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, - }; - }), - }; - - return formattedApiResponse; + return AddressSpaceApps.formatResponse(apiResponse, apiResponse.servletKey ?? null, apiResponse.queueID ?? null); } - /** - * Receive message from TSO application at address space with provided parameters. - * @static - * @param {AbstractSession} session - z/OSMF connection info - * @param {string} accountNumber - this key of IStartTsoParms required, because it cannot be default. - * @param {IStartTsoParms} parms - optional object with required parameters, - * @returns {Promise} command response on resolve, @see {IASAppResponse} - * @memberof SendTso - */ + public static async receive( session: AbstractSession, accountNumber: string, params: ITsoAppCommunicationParms ): Promise { TsoValidator.validateSession(session); - TsoValidator.validateNotEmptyString( - accountNumber, - noAccountNumber.message - ); + TsoValidator.validateNotEmptyString(accountNumber, noAccountNumber.message); const TIMEOUT_SECONDS: number = params.timeout; const endpoint = `${TsoConstants.RESOURCE}/app/${params.servletKey}/${params.appKey}`; @@ -167,47 +115,27 @@ export class AddressSpaceApps { let timeoutReached = false; do { - if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { // eslint-disable-line + // eslint-disable-next-line @typescript-eslint/no-magic-numbers + if (Date.now() - startTime > TIMEOUT_SECONDS * 1000) { timeoutReached = true; break; } try { - const apiResponse = await ZosmfRestClient.getExpectJSON< - IASAppResponse & { ver: string; appData?: any } - >(session, endpoint); - const response = apiResponse as IASAppResponse & { - ver: string; - appData?: any; - }; - const formattedApiResponse: IASAppResponse = { - version: response.ver, - reused: response.reused, - timeout: response.timeout, - servletKey: response.servletKey ?? null, - queueID: response.queueID ?? null, - tsoData: response.tsoData?.map((message: any) => { - const messageKey = message["TSO MESSAGE"] - ? "TSO MESSAGE" - : "TSO PROMPT"; - return { - VERSION: message[messageKey].VERSION, - DATA: message[messageKey].DATA, - }; - }) || [response.appData], - }; + const apiResponse = await ZosmfRestClient.getExpectJSON( + session, + endpoint + ); + const formattedResponse = AddressSpaceApps.formatResponse(apiResponse, apiResponse.servletKey ?? null, apiResponse.queueID ?? null); if (combinedResponse === null) { - combinedResponse = formattedApiResponse; + combinedResponse = formattedResponse; } else { - combinedResponse.tsoData.push( - ...formattedApiResponse.tsoData - ); + combinedResponse.tsoData.push(...formattedResponse.tsoData); } - endKeyword = formattedApiResponse.tsoData.some((data: any) => - typeof data === "string" - ? data.trim() === "READY" - : data.DATA.trim() === "READY" + + endKeyword = formattedResponse.tsoData.some((data: any) => + typeof data === "string" ? data.trim() === "READY" : data.DATA.trim() === "READY" ); } catch (error) { if (combinedResponse) { From f82c707561efb30a8f7d74365df97eed0dc55c74 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 29 Oct 2024 12:10:26 -0400 Subject: [PATCH 073/106] optional spinner functions such that api usage is not disrupted Signed-off-by: jace-roell --- .../src/cmd/__tests__/response/CommandResponse.unit.test.ts | 4 ++-- .../cmd/src/doc/response/api/handler/IHandlerProgressApi.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/imperative/src/cmd/__tests__/response/CommandResponse.unit.test.ts b/packages/imperative/src/cmd/__tests__/response/CommandResponse.unit.test.ts index d926bdf31f..894e26bd60 100644 --- a/packages/imperative/src/cmd/__tests__/response/CommandResponse.unit.test.ts +++ b/packages/imperative/src/cmd/__tests__/response/CommandResponse.unit.test.ts @@ -333,9 +333,9 @@ describe("Command Response", () => { responseFormat: "default", stream, }); - response.progress.startSpinner("Test Spinner...."); + (response.progress as any).startSpinner("Test Spinner...."); expect((response as any).progress.spinnerInterval).toBeDefined(); - response.progress.endSpinner("Done"); + (response.progress as any).endSpinner("Done"); expect((response as any).progress.spinnerInterval).toBe(null); }); it("should allow us to create an instance", () => { diff --git a/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts b/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts index 2eba57b1c2..9b728b0c53 100644 --- a/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts +++ b/packages/imperative/src/cmd/src/doc/response/api/handler/IHandlerProgressApi.ts @@ -34,11 +34,11 @@ export interface IHandlerProgressApi { * @param {IProgressBarParms} params * @memberof IHandlerProgressApi */ - startSpinner(pendingText: string): void; + startSpinner?(pendingText: string): void; /** * Stop a spinner - displays on the users terminal * @param {IProgressBarParms} params * @memberof IHandlerProgressApi */ - endSpinner(endText?: string): void; + endSpinner?(endText?: string): void; } From 6228e0f98122404d6fd34acc2e7f6fa86fe0d110 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 29 Oct 2024 12:12:16 -0400 Subject: [PATCH 074/106] redundant file Signed-off-by: jace-roell --- .../src/cmd/src/response/CommandResponse.ts | 570 +++++++++++++----- 1 file changed, 404 insertions(+), 166 deletions(-) diff --git a/packages/imperative/src/cmd/src/response/CommandResponse.ts b/packages/imperative/src/cmd/src/response/CommandResponse.ts index 7ec76af47e..ba879fdfbb 100644 --- a/packages/imperative/src/cmd/src/response/CommandResponse.ts +++ b/packages/imperative/src/cmd/src/response/CommandResponse.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 { IImperativeError, ImperativeError } from "../../../error"; import { IHandlerResponseConsoleApi } from "../doc/response/api/handler/IHandlerResponseConsoleApi"; @@ -15,14 +15,20 @@ import { IHandlerResponseDataApi } from "../doc/response/api/handler/IHandlerRes import { ICommandResponseParms } from "../doc/response/parms/ICommandResponseParms"; import { ICommandResponse } from "../doc/response/response/ICommandResponse"; import { CliUtils, TextUtils } from "../../../utilities"; -import { COMMAND_RESPONSE_FORMAT, ICommandResponseApi } from "../doc/response/api/processor/ICommandResponseApi"; +import { + COMMAND_RESPONSE_FORMAT, + ICommandResponseApi, +} from "../doc/response/api/processor/ICommandResponseApi"; import { ITaskWithStatus, TaskProgress, TaskStage } from "../../../operations"; import { IHandlerProgressApi } from "../doc/response/api/handler/IHandlerProgressApi"; import { IProgressBarParms } from "../doc/response/parms/IProgressBarParms"; import { Constants } from "../../../constants"; import { ImperativeExpect } from "../../../expect"; import { IHandlerFormatOutputApi } from "../doc/response/api/handler/IHandlerFormatOutputApi"; -import { ICommandOutputFormat, OUTPUT_FORMAT } from "../doc/response/response/ICommandOutputFormat"; +import { + ICommandOutputFormat, + OUTPUT_FORMAT, +} from "../doc/response/response/ICommandOutputFormat"; import { Arguments } from "yargs"; import { ICommandDefinition } from "../../src/doc/ICommandDefinition"; import { OptionConstants } from "../constants/OptionConstants"; @@ -59,7 +65,8 @@ export class CommandResponse implements ICommandResponseApi { * @type {string} * @memberof CommandResponse */ - private static readonly RESPONSE_ERR_TAG: string = "Command Response Error:"; + private static readonly RESPONSE_ERR_TAG: string = + "Command Response Error:"; /** * Max column width for formulating tabular output * @private @@ -219,15 +226,33 @@ export class CommandResponse implements ICommandResponseApi { this.mControl = params == null ? {} : params; this.mArguments = this.mControl.args; this.mDefinition = this.mControl.definition; - this.mPrimaryTextColor = this.mControl.primaryTextColor == null ? this.mPrimaryTextColor : this.mControl.primaryTextColor; - ImperativeExpect.toNotBeEqual(this.mPrimaryTextColor.trim(), "", - `${CommandResponse.RESPONSE_ERR_TAG} The primary text color supplied is blank. Must provide a valid color.`); + this.mPrimaryTextColor = + this.mControl.primaryTextColor == null + ? this.mPrimaryTextColor + : this.mControl.primaryTextColor; + ImperativeExpect.toNotBeEqual( + this.mPrimaryTextColor.trim(), + "", + `${CommandResponse.RESPONSE_ERR_TAG} The primary text color supplied is blank. Must provide a valid color.` + ); const formats: string[] = ["json", "default"]; - this.mResponseFormat = this.mControl.responseFormat == null ? "default" : this.mControl.responseFormat; - ImperativeExpect.toBeOneOf(this.mResponseFormat, formats, - `${CommandResponse.RESPONSE_ERR_TAG} Response format invalid. Valid formats: "${formats.join(",")}"`); - this.mSilent = this.mControl.silent == null ? false : this.mControl.silent; - this.mProgressBarSpinnerChars = this.mControl.progressBarSpinner == null ? this.mProgressBarSpinnerChars : this.mControl.progressBarSpinner; + this.mResponseFormat = + this.mControl.responseFormat == null + ? "default" + : this.mControl.responseFormat; + ImperativeExpect.toBeOneOf( + this.mResponseFormat, + formats, + `${ + CommandResponse.RESPONSE_ERR_TAG + } Response format invalid. Valid formats: "${formats.join(",")}"` + ); + this.mSilent = + this.mControl.silent == null ? false : this.mControl.silent; + this.mProgressBarSpinnerChars = + this.mControl.progressBarSpinner == null + ? this.mProgressBarSpinnerChars + : this.mControl.progressBarSpinner; this.mStream = params ? params.stream : undefined; } @@ -237,23 +262,35 @@ export class CommandResponse implements ICommandResponseApi { const outer: CommandResponse = this; if (this.mFormatApi == null) { - this.mFormatApi = new class implements IHandlerFormatOutputApi { + this.mFormatApi = new (class implements IHandlerFormatOutputApi { /** * Format output data from the command based on the defaults specified OR the parameters specified by * the user. * @param {ICommandOutputFormat} format */ public output(format: ICommandOutputFormat): void { - // The input parameters must not be null and we will make a copy to not alter the original - ImperativeExpect.toNotBeNullOrUndefined(format, "No format parameters were supplied"); - ImperativeExpect.toNotBeNullOrUndefined(format.output, "No output data to format was supplied"); - ImperativeExpect.toBeOneOf(format.format, OptionConstants.RESPONSE_FORMAT_TYPES, - `Output format must be one of the following: ${OptionConstants.RESPONSE_FORMAT_TYPES.toString()}`); + ImperativeExpect.toNotBeNullOrUndefined( + format, + "No format parameters were supplied" + ); + ImperativeExpect.toNotBeNullOrUndefined( + format.output, + "No output data to format was supplied" + ); + ImperativeExpect.toBeOneOf( + format.format, + OptionConstants.RESPONSE_FORMAT_TYPES, + `Output format must be one of the following: ${OptionConstants.RESPONSE_FORMAT_TYPES.toString()}` + ); // If the output is an array and the length is 0 or - do nothing - if (Array.isArray(format.output) && format.output.length === 0 || - Object.keys(format.output).length === 0 && format.output.constructor === Object) { + if ( + (Array.isArray(format.output) && + format.output.length === 0) || + (Object.keys(format.output).length === 0 && + format.output.constructor === Object) + ) { return; } @@ -263,21 +300,38 @@ export class CommandResponse implements ICommandResponseApi { formatCopy = JSON.parse(JSON.stringify(format)); } catch (copyErr) { outer.console.errorHeader(`Non-formatted output data`); - outer.console.error(`${inspect(format.output, { depth: null, compact: true } as any)}`); + outer.console.error( + `${inspect(format.output, { + depth: null, + compact: true, + } as any)}` + ); throw new ImperativeError({ msg: `Error copying input parameters. Details: ${copyErr.message}`, - additionalDetails: copyErr + additionalDetails: copyErr, }); } // Depending on the command definition and arguments, override the format options - if (outer.mDefinition != null && outer.mDefinition.outputFormatOptions != null) { - formatCopy.format = outer.mArguments != null && outer.mArguments.responseFormatType != null ? - outer.mArguments.responseFormatType : formatCopy.format; - formatCopy.fields = outer.mArguments != null && outer.mArguments.responseFormatFilter != null ? - outer.mArguments.responseFormatFilter : formatCopy.fields; - formatCopy.header = outer.mArguments != null && outer.mArguments.responseFormatHeader != null ? - outer.mArguments.responseFormatHeader : formatCopy.header; + if ( + outer.mDefinition != null && + outer.mDefinition.outputFormatOptions != null + ) { + formatCopy.format = + outer.mArguments != null && + outer.mArguments.responseFormatType != null + ? outer.mArguments.responseFormatType + : formatCopy.format; + formatCopy.fields = + outer.mArguments != null && + outer.mArguments.responseFormatFilter != null + ? outer.mArguments.responseFormatFilter + : formatCopy.fields; + formatCopy.header = + outer.mArguments != null && + outer.mArguments.responseFormatHeader != null + ? outer.mArguments.responseFormatHeader + : formatCopy.header; } // Format the output for the command, if an error occurs, output the format error data @@ -286,7 +340,11 @@ export class CommandResponse implements ICommandResponseApi { this.formatOutput(formatCopy, outer); } catch (formatErr) { outer.console.errorHeader(`Non-formatted output data`); - outer.console.error(`${inspect(format.output, { compact: true } as any)}`); + outer.console.error( + `${inspect(format.output, { + compact: true, + } as any)}` + ); throw formatErr; } } @@ -301,18 +359,23 @@ export class CommandResponse implements ICommandResponseApi { * @param {Arguments} args - the arguments passed on the command line by the user * @memberof CommandProcessor */ - private formatOutput(params: ICommandOutputFormat, response: CommandResponse) { - + private formatOutput( + params: ICommandOutputFormat, + response: CommandResponse + ) { // If a single filter is specified, save the field the data was extracted from - const extractedFrom = params.fields != null && params.fields.length === 1 && typeof params.output !== "string" ? - params.fields[0] : undefined; + const extractedFrom = + params.fields != null && + params.fields.length === 1 && + typeof params.output !== "string" + ? params.fields[0] + : undefined; // If filter fields are present, filter the object params.output = this.filterProperties(params); // Process each type according to the data presented from the handler switch (params.format) { - // Output the data as a string case "string": // Stringify if not a string @@ -326,7 +389,6 @@ export class CommandResponse implements ICommandResponseApi { // Output the data as a list of strings case "list": if (Array.isArray(params.output)) { - // Filter the properties by request and stringify if needed const list: string[] = []; params.output.forEach((entry) => { @@ -342,25 +404,37 @@ export class CommandResponse implements ICommandResponseApi { response.console.log(params.output); } else { throw new ImperativeError({ - msg: this.errorDetails(params, "Arrays", extractedFrom) + msg: this.errorDetails( + params, + "Arrays", + extractedFrom + ), }); } break; // Output the data as an object or list of objects (prettified) case "object": - if (Array.isArray(params.output) || typeof params.output === "object") { - + if ( + Array.isArray(params.output) || + typeof params.output === "object" + ) { // Build the table and catch any errors that may occur from the packages let pretty; try { // Prettify the data - pretty = TextUtils.prettyJson(params.output, undefined, undefined, ""); + pretty = TextUtils.prettyJson( + params.output, + undefined, + undefined, + "" + ); } catch (prettyErr) { throw new ImperativeError({ - msg: `Error formulating pretty JSON for command response. Details: ` + + msg: + `Error formulating pretty JSON for command response. Details: ` + `${prettyErr.message}`, - additionalDetails: prettyErr + additionalDetails: prettyErr, }); } @@ -368,15 +442,21 @@ export class CommandResponse implements ICommandResponseApi { response.console.log(pretty); } else { throw new ImperativeError({ - msg: this.errorDetails(params, "JSON objects or Arrays", extractedFrom) + msg: this.errorDetails( + params, + "JSON objects or Arrays", + extractedFrom + ), }); } break; // Output the data as a table case "table": - if (typeof params.output === "object" || Array.isArray(params.output)) { - + if ( + typeof params.output === "object" || + Array.isArray(params.output) + ) { // Build the table and catch any errors that may occur from the packages let table; try { @@ -386,13 +466,20 @@ export class CommandResponse implements ICommandResponseApi { } // Build the table - table = TextUtils.getTable(params.output, "yellow", CommandResponse.MAX_COLUMN_WIDTH, - params.header != null ? params.header : false); + table = TextUtils.getTable( + params.output, + "yellow", + CommandResponse.MAX_COLUMN_WIDTH, + params.header != null + ? params.header + : false + ); } catch (tableErr) { throw new ImperativeError({ - msg: `Error formulating table for command response. ` + + msg: + `Error formulating table for command response. ` + `Details: ${tableErr.message}`, - additionalDetails: tableErr + additionalDetails: tableErr, }); } @@ -400,14 +487,19 @@ export class CommandResponse implements ICommandResponseApi { response.console.log(table); } else { throw new ImperativeError({ - msg: this.errorDetails(params, "JSON objects or Arrays", extractedFrom) + msg: this.errorDetails( + params, + "JSON objects or Arrays", + extractedFrom + ), }); } break; default: throw new ImperativeError({ - msg: `Invalid output format of "${params.format}" supplied. ` + - `Contact the command handler creators for support.` + msg: + `Invalid output format of "${params.format}" supplied. ` + + `Contact the command handler creators for support.`, }); } } @@ -421,12 +513,26 @@ export class CommandResponse implements ICommandResponseApi { * that it makes sense to the user. * @returns {string} - the error string */ - private errorDetails(params: ICommandOutputFormat, appliedTo: string, extractedFrom?: string): string { - return `The format type of "${params.format}" can only be applied to ${appliedTo}.\n` + + private errorDetails( + params: ICommandOutputFormat, + appliedTo: string, + extractedFrom?: string + ): string { + return ( + `The format type of "${params.format}" can only be applied to ${appliedTo}.\n` + `The data being formatted is of type ` + - `"${Array.isArray(params.output) ? "array" : typeof params.output}".` + - `${extractedFrom != null ? `\nNote that the data being formatted was extracted from property "${extractedFrom}" ` + - `because that field was specified as the single filter.` : ""}`; + `"${ + Array.isArray(params.output) + ? "array" + : typeof params.output + }".` + + `${ + extractedFrom != null + ? `\nNote that the data being formatted was extracted from property "${extractedFrom}" ` + + `because that field was specified as the single filter.` + : "" + }` + ); } /** @@ -443,42 +549,62 @@ export class CommandResponse implements ICommandResponseApi { // If there are no filter fields, return the original object/data if (params.fields != null && params.fields.length > 0) { - // Extract the single filter if required let singleFilter: any; - if (params.fields.length === 1 && typeof params.output === "object") { + if ( + params.fields.length === 1 && + typeof params.output === "object" + ) { singleFilter = params.fields[0]; } // Perform the filtering depending on if a single filter was specified - if (singleFilter != null && !Array.isArray(params.output)) { - + if ( + singleFilter != null && + !Array.isArray(params.output) + ) { // Extract only the single field - this allows a single object property // to be selected and output without "meta" info (like the prop name) - const dataObjectParser = new DataObjectParser(params.output); + const dataObjectParser = new DataObjectParser( + params.output + ); filtered = dataObjectParser.get(singleFilter); - - } else if (singleFilter != null && Array.isArray(params.output) && (params.format === "list" || params.format === "string")) { - + } else if ( + singleFilter != null && + Array.isArray(params.output) && + (params.format === "list" || + params.format === "string") + ) { // Extract each of the single fields and output as a list of strings const strings: string[] = []; params.output.forEach((entry) => { - const dataObjectParser = new DataObjectParser(entry); - strings.push(dataObjectParser.get(singleFilter)); + const dataObjectParser = new DataObjectParser( + entry + ); + strings.push( + dataObjectParser.get(singleFilter) + ); }); filtered = strings; - } else if (Array.isArray(params.output)) { - // Extract all the fields from each entry in the array filtered = []; params.output.forEach((entry) => { - filtered.push(this.extractProperties(entry, params.fields, params.format)); + filtered.push( + this.extractProperties( + entry, + params.fields, + params.format + ) + ); }); } else if (typeof params.output === "object") { - // Extract each field from the object - filtered = this.extractProperties(params.output, params.fields, params.format); + filtered = this.extractProperties( + params.output, + params.fields, + params.format + ); } } @@ -494,33 +620,37 @@ export class CommandResponse implements ICommandResponseApi { * @param {OUTPUT_FORMAT} format - the output format * @returns {*} - the "filtered" object */ - private extractProperties(dataObj: any, keepProps: string[], format: OUTPUT_FORMAT): any { + private extractProperties( + dataObj: any, + keepProps: string[], + format: OUTPUT_FORMAT + ): any { let extracted: any = dataObj; - if (keepProps != null && keepProps.length > 0 && typeof dataObj === "object") { + if ( + keepProps != null && + keepProps.length > 0 && + typeof dataObj === "object" + ) { extracted = {}; const objParser = new DataObjectParser(dataObj); const extractedParser = new DataObjectParser(extracted); for (const extractProp of keepProps) { - // If the response format is table, then extract the data // and create a property with hyphenated names to allow // for the user to create a proper table fro nested extractions const propValue = objParser.get(extractProp); if (format === "table") { - // Use the dots for the table extracted[extractProp] = propValue; } else { - // Keep the object structure extractedParser.set(extractProp, propValue); } - } } return extracted; } - }(); + })(); } return this.mFormatApi; @@ -539,8 +669,9 @@ export class CommandResponse implements ICommandResponseApi { // Create only a single instance of the console API if (this.mConsoleApi == null) { - this.mConsoleApi = new class implements IHandlerResponseConsoleApi { - + this.mConsoleApi = new (class + implements IHandlerResponseConsoleApi + { /** * Write a message/data to stdout. Appends a newline character if the input is of type string. If the * command response indicates JSON format, then the message is automatically buffered. @@ -549,9 +680,14 @@ export class CommandResponse implements ICommandResponseApi { * @returns {string} - The formatted data or the original data.toString() if a buffer was passed */ public log(message: string | Buffer, ...values: any[]): string { - let msg: string = LoggerUtils.censorRawData(message.toString(), Logger.DEFAULT_CONSOLE_NAME); + let msg: string = LoggerUtils.censorRawData( + message.toString(), + Logger.DEFAULT_CONSOLE_NAME + ); if (!Buffer.isBuffer(message)) { - msg = outer.formatMessage(msg.toString(), ...values) + "\n"; + msg = + outer.formatMessage(msg.toString(), ...values) + + "\n"; } outer.writeAndBufferStdout(msg); return msg; @@ -564,10 +700,18 @@ export class CommandResponse implements ICommandResponseApi { * @param {...any[]} values - The format values. * @returns {string} - The formatted data, or the original data.toString() if a buffer was passed */ - public error(message: string | Buffer, ...values: any[]): string { - let msg: string = LoggerUtils.censorRawData(message.toString(), Logger.DEFAULT_CONSOLE_NAME); + public error( + message: string | Buffer, + ...values: any[] + ): string { + let msg: string = LoggerUtils.censorRawData( + message.toString(), + Logger.DEFAULT_CONSOLE_NAME + ); if (!Buffer.isBuffer(message)) { - msg = outer.formatMessage(msg.toString(), ...values) + "\n"; + msg = + outer.formatMessage(msg.toString(), ...values) + + "\n"; } outer.writeAndBufferStderr(msg); return msg; @@ -581,7 +725,10 @@ export class CommandResponse implements ICommandResponseApi { * @returns {string} - The string that is printed (including the color codes) */ public errorHeader(message: string, delimeter = ":"): string { - let msg: string = LoggerUtils.censorRawData(message.toString(), Logger.DEFAULT_CONSOLE_NAME); + let msg: string = LoggerUtils.censorRawData( + message.toString(), + Logger.DEFAULT_CONSOLE_NAME + ); msg = TextUtils.chalk.red(msg + `${delimeter}\n`); outer.writeAndBufferStderr(msg); return msg; @@ -593,23 +740,30 @@ export class CommandResponse implements ICommandResponseApi { * @param {IPromptOptions} [opts] * @returns {Promise} */ - public prompt(questionText: string, opts?: IPromptOptions): Promise { - const msg: string = LoggerUtils.censorRawData(questionText.toString(), Logger.DEFAULT_CONSOLE_NAME); + public prompt( + questionText: string, + opts?: IPromptOptions + ): Promise { + const msg: string = LoggerUtils.censorRawData( + questionText.toString(), + Logger.DEFAULT_CONSOLE_NAME + ); if (outer.mStream) { return new Promise((resolve) => { - // send prompt content - const daemonRequest = opts?.hideText ? - DaemonRequest.create({ securePrompt: msg }) : - DaemonRequest.create({ prompt: msg }); + const daemonRequest = opts?.hideText + ? DaemonRequest.create({ securePrompt: msg }) + : DaemonRequest.create({ prompt: msg }); outer.writeStream(daemonRequest); // wait for a response here outer.mStream.once("data", (data) => { // strip response header and give to content the waiting handler - const response: IDaemonResponse = JSON.parse(data.toString()); + const response: IDaemonResponse = JSON.parse( + data.toString() + ); resolve(response.stdin.trim()); }); }); @@ -617,7 +771,7 @@ export class CommandResponse implements ICommandResponseApi { return CliUtils.readPrompt(msg, opts); } } - }(); + })(); } // Return the instance of the console API @@ -638,8 +792,7 @@ export class CommandResponse implements ICommandResponseApi { // Only create a single instance if (this.mDataApi == null) { - this.mDataApi = new class { - + this.mDataApi = new (class { /** * Sets the response object "data" field to be the object passed. The data field indicates any structured * JSON/object data that the command wants to return for programmatic consumption. @@ -659,7 +812,10 @@ export class CommandResponse implements ICommandResponseApi { * @returns {string} - The formatted string. */ public setMessage(message: string, ...values: any[]): string { - const formatted: string = outer.formatMessage(message, values); + const formatted: string = outer.formatMessage( + message, + values + ); outer.mMessage = formatted; return outer.mMessage; } @@ -675,7 +831,7 @@ export class CommandResponse implements ICommandResponseApi { outer.mExitCode = code; return outer.mExitCode; } - }(); + })(); } // Return the data API @@ -695,9 +851,8 @@ export class CommandResponse implements ICommandResponseApi { // Ensure there is only a single instance created of the progress API class if (this.mProgressApi == null) { - // Create an instance of the class - this.mProgressApi = new class { + this.mProgressApi = new (class { private spinnerIndex = 0; private spinnerInterval: any; @@ -707,8 +862,16 @@ export class CommandResponse implements ICommandResponseApi { public startSpinner(pendingText: string): void { if (this.spinnerInterval == null) { this.spinnerInterval = setInterval(() => { - outer.writeStdout(`\r${pendingText} ${this.mProgressBarSpinnerChars[this.spinnerIndex]}`); - this.spinnerIndex = (this.spinnerIndex + 1) % this.mProgressBarSpinnerChars.length; + outer.writeStdout( + `\r${pendingText} ${ + this.mProgressBarSpinnerChars[ + this.spinnerIndex + ] + }` + ); + this.spinnerIndex = + (this.spinnerIndex + 1) % + this.mProgressBarSpinnerChars.length; }, 100); // eslint-disable-line } } @@ -716,20 +879,22 @@ export class CommandResponse implements ICommandResponseApi { * Stop a spinner */ public endSpinner(stopText?: string): void { - if (this.spinnerInterval != null) { - outer.write(); - clearInterval(this.spinnerInterval); - this.spinnerInterval = null; - if(stopText) outer.writeStdout(`\r${stopText}\n`); - outer.writeStdout("\r\x1b[K"); - } + outer.write(); + clearInterval(this.spinnerInterval); + this.spinnerInterval = null; + if (stopText) outer.writeStdout(`\r${stopText}\n`); + outer.writeStdout("\r\x1b[K"); } private mProgressBarSpinnerIndex = 0; private mProgressTask: ITaskWithStatus; - private mProgressBarPollFrequency = 65; // eslint-disable-line @typescript-eslint/no-magic-numbers - private mProgressBarTemplate: string = " " + TextUtils.chalk[outer.mPrimaryTextColor](":bar|") + " :current% " + - TextUtils.chalk[outer.mPrimaryTextColor](":spin") + " | :statusMessage"; + private mProgressBarPollFrequency = 65; // eslint-disable-line @typescript-eslint/no-magic-numbers + private mProgressBarTemplate: string = + " " + + TextUtils.chalk[outer.mPrimaryTextColor](":bar|") + + " :current% " + + TextUtils.chalk[outer.mPrimaryTextColor](":spin") + + " | :statusMessage"; private mProgressBarInterval: any; private mIsDaemon = false; @@ -739,7 +904,10 @@ export class CommandResponse implements ICommandResponseApi { * TODO: get from config - default value is below */ private mProgressBarSpinnerChars: string = "-oO0)|(0Oo-"; - private mDaemonProgressBarSpinnerChars = this.mProgressBarSpinnerChars.split("").map((char) => char + DaemonRequest.EOW_DELIMITER); + private mDaemonProgressBarSpinnerChars = + this.mProgressBarSpinnerChars + .split("") + .map((char) => char + DaemonRequest.EOW_DELIMITER); /** * Start a progress bar (assuming silent mode is not enabled). @@ -748,18 +916,26 @@ export class CommandResponse implements ICommandResponseApi { public startBar(params: IProgressBarParms): void { if (outer.mProgressBar != null) { throw new ImperativeError({ - msg: `${CommandResponse.RESPONSE_ERR_TAG} A progress bar has already been started. ` + - `Please call progress.endBar() before starting a new one.` + msg: + `${CommandResponse.RESPONSE_ERR_TAG} A progress bar has already been started. ` + + `Please call progress.endBar() before starting a new one.`, }); } - if (!outer.silent && outer.mResponseFormat !== "json" && - !(TextUtils.chalk.level === 0 || process.env.CI != null)) { - + if ( + !outer.silent && + outer.mResponseFormat !== "json" && + !(TextUtils.chalk.level === 0 || process.env.CI != null) + ) { // Persist the task specifications and determine the stream to use for the progress bar - this.mProgressBarStdoutStartIndex = outer.mStdout.length; - this.mProgressBarStderrStartIndex = outer.mStderr.length; + this.mProgressBarStdoutStartIndex = + outer.mStdout.length; + this.mProgressBarStderrStartIndex = + outer.mStderr.length; this.mProgressTask = params.task; - let stream: any = params.stream == null ? process.stderr : params.stream; + let stream: any = + params.stream == null + ? process.stderr + : params.stream; const arbitraryColumnSize = 80; // if we have an outer stream (e.g. socket connection for daemon mode) use it @@ -772,7 +948,9 @@ export class CommandResponse implements ICommandResponseApi { if (!(stream as any).isTTY) { const ttyPrototype = tty.WriteStream.prototype; Object.keys(ttyPrototype).forEach((key) => { - (stream as any)[key] = (ttyPrototype as any)[key]; + (stream as any)[key] = ( + ttyPrototype as any + )[key]; }); (stream as any).columns = arbitraryColumnSize; } @@ -780,21 +958,30 @@ export class CommandResponse implements ICommandResponseApi { // send header to enable progress bar streaming // const daemonHeaders = DaemonUtils.buildHeaders({ progress: true }); - outer.writeStream(DaemonRequest.create({ progress: true })); + outer.writeStream( + DaemonRequest.create({ progress: true }) + ); // Create the progress bar instance - outer.mProgressBar = new ProgressBar(this.mProgressBarTemplate, { - total: 100, - width: 10, - stream, - complete: "█", - clear: true, - incomplete: "_", - }); + outer.mProgressBar = new ProgressBar( + this.mProgressBarTemplate, + { + total: 100, + width: 10, + stream, + complete: "█", + clear: true, + incomplete: "_", + } + ); // Set the interval based on the params of the default - this.mProgressBarInterval = setInterval(this.updateProgressBar.bind(this), - params.updateInterval == null ? this.mProgressBarPollFrequency : params.updateInterval); + this.mProgressBarInterval = setInterval( + this.updateProgressBar.bind(this), + params.updateInterval == null + ? this.mProgressBarPollFrequency + : params.updateInterval + ); } } @@ -811,17 +998,29 @@ export class CommandResponse implements ICommandResponseApi { const statusMessage = "Complete"; outer.mProgressBar.update(1, { statusMessage, - spin: " " + spin: " ", }); outer.mProgressBar.terminate(); // NOTE(Kelosky): ansi escape codes for progress bar cursor and line clearing are written on the socket // so we need to ensure they're emptied out before we write to the stream. - if (this.mIsDaemon) outer.writeStream(DaemonRequest.EOW_DELIMITER + DaemonRequest.create({ progress: false })); - - outer.writeStdout(outer.mStdout.subarray(this.mProgressBarStdoutStartIndex)); - outer.writeStderr(outer.mStderr.subarray(this.mProgressBarStderrStartIndex)); + if (this.mIsDaemon) + outer.writeStream( + DaemonRequest.EOW_DELIMITER + + DaemonRequest.create({ progress: false }) + ); + + outer.writeStdout( + outer.mStdout.subarray( + this.mProgressBarStdoutStartIndex + ) + ); + outer.writeStderr( + outer.mStderr.subarray( + this.mProgressBarStderrStartIndex + ) + ); this.mProgressTask = undefined; // clear the progress bar field @@ -835,30 +1034,42 @@ export class CommandResponse implements ICommandResponseApi { * @private */ private updateProgressBar(): void { - if (this.mProgressTask == null || + if ( + this.mProgressTask == null || this.mProgressTask.stageName === TaskStage.COMPLETE || - this.mProgressTask.stageName === TaskStage.FAILED) { + this.mProgressTask.stageName === TaskStage.FAILED + ) { this.endBar(); } else { if (this.mProgressBarInterval != null) { - const percentRatio = this.mProgressTask.percentComplete / TaskProgress.ONE_HUNDRED_PERCENT; - this.mProgressBarSpinnerIndex = (this.mProgressBarSpinnerIndex + 1) % this.mProgressBarSpinnerChars.length; + const percentRatio = + this.mProgressTask.percentComplete / + TaskProgress.ONE_HUNDRED_PERCENT; + this.mProgressBarSpinnerIndex = + (this.mProgressBarSpinnerIndex + 1) % + this.mProgressBarSpinnerChars.length; if (this.mIsDaemon) { outer.mProgressBar.update(percentRatio, { - statusMessage: this.mProgressTask.statusMessage, - spin: this.mDaemonProgressBarSpinnerChars[this.mProgressBarSpinnerIndex] + statusMessage: + this.mProgressTask.statusMessage, + spin: this.mDaemonProgressBarSpinnerChars[ + this.mProgressBarSpinnerIndex + ], }); } else { outer.mProgressBar.update(percentRatio, { - statusMessage: this.mProgressTask.statusMessage, - spin: this.mProgressBarSpinnerChars[this.mProgressBarSpinnerIndex] + statusMessage: + this.mProgressTask.statusMessage, + spin: this.mProgressBarSpinnerChars[ + this.mProgressBarSpinnerIndex + ], }); } } } } - }(); + })(); } // Return the progress bar API @@ -898,7 +1109,10 @@ export class CommandResponse implements ICommandResponseApi { * @memberof CommandResponse */ public bufferStdout(data: Buffer | string) { - this.mStdout = Buffer.concat([this.mStdout, data instanceof Buffer ? data : Buffer.from(data)]); + this.mStdout = Buffer.concat([ + this.mStdout, + data instanceof Buffer ? data : Buffer.from(data), + ]); } /** @@ -908,7 +1122,10 @@ export class CommandResponse implements ICommandResponseApi { * @memberof CommandResponse */ public bufferStderr(data: Buffer | string) { - this.mStderr = Buffer.concat([this.mStderr, data instanceof Buffer ? data : Buffer.from(data)]); + this.mStderr = Buffer.concat([ + this.mStderr, + data instanceof Buffer ? data : Buffer.from(data), + ]); } /** @@ -927,7 +1144,6 @@ export class CommandResponse implements ICommandResponseApi { * @memberof CommandResponse */ public buildJsonResponse(): ICommandResponse { - if (this.mExitCode == null) { this.mExitCode = this.mSucceeded ? 0 : Constants.ERROR_EXIT_CODE; } @@ -939,7 +1155,7 @@ export class CommandResponse implements ICommandResponseApi { stdout: this.mStdout, stderr: this.mStderr, data: this.mData, - error: this.mError + error: this.mError, }; } @@ -955,18 +1171,36 @@ export class CommandResponse implements ICommandResponseApi { response = this.buildJsonResponse(); (response.stderr as any) = response.stderr.toString(); (response.stdout as any) = response.stdout.toString(); - response.message = LoggerUtils.censorRawData(response.message, "json"); - response.data = response.data ? JSON.parse(LoggerUtils.censorRawData(JSON.stringify(response.data), "json")) : undefined; - response.error = response.error ? JSON.parse(LoggerUtils.censorRawData(JSON.stringify(response.error), "json")) : undefined; + response.message = LoggerUtils.censorRawData( + response.message, + "json" + ); + response.data = response.data + ? JSON.parse( + LoggerUtils.censorRawData( + JSON.stringify(response.data), + "json" + ) + ) + : undefined; + response.error = response.error + ? JSON.parse( + LoggerUtils.censorRawData( + JSON.stringify(response.error), + "json" + ) + ) + : undefined; if (!this.mSilent) { this.writeStdout(JSON.stringify(response, null, 2)); } } catch (e) { throw new ImperativeError({ - msg: `${CommandResponse.RESPONSE_ERR_TAG} An error occurred stringifying the JSON response object. ` + + msg: + `${CommandResponse.RESPONSE_ERR_TAG} An error occurred stringifying the JSON response object. ` + `Error Details: ${e.message}`, - additionalDetails: e + additionalDetails: e, }); } return response; @@ -1106,6 +1340,10 @@ export class CommandResponse implements ICommandResponseApi { * @memberof CommandResponse */ private write(): boolean { - return !this.control.silent && this.mResponseFormat !== "json" && this.mProgressBar == null; + return ( + !this.control.silent && + this.mResponseFormat !== "json" && + this.mProgressBar == null + ); } } From 01f673ee96f65a97a8a1680017821430b581b817 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 29 Oct 2024 12:12:38 -0400 Subject: [PATCH 075/106] formatting Signed-off-by: jace-roell --- .../src/cmd/src/response/CommandResponse.ts | 560 +++++------------- 1 file changed, 160 insertions(+), 400 deletions(-) diff --git a/packages/imperative/src/cmd/src/response/CommandResponse.ts b/packages/imperative/src/cmd/src/response/CommandResponse.ts index ba879fdfbb..93d71b3176 100644 --- a/packages/imperative/src/cmd/src/response/CommandResponse.ts +++ b/packages/imperative/src/cmd/src/response/CommandResponse.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 { IImperativeError, ImperativeError } from "../../../error"; import { IHandlerResponseConsoleApi } from "../doc/response/api/handler/IHandlerResponseConsoleApi"; @@ -15,20 +15,14 @@ import { IHandlerResponseDataApi } from "../doc/response/api/handler/IHandlerRes import { ICommandResponseParms } from "../doc/response/parms/ICommandResponseParms"; import { ICommandResponse } from "../doc/response/response/ICommandResponse"; import { CliUtils, TextUtils } from "../../../utilities"; -import { - COMMAND_RESPONSE_FORMAT, - ICommandResponseApi, -} from "../doc/response/api/processor/ICommandResponseApi"; +import { COMMAND_RESPONSE_FORMAT, ICommandResponseApi } from "../doc/response/api/processor/ICommandResponseApi"; import { ITaskWithStatus, TaskProgress, TaskStage } from "../../../operations"; import { IHandlerProgressApi } from "../doc/response/api/handler/IHandlerProgressApi"; import { IProgressBarParms } from "../doc/response/parms/IProgressBarParms"; import { Constants } from "../../../constants"; import { ImperativeExpect } from "../../../expect"; import { IHandlerFormatOutputApi } from "../doc/response/api/handler/IHandlerFormatOutputApi"; -import { - ICommandOutputFormat, - OUTPUT_FORMAT, -} from "../doc/response/response/ICommandOutputFormat"; +import { ICommandOutputFormat, OUTPUT_FORMAT } from "../doc/response/response/ICommandOutputFormat"; import { Arguments } from "yargs"; import { ICommandDefinition } from "../../src/doc/ICommandDefinition"; import { OptionConstants } from "../constants/OptionConstants"; @@ -65,8 +59,7 @@ export class CommandResponse implements ICommandResponseApi { * @type {string} * @memberof CommandResponse */ - private static readonly RESPONSE_ERR_TAG: string = - "Command Response Error:"; + private static readonly RESPONSE_ERR_TAG: string = "Command Response Error:"; /** * Max column width for formulating tabular output * @private @@ -226,33 +219,15 @@ export class CommandResponse implements ICommandResponseApi { this.mControl = params == null ? {} : params; this.mArguments = this.mControl.args; this.mDefinition = this.mControl.definition; - this.mPrimaryTextColor = - this.mControl.primaryTextColor == null - ? this.mPrimaryTextColor - : this.mControl.primaryTextColor; - ImperativeExpect.toNotBeEqual( - this.mPrimaryTextColor.trim(), - "", - `${CommandResponse.RESPONSE_ERR_TAG} The primary text color supplied is blank. Must provide a valid color.` - ); + this.mPrimaryTextColor = this.mControl.primaryTextColor == null ? this.mPrimaryTextColor : this.mControl.primaryTextColor; + ImperativeExpect.toNotBeEqual(this.mPrimaryTextColor.trim(), "", + `${CommandResponse.RESPONSE_ERR_TAG} The primary text color supplied is blank. Must provide a valid color.`); const formats: string[] = ["json", "default"]; - this.mResponseFormat = - this.mControl.responseFormat == null - ? "default" - : this.mControl.responseFormat; - ImperativeExpect.toBeOneOf( - this.mResponseFormat, - formats, - `${ - CommandResponse.RESPONSE_ERR_TAG - } Response format invalid. Valid formats: "${formats.join(",")}"` - ); - this.mSilent = - this.mControl.silent == null ? false : this.mControl.silent; - this.mProgressBarSpinnerChars = - this.mControl.progressBarSpinner == null - ? this.mProgressBarSpinnerChars - : this.mControl.progressBarSpinner; + this.mResponseFormat = this.mControl.responseFormat == null ? "default" : this.mControl.responseFormat; + ImperativeExpect.toBeOneOf(this.mResponseFormat, formats, + `${CommandResponse.RESPONSE_ERR_TAG} Response format invalid. Valid formats: "${formats.join(",")}"`); + this.mSilent = this.mControl.silent == null ? false : this.mControl.silent; + this.mProgressBarSpinnerChars = this.mControl.progressBarSpinner == null ? this.mProgressBarSpinnerChars : this.mControl.progressBarSpinner; this.mStream = params ? params.stream : undefined; } @@ -262,35 +237,23 @@ export class CommandResponse implements ICommandResponseApi { const outer: CommandResponse = this; if (this.mFormatApi == null) { - this.mFormatApi = new (class implements IHandlerFormatOutputApi { + this.mFormatApi = new class implements IHandlerFormatOutputApi { /** * Format output data from the command based on the defaults specified OR the parameters specified by * the user. * @param {ICommandOutputFormat} format */ public output(format: ICommandOutputFormat): void { + // The input parameters must not be null and we will make a copy to not alter the original - ImperativeExpect.toNotBeNullOrUndefined( - format, - "No format parameters were supplied" - ); - ImperativeExpect.toNotBeNullOrUndefined( - format.output, - "No output data to format was supplied" - ); - ImperativeExpect.toBeOneOf( - format.format, - OptionConstants.RESPONSE_FORMAT_TYPES, - `Output format must be one of the following: ${OptionConstants.RESPONSE_FORMAT_TYPES.toString()}` - ); + ImperativeExpect.toNotBeNullOrUndefined(format, "No format parameters were supplied"); + ImperativeExpect.toNotBeNullOrUndefined(format.output, "No output data to format was supplied"); + ImperativeExpect.toBeOneOf(format.format, OptionConstants.RESPONSE_FORMAT_TYPES, + `Output format must be one of the following: ${OptionConstants.RESPONSE_FORMAT_TYPES.toString()}`); // If the output is an array and the length is 0 or - do nothing - if ( - (Array.isArray(format.output) && - format.output.length === 0) || - (Object.keys(format.output).length === 0 && - format.output.constructor === Object) - ) { + if (Array.isArray(format.output) && format.output.length === 0 || + Object.keys(format.output).length === 0 && format.output.constructor === Object) { return; } @@ -300,38 +263,21 @@ export class CommandResponse implements ICommandResponseApi { formatCopy = JSON.parse(JSON.stringify(format)); } catch (copyErr) { outer.console.errorHeader(`Non-formatted output data`); - outer.console.error( - `${inspect(format.output, { - depth: null, - compact: true, - } as any)}` - ); + outer.console.error(`${inspect(format.output, { depth: null, compact: true } as any)}`); throw new ImperativeError({ msg: `Error copying input parameters. Details: ${copyErr.message}`, - additionalDetails: copyErr, + additionalDetails: copyErr }); } // Depending on the command definition and arguments, override the format options - if ( - outer.mDefinition != null && - outer.mDefinition.outputFormatOptions != null - ) { - formatCopy.format = - outer.mArguments != null && - outer.mArguments.responseFormatType != null - ? outer.mArguments.responseFormatType - : formatCopy.format; - formatCopy.fields = - outer.mArguments != null && - outer.mArguments.responseFormatFilter != null - ? outer.mArguments.responseFormatFilter - : formatCopy.fields; - formatCopy.header = - outer.mArguments != null && - outer.mArguments.responseFormatHeader != null - ? outer.mArguments.responseFormatHeader - : formatCopy.header; + if (outer.mDefinition != null && outer.mDefinition.outputFormatOptions != null) { + formatCopy.format = outer.mArguments != null && outer.mArguments.responseFormatType != null ? + outer.mArguments.responseFormatType : formatCopy.format; + formatCopy.fields = outer.mArguments != null && outer.mArguments.responseFormatFilter != null ? + outer.mArguments.responseFormatFilter : formatCopy.fields; + formatCopy.header = outer.mArguments != null && outer.mArguments.responseFormatHeader != null ? + outer.mArguments.responseFormatHeader : formatCopy.header; } // Format the output for the command, if an error occurs, output the format error data @@ -340,11 +286,7 @@ export class CommandResponse implements ICommandResponseApi { this.formatOutput(formatCopy, outer); } catch (formatErr) { outer.console.errorHeader(`Non-formatted output data`); - outer.console.error( - `${inspect(format.output, { - compact: true, - } as any)}` - ); + outer.console.error(`${inspect(format.output, { compact: true } as any)}`); throw formatErr; } } @@ -359,23 +301,18 @@ export class CommandResponse implements ICommandResponseApi { * @param {Arguments} args - the arguments passed on the command line by the user * @memberof CommandProcessor */ - private formatOutput( - params: ICommandOutputFormat, - response: CommandResponse - ) { + private formatOutput(params: ICommandOutputFormat, response: CommandResponse) { + // If a single filter is specified, save the field the data was extracted from - const extractedFrom = - params.fields != null && - params.fields.length === 1 && - typeof params.output !== "string" - ? params.fields[0] - : undefined; + const extractedFrom = params.fields != null && params.fields.length === 1 && typeof params.output !== "string" ? + params.fields[0] : undefined; // If filter fields are present, filter the object params.output = this.filterProperties(params); // Process each type according to the data presented from the handler switch (params.format) { + // Output the data as a string case "string": // Stringify if not a string @@ -389,6 +326,7 @@ export class CommandResponse implements ICommandResponseApi { // Output the data as a list of strings case "list": if (Array.isArray(params.output)) { + // Filter the properties by request and stringify if needed const list: string[] = []; params.output.forEach((entry) => { @@ -404,37 +342,25 @@ export class CommandResponse implements ICommandResponseApi { response.console.log(params.output); } else { throw new ImperativeError({ - msg: this.errorDetails( - params, - "Arrays", - extractedFrom - ), + msg: this.errorDetails(params, "Arrays", extractedFrom) }); } break; // Output the data as an object or list of objects (prettified) case "object": - if ( - Array.isArray(params.output) || - typeof params.output === "object" - ) { + if (Array.isArray(params.output) || typeof params.output === "object") { + // Build the table and catch any errors that may occur from the packages let pretty; try { // Prettify the data - pretty = TextUtils.prettyJson( - params.output, - undefined, - undefined, - "" - ); + pretty = TextUtils.prettyJson(params.output, undefined, undefined, ""); } catch (prettyErr) { throw new ImperativeError({ - msg: - `Error formulating pretty JSON for command response. Details: ` + + msg: `Error formulating pretty JSON for command response. Details: ` + `${prettyErr.message}`, - additionalDetails: prettyErr, + additionalDetails: prettyErr }); } @@ -442,21 +368,15 @@ export class CommandResponse implements ICommandResponseApi { response.console.log(pretty); } else { throw new ImperativeError({ - msg: this.errorDetails( - params, - "JSON objects or Arrays", - extractedFrom - ), + msg: this.errorDetails(params, "JSON objects or Arrays", extractedFrom) }); } break; // Output the data as a table case "table": - if ( - typeof params.output === "object" || - Array.isArray(params.output) - ) { + if (typeof params.output === "object" || Array.isArray(params.output)) { + // Build the table and catch any errors that may occur from the packages let table; try { @@ -466,20 +386,13 @@ export class CommandResponse implements ICommandResponseApi { } // Build the table - table = TextUtils.getTable( - params.output, - "yellow", - CommandResponse.MAX_COLUMN_WIDTH, - params.header != null - ? params.header - : false - ); + table = TextUtils.getTable(params.output, "yellow", CommandResponse.MAX_COLUMN_WIDTH, + params.header != null ? params.header : false); } catch (tableErr) { throw new ImperativeError({ - msg: - `Error formulating table for command response. ` + + msg: `Error formulating table for command response. ` + `Details: ${tableErr.message}`, - additionalDetails: tableErr, + additionalDetails: tableErr }); } @@ -487,19 +400,14 @@ export class CommandResponse implements ICommandResponseApi { response.console.log(table); } else { throw new ImperativeError({ - msg: this.errorDetails( - params, - "JSON objects or Arrays", - extractedFrom - ), + msg: this.errorDetails(params, "JSON objects or Arrays", extractedFrom) }); } break; default: throw new ImperativeError({ - msg: - `Invalid output format of "${params.format}" supplied. ` + - `Contact the command handler creators for support.`, + msg: `Invalid output format of "${params.format}" supplied. ` + + `Contact the command handler creators for support.` }); } } @@ -513,26 +421,12 @@ export class CommandResponse implements ICommandResponseApi { * that it makes sense to the user. * @returns {string} - the error string */ - private errorDetails( - params: ICommandOutputFormat, - appliedTo: string, - extractedFrom?: string - ): string { - return ( - `The format type of "${params.format}" can only be applied to ${appliedTo}.\n` + + private errorDetails(params: ICommandOutputFormat, appliedTo: string, extractedFrom?: string): string { + return `The format type of "${params.format}" can only be applied to ${appliedTo}.\n` + `The data being formatted is of type ` + - `"${ - Array.isArray(params.output) - ? "array" - : typeof params.output - }".` + - `${ - extractedFrom != null - ? `\nNote that the data being formatted was extracted from property "${extractedFrom}" ` + - `because that field was specified as the single filter.` - : "" - }` - ); + `"${Array.isArray(params.output) ? "array" : typeof params.output}".` + + `${extractedFrom != null ? `\nNote that the data being formatted was extracted from property "${extractedFrom}" ` + + `because that field was specified as the single filter.` : ""}`; } /** @@ -549,62 +443,42 @@ export class CommandResponse implements ICommandResponseApi { // If there are no filter fields, return the original object/data if (params.fields != null && params.fields.length > 0) { + // Extract the single filter if required let singleFilter: any; - if ( - params.fields.length === 1 && - typeof params.output === "object" - ) { + if (params.fields.length === 1 && typeof params.output === "object") { singleFilter = params.fields[0]; } // Perform the filtering depending on if a single filter was specified - if ( - singleFilter != null && - !Array.isArray(params.output) - ) { + if (singleFilter != null && !Array.isArray(params.output)) { + // Extract only the single field - this allows a single object property // to be selected and output without "meta" info (like the prop name) - const dataObjectParser = new DataObjectParser( - params.output - ); + const dataObjectParser = new DataObjectParser(params.output); filtered = dataObjectParser.get(singleFilter); - } else if ( - singleFilter != null && - Array.isArray(params.output) && - (params.format === "list" || - params.format === "string") - ) { + + } else if (singleFilter != null && Array.isArray(params.output) && (params.format === "list" || params.format === "string")) { + // Extract each of the single fields and output as a list of strings const strings: string[] = []; params.output.forEach((entry) => { - const dataObjectParser = new DataObjectParser( - entry - ); - strings.push( - dataObjectParser.get(singleFilter) - ); + const dataObjectParser = new DataObjectParser(entry); + strings.push(dataObjectParser.get(singleFilter)); }); filtered = strings; + } else if (Array.isArray(params.output)) { + // Extract all the fields from each entry in the array filtered = []; params.output.forEach((entry) => { - filtered.push( - this.extractProperties( - entry, - params.fields, - params.format - ) - ); + filtered.push(this.extractProperties(entry, params.fields, params.format)); }); } else if (typeof params.output === "object") { + // Extract each field from the object - filtered = this.extractProperties( - params.output, - params.fields, - params.format - ); + filtered = this.extractProperties(params.output, params.fields, params.format); } } @@ -620,37 +494,33 @@ export class CommandResponse implements ICommandResponseApi { * @param {OUTPUT_FORMAT} format - the output format * @returns {*} - the "filtered" object */ - private extractProperties( - dataObj: any, - keepProps: string[], - format: OUTPUT_FORMAT - ): any { + private extractProperties(dataObj: any, keepProps: string[], format: OUTPUT_FORMAT): any { let extracted: any = dataObj; - if ( - keepProps != null && - keepProps.length > 0 && - typeof dataObj === "object" - ) { + if (keepProps != null && keepProps.length > 0 && typeof dataObj === "object") { extracted = {}; const objParser = new DataObjectParser(dataObj); const extractedParser = new DataObjectParser(extracted); for (const extractProp of keepProps) { + // If the response format is table, then extract the data // and create a property with hyphenated names to allow // for the user to create a proper table fro nested extractions const propValue = objParser.get(extractProp); if (format === "table") { + // Use the dots for the table extracted[extractProp] = propValue; } else { + // Keep the object structure extractedParser.set(extractProp, propValue); } + } } return extracted; } - })(); + }(); } return this.mFormatApi; @@ -669,9 +539,8 @@ export class CommandResponse implements ICommandResponseApi { // Create only a single instance of the console API if (this.mConsoleApi == null) { - this.mConsoleApi = new (class - implements IHandlerResponseConsoleApi - { + this.mConsoleApi = new class implements IHandlerResponseConsoleApi { + /** * Write a message/data to stdout. Appends a newline character if the input is of type string. If the * command response indicates JSON format, then the message is automatically buffered. @@ -680,14 +549,9 @@ export class CommandResponse implements ICommandResponseApi { * @returns {string} - The formatted data or the original data.toString() if a buffer was passed */ public log(message: string | Buffer, ...values: any[]): string { - let msg: string = LoggerUtils.censorRawData( - message.toString(), - Logger.DEFAULT_CONSOLE_NAME - ); + let msg: string = LoggerUtils.censorRawData(message.toString(), Logger.DEFAULT_CONSOLE_NAME); if (!Buffer.isBuffer(message)) { - msg = - outer.formatMessage(msg.toString(), ...values) + - "\n"; + msg = outer.formatMessage(msg.toString(), ...values) + "\n"; } outer.writeAndBufferStdout(msg); return msg; @@ -700,18 +564,10 @@ export class CommandResponse implements ICommandResponseApi { * @param {...any[]} values - The format values. * @returns {string} - The formatted data, or the original data.toString() if a buffer was passed */ - public error( - message: string | Buffer, - ...values: any[] - ): string { - let msg: string = LoggerUtils.censorRawData( - message.toString(), - Logger.DEFAULT_CONSOLE_NAME - ); + public error(message: string | Buffer, ...values: any[]): string { + let msg: string = LoggerUtils.censorRawData(message.toString(), Logger.DEFAULT_CONSOLE_NAME); if (!Buffer.isBuffer(message)) { - msg = - outer.formatMessage(msg.toString(), ...values) + - "\n"; + msg = outer.formatMessage(msg.toString(), ...values) + "\n"; } outer.writeAndBufferStderr(msg); return msg; @@ -725,10 +581,7 @@ export class CommandResponse implements ICommandResponseApi { * @returns {string} - The string that is printed (including the color codes) */ public errorHeader(message: string, delimeter = ":"): string { - let msg: string = LoggerUtils.censorRawData( - message.toString(), - Logger.DEFAULT_CONSOLE_NAME - ); + let msg: string = LoggerUtils.censorRawData(message.toString(), Logger.DEFAULT_CONSOLE_NAME); msg = TextUtils.chalk.red(msg + `${delimeter}\n`); outer.writeAndBufferStderr(msg); return msg; @@ -740,30 +593,23 @@ export class CommandResponse implements ICommandResponseApi { * @param {IPromptOptions} [opts] * @returns {Promise} */ - public prompt( - questionText: string, - opts?: IPromptOptions - ): Promise { - const msg: string = LoggerUtils.censorRawData( - questionText.toString(), - Logger.DEFAULT_CONSOLE_NAME - ); + public prompt(questionText: string, opts?: IPromptOptions): Promise { + const msg: string = LoggerUtils.censorRawData(questionText.toString(), Logger.DEFAULT_CONSOLE_NAME); if (outer.mStream) { return new Promise((resolve) => { + // send prompt content - const daemonRequest = opts?.hideText - ? DaemonRequest.create({ securePrompt: msg }) - : DaemonRequest.create({ prompt: msg }); + const daemonRequest = opts?.hideText ? + DaemonRequest.create({ securePrompt: msg }) : + DaemonRequest.create({ prompt: msg }); outer.writeStream(daemonRequest); // wait for a response here outer.mStream.once("data", (data) => { // strip response header and give to content the waiting handler - const response: IDaemonResponse = JSON.parse( - data.toString() - ); + const response: IDaemonResponse = JSON.parse(data.toString()); resolve(response.stdin.trim()); }); }); @@ -771,7 +617,7 @@ export class CommandResponse implements ICommandResponseApi { return CliUtils.readPrompt(msg, opts); } } - })(); + }(); } // Return the instance of the console API @@ -792,7 +638,8 @@ export class CommandResponse implements ICommandResponseApi { // Only create a single instance if (this.mDataApi == null) { - this.mDataApi = new (class { + this.mDataApi = new class { + /** * Sets the response object "data" field to be the object passed. The data field indicates any structured * JSON/object data that the command wants to return for programmatic consumption. @@ -812,10 +659,7 @@ export class CommandResponse implements ICommandResponseApi { * @returns {string} - The formatted string. */ public setMessage(message: string, ...values: any[]): string { - const formatted: string = outer.formatMessage( - message, - values - ); + const formatted: string = outer.formatMessage(message, values); outer.mMessage = formatted; return outer.mMessage; } @@ -831,7 +675,7 @@ export class CommandResponse implements ICommandResponseApi { outer.mExitCode = code; return outer.mExitCode; } - })(); + }(); } // Return the data API @@ -851,8 +695,9 @@ export class CommandResponse implements ICommandResponseApi { // Ensure there is only a single instance created of the progress API class if (this.mProgressApi == null) { + // Create an instance of the class - this.mProgressApi = new (class { + this.mProgressApi = new class { private spinnerIndex = 0; private spinnerInterval: any; @@ -862,16 +707,8 @@ export class CommandResponse implements ICommandResponseApi { public startSpinner(pendingText: string): void { if (this.spinnerInterval == null) { this.spinnerInterval = setInterval(() => { - outer.writeStdout( - `\r${pendingText} ${ - this.mProgressBarSpinnerChars[ - this.spinnerIndex - ] - }` - ); - this.spinnerIndex = - (this.spinnerIndex + 1) % - this.mProgressBarSpinnerChars.length; + outer.writeStdout(`\r${pendingText} ${this.mProgressBarSpinnerChars[this.spinnerIndex]}`); + this.spinnerIndex = (this.spinnerIndex + 1) % this.mProgressBarSpinnerChars.length; }, 100); // eslint-disable-line } } @@ -882,19 +719,15 @@ export class CommandResponse implements ICommandResponseApi { outer.write(); clearInterval(this.spinnerInterval); this.spinnerInterval = null; - if (stopText) outer.writeStdout(`\r${stopText}\n`); + if(stopText) outer.writeStdout(`\r${stopText}\n`); outer.writeStdout("\r\x1b[K"); } private mProgressBarSpinnerIndex = 0; private mProgressTask: ITaskWithStatus; - private mProgressBarPollFrequency = 65; // eslint-disable-line @typescript-eslint/no-magic-numbers - private mProgressBarTemplate: string = - " " + - TextUtils.chalk[outer.mPrimaryTextColor](":bar|") + - " :current% " + - TextUtils.chalk[outer.mPrimaryTextColor](":spin") + - " | :statusMessage"; + private mProgressBarPollFrequency = 65; // eslint-disable-line @typescript-eslint/no-magic-numbers + private mProgressBarTemplate: string = " " + TextUtils.chalk[outer.mPrimaryTextColor](":bar|") + " :current% " + + TextUtils.chalk[outer.mPrimaryTextColor](":spin") + " | :statusMessage"; private mProgressBarInterval: any; private mIsDaemon = false; @@ -904,10 +737,7 @@ export class CommandResponse implements ICommandResponseApi { * TODO: get from config - default value is below */ private mProgressBarSpinnerChars: string = "-oO0)|(0Oo-"; - private mDaemonProgressBarSpinnerChars = - this.mProgressBarSpinnerChars - .split("") - .map((char) => char + DaemonRequest.EOW_DELIMITER); + private mDaemonProgressBarSpinnerChars = this.mProgressBarSpinnerChars.split("").map((char) => char + DaemonRequest.EOW_DELIMITER); /** * Start a progress bar (assuming silent mode is not enabled). @@ -916,26 +746,18 @@ export class CommandResponse implements ICommandResponseApi { public startBar(params: IProgressBarParms): void { if (outer.mProgressBar != null) { throw new ImperativeError({ - msg: - `${CommandResponse.RESPONSE_ERR_TAG} A progress bar has already been started. ` + - `Please call progress.endBar() before starting a new one.`, + msg: `${CommandResponse.RESPONSE_ERR_TAG} A progress bar has already been started. ` + + `Please call progress.endBar() before starting a new one.` }); } - if ( - !outer.silent && - outer.mResponseFormat !== "json" && - !(TextUtils.chalk.level === 0 || process.env.CI != null) - ) { + if (!outer.silent && outer.mResponseFormat !== "json" && + !(TextUtils.chalk.level === 0 || process.env.CI != null)) { + // Persist the task specifications and determine the stream to use for the progress bar - this.mProgressBarStdoutStartIndex = - outer.mStdout.length; - this.mProgressBarStderrStartIndex = - outer.mStderr.length; + this.mProgressBarStdoutStartIndex = outer.mStdout.length; + this.mProgressBarStderrStartIndex = outer.mStderr.length; this.mProgressTask = params.task; - let stream: any = - params.stream == null - ? process.stderr - : params.stream; + let stream: any = params.stream == null ? process.stderr : params.stream; const arbitraryColumnSize = 80; // if we have an outer stream (e.g. socket connection for daemon mode) use it @@ -948,9 +770,7 @@ export class CommandResponse implements ICommandResponseApi { if (!(stream as any).isTTY) { const ttyPrototype = tty.WriteStream.prototype; Object.keys(ttyPrototype).forEach((key) => { - (stream as any)[key] = ( - ttyPrototype as any - )[key]; + (stream as any)[key] = (ttyPrototype as any)[key]; }); (stream as any).columns = arbitraryColumnSize; } @@ -958,30 +778,21 @@ export class CommandResponse implements ICommandResponseApi { // send header to enable progress bar streaming // const daemonHeaders = DaemonUtils.buildHeaders({ progress: true }); - outer.writeStream( - DaemonRequest.create({ progress: true }) - ); + outer.writeStream(DaemonRequest.create({ progress: true })); // Create the progress bar instance - outer.mProgressBar = new ProgressBar( - this.mProgressBarTemplate, - { - total: 100, - width: 10, - stream, - complete: "█", - clear: true, - incomplete: "_", - } - ); + outer.mProgressBar = new ProgressBar(this.mProgressBarTemplate, { + total: 100, + width: 10, + stream, + complete: "█", + clear: true, + incomplete: "_", + }); // Set the interval based on the params of the default - this.mProgressBarInterval = setInterval( - this.updateProgressBar.bind(this), - params.updateInterval == null - ? this.mProgressBarPollFrequency - : params.updateInterval - ); + this.mProgressBarInterval = setInterval(this.updateProgressBar.bind(this), + params.updateInterval == null ? this.mProgressBarPollFrequency : params.updateInterval); } } @@ -998,29 +809,17 @@ export class CommandResponse implements ICommandResponseApi { const statusMessage = "Complete"; outer.mProgressBar.update(1, { statusMessage, - spin: " ", + spin: " " }); outer.mProgressBar.terminate(); // NOTE(Kelosky): ansi escape codes for progress bar cursor and line clearing are written on the socket // so we need to ensure they're emptied out before we write to the stream. - if (this.mIsDaemon) - outer.writeStream( - DaemonRequest.EOW_DELIMITER + - DaemonRequest.create({ progress: false }) - ); - - outer.writeStdout( - outer.mStdout.subarray( - this.mProgressBarStdoutStartIndex - ) - ); - outer.writeStderr( - outer.mStderr.subarray( - this.mProgressBarStderrStartIndex - ) - ); + if (this.mIsDaemon) outer.writeStream(DaemonRequest.EOW_DELIMITER + DaemonRequest.create({ progress: false })); + + outer.writeStdout(outer.mStdout.subarray(this.mProgressBarStdoutStartIndex)); + outer.writeStderr(outer.mStderr.subarray(this.mProgressBarStderrStartIndex)); this.mProgressTask = undefined; // clear the progress bar field @@ -1034,42 +833,30 @@ export class CommandResponse implements ICommandResponseApi { * @private */ private updateProgressBar(): void { - if ( - this.mProgressTask == null || + if (this.mProgressTask == null || this.mProgressTask.stageName === TaskStage.COMPLETE || - this.mProgressTask.stageName === TaskStage.FAILED - ) { + this.mProgressTask.stageName === TaskStage.FAILED) { this.endBar(); } else { if (this.mProgressBarInterval != null) { - const percentRatio = - this.mProgressTask.percentComplete / - TaskProgress.ONE_HUNDRED_PERCENT; - this.mProgressBarSpinnerIndex = - (this.mProgressBarSpinnerIndex + 1) % - this.mProgressBarSpinnerChars.length; + const percentRatio = this.mProgressTask.percentComplete / TaskProgress.ONE_HUNDRED_PERCENT; + this.mProgressBarSpinnerIndex = (this.mProgressBarSpinnerIndex + 1) % this.mProgressBarSpinnerChars.length; if (this.mIsDaemon) { outer.mProgressBar.update(percentRatio, { - statusMessage: - this.mProgressTask.statusMessage, - spin: this.mDaemonProgressBarSpinnerChars[ - this.mProgressBarSpinnerIndex - ], + statusMessage: this.mProgressTask.statusMessage, + spin: this.mDaemonProgressBarSpinnerChars[this.mProgressBarSpinnerIndex] }); } else { outer.mProgressBar.update(percentRatio, { - statusMessage: - this.mProgressTask.statusMessage, - spin: this.mProgressBarSpinnerChars[ - this.mProgressBarSpinnerIndex - ], + statusMessage: this.mProgressTask.statusMessage, + spin: this.mProgressBarSpinnerChars[this.mProgressBarSpinnerIndex] }); } } } } - })(); + }(); } // Return the progress bar API @@ -1109,10 +896,7 @@ export class CommandResponse implements ICommandResponseApi { * @memberof CommandResponse */ public bufferStdout(data: Buffer | string) { - this.mStdout = Buffer.concat([ - this.mStdout, - data instanceof Buffer ? data : Buffer.from(data), - ]); + this.mStdout = Buffer.concat([this.mStdout, data instanceof Buffer ? data : Buffer.from(data)]); } /** @@ -1122,10 +906,7 @@ export class CommandResponse implements ICommandResponseApi { * @memberof CommandResponse */ public bufferStderr(data: Buffer | string) { - this.mStderr = Buffer.concat([ - this.mStderr, - data instanceof Buffer ? data : Buffer.from(data), - ]); + this.mStderr = Buffer.concat([this.mStderr, data instanceof Buffer ? data : Buffer.from(data)]); } /** @@ -1144,6 +925,7 @@ export class CommandResponse implements ICommandResponseApi { * @memberof CommandResponse */ public buildJsonResponse(): ICommandResponse { + if (this.mExitCode == null) { this.mExitCode = this.mSucceeded ? 0 : Constants.ERROR_EXIT_CODE; } @@ -1155,7 +937,7 @@ export class CommandResponse implements ICommandResponseApi { stdout: this.mStdout, stderr: this.mStderr, data: this.mData, - error: this.mError, + error: this.mError }; } @@ -1171,36 +953,18 @@ export class CommandResponse implements ICommandResponseApi { response = this.buildJsonResponse(); (response.stderr as any) = response.stderr.toString(); (response.stdout as any) = response.stdout.toString(); - response.message = LoggerUtils.censorRawData( - response.message, - "json" - ); - response.data = response.data - ? JSON.parse( - LoggerUtils.censorRawData( - JSON.stringify(response.data), - "json" - ) - ) - : undefined; - response.error = response.error - ? JSON.parse( - LoggerUtils.censorRawData( - JSON.stringify(response.error), - "json" - ) - ) - : undefined; + response.message = LoggerUtils.censorRawData(response.message, "json"); + response.data = response.data ? JSON.parse(LoggerUtils.censorRawData(JSON.stringify(response.data), "json")) : undefined; + response.error = response.error ? JSON.parse(LoggerUtils.censorRawData(JSON.stringify(response.error), "json")) : undefined; if (!this.mSilent) { this.writeStdout(JSON.stringify(response, null, 2)); } } catch (e) { throw new ImperativeError({ - msg: - `${CommandResponse.RESPONSE_ERR_TAG} An error occurred stringifying the JSON response object. ` + + msg: `${CommandResponse.RESPONSE_ERR_TAG} An error occurred stringifying the JSON response object. ` + `Error Details: ${e.message}`, - additionalDetails: e, + additionalDetails: e }); } return response; @@ -1340,10 +1104,6 @@ export class CommandResponse implements ICommandResponseApi { * @memberof CommandResponse */ private write(): boolean { - return ( - !this.control.silent && - this.mResponseFormat !== "json" && - this.mProgressBar == null - ); + return !this.control.silent && this.mResponseFormat !== "json" && this.mProgressBar == null; } } From 06c65a4e65acc2435bb169ffb63145d9adc8e525 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Tue, 29 Oct 2024 13:30:42 -0400 Subject: [PATCH 076/106] added null check Signed-off-by: jace-roell --- .../src/cmd/src/response/CommandResponse.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/imperative/src/cmd/src/response/CommandResponse.ts b/packages/imperative/src/cmd/src/response/CommandResponse.ts index 93d71b3176..17470952f2 100644 --- a/packages/imperative/src/cmd/src/response/CommandResponse.ts +++ b/packages/imperative/src/cmd/src/response/CommandResponse.ts @@ -716,11 +716,12 @@ export class CommandResponse implements ICommandResponseApi { * Stop a spinner */ public endSpinner(stopText?: string): void { - outer.write(); - clearInterval(this.spinnerInterval); - this.spinnerInterval = null; - if(stopText) outer.writeStdout(`\r${stopText}\n`); - outer.writeStdout("\r\x1b[K"); + if (this.spinnerInterval != null) { + clearInterval(this.spinnerInterval); + this.spinnerInterval = null; + if(stopText) outer.writeStdout(`\r${stopText}\n`); + outer.writeStdout("\r\x1b[K"); + } } private mProgressBarSpinnerIndex = 0; From cc6d186abc9afaf12793b4e725462210b83b16bb Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 30 Oct 2024 10:36:28 -0400 Subject: [PATCH 077/106] changelog Signed-off-by: jace-roell --- packages/cli/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 2c571c6f39..ddff12972d 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe CLI package will be documented in this file. +## Recent Changes + +- Enhancement: Added support for running applications on TSO/E address spaces. Applications can be started, receive messages and transmit messages [#2280](https://github.com/zowe/zowe-cli/pull/2280) + ## `8.4.0` - Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319] (https://github.com/zowe/zowe-cli/pull/2319) From 1f09b857d879d367deef1a1555f4becfe596a7d6 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 30 Oct 2024 10:41:51 -0400 Subject: [PATCH 078/106] header fix Signed-off-by: jace-roell --- .../zosfiles/upload/ftu/FileToUSS.handler.ts | 18 +++++++++--------- packages/zostso/src/AddressSpaceApps.ts | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts index 45cfe46971..654553ee6f 100644 --- a/packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.ts +++ b/packages/cli/src/zosfiles/upload/ftu/FileToUSS.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 { AbstractSession, diff --git a/packages/zostso/src/AddressSpaceApps.ts b/packages/zostso/src/AddressSpaceApps.ts index c114cad049..3169d464c2 100644 --- a/packages/zostso/src/AddressSpaceApps.ts +++ b/packages/zostso/src/AddressSpaceApps.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 { noAccountNumber, TsoConstants } from "./TsoConstants"; import { ITsoAppCommunicationParms } from "./doc/input/ITsoAppCommunicationParms"; From 7d9903eb1ccb2b678b327ba0a30102ac8abe9a97 Mon Sep 17 00:00:00 2001 From: jace-roell Date: Wed, 30 Oct 2024 10:46:02 -0400 Subject: [PATCH 079/106] changelog Signed-off-by: jace-roell --- packages/cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index ddff12972d..2cada23679 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -8,7 +8,7 @@ All notable changes to the Zowe CLI package will be documented in this file. ## `8.4.0` -- Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319] (https://github.com/zowe/zowe-cli/pull/2319) +- Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319](https://github.com/zowe/zowe-cli/pull/2319) ## `8.3.0` From de5f1089c6cf80f840d9d1ba839d8a55a700cce6 Mon Sep 17 00:00:00 2001 From: Jace Roell <111985297+jace-roell@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:55:32 -0400 Subject: [PATCH 080/106] Update packages/cli/CHANGELOG.md Co-authored-by: Trae Yelovich Signed-off-by: Jace Roell <111985297+jace-roell@users.noreply.github.com> --- packages/cli/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 2cada23679..11227f789f 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Zowe CLI package will be documented in this file. ## Recent Changes -- Enhancement: Added support for running applications on TSO/E address spaces. Applications can be started, receive messages and transmit messages [#2280](https://github.com/zowe/zowe-cli/pull/2280) +- Enhancement: Added support for running applications on TSO/E address spaces. Start applications and receive/transmit messages using the new `tso start`, `tso receive` and `tso send` commands. [#2280](https://github.com/zowe/zowe-cli/pull/2280) ## `8.4.0` From 4f2d79928eb0ad42109c5eab0c0352b32129cee1 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 11:35:21 -0400 Subject: [PATCH 081/106] Add missing shebang lines Signed-off-by: Andrew W. Harn --- .../auto-init/__system__/__scripts__/config_auto_init.sh | 1 + .../__system__/__scripts__/config_auto_init_cert.sh | 1 + .../__system__/__scripts__/config_auto_init_profile.sh | 1 + .../check/status/zosmf.check.status.system.test.ts | 7 +++++-- .../list/systems/zosmf.list.systems.system.test.ts | 7 +++++-- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init.sh b/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init.sh index 6328d7d363..dd62bf40a8 100755 --- a/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init.sh +++ b/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init.sh @@ -1,3 +1,4 @@ +#!/bin/bash set -e HOST=$1 diff --git a/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init_cert.sh b/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init_cert.sh index 88d6e63d2c..d1478052f2 100755 --- a/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init_cert.sh +++ b/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init_cert.sh @@ -1,3 +1,4 @@ +#!/bin/bash set -e HOST=$1 diff --git a/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init_profile.sh b/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init_profile.sh index 1b39110909..a0ed357b6a 100755 --- a/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init_profile.sh +++ b/packages/cli/__tests__/config/auto-init/__system__/__scripts__/config_auto_init_profile.sh @@ -1,3 +1,4 @@ +#!/bin/bash set -e zowe config auto-init diff --git a/packages/cli/__tests__/zosmf/__system__/check/status/zosmf.check.status.system.test.ts b/packages/cli/__tests__/zosmf/__system__/check/status/zosmf.check.status.system.test.ts index a2cb9867c9..b7c1d8ebcc 100644 --- a/packages/cli/__tests__/zosmf/__system__/check/status/zosmf.check.status.system.test.ts +++ b/packages/cli/__tests__/zosmf/__system__/check/status/zosmf.check.status.system.test.ts @@ -14,6 +14,8 @@ import { TestEnvironment } from "../../../../../../../__tests__/__src__/environm import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { stripNewLines } from "../../../../../../../__tests__/__src__/TestUtils"; import { IO } from "@zowe/imperative"; +import { join } from "path"; +import { chmodSync } from "fs"; let testEnvironment: ITestEnvironment; let host: string; @@ -105,10 +107,11 @@ describe("zosmf check status", () => { (!process.env.HTTP_PROXY && !process.env.HTTPS_PROXY ? it : it.skip)("should fail due to invalid port", async () => { // update temporary zowe profile with an invalid port - const scriptPath = testEnvironment.workingDir + "_create_profile_invalid_port"; + const scriptPath = join(testEnvironment.workingDir, "create_profile_invalid_port.sh"); const bogusPort = 12345; - const command = `zowe config set profiles.${testEnvironment.tempProfiles?.zosmf[0]}.properties.port ${bogusPort} --gc`; + const command = `#!/bin/bash\nzowe config set profiles.${testEnvironment.tempProfiles?.zosmf[0]}.properties.port ${bogusPort} --gc`; await IO.writeFileAsync(scriptPath, command); + if (process.platform !== "win32") { chmodSync(scriptPath, 0o755); } let response = runCliScript(scriptPath, testEnvironment); expect(response.status).toBe(0); // now check the status diff --git a/packages/cli/__tests__/zosmf/__system__/list/systems/zosmf.list.systems.system.test.ts b/packages/cli/__tests__/zosmf/__system__/list/systems/zosmf.list.systems.system.test.ts index 790f7849b3..a357c4171a 100644 --- a/packages/cli/__tests__/zosmf/__system__/list/systems/zosmf.list.systems.system.test.ts +++ b/packages/cli/__tests__/zosmf/__system__/list/systems/zosmf.list.systems.system.test.ts @@ -14,6 +14,8 @@ import { TestEnvironment } from "../../../../../../../__tests__/__src__/environm import { ITestPropertiesSchema } from "../../../../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { stripNewLines } from "../../../../../../../__tests__/__src__/TestUtils"; import { IO } from "@zowe/imperative"; +import { join } from "path"; +import { chmodSync } from "fs"; let testEnvironment: ITestEnvironment; let host: string; @@ -123,10 +125,11 @@ describe("zosmf list systems", () => { (!process.env.HTTP_PROXY && !process.env.HTTPS_PROXY ? it : it.skip)("should fail due to invalid port", async () => { // update temporary zowe profile with an invalid port - const scriptPath = testEnvironment.workingDir + "_create_profile_invalid_port"; + const scriptPath = join(testEnvironment.workingDir, "create_profile_invalid_port.sh"); const bogusPort = 12345; - const command = `zowe config set profiles.${testEnvironment.tempProfiles?.zosmf[0]}.properties.port ${bogusPort} --gc`; + const command = `#!/bin/bash\nzowe config set profiles.${testEnvironment.tempProfiles?.zosmf[0]}.properties.port ${bogusPort} --gc`; await IO.writeFileAsync(scriptPath, command); + if (process.platform !== "win32") { chmodSync(scriptPath, 0o755); } let response = runCliScript(scriptPath, testEnvironment); expect(response.status).toBe(0); // now check the status From 2f8655d982baa2b4eba7dbbdb1cb3678b9786175 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 11:35:55 -0400 Subject: [PATCH 082/106] Add checks that required CLI scripts ran correctly. Signed-off-by: Andrew W. Harn --- .../__system__/cli.config.auto-init.system.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/cli/__tests__/config/auto-init/__system__/cli.config.auto-init.system.test.ts b/packages/cli/__tests__/config/auto-init/__system__/cli.config.auto-init.system.test.ts index 863f93d0ef..9a4bd30fe2 100644 --- a/packages/cli/__tests__/config/auto-init/__system__/cli.config.auto-init.system.test.ts +++ b/packages/cli/__tests__/config/auto-init/__system__/cli.config.auto-init.system.test.ts @@ -45,6 +45,7 @@ describe("config auto-init without profile", () => { base.rejectUnauthorized ] ); + expect(response.status).toEqual(0); const config = fs.readFileSync(path.join(TEST_ENVIRONMENT.workingDir, "zowe.config.json")).toString(); // Typecasting because of this issue: https://github.com/kaelzhang/node-comment-json/issues/42 @@ -107,6 +108,7 @@ describe("config auto-init without profile", () => { base.rejectUnauthorized ] ); + expect(response.status).toEqual(0); config = fs.readFileSync(path.join(TEST_ENVIRONMENT.workingDir, "zowe.config.json")).toString(); // Typecasting because of this issue: https://github.com/kaelzhang/node-comment-json/issues/42 @@ -186,6 +188,7 @@ describe("config auto-init without profile and with certificates", () => { base.rejectUnauthorized ] ); + expect(response.status).toEqual(0); const config = fs.readFileSync(path.join(TEST_ENVIRONMENT.workingDir, "zowe.config.json")).toString(); // Typecasting because of this issue: https://github.com/kaelzhang/node-comment-json/issues/42 @@ -254,6 +257,7 @@ describe("config auto-init without profile and with certificates", () => { base.rejectUnauthorized ] ); + expect(response.status).toEqual(0); config = fs.readFileSync(path.join(TEST_ENVIRONMENT.workingDir, "zowe.config.json")).toString(); // Typecasting because of this issue: https://github.com/kaelzhang/node-comment-json/issues/42 @@ -319,6 +323,7 @@ describe("config auto-init with profile", () => { it("should successfully issue the auto-init command", () => { const response = runCliScript(__dirname + "/__scripts__/config_auto_init_profile.sh", TEST_ENVIRONMENT); + expect(response.status).toEqual(0); const config = fs.readFileSync(path.join(TEST_ENVIRONMENT.workingDir, "zowe.config.json")).toString(); // Typecasting because of this issue: https://github.com/kaelzhang/node-comment-json/issues/42 @@ -379,6 +384,7 @@ describe("config auto-init with profile and certificates", () => { it("should successfully issue the auto-init command", () => { const response = runCliScript(__dirname + "/__scripts__/config_auto_init_profile.sh", TEST_ENVIRONMENT); + expect(response.status).toEqual(0); const config = fs.readFileSync(path.join(TEST_ENVIRONMENT.workingDir, "zowe.config.json")).toString(); // Typecasting because of this issue: https://github.com/kaelzhang/node-comment-json/issues/42 From 0da0ad0d777a85d2dd545ee87ebec5a4f283b2a4 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 11:36:07 -0400 Subject: [PATCH 083/106] Use local IP address due to AggregateError Signed-off-by: Andrew W. Harn --- packages/zosuss/__tests__/__system__/Shell.system.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zosuss/__tests__/__system__/Shell.system.test.ts b/packages/zosuss/__tests__/__system__/Shell.system.test.ts index 1f8c07360d..eece57bd59 100644 --- a/packages/zosuss/__tests__/__system__/Shell.system.test.ts +++ b/packages/zosuss/__tests__/__system__/Shell.system.test.ts @@ -126,7 +126,7 @@ describe("zowe uss issue ssh api call test", () => { it("should handle errors correctly when connection is refused", async () => { const invalidSshSession = new SshSession({ - hostname: "localhost", + hostname: "127.0.0.1", port: 22, user: "root", password: "**ThisPasswordIsExpectedNotToBeTheRealPasswordForRoot**" From 977706061ea6e634e66e107b8115fd6d8a413e7b Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 11:36:32 -0400 Subject: [PATCH 084/106] Use cross platform supported tools in Bash scripts Signed-off-by: Andrew W. Harn --- .../stop/__scripts__/address-space/as_fully_qualified.sh | 3 ++- .../stop/__scripts__/address-space/as_success_stop.sh | 3 ++- .../stop/__scripts__/address-space/as_success_stop_rfj.sh | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_fully_qualified.sh b/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_fully_qualified.sh index 97bf3bf6e4..a4966fd2d0 100755 --- a/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_fully_qualified.sh +++ b/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_fully_qualified.sh @@ -7,7 +7,8 @@ PORT=$3 USER=$4 PASSWORD=$5 -SERVLET_KEY=`zowe tso start as --host $HOST --account $ACCOUNT --port $PORT --user $USER --password $PASSWORD --ru=false | grep -oP "(?<=: ).*"` +# SERVLET_KEY=`zowe tso start as --host $HOST --account $ACCOUNT --port $PORT --user $USER --password $PASSWORD --ru=false | grep -oP "(?<=: ).*"` +SERVLET_KEY=`zowe tso start as --host $HOST --account $ACCOUNT --port $PORT --user $USER --password $PASSWORD --ru=false | awk -F': ' '{print $2}' | sed '1p;d'` zowe zos-tso stop address-space ${SERVLET_KEY} --host $HOST --port $PORT --user $USER --password $PASSWORD --ru=false exit $? \ No newline at end of file diff --git a/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_success_stop.sh b/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_success_stop.sh index 88d2188082..a32a4d780a 100755 --- a/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_success_stop.sh +++ b/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_success_stop.sh @@ -1,7 +1,8 @@ #!/bin/bash set -e -SERVLET_KEY=`zowe tso start as | grep -oP "(?<=: ).*"` +# SERVLET_KEY=`zowe tso start as | grep -oP "(?<=: ).*"` +SERVLET_KEY=`zowe tso start as | awk -F': ' '{print $2}' | sed '1p;d'` zowe zos-tso stop address-space ${SERVLET_KEY} exit $? \ No newline at end of file diff --git a/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_success_stop_rfj.sh b/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_success_stop_rfj.sh index f587af271f..bcccfa0f26 100755 --- a/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_success_stop_rfj.sh +++ b/packages/cli/__tests__/zostso/__system__/stop/__scripts__/address-space/as_success_stop_rfj.sh @@ -1,7 +1,8 @@ #!/bin/bash set -e -SERVLET_KEY=`zowe tso start as | grep -oP "(?<=: ).*"` +# SERVLET_KEY=`zowe tso start as | grep -oP "(?<=: ).*"` +SERVLET_KEY=`zowe tso start as | awk -F': ' '{print $2}' | sed '1p;d'` zowe zos-tso stop address-space ${SERVLET_KEY} --response-format-json exit $? \ No newline at end of file From f7a61a6dd4853c544f18bfcdc62aa2a331c98e7b Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 11:37:11 -0400 Subject: [PATCH 085/106] Fix DS name too long issues Signed-off-by: Andrew W. Harn --- .../__tests__/__system__/methods/invoke/Invoke.system.test.ts | 2 +- .../__tests__/__system__/methods/list/List.system.test.ts | 2 +- .../__tests__/__system__/methods/search/Search.system.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts index a1daccc33d..ffe59aa738 100644 --- a/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/invoke/Invoke.system.test.ts @@ -205,7 +205,7 @@ describe("Invoke AMS - encoded", () => { systemProps = testEnvironment.systemTestProperties; REAL_SESSION = TestEnvironment.createZosmfSession(testEnvironment); - dsname = getUniqueDatasetName(`${systemProps.zosmf.user}.ZOSFILE.ENCO#ED.VSAM`); + dsname = getUniqueDatasetName(`${systemProps.zosmf.user}.ZOSFILE.ENCO#ED.VSAM`, false, 1); volume = systemProps.datasets.vol.toUpperCase(); }); diff --git a/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts index 4e3981e4ae..b9011e5724 100644 --- a/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts @@ -648,7 +648,7 @@ describe("List command group", () => { let caughtError; try { - response = await List.dataSetsMatchingPattern(REAL_SESSION, [dsname + ".INVALID"]); + response = await List.dataSetsMatchingPattern(REAL_SESSION, [dsname + ".INVAL"]); } catch (error) { caughtError = error; } diff --git a/packages/zosfiles/__tests__/__system__/methods/search/Search.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/search/Search.system.test.ts index db839abc14..f982c81787 100644 --- a/packages/zosfiles/__tests__/__system__/methods/search/Search.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/search/Search.system.test.ts @@ -59,7 +59,7 @@ describe("Search", () => { let expectedApiResponse: any; beforeAll(async () => { - dsnPrefix = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILES.SEARCH`); + dsnPrefix = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSFILES.SEARCH`, false, 1); pattern = dsnPrefix + ".*"; goodDsNames = [`${dsnPrefix}.SEQ1`, `${dsnPrefix}.SEQ4`, `${dsnPrefix}.SEQ5`]; From 724cb45bd642101bd271545ab9b63c8c2d1d67f2 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 11:37:50 -0400 Subject: [PATCH 086/106] Handle ECONNRESET error when reusing sockets in AbstractRestClient Signed-off-by: Andrew W. Harn --- .../client/AbstractRestClient.unit.test.ts | 50 +++++++++++++++++++ .../__model__/MockHttpRequestResponse.ts | 6 +++ .../src/rest/src/client/AbstractRestClient.ts | 19 +++++-- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts b/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts index d77a854961..d81ea50636 100644 --- a/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts +++ b/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts @@ -426,6 +426,56 @@ describe("AbstractRestClient tests", () => { expect(error.message).toMatchSnapshot(); }); + // called IRL when socket is reused and HTTP 1.1 race condition is hit + it("should handle a socket reuse error", async () => { + const errorObject: any = { + name: "socket hang up", + message: "socket hang up", + code: "ECONNRESET" + }; + + let reusedSocket = true; + const requestFnc = jest.fn((options, callback) => { + let emitter = new MockHttpRequestResponse(); + + ProcessUtils.nextTick(() => { + callback(emitter); + + if (reusedSocket) { + emitter.reusedSocket = true; + ProcessUtils.nextTick(() => { + emitter.emit("error", errorObject); + reusedSocket = false; + }); + } else { + ProcessUtils.nextTick(() => { + emitter.emit("data", Buffer.from("\"response data\"", "utf8")); + }); + + ProcessUtils.nextTick(() => { + emitter.emit("end"); + }); + } + }); + return emitter; + }); + + (https.request as any) = requestFnc; + + let error; + let response: string = ""; + + try { + response = await RestClient.getExpectString(new Session({hostname: "test"}), "/resource"); + } catch (thrownError) { + error = thrownError; + } + + expect(error).not.toBeDefined(); + expect(response).toEqual("\"response data\""); + expect(requestFnc).toHaveBeenCalledTimes(2); + }); + it("should call http request for http requests", async () => { const requestEmitter = new MockHttpRequestResponse(); const httpRequestFnc = jest.fn((options, callback) => { diff --git a/packages/imperative/src/rest/__tests__/client/__model__/MockHttpRequestResponse.ts b/packages/imperative/src/rest/__tests__/client/__model__/MockHttpRequestResponse.ts index 5306899a13..59a92ab446 100644 --- a/packages/imperative/src/rest/__tests__/client/__model__/MockHttpRequestResponse.ts +++ b/packages/imperative/src/rest/__tests__/client/__model__/MockHttpRequestResponse.ts @@ -65,4 +65,10 @@ export class MockHttpRequestResponse extends EventEmitter { * @memberof RequestOrResponse */ public headers: { [key: string]: any }; + + /** + * Simulate a reused socket + * @memberof MockHttpRequestResponse + */ + public reusedSocket: boolean = false; } diff --git a/packages/imperative/src/rest/src/client/AbstractRestClient.ts b/packages/imperative/src/rest/src/client/AbstractRestClient.ts index 46b6eec4b3..471c16a721 100644 --- a/packages/imperative/src/rest/src/client/AbstractRestClient.ts +++ b/packages/imperative/src/rest/src/client/AbstractRestClient.ts @@ -330,11 +330,20 @@ export abstract class AbstractRestClient { * Invoke any onError method whenever an error occurs on writing */ clientRequest.on("error", (errorResponse: any) => { - reject(this.populateError({ - msg: "Failed to send an HTTP request.", - causeErrors: errorResponse, - source: "client" - })); + // Handle the HTTP 1.1 Keep-Alive race condition + if (errorResponse.code === "ECONNRESET" && clientRequest.reusedSocket) { + this.request(options).then((response: string) => { + resolve(response); + }).catch((err) => { + reject(err); + }); + } else { + reject(this.populateError({ + msg: "Failed to send an HTTP request.", + causeErrors: errorResponse, + source: "client" + })); + } }); if (options.requestStream != null) { From 97402aadb868404bf918e3f622f4c554e87de7d6 Mon Sep 17 00:00:00 2001 From: zowe-robot Date: Wed, 30 Oct 2024 16:11:27 +0000 Subject: [PATCH 087/106] Bump version to 8.6.0 [ci skip] Signed-off-by: zowe-robot --- .../__packages__/cli-test-utils/package.json | 4 +- lerna.json | 2 +- npm-shrinkwrap.json | 116 +++++++++--------- packages/cli/CHANGELOG.md | 2 +- packages/cli/package.json | 26 ++-- packages/core/package.json | 6 +- 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/CHANGELOG.md | 2 +- packages/zostso/package.json | 10 +- packages/zosuss/package.json | 6 +- 17 files changed, 119 insertions(+), 119 deletions(-) diff --git a/__tests__/__packages__/cli-test-utils/package.json b/__tests__/__packages__/cli-test-utils/package.json index 44b3fd102f..b40dbc3948 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.3.1", + "version": "8.6.0", "description": "Test utilities package for Zowe CLI plug-ins", "author": "Zowe", "license": "EPL-2.0", @@ -43,7 +43,7 @@ "devDependencies": { "@types/js-yaml": "^4.0.9", "@types/uuid": "^10.0.0", - "@zowe/imperative": "8.3.1" + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" diff --git a/lerna.json b/lerna.json index e60247f527..5998ae5311 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "8.5.0", + "version": "8.6.0", "command": { "publish": { "ignoreChanges": [ diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e4e1c1bd9b..a5a356aef5 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.3.1", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { "find-up": "^5.0.0", @@ -63,7 +63,7 @@ "devDependencies": { "@types/js-yaml": "^4.0.9", "@types/uuid": "^10.0.0", - "@zowe/imperative": "8.3.1" + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" @@ -16267,21 +16267,21 @@ }, "packages/cli": { "name": "@zowe/cli", - "version": "8.5.0", + "version": "8.6.0", "hasInstallScript": true, "license": "EPL-2.0", "dependencies": { - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1", - "@zowe/provisioning-for-zowe-sdk": "8.3.1", - "@zowe/zos-console-for-zowe-sdk": "8.3.1", - "@zowe/zos-files-for-zowe-sdk": "8.4.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.5.0", - "@zowe/zos-logs-for-zowe-sdk": "8.3.1", - "@zowe/zos-tso-for-zowe-sdk": "8.3.1", - "@zowe/zos-uss-for-zowe-sdk": "8.3.1", - "@zowe/zos-workflows-for-zowe-sdk": "8.4.0", - "@zowe/zosmf-for-zowe-sdk": "8.3.1", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0", + "@zowe/provisioning-for-zowe-sdk": "8.6.0", + "@zowe/zos-console-for-zowe-sdk": "8.6.0", + "@zowe/zos-files-for-zowe-sdk": "8.6.0", + "@zowe/zos-jobs-for-zowe-sdk": "8.6.0", + "@zowe/zos-logs-for-zowe-sdk": "8.6.0", + "@zowe/zos-tso-for-zowe-sdk": "8.6.0", + "@zowe/zos-uss-for-zowe-sdk": "8.6.0", + "@zowe/zos-workflows-for-zowe-sdk": "8.6.0", + "@zowe/zosmf-for-zowe-sdk": "8.6.0", "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.3.1", + "@zowe/cli-test-utils": "8.6.0", "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.3.1", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { "comment-json": "~4.2.3", "string-width": "^4.2.3" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16369,7 +16369,7 @@ }, "packages/imperative": { "name": "@zowe/imperative", - "version": "8.3.1", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { "@types/yargs": "^17.0.32", @@ -16563,16 +16563,16 @@ }, "packages/provisioning": { "name": "@zowe/provisioning-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { "js-yaml": "^4.1.0" }, "devDependencies": { "@types/js-yaml": "^4.0.9", - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16597,15 +16597,15 @@ }, "packages/workflows": { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.4.0", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.4.0" + "@zowe/zos-files-for-zowe-sdk": "8.6.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16617,12 +16617,12 @@ }, "packages/zosconsole": { "name": "@zowe/zos-console-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16634,17 +16634,17 @@ }, "packages/zosfiles": { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.4.0", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { "lodash": "^4.17.21", "minimatch": "^9.0.5" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1", - "@zowe/zos-uss-for-zowe-sdk": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0", + "@zowe/zos-uss-for-zowe-sdk": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16676,15 +16676,15 @@ }, "packages/zosjobs": { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.5.0", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.4.0" + "@zowe/zos-files-for-zowe-sdk": "8.6.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16696,12 +16696,12 @@ }, "packages/zoslogs": { "name": "@zowe/zos-logs-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16713,12 +16713,12 @@ }, "packages/zosmf": { "name": "@zowe/zosmf-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16730,15 +16730,15 @@ }, "packages/zostso": { "name": "@zowe/zos-tso-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { - "@zowe/zosmf-for-zowe-sdk": "8.3.1" + "@zowe/zosmf-for-zowe-sdk": "8.6.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" @@ -16750,15 +16750,15 @@ }, "packages/zosuss": { "name": "@zowe/zos-uss-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "license": "EPL-2.0", "dependencies": { "ssh2": "^1.15.0" }, "devDependencies": { "@types/ssh2": "^1.11.19", - "@zowe/cli-test-utils": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/imperative": "8.6.0" }, "engines": { "node": ">=18.12.0" diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 11227f789f..9e57df0fef 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe CLI package will be documented in this file. -## Recent Changes +## `8.6.0` - Enhancement: Added support for running applications on TSO/E address spaces. Start applications and receive/transmit messages using the new `tso start`, `tso receive` and `tso send` commands. [#2280](https://github.com/zowe/zowe-cli/pull/2280) diff --git a/packages/cli/package.json b/packages/cli/package.json index 20051e25c5..473f19a074 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cli", - "version": "8.5.0", + "version": "8.6.0", "zoweVersion": "v3.0.0", "description": "Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.", "author": "Zowe", @@ -58,17 +58,17 @@ "preshrinkwrap": "node ../../scripts/rewriteShrinkwrap.js" }, "dependencies": { - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1", - "@zowe/provisioning-for-zowe-sdk": "8.3.1", - "@zowe/zos-console-for-zowe-sdk": "8.3.1", - "@zowe/zos-files-for-zowe-sdk": "8.4.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.5.0", - "@zowe/zos-logs-for-zowe-sdk": "8.3.1", - "@zowe/zos-tso-for-zowe-sdk": "8.3.1", - "@zowe/zos-uss-for-zowe-sdk": "8.3.1", - "@zowe/zos-workflows-for-zowe-sdk": "8.4.0", - "@zowe/zosmf-for-zowe-sdk": "8.3.1", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0", + "@zowe/provisioning-for-zowe-sdk": "8.6.0", + "@zowe/zos-console-for-zowe-sdk": "8.6.0", + "@zowe/zos-files-for-zowe-sdk": "8.6.0", + "@zowe/zos-jobs-for-zowe-sdk": "8.6.0", + "@zowe/zos-logs-for-zowe-sdk": "8.6.0", + "@zowe/zos-tso-for-zowe-sdk": "8.6.0", + "@zowe/zos-uss-for-zowe-sdk": "8.6.0", + "@zowe/zos-workflows-for-zowe-sdk": "8.6.0", + "@zowe/zosmf-for-zowe-sdk": "8.6.0", "find-process": "1.4.7", "lodash": "4.17.21", "minimatch": "9.0.5", @@ -78,7 +78,7 @@ "@types/diff": "^5.0.9", "@types/lodash": "^4.17.6", "@types/tar": "^6.1.11", - "@zowe/cli-test-utils": "8.3.1", + "@zowe/cli-test-utils": "8.6.0", "comment-json": "^4.2.3", "strip-ansi": "^6.0.1", "which": "^4.0.0" diff --git a/packages/core/package.json b/packages/core/package.json index 4139cdcb81..edb95dc101 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/core-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "description": "Core libraries shared by Zowe SDK packages", "author": "Zowe", "license": "EPL-2.0", @@ -49,8 +49,8 @@ "string-width": "^4.2.3" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" diff --git a/packages/imperative/package.json b/packages/imperative/package.json index 112b248d92..907c361ab7 100644 --- a/packages/imperative/package.json +++ b/packages/imperative/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/imperative", - "version": "8.3.1", + "version": "8.6.0", "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 2857fc26c2..8cf47f139e 100644 --- a/packages/provisioning/package.json +++ b/packages/provisioning/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/provisioning-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "description": "Zowe SDK to interact with the z/OS provisioning APIs", "author": "Zowe", "license": "EPL-2.0", @@ -49,9 +49,9 @@ }, "devDependencies": { "@types/js-yaml": "^4.0.9", - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/workflows/package.json b/packages/workflows/package.json index b9e3e3e8bd..d4810ab8db 100644 --- a/packages/workflows/package.json +++ b/packages/workflows/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.4.0", + "version": "8.6.0", "description": "Zowe SDK to interact with the z/OS workflows APIs", "author": "Zowe", "license": "EPL-2.0", @@ -45,12 +45,12 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.4.0" + "@zowe/zos-files-for-zowe-sdk": "8.6.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosconsole/package.json b/packages/zosconsole/package.json index de2d7c8366..1842509479 100644 --- a/packages/zosconsole/package.json +++ b/packages/zosconsole/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-console-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "description": "Zowe SDK to interact with the z/OS console", "author": "Zowe", "license": "EPL-2.0", @@ -45,9 +45,9 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosfiles/package.json b/packages/zosfiles/package.json index 25e8342c16..23cdbd9e54 100644 --- a/packages/zosfiles/package.json +++ b/packages/zosfiles/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.4.0", + "version": "8.6.0", "description": "Zowe SDK to interact with files and data sets on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -50,10 +50,10 @@ "minimatch": "^9.0.5" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1", - "@zowe/zos-uss-for-zowe-sdk": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0", + "@zowe/zos-uss-for-zowe-sdk": "8.6.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosjobs/package.json b/packages/zosjobs/package.json index 19464cbade..6c7c787865 100644 --- a/packages/zosjobs/package.json +++ b/packages/zosjobs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.5.0", + "version": "8.6.0", "description": "Zowe SDK to interact with jobs on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -46,12 +46,12 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.4.0" + "@zowe/zos-files-for-zowe-sdk": "8.6.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zoslogs/package.json b/packages/zoslogs/package.json index 20dde12e4a..1f25dd30a8 100644 --- a/packages/zoslogs/package.json +++ b/packages/zoslogs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-logs-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "description": "Zowe SDK to interact with the z/OS logs", "author": "Zowe", "license": "EPL-2.0", @@ -45,9 +45,9 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosmf/package.json b/packages/zosmf/package.json index e3598300c3..86b5f88a9e 100644 --- a/packages/zosmf/package.json +++ b/packages/zosmf/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zosmf-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "description": "Zowe SDK to interact with the z/OS Management Facility", "author": "Zowe", "license": "EPL-2.0", @@ -44,9 +44,9 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zostso/CHANGELOG.md b/packages/zostso/CHANGELOG.md index 394969b008..63188b9bea 100644 --- a/packages/zostso/CHANGELOG.md +++ b/packages/zostso/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe z/OS TSO SDK package will be documented in this file. -## Recent Changes +## `8.6.0` - Enhancement: Issue `app` commands to better target communication with a TSO/E application. The `app` command is now included in the `start`/`send` command group and the new `receive` command group, allowing direct interaction with an application through a z/OS message queue. [#2280] (https://github.com/zowe/zowe-cli/pull/2280) diff --git a/packages/zostso/package.json b/packages/zostso/package.json index 5bd097a3a7..65d20a0763 100644 --- a/packages/zostso/package.json +++ b/packages/zostso/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-tso-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "description": "Zowe SDK to interact with TSO on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -45,12 +45,12 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zosmf-for-zowe-sdk": "8.3.1" + "@zowe/zosmf-for-zowe-sdk": "8.6.0" }, "devDependencies": { - "@zowe/cli-test-utils": "8.3.1", - "@zowe/core-for-zowe-sdk": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosuss/package.json b/packages/zosuss/package.json index 5dd3ba0576..0c1cbd507d 100644 --- a/packages/zosuss/package.json +++ b/packages/zosuss/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-uss-for-zowe-sdk", - "version": "8.3.1", + "version": "8.6.0", "description": "Zowe SDK to interact with USS on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -49,8 +49,8 @@ }, "devDependencies": { "@types/ssh2": "^1.11.19", - "@zowe/cli-test-utils": "8.3.1", - "@zowe/imperative": "8.3.1" + "@zowe/cli-test-utils": "8.6.0", + "@zowe/imperative": "8.6.0" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" From cd63e8f006fd5c0e87f47c3ce325440517936988 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 14:47:39 -0400 Subject: [PATCH 088/106] Add CIM flag to skip CIM 1.0 tests on systems that do not support it Signed-off-by: Andrew W. Harn --- .../properties/default_properties.yaml | 2 + .../__src__/properties/ITestZosJobsSchema.ts | 1 + ...li.zos-jobs.delete.old-jobs.system.test.ts | 57 +++++--- .../__system__/CancelJobs.system.test.ts | 135 +++++++++++------- .../__system__/DeleteJobs.system.test.ts | 37 +++-- 5 files changed, 151 insertions(+), 81 deletions(-) diff --git a/__tests__/__resources__/properties/default_properties.yaml b/__tests__/__resources__/properties/default_properties.yaml index 9e3c215a5e..a3c570b6bc 100644 --- a/__tests__/__resources__/properties/default_properties.yaml +++ b/__tests__/__resources__/properties/default_properties.yaml @@ -104,6 +104,8 @@ zosjobs: modifiedJobclass: B # System affinity sysaff: zosjobs-sysaff + # CIM Support + skipCIM: cim-skipped #-----------------------------------------------------------------------------# # Set of properties for testing provisioning # #-----------------------------------------------------------------------------# diff --git a/__tests__/__src__/properties/ITestZosJobsSchema.ts b/__tests__/__src__/properties/ITestZosJobsSchema.ts index ba6685b85d..cb18e46020 100644 --- a/__tests__/__src__/properties/ITestZosJobsSchema.ts +++ b/__tests__/__src__/properties/ITestZosJobsSchema.ts @@ -16,4 +16,5 @@ export interface ITestZosJobsSchema { jobclass: string; modifiedJobclass: string; sysaff: string; + skipCIM?: boolean; } diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.old-jobs.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.old-jobs.system.test.ts index be09c0dfaf..743e3a41a9 100644 --- a/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.old-jobs.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.old-jobs.system.test.ts @@ -17,6 +17,7 @@ import { runCliScript } from "@zowe/cli-test-utils"; // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; let IEFBR14_JCL: string; +const modifyVersionDefaultUsesCIM = false; describe("zos-jobs delete old-jobs command", () => { // Create the unique test environment @@ -39,35 +40,51 @@ describe("zos-jobs delete old-jobs command", () => { describe("successful scenario", () => { it("should delete all old jobs sequentially default", () => { - const response = runCliScript(__dirname + "/__scripts__/old-jobs/delete_old_jobs.sh", - TEST_ENVIRONMENT, [IEFBR14_JCL]); - expect(response.status).toBe(0); - expect(response.stderr.toString()).toBe(""); - expect(response.stdout.toString()).toContain("Successfully deleted"); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/old-jobs/delete_old_jobs.sh", + TEST_ENVIRONMENT, [IEFBR14_JCL]); + expect(response.status).toBe(0); + expect(response.stderr.toString()).toBe(""); + expect(response.stdout.toString()).toContain("Successfully deleted"); + } }); it("should delete all old jobs in parallel default", () => { - const response = runCliScript(__dirname + "/__scripts__/old-jobs/delete_old_jobs.sh", - TEST_ENVIRONMENT, [IEFBR14_JCL, "--mcr", "0"]); - expect(response.status).toBe(0); - expect(response.stderr.toString()).toBe(""); - expect(response.stdout.toString()).toContain("Successfully deleted"); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/old-jobs/delete_old_jobs.sh", + TEST_ENVIRONMENT, [IEFBR14_JCL, "--mcr", "0"]); + expect(response.status).toBe(0); + expect(response.stderr.toString()).toBe(""); + expect(response.stdout.toString()).toContain("Successfully deleted"); + } }); it("should delete all old jobs with modifyVersion 1.0 sequentially", () => { - const response = runCliScript(__dirname + "/__scripts__/old-jobs/delete_old_jobs.sh", - TEST_ENVIRONMENT, [IEFBR14_JCL, "--modify-version", "1.0"]); - expect(response.status).toBe(0); - expect(response.stderr.toString()).toBe(""); - expect(response.stdout.toString()).toContain("Successfully deleted"); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/old-jobs/delete_old_jobs.sh", + TEST_ENVIRONMENT, [IEFBR14_JCL, "--modify-version", "1.0"]); + expect(response.status).toBe(0); + expect(response.stderr.toString()).toBe(""); + expect(response.stdout.toString()).toContain("Successfully deleted"); + } }); it("should delete all old jobs with modifyVersion 1.0 parallel", () => { - const response = runCliScript(__dirname + "/__scripts__/old-jobs/delete_old_jobs.sh", - TEST_ENVIRONMENT, [IEFBR14_JCL, "--mcr", "0", "--modify-version", "1.0"]); - expect(response.status).toBe(0); - expect(response.stderr.toString()).toBe(""); - expect(response.stdout.toString()).toContain("Successfully deleted"); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/old-jobs/delete_old_jobs.sh", + TEST_ENVIRONMENT, [IEFBR14_JCL, "--mcr", "0", "--modify-version", "1.0"]); + expect(response.status).toBe(0); + expect(response.stderr.toString()).toBe(""); + expect(response.stdout.toString()).toContain("Successfully deleted"); + } }); it("should delete all old jobs with modifyVersion 2.0 sequentially", () => { diff --git a/packages/zosjobs/__tests__/__system__/CancelJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/CancelJobs.system.test.ts index 5ce5b20883..ecd4bb3a20 100644 --- a/packages/zosjobs/__tests__/__system__/CancelJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/CancelJobs.system.test.ts @@ -22,6 +22,7 @@ let sleepJCL: string; let systemProps: ITestPropertiesSchema; let testEnvironment: ITestEnvironment; const LONG_TIMEOUT = 100000; // 100 second timeout - jobs could take a while to complete due to system load +const modifyVersionDefaultUsesCIM = false; describe("CancelJobs System tests", () => { @@ -44,11 +45,15 @@ describe("CancelJobs System tests", () => { describe("Positive tests", () => { it("should be able to cancel a job using cancelJob (modify version 1)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid, "1.0"); - expect(response).toBeUndefined(); - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid, "1.0"); + expect(response).toBeUndefined(); + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJob (modify version 2)", async () => { @@ -61,20 +66,28 @@ describe("CancelJobs System tests", () => { }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJob (modify version default)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid); - expect(response).not.toBeUndefined(); - expect(response?.status).toEqual("0"); // intermittent failure - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid); + expect(response).not.toBeUndefined(); + expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobForJob (modify version 1)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job, "1.0"); - expect(response).toBeUndefined(); - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job, "1.0"); + expect(response).toBeUndefined(); + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobForJob (modify version 2)", async () => { @@ -87,20 +100,28 @@ describe("CancelJobs System tests", () => { }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobForJob (modify version default)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job); - expect(response).not.toBeUndefined(); - expect(response?.status).toEqual("0"); // intermittent failure - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job); + expect(response).not.toBeUndefined(); + expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version 1)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid, version: "1.0"}); - expect(response).toBeUndefined(); - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid, version: "1.0"}); + expect(response).toBeUndefined(); + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version 2.0 - synchronous)", async () => { @@ -113,11 +134,15 @@ describe("CancelJobs System tests", () => { }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version default)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - expect(response?.status).toEqual("0"); // intermittent failure - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version 2.0 - synchronous) and return an error feedback object", async () => { @@ -206,29 +231,41 @@ describe("CancelJobs System tests - encoded", () => { describe("Positive tests", () => { it("should be able to cancel a job using cancelJob (modify version default)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid); - expect(response).not.toBeUndefined(); - expect(response?.status).toEqual("0"); // intermittent failure - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJob(REAL_SESSION, job.jobname, job.jobid); + expect(response).not.toBeUndefined(); + expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobForJob (modify version default)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job); - expect(response).not.toBeUndefined(); - expect(response?.status).toEqual("0"); // intermittent failure - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJobForJob(REAL_SESSION, job); + expect(response).not.toBeUndefined(); + expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version default)", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); - expect(job.retcode).toBeNull(); // job is not complete, no CC - const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - expect(response?.status).toEqual("0"); // intermittent failure - testEnvironment.resources.jobs.push(job); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: sleepJCL, status: "INPUT"}); + expect(job.retcode).toBeNull(); // job is not complete, no CC + const response = await CancelJobs.cancelJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + expect(response?.status).toEqual("0"); // intermittent failure + testEnvironment.resources.jobs.push(job); + } }, LONG_TIMEOUT); it("should be able to cancel a job using cancelJobCommon (job version 2.0 - synchronous) and return an error feedback object", async () => { diff --git a/packages/zosjobs/__tests__/__system__/DeleteJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/DeleteJobs.system.test.ts index d0f96bf6bf..8dcb1c8b58 100644 --- a/packages/zosjobs/__tests__/__system__/DeleteJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/DeleteJobs.system.test.ts @@ -24,6 +24,7 @@ let iefbr14JCL: string; let defaultSystem: ITestPropertiesSchema; let testEnvironment: ITestEnvironment; const LONG_TIMEOUT = 100000; // 100 second timeout - jobs could take a while to complete due to system load +const modifyVersionDefaultUsesCIM = false; describe("DeleteJobs System tests", () => { @@ -44,24 +45,36 @@ describe("DeleteJobs System tests", () => { describe("Positive tests", () => { it("should be able to delete a job using deleteJob", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: iefbr14JCL}); - expect(job.retcode).toEqual("CC 0000"); - const response = await DeleteJobs.deleteJob(REAL_SESSION, job.jobname, job.jobid); - expect(response).toBeUndefined(); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: iefbr14JCL}); + expect(job.retcode).toEqual("CC 0000"); + const response = await DeleteJobs.deleteJob(REAL_SESSION, job.jobname, job.jobid); + expect(response).toBeUndefined(); + } }, LONG_TIMEOUT); it("should be able to delete a job using deleteJobForJob", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: iefbr14JCL}); - expect(job.retcode).toEqual("CC 0000"); - const response = await DeleteJobs.deleteJobForJob(REAL_SESSION, job); - expect(response).toBeUndefined(); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: iefbr14JCL}); + expect(job.retcode).toEqual("CC 0000"); + const response = await DeleteJobs.deleteJobForJob(REAL_SESSION, job); + expect(response).toBeUndefined(); + } }, LONG_TIMEOUT); it("should be able to delete a job using deleteJobCommon", async () => { - const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: iefbr14JCL}); - expect(job.retcode).toEqual("CC 0000"); - const response = await DeleteJobs.deleteJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); - expect(response).toBeUndefined(); + if (testEnvironment.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const job = await SubmitJobs.submitJclNotifyCommon(REAL_SESSION, {jcl: iefbr14JCL}); + expect(job.retcode).toEqual("CC 0000"); + const response = await DeleteJobs.deleteJobCommon(REAL_SESSION, {jobname: job.jobname, jobid: job.jobid}); + expect(response).toBeUndefined(); + } }, LONG_TIMEOUT); it("should be able to delete a job using deleteJobCommon (job modify version 2.0 - synchronous)", async () => { From ff32587cf74b1ce31121fedfc85f8ef4f733457b Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 14:48:15 -0400 Subject: [PATCH 089/106] Fix system tests where firewall can return a timeout instead Signed-off-by: Andrew W. Harn --- .../__system__/check/status/zosmf.check.status.system.test.ts | 2 +- .../__system__/list/systems/zosmf.list.systems.system.test.ts | 2 +- .../__tests__/__system__/methods/CheckStatus.system.test.ts | 2 +- .../__system__/methods/ListDefinedSystems.system.test.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/__tests__/zosmf/__system__/check/status/zosmf.check.status.system.test.ts b/packages/cli/__tests__/zosmf/__system__/check/status/zosmf.check.status.system.test.ts index b7c1d8ebcc..70dbf02be3 100644 --- a/packages/cli/__tests__/zosmf/__system__/check/status/zosmf.check.status.system.test.ts +++ b/packages/cli/__tests__/zosmf/__system__/check/status/zosmf.check.status.system.test.ts @@ -116,7 +116,7 @@ describe("zosmf check status", () => { expect(response.status).toBe(0); // now check the status response = runCliScript(__dirname + "/__scripts__/command/zosmf_check_status.sh", testEnvironment); - expect(stripNewLines(response.stderr.toString())).toContain("connect ECONNREFUSED"); + expect(stripNewLines(response.stderr.toString())).toMatch(/.*(ECONNREFUSED|ECONNRESET|ETIMEDOUT).*/); }); }); }); diff --git a/packages/cli/__tests__/zosmf/__system__/list/systems/zosmf.list.systems.system.test.ts b/packages/cli/__tests__/zosmf/__system__/list/systems/zosmf.list.systems.system.test.ts index a357c4171a..1654798fd9 100644 --- a/packages/cli/__tests__/zosmf/__system__/list/systems/zosmf.list.systems.system.test.ts +++ b/packages/cli/__tests__/zosmf/__system__/list/systems/zosmf.list.systems.system.test.ts @@ -134,7 +134,7 @@ describe("zosmf list systems", () => { expect(response.status).toBe(0); // now check the status response = runCliScript(__dirname + "/__scripts__/command/zosmf_list_systems.sh", testEnvironment); - expect(stripNewLines(response.stderr.toString())).toContain("connect ECONNREFUSED"); + expect(stripNewLines(response.stderr.toString())).toMatch(/.*(ECONNREFUSED|ECONNRESET|ETIMEDOUT).*/); }); }); }); diff --git a/packages/zosmf/__tests__/__system__/methods/CheckStatus.system.test.ts b/packages/zosmf/__tests__/__system__/methods/CheckStatus.system.test.ts index d08670a8d1..5c0f79f376 100644 --- a/packages/zosmf/__tests__/__system__/methods/CheckStatus.system.test.ts +++ b/packages/zosmf/__tests__/__system__/methods/CheckStatus.system.test.ts @@ -122,7 +122,7 @@ describe("Check Status Api", () => { expect(error).toBeTruthy(); expect(response).toBeFalsy(); const jsonCauseErrors = error.causeErrors; - expect(jsonCauseErrors.code).toMatch(/(ECONNREFUSED|ECONNRESET)/); + expect(jsonCauseErrors.code).toMatch(/(ECONNREFUSED|ECONNRESET|ETIMEDOUT)/); expect(jsonCauseErrors.syscall).toEqual("connect"); expect(jsonCauseErrors.port).toEqual(badPort); }); diff --git a/packages/zosmf/__tests__/__system__/methods/ListDefinedSystems.system.test.ts b/packages/zosmf/__tests__/__system__/methods/ListDefinedSystems.system.test.ts index faeae9c6c2..294d6895ab 100644 --- a/packages/zosmf/__tests__/__system__/methods/ListDefinedSystems.system.test.ts +++ b/packages/zosmf/__tests__/__system__/methods/ListDefinedSystems.system.test.ts @@ -122,7 +122,7 @@ describe("List Defined Systems Api", () => { expect(error).toBeTruthy(); expect(response).toBeFalsy(); const jsonCauseErrors = error.causeErrors; - expect(jsonCauseErrors.code).toMatch(/(ECONNREFUSED|ECONNRESET)/); + expect(jsonCauseErrors.code).toMatch(/(ECONNREFUSED|ECONNRESET|ETIMEDOUT)/); expect(jsonCauseErrors.syscall).toMatch(/(connect|read)/); }); }); From 0b06d95b0968e73b965551ed93d5bbc0103bc913 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 14:48:26 -0400 Subject: [PATCH 090/106] Fix another DSN name too long error Signed-off-by: Andrew W. Harn --- .../__tests__/__system__/methods/list/List.system.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts index b9011e5724..3cba83972c 100644 --- a/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/list/List.system.test.ts @@ -985,7 +985,7 @@ describe("List command group - encoded", () => { let caughtError; try { - response = await List.dataSetsMatchingPattern(REAL_SESSION, [dsname + ".INVALID"]); + response = await List.dataSetsMatchingPattern(REAL_SESSION, [dsname + ".INVAL"]); } catch (error) { caughtError = error; } From eec3141039d3d200eb255d796b3ef97149e99f8b Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 16:00:24 -0400 Subject: [PATCH 091/106] Add missing CIM related tests Signed-off-by: Andrew W. Harn --- .../cli.zos-jobs.cancel.job.system.test.ts | 105 +++++++++------- .../cli.zos-jobs.delete.job.system.test.ts | 113 ++++++++++-------- 2 files changed, 126 insertions(+), 92 deletions(-) diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/cli.zos-jobs.cancel.job.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/cancel/cli.zos-jobs.cancel.job.system.test.ts index 06bc908393..9d9f82b0ab 100644 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/cli.zos-jobs.cancel.job.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/cli.zos-jobs.cancel.job.system.test.ts @@ -21,6 +21,7 @@ let TEST_ENVIRONMENT: ITestEnvironment; const LOCAL_JCL_FILE: string = __dirname + "/" + "testFileOfLocalJCL.txt"; const jobDataRegexV1 = /Successfully submitted request to cancel job (\w+) \((JOB\d+)\)/; const jobDataRegex = /Successfully canceled job (\w+) \((JOB\d+)\)/; +const modifyVersionDefaultUsesCIM = false; describe("zos-jobs cancel job command", () => { // Create the unique test environment @@ -73,13 +74,17 @@ describe("zos-jobs cancel job command", () => { describe("successful scenario", () => { it("should cancel a job v1", () => { - const response = runCliScript(__dirname + "/__scripts__/job/cancel_job_v1.sh", TEST_ENVIRONMENT, [LOCAL_JCL_FILE]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("Successfully submitted request to cancel job"); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/job/cancel_job_v1.sh", TEST_ENVIRONMENT, [LOCAL_JCL_FILE]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Successfully submitted request to cancel job"); - const jobid = response.stdout.toString().match(jobDataRegexV1).pop(); - TEST_ENVIRONMENT.resources.jobs.push(jobid); + const jobid = response.stdout.toString().match(jobDataRegexV1).pop(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); + } }); it("should cancel a job v2", () => { @@ -94,15 +99,19 @@ describe("zos-jobs cancel job command", () => { }); it("should cancel a job default", () => { - const response = runCliScript(__dirname + "/__scripts__/job/cancel_job.sh", TEST_ENVIRONMENT, [LOCAL_JCL_FILE]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("Successfully canceled job"); - expect(response.stdout.toString()).not.toContain("Failed to cancel job"); - expect(response.stdout.toString()).not.toContain("Failed to cancel job"); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/job/cancel_job.sh", TEST_ENVIRONMENT, [LOCAL_JCL_FILE]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Successfully canceled job"); + expect(response.stdout.toString()).not.toContain("Failed to cancel job"); + expect(response.stdout.toString()).not.toContain("Failed to cancel job"); - const jobid = response.stdout.toString().match(jobDataRegex).pop(); - TEST_ENVIRONMENT.resources.jobs.push(jobid); + const jobid = response.stdout.toString().match(jobDataRegex).pop(); + TEST_ENVIRONMENT.resources.jobs.push(jobid); + } }); describe("without profiles", () => { @@ -124,21 +133,25 @@ describe("zos-jobs cancel job command", () => { }); it("cancel a job without a profile 1.0", async () => { - const response = runCliScript(__dirname + "/__scripts__/job/cancel_job_v1_fully_qualified.sh", - TEST_ENVIRONMENT_NO_PROF, - [ - LOCAL_JCL_FILE, - DEFAULT_SYSTEM_PROPS.zosmf.host, - DEFAULT_SYSTEM_PROPS.zosmf.port, - DEFAULT_SYSTEM_PROPS.zosmf.user, - DEFAULT_SYSTEM_PROPS.zosmf.password, - ]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("Successfully submitted request to cancel job"); - - const jobid = response.stdout.toString().match(jobDataRegexV1).pop(); - TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(jobid); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/job/cancel_job_v1_fully_qualified.sh", + TEST_ENVIRONMENT_NO_PROF, + [ + LOCAL_JCL_FILE, + DEFAULT_SYSTEM_PROPS.zosmf.host, + DEFAULT_SYSTEM_PROPS.zosmf.port, + DEFAULT_SYSTEM_PROPS.zosmf.user, + DEFAULT_SYSTEM_PROPS.zosmf.password, + ]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Successfully submitted request to cancel job"); + + const jobid = response.stdout.toString().match(jobDataRegexV1).pop(); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(jobid); + } }); it("cancel a job without a profile 2.0", async () => { @@ -160,21 +173,25 @@ describe("zos-jobs cancel job command", () => { }); it("cancel a job without a profile default", async () => { - const response = runCliScript(__dirname + "/__scripts__/job/cancel_job_fully_qualified.sh", - TEST_ENVIRONMENT_NO_PROF, - [ - LOCAL_JCL_FILE, - DEFAULT_SYSTEM_PROPS.zosmf.host, - DEFAULT_SYSTEM_PROPS.zosmf.port, - DEFAULT_SYSTEM_PROPS.zosmf.user, - DEFAULT_SYSTEM_PROPS.zosmf.password, - ]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("Successfully canceled job"); - - const jobid = response.stdout.toString().match(jobDataRegex).pop(); - TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(jobid); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/job/cancel_job_fully_qualified.sh", + TEST_ENVIRONMENT_NO_PROF, + [ + LOCAL_JCL_FILE, + DEFAULT_SYSTEM_PROPS.zosmf.host, + DEFAULT_SYSTEM_PROPS.zosmf.port, + DEFAULT_SYSTEM_PROPS.zosmf.user, + DEFAULT_SYSTEM_PROPS.zosmf.password, + ]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Successfully canceled job"); + + const jobid = response.stdout.toString().match(jobDataRegex).pop(); + TEST_ENVIRONMENT_NO_PROF.resources.jobs.push(jobid); + } }); }); }); diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.job.system.test.ts b/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.job.system.test.ts index e34559b5fe..12d55be2bc 100644 --- a/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.job.system.test.ts +++ b/packages/cli/__tests__/zosjobs/__system__/delete/cli.zos-jobs.delete.job.system.test.ts @@ -17,6 +17,7 @@ import { ITestPropertiesSchema } from "../../../../../../__tests__/__src__/prope // Test Environment populated in the beforeAll(); let TEST_ENVIRONMENT: ITestEnvironment; let IEFBR14_JCL: string; +const modifyVersionDefaultUsesCIM = false; describe("zos-jobs delete job command", () => { // Create the unique test environment @@ -41,11 +42,15 @@ describe("zos-jobs delete job command", () => { describe("successful scenario", () => { it("should delete a job 1.0", () => { - const response = runCliScript(__dirname + "/__scripts__/job/delete_job_v1.sh", - TEST_ENVIRONMENT, [IEFBR14_JCL]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("Successfully submitted request to delete job"); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/job/delete_job_v1.sh", + TEST_ENVIRONMENT, [IEFBR14_JCL]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Successfully submitted request to delete job"); + } }); it("should delete a job 2.0", () => { @@ -57,11 +62,15 @@ describe("zos-jobs delete job command", () => { }); it("should delete a job default", () => { - const response = runCliScript(__dirname + "/__scripts__/job/delete_job.sh", - TEST_ENVIRONMENT, [IEFBR14_JCL]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("Successfully deleted job"); + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const response = runCliScript(__dirname + "/__scripts__/job/delete_job.sh", + TEST_ENVIRONMENT, [IEFBR14_JCL]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Successfully deleted job"); + } }); describe("without profiles", () => { @@ -83,26 +92,30 @@ describe("zos-jobs delete job command", () => { }); it("delete a job without a profile 1.0", async () => { - const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; - - // if API Mediation layer is being used (basePath has a value) then - // set an ENVIRONMENT variable to be used by zowe. - if (DEFAULT_SYSTEM_PROPS.zosmf.basePath != null) { - TEST_ENVIRONMENT_NO_PROF.env[ZOWE_OPT_BASE_PATH] = DEFAULT_SYSTEM_PROPS.zosmf.basePath; + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; + + // if API Mediation layer is being used (basePath has a value) then + // set an ENVIRONMENT variable to be used by zowe. + if (DEFAULT_SYSTEM_PROPS.zosmf.basePath != null) { + TEST_ENVIRONMENT_NO_PROF.env[ZOWE_OPT_BASE_PATH] = DEFAULT_SYSTEM_PROPS.zosmf.basePath; + } + + const response = runCliScript(__dirname + "/__scripts__/job/delete_job_v1_fully_qualified.sh", + TEST_ENVIRONMENT_NO_PROF, + [ + IEFBR14_JCL, + DEFAULT_SYSTEM_PROPS.zosmf.host, + DEFAULT_SYSTEM_PROPS.zosmf.port, + DEFAULT_SYSTEM_PROPS.zosmf.user, + DEFAULT_SYSTEM_PROPS.zosmf.password, + ]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Successfully submitted request to delete job"); } - - const response = runCliScript(__dirname + "/__scripts__/job/delete_job_v1_fully_qualified.sh", - TEST_ENVIRONMENT_NO_PROF, - [ - IEFBR14_JCL, - DEFAULT_SYSTEM_PROPS.zosmf.host, - DEFAULT_SYSTEM_PROPS.zosmf.port, - DEFAULT_SYSTEM_PROPS.zosmf.user, - DEFAULT_SYSTEM_PROPS.zosmf.password, - ]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("Successfully submitted request to delete job"); }); it("delete a job without a profile 2.0", async () => { @@ -129,26 +142,30 @@ describe("zos-jobs delete job command", () => { }); it("delete a job without a profile default", async () => { - const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; - - // if API Mediation layer is being used (basePath has a value) then - // set an ENVIRONMENT variable to be used by zowe. - if (DEFAULT_SYSTEM_PROPS.zosmf.basePath != null) { - TEST_ENVIRONMENT_NO_PROF.env[ZOWE_OPT_BASE_PATH] = DEFAULT_SYSTEM_PROPS.zosmf.basePath; + if (TEST_ENVIRONMENT.systemTestProperties.zosjobs.skipCIM && modifyVersionDefaultUsesCIM) { + process.stdout.write("Skipping test because skipCIM is set."); + } else { + const ZOWE_OPT_BASE_PATH = "ZOWE_OPT_BASE_PATH"; + + // if API Mediation layer is being used (basePath has a value) then + // set an ENVIRONMENT variable to be used by zowe. + if (DEFAULT_SYSTEM_PROPS.zosmf.basePath != null) { + TEST_ENVIRONMENT_NO_PROF.env[ZOWE_OPT_BASE_PATH] = DEFAULT_SYSTEM_PROPS.zosmf.basePath; + } + + const response = runCliScript(__dirname + "/__scripts__/job/delete_job_fully_qualified.sh", + TEST_ENVIRONMENT_NO_PROF, + [ + IEFBR14_JCL, + DEFAULT_SYSTEM_PROPS.zosmf.host, + DEFAULT_SYSTEM_PROPS.zosmf.port, + DEFAULT_SYSTEM_PROPS.zosmf.user, + DEFAULT_SYSTEM_PROPS.zosmf.password, + ]); + expect(response.stderr.toString()).toBe(""); + expect(response.status).toBe(0); + expect(response.stdout.toString()).toContain("Successfully deleted job"); } - - const response = runCliScript(__dirname + "/__scripts__/job/delete_job_fully_qualified.sh", - TEST_ENVIRONMENT_NO_PROF, - [ - IEFBR14_JCL, - DEFAULT_SYSTEM_PROPS.zosmf.host, - DEFAULT_SYSTEM_PROPS.zosmf.port, - DEFAULT_SYSTEM_PROPS.zosmf.user, - DEFAULT_SYSTEM_PROPS.zosmf.password, - ]); - expect(response.stderr.toString()).toBe(""); - expect(response.status).toBe(0); - expect(response.stdout.toString()).toContain("Successfully deleted job"); }); }); }); From 5f8c518174c6d245767b3cfc6040a932dc931ba2 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 16:00:34 -0400 Subject: [PATCH 092/106] Add timeout tests Signed-off-by: Andrew W. Harn --- .../__tests__/__system__/methods/CheckStatus.system.test.ts | 2 +- .../__system__/methods/ListDefinedSystems.system.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zosmf/__tests__/__system__/methods/CheckStatus.system.test.ts b/packages/zosmf/__tests__/__system__/methods/CheckStatus.system.test.ts index 5c0f79f376..2054077af1 100644 --- a/packages/zosmf/__tests__/__system__/methods/CheckStatus.system.test.ts +++ b/packages/zosmf/__tests__/__system__/methods/CheckStatus.system.test.ts @@ -125,6 +125,6 @@ describe("Check Status Api", () => { expect(jsonCauseErrors.code).toMatch(/(ECONNREFUSED|ECONNRESET|ETIMEDOUT)/); expect(jsonCauseErrors.syscall).toEqual("connect"); expect(jsonCauseErrors.port).toEqual(badPort); - }); + }, 300000); }); }); diff --git a/packages/zosmf/__tests__/__system__/methods/ListDefinedSystems.system.test.ts b/packages/zosmf/__tests__/__system__/methods/ListDefinedSystems.system.test.ts index 294d6895ab..a855091dae 100644 --- a/packages/zosmf/__tests__/__system__/methods/ListDefinedSystems.system.test.ts +++ b/packages/zosmf/__tests__/__system__/methods/ListDefinedSystems.system.test.ts @@ -124,6 +124,6 @@ describe("List Defined Systems Api", () => { const jsonCauseErrors = error.causeErrors; expect(jsonCauseErrors.code).toMatch(/(ECONNREFUSED|ECONNRESET|ETIMEDOUT)/); expect(jsonCauseErrors.syscall).toMatch(/(connect|read)/); - }); + }, 300000); }); }); From dd99b92c13f9ffcdced65e37e96c139d0bb0b086 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 16:00:59 -0400 Subject: [PATCH 093/106] Fix lint error Signed-off-by: Andrew W. Harn --- .../src/rest/__tests__/client/AbstractRestClient.unit.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts b/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts index d81ea50636..24249d7f0c 100644 --- a/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts +++ b/packages/imperative/src/rest/__tests__/client/AbstractRestClient.unit.test.ts @@ -436,7 +436,7 @@ describe("AbstractRestClient tests", () => { let reusedSocket = true; const requestFnc = jest.fn((options, callback) => { - let emitter = new MockHttpRequestResponse(); + const emitter = new MockHttpRequestResponse(); ProcessUtils.nextTick(() => { callback(emitter); From e56c96217e132551e088a0bb32a7d8551ed6206f Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 16:01:25 -0400 Subject: [PATCH 094/106] Fix Logs error (#2336) Signed-off-by: Andrew W. Harn --- packages/cli/src/zoslogs/list/logs/Logs.handler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/zoslogs/list/logs/Logs.handler.ts b/packages/cli/src/zoslogs/list/logs/Logs.handler.ts index 4ff94a9b3c..66c4e504e3 100644 --- a/packages/cli/src/zoslogs/list/logs/Logs.handler.ts +++ b/packages/cli/src/zoslogs/list/logs/Logs.handler.ts @@ -22,7 +22,8 @@ export default class LogsHandler extends ZosmfBaseHandler { public async processCmd(commandParameters: IHandlerParameters) { const outputHeader = "Retrieved %s messages from %s, starts from %s, ends at %s. "; - let startTime = new Date().toISOString(); + let startTime: any; + const startDate = new Date().toISOString(); if (commandParameters.arguments.startTime !== undefined) { startTime = commandParameters.arguments.startTime; // in case the input is milliseconds format, which is a long number @@ -39,6 +40,7 @@ export default class LogsHandler extends ZosmfBaseHandler { try{ const resp: IZosLogType = await GetZosLog.getZosLog(this.mSession, zosLogParms); + if (startTime == null) { startTime = startDate; } const logItems: Array = resp.items; if (logItems === undefined || logItems.length === 0) { From 0326f8b50bae92271f3a289fb6ef2e2b3b04b1a6 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Wed, 30 Oct 2024 16:16:39 -0400 Subject: [PATCH 095/106] Add a sleep for fast running systems Signed-off-by: Andrew W. Harn --- .../list-jobs/submit_and_list_jobs_fully_qualified.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh index 922016bd87..a8cf9c24ba 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh @@ -11,6 +11,7 @@ PASS=$5 JOBID1=`zowe zos-jobs submit data-set $JCL --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff jobid --rft string` JOBID2=`zowe zos-jobs submit data-set $JCL --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff jobid --rft string` +sleep 1 echo "Listing jobs to find job IDs $JOBID1 and $JOBID2" LIST_JOB_OUTPUT=`zowe zos-jobs list jobs --host $HOST --port $PORT --user $USER --password $PASS --ru=false` From bd2ccd40fd6d63ad6736f14aff5ca8766da35b7d Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Thu, 31 Oct 2024 11:47:55 -0400 Subject: [PATCH 096/106] Fix Issue Tso issue Signed-off-by: Andrew W. Harn --- 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 48f3d3ce6a..ad417afce5 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -72,7 +72,7 @@ export class IssueTso { }; return response; } catch (e) { - if (e.mMessage.includes("status 404")) { + if (e.mMessage?.includes("status 404")) { // Set useNewApi to false to handle fallback logic useNewApi = false; } else { From 5068ade390275512ab822451d386dbd0ab0b82dc Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Thu, 31 Oct 2024 11:51:08 -0400 Subject: [PATCH 097/106] Replace mMessage with message Signed-off-by: Andrew W. Harn --- 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 ad417afce5..2fd0d5e26d 100644 --- a/packages/zostso/src/IssueTso.ts +++ b/packages/zostso/src/IssueTso.ts @@ -72,7 +72,7 @@ export class IssueTso { }; return response; } catch (e) { - if (e.mMessage?.includes("status 404")) { + if (e.message?.includes("status 404")) { // Set useNewApi to false to handle fallback logic useNewApi = false; } else { From 06b65091798928b222ec1ebd07d48eac75625dd7 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Thu, 31 Oct 2024 14:31:33 -0400 Subject: [PATCH 098/106] Fix small timing issues Signed-off-by: Andrew W. Harn --- .../cancel/__scripts__/job/cancel_job_fully_qualified.sh | 2 ++ .../list/__scripts__/list-jobs/submit_and_list_jobs.sh | 2 ++ .../__tests__/__system__/ModifyJobs.system.test.ts | 9 +++++++++ .../__tests__/__system__/MonitorJobs.system.test.ts | 8 +++----- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_fully_qualified.sh index a192432415..66e33b592f 100755 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_fully_qualified.sh @@ -22,6 +22,8 @@ then exit $RC fi +sleep 1 + # Cancel the job zowe jobs cancel job $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh index fc6f6e9979..ae162ab180 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh @@ -3,10 +3,12 @@ set -e # Submit two jobs and capture their IDs JOBID1=`zowe zos-jobs submit data-set $1 --rff jobid --rft string` +sleep 1 JOBID2=`zowe zos-jobs submit data-set $1 --rff jobid --rft string` echo "Listing jobs to find job IDs $JOBID1 and $JOBID2" +sleep 1 LIST_JOB_OUTPUT=`zowe zos-jobs list jobs` if echo $LIST_JOB_OUTPUT | grep -q $JOBID1 then diff --git a/packages/zosjobs/__tests__/__system__/ModifyJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/ModifyJobs.system.test.ts index 2ccc7fff18..407b9aefc4 100644 --- a/packages/zosjobs/__tests__/__system__/ModifyJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/ModifyJobs.system.test.ts @@ -15,6 +15,7 @@ import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITes import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { JobTestsUtils } from "./JobTestsUtils"; +import { wait } from "../../../../__tests__/__src__/TestUtils"; let testEnvironment: ITestEnvironment; let systemProps: ITestPropertiesSchema; @@ -47,6 +48,10 @@ describe("Modify Jobs - System Tests", () => { await TestEnvironment.cleanUp(testEnvironment); }); + beforeEach(async () => { + await wait(1000); + }); + describe("Positive tests", () => { it("should return a success message once jobclass has been modified", async () => { const job: any = await ModifyJobs.modifyJobCommon( @@ -120,6 +125,10 @@ describe("Modify Jobs - System Tests - Encoded", () => { await TestEnvironment.cleanUp(testEnvironment); }); + beforeEach(async () => { + await wait(1000); + }); + describe("Positive tests", () => { it("should return a success message once jobclass has been modified", async () => { const job: any = await ModifyJobs.modifyJobCommon( diff --git a/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts index 5ba150128f..ad44714e69 100644 --- a/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts @@ -18,6 +18,7 @@ import { ZosmfRestClient } from "@zowe/core-for-zowe-sdk"; import { TestEnvironment } from "../../../../__tests__/__src__/environment/TestEnvironment"; import { ITestPropertiesSchema } from "../../../../__tests__/__src__/properties/ITestPropertiesSchema"; import { ITestEnvironment } from "../../../../__tests__/__src__/environment/ITestEnvironment"; +import { wait } from "../../../../__tests__/__src__/TestUtils"; // long running test timeout const LONG_TIMEOUT = 100000; @@ -45,6 +46,7 @@ let MONITOR_JOB_NAME: string; // Utility function to cleanup async function cleanTestJobs() { // The tests may submit jobs - we will clean every job that may have been left by failures, etc. + await wait(1000); // Wait for jobs to register in z/OSMF const jobs: IJob[] = await GetJobs.getJobsCommon(REAL_SESSION, {owner: REAL_SESSION.ISession.user, prefix: MONITOR_JOB_NAME}); if (jobs.length > 0) { for (const job of jobs) { @@ -89,12 +91,8 @@ describe.each([false, true])("System Tests - Monitor Jobs - Encoded: %s", (encod SYSAFF = testEnvironment.systemTestProperties.zosjobs.sysaff; }); - // Cleanup before & after each test - this will ensure that hopefully no jobs are left outstanding (or are currently + // Cleanup after each test - this will ensure that hopefully no jobs are left outstanding (or are currently // outstanding) when the tests run - beforeEach(async () => { - GetJobs.getStatusCommon = ORIG_JOBS_STATUS; - await cleanTestJobs(); - }); afterEach(async () => { GetJobs.getStatusCommon = ORIG_JOBS_STATUS; await cleanTestJobs(); From 45e1e65b60ad6c01764a49edbf6f49c34c5f6694 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Thu, 31 Oct 2024 16:11:38 -0400 Subject: [PATCH 099/106] Fix more timing issues & logic errors Signed-off-by: Andrew W. Harn --- .../zosjobs/__system__/cancel/__scripts__/job/cancel_job.sh | 2 ++ .../__system__/cancel/__scripts__/job/cancel_job_v1.sh | 2 ++ .../cancel/__scripts__/job/cancel_job_v1_fully_qualified.sh | 2 ++ .../__system__/cancel/__scripts__/job/cancel_job_v2.sh | 2 ++ .../__system__/cancel/__scripts__/job/cancel_job_v2_bad.sh | 4 ++++ .../cancel/__scripts__/job/cancel_job_v2_fully_qualified.sh | 2 ++ .../zosjobs/__system__/delete/__scripts__/job/delete_job.sh | 2 +- .../delete/__scripts__/job/delete_job_fully_qualified.sh | 2 +- .../__system__/delete/__scripts__/job/delete_job_v1.sh | 2 +- .../delete/__scripts__/job/delete_job_v1_fully_qualified.sh | 2 +- .../__system__/delete/__scripts__/job/delete_job_v2.sh | 2 +- .../delete/__scripts__/job/delete_job_v2_fully_qualified.sh | 2 +- .../__system__/delete/__scripts__/old-jobs/delete_old_jobs.sh | 2 +- .../download/__scripts__/download-output/download.sh | 2 +- .../__scripts__/download-output/download_fully_qualified.sh | 2 +- .../list/__scripts__/list-jobs/submit_and_list_jobs.sh | 1 + .../list-jobs/submit_and_list_jobs_fully_qualified.sh | 2 ++ .../__scripts__/all-spool-content/get_all_spool_content.sh | 2 +- 18 files changed, 27 insertions(+), 10 deletions(-) diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job.sh b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job.sh index d3632092d7..9e11ffd46b 100755 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job.sh +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job.sh @@ -16,6 +16,8 @@ then exit $RC fi +sleep 1 + # Cancel the job zowe jobs cancel job $JOBID RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v1.sh b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v1.sh index 3c21f25e03..1f08c8455b 100755 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v1.sh +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v1.sh @@ -16,6 +16,8 @@ then exit $RC fi +sleep 1 + # Cancel the job 1 zowe jobs cancel job $JOBID --modify-version 1.0 RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v1_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v1_fully_qualified.sh index a9d11afbe5..0a062d6d82 100755 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v1_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v1_fully_qualified.sh @@ -22,6 +22,8 @@ then exit $RC fi +sleep 1 + # Cancel the job zowe jobs cancel job $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false --modify-version 1.0 RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2.sh b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2.sh index d5abaaaee2..0c1170f4fe 100755 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2.sh +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2.sh @@ -16,6 +16,8 @@ then exit $RC fi +sleep 1 + # Cancel the job 1 zowe jobs cancel job $JOBID --modify-version 2.0 RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2_bad.sh b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2_bad.sh index c3165a9047..c87f49179f 100755 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2_bad.sh +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2_bad.sh @@ -16,6 +16,8 @@ then exit $RC fi +sleep 1 + # Cancel the job 1 zowe jobs cancel job $JOBID --modify-version 2.0 RC=$? @@ -26,6 +28,8 @@ then exit $RC fi +sleep 1 + # Cancel the job 2 zowe jobs cancel job $JOBID --modify-version 2.0 RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2_fully_qualified.sh index 3a0d1b7177..5f1f40917d 100755 --- a/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/cancel/__scripts__/job/cancel_job_v2_fully_qualified.sh @@ -22,6 +22,8 @@ then exit $RC fi +sleep 1 + # Cancel the job zowe jobs cancel job $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false --modify-version 2.0 RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job.sh b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job.sh index e560bfdadf..a8d234d19d 100755 --- a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job.sh +++ b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job.sh @@ -17,7 +17,7 @@ then fi # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_fully_qualified.sh index 2642614827..40477cafd7 100755 --- a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_fully_qualified.sh @@ -23,7 +23,7 @@ then fi # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v1.sh b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v1.sh index 5142e33080..9fad992df1 100755 --- a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v1.sh +++ b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v1.sh @@ -17,7 +17,7 @@ then fi # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v1_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v1_fully_qualified.sh index ddb46643a3..5041a60c53 100755 --- a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v1_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v1_fully_qualified.sh @@ -23,7 +23,7 @@ then fi # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v2.sh b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v2.sh index b8a80a8af4..0887eab49a 100755 --- a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v2.sh +++ b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v2.sh @@ -17,7 +17,7 @@ then fi # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v2_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v2_fully_qualified.sh index e8f114b68c..f10be13a6f 100755 --- a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v2_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/job/delete_job_v2_fully_qualified.sh @@ -23,7 +23,7 @@ then fi # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/old-jobs/delete_old_jobs.sh b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/old-jobs/delete_old_jobs.sh index 6946cc549d..e165a2fb02 100755 --- a/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/old-jobs/delete_old_jobs.sh +++ b/packages/cli/__tests__/zosjobs/__system__/delete/__scripts__/old-jobs/delete_old_jobs.sh @@ -18,7 +18,7 @@ then fi # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download.sh b/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download.sh index 8563a01a94..0ccea48361 100755 --- a/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download.sh +++ b/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download.sh @@ -20,7 +20,7 @@ fi echo "Submitted job ID: $JOBID" # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download_fully_qualified.sh index cb7def1726..534394bf09 100755 --- a/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/download/__scripts__/download-output/download_fully_qualified.sh @@ -26,7 +26,7 @@ fi echo "Submitted job ID: $JOBID" # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe jobs view job-status-by-jobid $JOBID --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff status --rft string` RC=$? diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh index ae162ab180..bff24c1186 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs.sh @@ -9,6 +9,7 @@ JOBID2=`zowe zos-jobs submit data-set $1 --rff jobid --rft string` echo "Listing jobs to find job IDs $JOBID1 and $JOBID2" sleep 1 + LIST_JOB_OUTPUT=`zowe zos-jobs list jobs` if echo $LIST_JOB_OUTPUT | grep -q $JOBID1 then diff --git a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh index a8cf9c24ba..1c05c40b9c 100755 --- a/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh +++ b/packages/cli/__tests__/zosjobs/__system__/list/__scripts__/list-jobs/submit_and_list_jobs_fully_qualified.sh @@ -9,9 +9,11 @@ PASS=$5 # Submit two jobs and capture their IDs JOBID1=`zowe zos-jobs submit data-set $JCL --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff jobid --rft string` +sleep 1 JOBID2=`zowe zos-jobs submit data-set $JCL --host $HOST --port $PORT --user $USER --password $PASS --ru=false --rff jobid --rft string` sleep 1 + echo "Listing jobs to find job IDs $JOBID1 and $JOBID2" LIST_JOB_OUTPUT=`zowe zos-jobs list jobs --host $HOST --port $PORT --user $USER --password $PASS --ru=false` diff --git a/packages/cli/__tests__/zosjobs/__system__/view/__scripts__/all-spool-content/get_all_spool_content.sh b/packages/cli/__tests__/zosjobs/__system__/view/__scripts__/all-spool-content/get_all_spool_content.sh index f60e02909b..0cfed87ae2 100755 --- a/packages/cli/__tests__/zosjobs/__system__/view/__scripts__/all-spool-content/get_all_spool_content.sh +++ b/packages/cli/__tests__/zosjobs/__system__/view/__scripts__/all-spool-content/get_all_spool_content.sh @@ -17,7 +17,7 @@ then fi # Loop until the job goes to the output queue -until [ $ATTEMPTS -gt 0 ] +until [ $ATTEMPTS -lt 1 ] do STATUS=`zowe zos-jobs view job-status-by-jobid $JOBID --rff status --rft string` RC=$? From 93a851428a597011c657e86148568ce3c9ef528a Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Thu, 31 Oct 2024 16:22:59 -0400 Subject: [PATCH 100/106] Update changelogs Signed-off-by: Andrew W. Harn --- packages/cli/CHANGELOG.md | 4 ++++ packages/imperative/CHANGELOG.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 2c571c6f39..979c731153 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to the Zowe CLI package will be documented in this file. +## Recent Changes + +- BugFix: Fixed an issue where the `zowe zos-logs list logs` command could fail or not return all logs if a start time was not supplied. [#2336](https://github.com/zowe/zowe-cli/pull/2336) + ## `8.4.0` - Enhancement: Added optional `--attributes` flag to `zowe zos-files upload file-to-uss` to allow passing a .zosattributes file path for upload encoding format. [#2319] (https://github.com/zowe/zowe-cli/pull/2319) diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 090ec53b33..590109e856 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: Handled an HTTP 1.1 race condition where an SDK user may experience an ECONNRESET error if a session was reused on Node 20 and above due to HTTP Keep-Alive. [#2339](https://github.com/zowe/zowe-cli/pull/2339) + ## `8.3.1` - BugFix: Fixed an issue where the `plugins install` command could fail when installing a scoped package because scoped registry was used to fetch all dependencies. [#2317](https://github.com/zowe/zowe-cli/issues/2317) From 62a48b1fe89d2081e5c587524af981923f7b20d8 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Fri, 1 Nov 2024 08:33:04 -0400 Subject: [PATCH 101/106] Fix errors that surfaced on Jenkins Signed-off-by: Andrew W. Harn --- .../stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap | 4 ++-- .../methods/upload/__resources__/upload_file_to_uss.sh | 2 +- .../__system__/methods/upload/__resources__/view_file_uss.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/__tests__/zostso/__system__/stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap b/packages/cli/__tests__/zostso/__system__/stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap index aab1477817..f536d4cdf8 100644 --- a/packages/cli/__tests__/zostso/__system__/stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap +++ b/packages/cli/__tests__/zostso/__system__/stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap @@ -5,7 +5,7 @@ exports[`zos-tso stop should fail with invalid option 1`] = ` Unknown arguments: foo-bar, fooBar Command failed due to improper syntax Command entered: \\"zos-tso start as --foo-bar\\" -Available commands are \\"address-space\\". +Available commands are \\"address-space, app\\". Use \\"zowe zos-tso start --help\\" to view groups, commands, and options. Response From Service @@ -28,7 +28,7 @@ Command failed due to improper syntax Did you mean: zos-tso stop as? Command entered: \\"zos-tso stop foobar\\" -Available commands are \\"address-space\\". +Available commands are \\"address-space, app\\". Use \\"zowe zos-tso stop --help\\" to view groups, commands, and options. Response From Service diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/upload_file_to_uss.sh b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/upload_file_to_uss.sh index ae60e4afa2..c09803cce6 100755 --- a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/upload_file_to_uss.sh +++ b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/upload_file_to_uss.sh @@ -9,5 +9,5 @@ inputFile=$7 ussName=$8 attributes=$9 -zowe zos-files upload file-to-uss $inputFile $ussName --attributes $attributes --host $host --port $port --user $user --password $password --ru $ru +zowe zos-files upload file-to-uss "$inputFile" "$ussName" --attributes "$attributes" --host $host --port $port --user $user --password $password --ru $ru exit $? \ No newline at end of file diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh index a1356ff9bf..bfa85f180b 100755 --- a/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh +++ b/packages/zosfiles/__tests__/__system__/methods/upload/__resources__/view_file_uss.sh @@ -8,5 +8,5 @@ ru=$6 ussName=$7 encoding=$8 -zowe zos-files view uf $ussName --encoding $encoding --host $host --port $port --user $user --password $password --ru $ru +zowe zos-files view uf "$ussName" --encoding $encoding --host $host --port $port --user $user --password $password --ru $ru exit $? \ No newline at end of file From 356d2777bb4d202cf4ecd1dc339ae53545c4c870 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Fri, 1 Nov 2024 08:46:18 -0400 Subject: [PATCH 102/106] Update defaults to prevent breakage Signed-off-by: Andrew W. Harn --- __tests__/__resources__/properties/default_properties.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/__resources__/properties/default_properties.yaml b/__tests__/__resources__/properties/default_properties.yaml index a3c570b6bc..21fc02313f 100644 --- a/__tests__/__resources__/properties/default_properties.yaml +++ b/__tests__/__resources__/properties/default_properties.yaml @@ -105,7 +105,7 @@ zosjobs: # System affinity sysaff: zosjobs-sysaff # CIM Support - skipCIM: cim-skipped + skipCIM: false #-----------------------------------------------------------------------------# # Set of properties for testing provisioning # #-----------------------------------------------------------------------------# From b3dda5190499ec71c34f538e354f405ca310e9bf Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Fri, 1 Nov 2024 10:29:26 -0400 Subject: [PATCH 103/106] Resolve some TSO system test timing issues Signed-off-by: Andrew W. Harn --- .../__system__/api.TsoASApp.system.test.ts | 76 +++++++++---------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts index 849a4ee778..3fd55b14d4 100644 --- a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts @@ -47,7 +47,7 @@ describe("All test", () => { it("should create TSO address space and run an application instance at the created AS", async () => { let error: ImperativeError; - const response = await runCliScript( + const response = runCliScript( __dirname + "/__scripts__/start/start_app_new_as.sh", testEnvironment, [ @@ -65,24 +65,13 @@ describe("All test", () => { expect(response.stdout.toString()).toContain( "HELLOW exec processing has started" ); - expect(response.stdout.toString()).toContain( - "UNIX message queue id = " - ); - expect(response.stdout.toString()).toContain( - "Input message type = " - ); - expect(response.stdout.toString()).toContain( - "Output message type = " - ); - expect(response.stdout.toString()).toContain( - "Reading application input from the UNIX message queue." - ); expect(error).toBeUndefined(); await StopTso.stop( REAL_SESSION, JSON.parse(response.stdout.toString()).servletKey ); }); + it("should create TSO application instance on existing address space", async () => { dsname = getUniqueDatasetName(`${defaultSystem.zosmf.user}.ZOSTEST`); await Create.dataSet(REAL_SESSION, CreateDataSetTypeEnum.DATA_SET_PARTITIONED, dsname); @@ -100,7 +89,7 @@ describe("All test", () => { stopResponse: null, }; - const response = await runCliScript( + const response = runCliScript( __dirname + "/__scripts__/start/start_app_existing_as.sh", testEnvironment, [ @@ -119,18 +108,6 @@ describe("All test", () => { expect(response.stdout.toString()).toContain( "HELLOW exec processing has started" ); - expect(response.stdout.toString()).toContain( - "UNIX message queue id = " - ); - expect(response.stdout.toString()).toContain( - "Input message type = " - ); - expect(response.stdout.toString()).toContain( - "Output message type = " - ); - expect(response.stdout.toString()).toContain( - "Reading application input from the UNIX message queue." - ); //Clean up test await StopTso.stop( @@ -141,7 +118,7 @@ describe("All test", () => { }); describe("Send TSO app tests", () => { it("Should send message to TSO address space app", async () => { - const startResponse = await runCliScript( + const startResponse = runCliScript( __dirname + "/__scripts__/start/start_app_new_as.sh", testEnvironment, [ @@ -154,10 +131,12 @@ describe("All test", () => { dsname+"(TESTAPP)" ] ); + const startServletkey = JSON.parse( startResponse.stdout.toString() ).servletKey; - const response = await runCliScript( + + const response = runCliScript( __dirname + "/__scripts__/send/send_tso_app.sh", testEnvironment, [ @@ -172,13 +151,30 @@ describe("All test", () => { "test2", ] ); + const response2 = runCliScript( + __dirname + "/__scripts__/receive/receive_tso_app.sh", + testEnvironment, + [ + ACCOUNT_NUMBER, + defaultSystem.zosmf.host, + defaultSystem.zosmf.port, + defaultSystem.zosmf.user, + defaultSystem.zosmf.password, + defaultSystem.zosmf.rejectUnauthorized, + startServletkey, + "test2", + "true", + ] + ); + const responses = response.stdout.toString() + response2.stdout.toString(); expect(response.stdout.toString()).toBeDefined(); - expect(response.stdout.toString()).toContain( + expect(response2.stdout.toString()).toBeDefined; + expect(responses).toContain( "Application input = LONG 100" ); - expect(response.stdout.toString()).toContain("servletKey"); - expect(response.stdout.toString()).toContain("READY "); + expect(responses).toContain("servletKey"); + expect(responses).toContain("READY "); //Clean up test await StopTso.stop(REAL_SESSION, startServletkey); @@ -186,7 +182,7 @@ describe("All test", () => { }); describe("Receive TSO app tests", () => { it("should pull from message queue but not reach the end (--no-rur)", async () => { - const startResponse = await runCliScript( + const startResponse = runCliScript( __dirname + "/__scripts__/start/start_app_new_as.sh", testEnvironment, [ @@ -202,7 +198,7 @@ describe("All test", () => { const startServletkey = JSON.parse( startResponse.stdout.toString() ).servletKey; - await runCliScript( + runCliScript( __dirname + "/__scripts__/send/send_tso_app.sh", testEnvironment, [ @@ -217,7 +213,7 @@ describe("All test", () => { "test2", ] ); - const response = await runCliScript( + const response = runCliScript( __dirname + "/__scripts__/receive/receive_tso_app.sh", testEnvironment, [ @@ -232,16 +228,14 @@ describe("All test", () => { "false", ] ); - expect(response.stdout.toString()).toContain("999"); - expect(response.stdout.toString()).toContain("1000"); - expect(response.stdout.toString()).toContain("1001"); - expect(response.stdout.toString()).not.toContain("4000"); + expect(response.stdout.toString()).toContain("1"); + expect(response.stdout.toString()).not.toContain("3999"); //Clean up test await StopTso.stop(REAL_SESSION, startServletkey); }); it("should empty message queue using --rur flag", async () => { - const startResponse = await runCliScript( + const startResponse = runCliScript( __dirname + "/__scripts__/start/start_app_new_as.sh", testEnvironment, [ @@ -257,7 +251,7 @@ describe("All test", () => { const startServletkey = JSON.parse( startResponse.stdout.toString() ).servletKey; - await runCliScript( + runCliScript( __dirname + "/__scripts__/send/send_tso_app.sh", testEnvironment, [ @@ -272,7 +266,7 @@ describe("All test", () => { "test2", ] ); - const response = await runCliScript( + const response = runCliScript( __dirname + "/__scripts__/receive/receive_tso_app.sh", testEnvironment, [ From d37d43126d8e16a721273fb6195d6c4acee2cfbf Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Fri, 1 Nov 2024 10:32:58 -0400 Subject: [PATCH 104/106] Fix test Signed-off-by: Andrew W. Harn --- .../zostso/__tests__/__system__/api.TsoASApp.system.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts index 3fd55b14d4..199725d1a8 100644 --- a/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts +++ b/packages/zostso/__tests__/__system__/api.TsoASApp.system.test.ts @@ -169,7 +169,7 @@ describe("All test", () => { const responses = response.stdout.toString() + response2.stdout.toString(); expect(response.stdout.toString()).toBeDefined(); - expect(response2.stdout.toString()).toBeDefined; + expect(response2.stdout.toString()).toBeDefined(); expect(responses).toContain( "Application input = LONG 100" ); From dbe3e4af01df969e9b807e9a28b561abfe17fe28 Mon Sep 17 00:00:00 2001 From: "Andrew W. Harn" Date: Fri, 1 Nov 2024 10:47:39 -0400 Subject: [PATCH 105/106] Fix system test snapshot Signed-off-by: Andrew W. Harn --- .../stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/__tests__/zostso/__system__/stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap b/packages/cli/__tests__/zostso/__system__/stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap index f536d4cdf8..fc29854daa 100644 --- a/packages/cli/__tests__/zostso/__system__/stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap +++ b/packages/cli/__tests__/zostso/__system__/stop/__snapshots__/cli.zos-tso.stop.system.test.ts.snap @@ -28,7 +28,7 @@ Command failed due to improper syntax Did you mean: zos-tso stop as? Command entered: \\"zos-tso stop foobar\\" -Available commands are \\"address-space, app\\". +Available commands are \\"address-space\\". Use \\"zowe zos-tso stop --help\\" to view groups, commands, and options. Response From Service From 1d2cdc9207d545bd6b860fbd06a6a6d9e86ba875 Mon Sep 17 00:00:00 2001 From: zowe-robot Date: Fri, 1 Nov 2024 17:28:46 +0000 Subject: [PATCH 106/106] Bump version to 8.6.1 [ci skip] Signed-off-by: zowe-robot --- .../__packages__/cli-test-utils/package.json | 4 +- lerna.json | 2 +- npm-shrinkwrap.json | 116 +++++++++--------- packages/cli/CHANGELOG.md | 2 +- 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 +- 17 files changed, 119 insertions(+), 119 deletions(-) diff --git a/__tests__/__packages__/cli-test-utils/package.json b/__tests__/__packages__/cli-test-utils/package.json index b40dbc3948..40a1cfb090 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.6.0", + "version": "8.6.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.6.0" + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" diff --git a/lerna.json b/lerna.json index 5998ae5311..7d52575206 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "8.6.0", + "version": "8.6.1", "command": { "publish": { "ignoreChanges": [ diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index a5a356aef5..face8cd51d 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.6.0", + "version": "8.6.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.6.0" + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" @@ -16267,21 +16267,21 @@ }, "packages/cli": { "name": "@zowe/cli", - "version": "8.6.0", + "version": "8.6.1", "hasInstallScript": true, "license": "EPL-2.0", "dependencies": { - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0", - "@zowe/provisioning-for-zowe-sdk": "8.6.0", - "@zowe/zos-console-for-zowe-sdk": "8.6.0", - "@zowe/zos-files-for-zowe-sdk": "8.6.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.6.0", - "@zowe/zos-logs-for-zowe-sdk": "8.6.0", - "@zowe/zos-tso-for-zowe-sdk": "8.6.0", - "@zowe/zos-uss-for-zowe-sdk": "8.6.0", - "@zowe/zos-workflows-for-zowe-sdk": "8.6.0", - "@zowe/zosmf-for-zowe-sdk": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1", + "@zowe/provisioning-for-zowe-sdk": "8.6.1", + "@zowe/zos-console-for-zowe-sdk": "8.6.1", + "@zowe/zos-files-for-zowe-sdk": "8.6.1", + "@zowe/zos-jobs-for-zowe-sdk": "8.6.1", + "@zowe/zos-logs-for-zowe-sdk": "8.6.1", + "@zowe/zos-tso-for-zowe-sdk": "8.6.1", + "@zowe/zos-uss-for-zowe-sdk": "8.6.1", + "@zowe/zos-workflows-for-zowe-sdk": "8.6.1", + "@zowe/zosmf-for-zowe-sdk": "8.6.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.6.0", + "@zowe/cli-test-utils": "8.6.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.6.0", + "version": "8.6.1", "license": "EPL-2.0", "dependencies": { "comment-json": "~4.2.3", "string-width": "^4.2.3" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16369,7 +16369,7 @@ }, "packages/imperative": { "name": "@zowe/imperative", - "version": "8.6.0", + "version": "8.6.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.6.0", + "version": "8.6.1", "license": "EPL-2.0", "dependencies": { "js-yaml": "^4.1.0" }, "devDependencies": { "@types/js-yaml": "^4.0.9", - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16597,15 +16597,15 @@ }, "packages/workflows": { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.6.0" + "@zowe/zos-files-for-zowe-sdk": "8.6.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16617,12 +16617,12 @@ }, "packages/zosconsole": { "name": "@zowe/zos-console-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16634,17 +16634,17 @@ }, "packages/zosfiles": { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "license": "EPL-2.0", "dependencies": { "lodash": "^4.17.21", "minimatch": "^9.0.5" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0", - "@zowe/zos-uss-for-zowe-sdk": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1", + "@zowe/zos-uss-for-zowe-sdk": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16676,15 +16676,15 @@ }, "packages/zosjobs": { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.6.0" + "@zowe/zos-files-for-zowe-sdk": "8.6.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16696,12 +16696,12 @@ }, "packages/zoslogs": { "name": "@zowe/zos-logs-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16713,12 +16713,12 @@ }, "packages/zosmf": { "name": "@zowe/zosmf-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "license": "EPL-2.0", "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16730,15 +16730,15 @@ }, "packages/zostso": { "name": "@zowe/zos-tso-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "license": "EPL-2.0", "dependencies": { - "@zowe/zosmf-for-zowe-sdk": "8.6.0" + "@zowe/zosmf-for-zowe-sdk": "8.6.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" @@ -16750,15 +16750,15 @@ }, "packages/zosuss": { "name": "@zowe/zos-uss-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "license": "EPL-2.0", "dependencies": { "ssh2": "^1.15.0" }, "devDependencies": { "@types/ssh2": "^1.11.19", - "@zowe/cli-test-utils": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/imperative": "8.6.1" }, "engines": { "node": ">=18.12.0" diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index ff2a2cd8e9..5d1347a6bc 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to the Zowe CLI package will be documented in this file. -## Recent Changes +## `8.6.1` - BugFix: Fixed an issue where the `zowe zos-logs list logs` command could fail or not return all logs if a start time was not supplied. [#2336](https://github.com/zowe/zowe-cli/pull/2336) diff --git a/packages/cli/package.json b/packages/cli/package.json index 473f19a074..d6270f3599 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cli", - "version": "8.6.0", + "version": "8.6.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.6.0", - "@zowe/imperative": "8.6.0", - "@zowe/provisioning-for-zowe-sdk": "8.6.0", - "@zowe/zos-console-for-zowe-sdk": "8.6.0", - "@zowe/zos-files-for-zowe-sdk": "8.6.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.6.0", - "@zowe/zos-logs-for-zowe-sdk": "8.6.0", - "@zowe/zos-tso-for-zowe-sdk": "8.6.0", - "@zowe/zos-uss-for-zowe-sdk": "8.6.0", - "@zowe/zos-workflows-for-zowe-sdk": "8.6.0", - "@zowe/zosmf-for-zowe-sdk": "8.6.0", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1", + "@zowe/provisioning-for-zowe-sdk": "8.6.1", + "@zowe/zos-console-for-zowe-sdk": "8.6.1", + "@zowe/zos-files-for-zowe-sdk": "8.6.1", + "@zowe/zos-jobs-for-zowe-sdk": "8.6.1", + "@zowe/zos-logs-for-zowe-sdk": "8.6.1", + "@zowe/zos-tso-for-zowe-sdk": "8.6.1", + "@zowe/zos-uss-for-zowe-sdk": "8.6.1", + "@zowe/zos-workflows-for-zowe-sdk": "8.6.1", + "@zowe/zosmf-for-zowe-sdk": "8.6.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.6.0", + "@zowe/cli-test-utils": "8.6.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 edb95dc101..f577a2df2f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/core-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/imperative": "^8.0.0" diff --git a/packages/imperative/CHANGELOG.md b/packages/imperative/CHANGELOG.md index 590109e856..3b84440c58 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.6.1` - BugFix: Handled an HTTP 1.1 race condition where an SDK user may experience an ECONNRESET error if a session was reused on Node 20 and above due to HTTP Keep-Alive. [#2339](https://github.com/zowe/zowe-cli/pull/2339) diff --git a/packages/imperative/package.json b/packages/imperative/package.json index 907c361ab7..a0aa2979df 100644 --- a/packages/imperative/package.json +++ b/packages/imperative/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/imperative", - "version": "8.6.0", + "version": "8.6.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 8cf47f139e..5ec3550d6b 100644 --- a/packages/provisioning/package.json +++ b/packages/provisioning/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/provisioning-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/workflows/package.json b/packages/workflows/package.json index d4810ab8db..322a783c6a 100644 --- a/packages/workflows/package.json +++ b/packages/workflows/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0" + "@zowe/zos-files-for-zowe-sdk": "8.6.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosconsole/package.json b/packages/zosconsole/package.json index 1842509479..2db608eeb1 100644 --- a/packages/zosconsole/package.json +++ b/packages/zosconsole/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-console-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosfiles/package.json b/packages/zosfiles/package.json index 23cdbd9e54..e2b823ff63 100644 --- a/packages/zosfiles/package.json +++ b/packages/zosfiles/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.1", "description": "Zowe SDK to interact with files and data sets on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -50,10 +50,10 @@ "minimatch": "^9.0.5" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0", - "@zowe/zos-uss-for-zowe-sdk": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1", + "@zowe/zos-uss-for-zowe-sdk": "8.6.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosjobs/package.json b/packages/zosjobs/package.json index 6c7c787865..dd7660d7dd 100644 --- a/packages/zosjobs/package.json +++ b/packages/zosjobs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0" + "@zowe/zos-files-for-zowe-sdk": "8.6.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zoslogs/package.json b/packages/zoslogs/package.json index 1f25dd30a8..112c0bc7cb 100644 --- a/packages/zoslogs/package.json +++ b/packages/zoslogs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-logs-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosmf/package.json b/packages/zosmf/package.json index 86b5f88a9e..ef2644bfa6 100644 --- a/packages/zosmf/package.json +++ b/packages/zosmf/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zosmf-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zostso/package.json b/packages/zostso/package.json index 65d20a0763..66013cb01c 100644 --- a/packages/zostso/package.json +++ b/packages/zostso/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-tso-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0" + "@zowe/zosmf-for-zowe-sdk": "8.6.1" }, "devDependencies": { - "@zowe/cli-test-utils": "8.6.0", - "@zowe/core-for-zowe-sdk": "8.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/core-for-zowe-sdk": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/core-for-zowe-sdk": "^8.0.0", diff --git a/packages/zosuss/package.json b/packages/zosuss/package.json index 0c1cbd507d..c6a33495e4 100644 --- a/packages/zosuss/package.json +++ b/packages/zosuss/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-uss-for-zowe-sdk", - "version": "8.6.0", + "version": "8.6.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.6.0", - "@zowe/imperative": "8.6.0" + "@zowe/cli-test-utils": "8.6.1", + "@zowe/imperative": "8.6.1" }, "peerDependencies": { "@zowe/imperative": "^8.0.0"