diff --git a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts index 30d3fc0eb6..6952abcc7c 100644 --- a/__tests__/__packages__/cli-test-utils/src/TestUtils.ts +++ b/__tests__/__packages__/cli-test-utils/src/TestUtils.ts @@ -12,7 +12,7 @@ import * as fs from "fs"; import { spawnSync, SpawnSyncReturns, ExecFileException } from "child_process"; import { ITestEnvironment } from "./environment/doc/response/ITestEnvironment"; -import { CommandProfiles, ICommandDefinition, IHandlerParameters } from "@zowe/imperative"; +import { ICommandDefinition, IHandlerParameters } from "@zowe/imperative"; /** * Execute a CLI script @@ -135,8 +135,6 @@ export function mockHandlerParameters(params: PartialHandlerParameters): IHandle ...params.arguments || {} }, positionals: params.positionals || [], - // eslint-disable-next-line deprecation/deprecation - profiles: params.profiles || new CommandProfiles(new Map()), definition: params.definition, fullDefinition: params.definition, stdin: process.stdin, diff --git a/__tests__/__src__/TestConstants.ts b/__tests__/__src__/TestConstants.ts new file mode 100644 index 0000000000..e87e89998a --- /dev/null +++ b/__tests__/__src__/TestConstants.ts @@ -0,0 +1,25 @@ +/* +* 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. +* +*/ + +// Some test constants that are needed by multiple packages for unit tests + +// Mocked profile options to be added to args +export const UNIT_TEST_ZOSMF_PROF_OPTS = { + host: "somewhere.com", + port: "43443", + user: "someone", + password: "somesecret" +}; + +export const UNIT_TEST_TSO_PROF_OPTS = { + password: "fake", + account: "fake" +}; diff --git a/__tests__/__src__/mocks/ZosmfProfileMock.ts b/__tests__/__src__/mocks/ZosmfProfileMock.ts deleted file mode 100644 index 844d10a7f6..0000000000 --- a/__tests__/__src__/mocks/ZosmfProfileMock.ts +++ /dev/null @@ -1,55 +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 { IProfile, CommandProfiles } from "@zowe/imperative"; -// Some test constants that are needed by multiple packages for unit tests - -// Mocked profile options to be added to args -export const UNIT_TEST_ZOSMF_PROF_OPTS = { - host: "somewhere.com", - port: "43443", - user: "someone", - password: "somesecret" -}; - -export const UNIT_TEST_TSO_PROF_OPTS = { - password: "fake", - account: "fake" -}; - -// A mocked profile map with zosmf profile -export const UNIT_TEST_PROFILE_MAP = new Map(); -UNIT_TEST_PROFILE_MAP.set( - "zosmf", [{ - name: "zosmf", - type: "zosmf", - ...UNIT_TEST_ZOSMF_PROF_OPTS - }] -); -export const UNIT_TEST_PROFILES_ZOSMF: CommandProfiles = new CommandProfiles(UNIT_TEST_PROFILE_MAP); - -// A mocked profile map with both -export const UNIT_TEST_PROFILE_MAP_ZOSMF_TSO = new Map(); -UNIT_TEST_PROFILE_MAP_ZOSMF_TSO.set( - "zosmf", [{ - name: "zosmf", - type: "zosmf", - ...UNIT_TEST_ZOSMF_PROF_OPTS - }] -); -UNIT_TEST_PROFILE_MAP_ZOSMF_TSO.set( - "tso", [{ - name: "tso", - type: "tso", - ...UNIT_TEST_TSO_PROF_OPTS - }] -); -export const UNIT_TEST_PROFILES_ZOSMF_TSO: CommandProfiles = new CommandProfiles(UNIT_TEST_PROFILE_MAP_ZOSMF_TSO); diff --git a/packages/cli/__tests__/provisioning/__unit__/delete/instance/DeleteInstance.handler.unit.test.ts b/packages/cli/__tests__/provisioning/__unit__/delete/instance/DeleteInstance.handler.unit.test.ts index 383b7df853..a82af61b33 100644 --- a/packages/cli/__tests__/provisioning/__unit__/delete/instance/DeleteInstance.handler.unit.test.ts +++ b/packages/cli/__tests__/provisioning/__unit__/delete/instance/DeleteInstance.handler.unit.test.ts @@ -19,17 +19,13 @@ import { ListRegistryInstances, ProvisioningConstants } from "@zowe/provisioning-for-zowe-sdk"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["provisioning", "delete", "instance"], - definition: DeleteInstanceDefinition.DeleteInstanceDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: DeleteInstanceDefinition.DeleteInstanceDefinition }); describe("delete deprovisioned instance handler tests", () => { diff --git a/packages/cli/__tests__/provisioning/__unit__/list/catalogTemplates/CatalogTemplates.handler.unit.test.ts b/packages/cli/__tests__/provisioning/__unit__/list/catalogTemplates/CatalogTemplates.handler.unit.test.ts index ee68d4ddc1..ad11da8448 100644 --- a/packages/cli/__tests__/provisioning/__unit__/list/catalogTemplates/CatalogTemplates.handler.unit.test.ts +++ b/packages/cli/__tests__/provisioning/__unit__/list/catalogTemplates/CatalogTemplates.handler.unit.test.ts @@ -14,10 +14,7 @@ import { ListCatalogTemplates } from "@zowe/provisioning-for-zowe-sdk"; import { IHandlerParameters } from "@zowe/imperative"; import * as Handler from "../../../../../src/provisioning/list/catalogTemplates/CatalogTemplates.handler"; import { catalogTemplates } from "../../../../../src/provisioning/list/catalogTemplates/CatalogTemplates.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; jest.mock("../../../../../../../packages/provisioning/src/ListCatalogTemplates"); @@ -25,8 +22,7 @@ jest.mock("../../../../../../../packages/provisioning/src/ListCatalogTemplates") const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["provisioning", "list", "catalog-templates"], - definition: catalogTemplates, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: catalogTemplates }); describe("list catalog templates handler tests", () => { diff --git a/packages/cli/__tests__/provisioning/__unit__/list/instanceInfo/InstanceInfo.handler.unit.test.ts b/packages/cli/__tests__/provisioning/__unit__/list/instanceInfo/InstanceInfo.handler.unit.test.ts index a590bc1d97..b0c60c198d 100644 --- a/packages/cli/__tests__/provisioning/__unit__/list/instanceInfo/InstanceInfo.handler.unit.test.ts +++ b/packages/cli/__tests__/provisioning/__unit__/list/instanceInfo/InstanceInfo.handler.unit.test.ts @@ -18,17 +18,13 @@ import { import * as Handler from "../../../../../src/provisioning/list/instanceInfo/InstanceInfo.handler"; import { instanceInfo } from "../../../../../src/provisioning/list/instanceInfo/InstanceInfo.definition"; import { ProvisioningListMocks } from "../../../__resources__/ProvisioningListMocks"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["provisioning", "list", "instance-info"], - definition: instanceInfo, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: instanceInfo }); describe("list instance info handler tests", () => { diff --git a/packages/cli/__tests__/provisioning/__unit__/list/instanceVars/InstanceVariables.handler.unit.test.ts b/packages/cli/__tests__/provisioning/__unit__/list/instanceVars/InstanceVariables.handler.unit.test.ts index 631ec695a0..ac0b24d4b9 100644 --- a/packages/cli/__tests__/provisioning/__unit__/list/instanceVars/InstanceVariables.handler.unit.test.ts +++ b/packages/cli/__tests__/provisioning/__unit__/list/instanceVars/InstanceVariables.handler.unit.test.ts @@ -16,17 +16,13 @@ import { IHandlerParameters } from "@zowe/imperative"; import * as Handler from "../../../../../src/provisioning/list/instanceVariables/InstanceVariables.handler"; import { instanceVariables } from "../../../../../src/provisioning/list/instanceVariables/InstanceVariables.definition"; import { ProvisioningListMocks } from "../../../__resources__/ProvisioningListMocks"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["provisioning", "list", "instance-variables"], - definition: instanceVariables, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: instanceVariables }); describe("list instance variables handler tests", () => { diff --git a/packages/cli/__tests__/provisioning/__unit__/list/registryInstances/RegistryInstances.handler.unit.test.ts b/packages/cli/__tests__/provisioning/__unit__/list/registryInstances/RegistryInstances.handler.unit.test.ts index b333e6cb3b..8136f7560b 100644 --- a/packages/cli/__tests__/provisioning/__unit__/list/registryInstances/RegistryInstances.handler.unit.test.ts +++ b/packages/cli/__tests__/provisioning/__unit__/list/registryInstances/RegistryInstances.handler.unit.test.ts @@ -13,10 +13,7 @@ import { ListRegistryInstances } from "@zowe/provisioning-for-zowe-sdk"; import { IHandlerParameters } from "@zowe/imperative"; import * as Handler from "../../../../../src/provisioning/list/registry/RegistryInstances.handler"; import { registryInstances } from "../../../../../src/provisioning/list/registry/RegistryInstances.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; jest.mock("@zowe/provisioning-for-zowe-sdk"); @@ -24,8 +21,7 @@ jest.mock("@zowe/provisioning-for-zowe-sdk"); const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["provisioning", "list", "catalog-templates"], - definition: registryInstances, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: registryInstances }); describe("list registry instances handler tests", () => { diff --git a/packages/cli/__tests__/provisioning/__unit__/list/templateInfo/TemplateInfo.handler.unit.test.ts b/packages/cli/__tests__/provisioning/__unit__/list/templateInfo/TemplateInfo.handler.unit.test.ts index 21165a3998..35b25fb87e 100644 --- a/packages/cli/__tests__/provisioning/__unit__/list/templateInfo/TemplateInfo.handler.unit.test.ts +++ b/packages/cli/__tests__/provisioning/__unit__/list/templateInfo/TemplateInfo.handler.unit.test.ts @@ -14,17 +14,13 @@ import { ListTemplateInfo } from "@zowe/provisioning-for-zowe-sdk"; import { IHandlerParameters } from "@zowe/imperative"; import * as Handler from "../../../../../src/provisioning/list/templateInfo/TemplateInfo.handler"; import { templateInfo } from "../../../../../src/provisioning/list/templateInfo/TemplateInfo.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["provisioning", "list", "catalog-templates"], - definition: templateInfo, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: templateInfo }); describe("list template info handler tests", () => { diff --git a/packages/cli/__tests__/provisioning/__unit__/perform/action/Action.handler.unit.test.ts b/packages/cli/__tests__/provisioning/__unit__/perform/action/Action.handler.unit.test.ts index fed787cf42..6f52fccf58 100644 --- a/packages/cli/__tests__/provisioning/__unit__/perform/action/Action.handler.unit.test.ts +++ b/packages/cli/__tests__/provisioning/__unit__/perform/action/Action.handler.unit.test.ts @@ -20,17 +20,13 @@ import { import { IHandlerParameters } from "@zowe/imperative"; import * as ActionHandler from "../../../../../src/provisioning/perform/action/Action.handler"; import * as ActionDefinition from "../../../../../src/provisioning/perform/action/Action.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["provisioning", "perform", "action"], - definition: ActionDefinition.ActionDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: ActionDefinition.ActionDefinition }); describe("perform action handler tests", () => { diff --git a/packages/cli/__tests__/provisioning/__unit__/provision/template/Template.handler.unit.test.ts b/packages/cli/__tests__/provisioning/__unit__/provision/template/Template.handler.unit.test.ts index dc8d39cb4d..42337c91ce 100644 --- a/packages/cli/__tests__/provisioning/__unit__/provision/template/Template.handler.unit.test.ts +++ b/packages/cli/__tests__/provisioning/__unit__/provision/template/Template.handler.unit.test.ts @@ -18,17 +18,13 @@ import { ProvisionTemplateData } from "../../../__resources__/ProvisionTemplateD import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import * as TemplateHandler from "../../../../../src/provisioning/provision/template/Template.handler"; import * as TemplateDefinition from "../../../../../src/provisioning/provision/template/Template.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["provisioning", "provision", "template"], - definition: TemplateDefinition.TemplateDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: TemplateDefinition.TemplateDefinition }); describe("provision template handler tests", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/compare/ds/Dataset.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/compare/ds/Dataset.handler.unit.test.ts index 74d90159a8..c831d710a5 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/compare/ds/Dataset.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/compare/ds/Dataset.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Get } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { DiffUtils, IDiffOptions, ImperativeError } from "@zowe/imperative"; describe("Compare data set handler", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/compare/lf-ds/LocalfileDataset.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/compare/lf-ds/LocalfileDataset.handler.unit.test.ts index 108b0544fc..c5f1f32ccb 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/compare/lf-ds/LocalfileDataset.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/compare/lf-ds/LocalfileDataset.handler.unit.test.ts @@ -12,7 +12,7 @@ jest.mock("fs"); import { Get } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { DiffUtils, IDiffOptions, ImperativeError } from "@zowe/imperative"; import * as fs from "fs"; describe("Compare local-file and data-set handler", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/compare/lf-sdd/LocalfileSpooldd.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/compare/lf-sdd/LocalfileSpooldd.handler.unit.test.ts index 79eadc9972..e7c137a664 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/compare/lf-sdd/LocalfileSpooldd.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/compare/lf-sdd/LocalfileSpooldd.handler.unit.test.ts @@ -12,7 +12,7 @@ jest.mock("fs"); import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { DiffUtils, IDiffOptions, ImperativeError } from "@zowe/imperative"; import * as fs from "fs"; diff --git a/packages/cli/__tests__/zosfiles/__unit__/compare/lf-uss/LocalfileUss.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/compare/lf-uss/LocalfileUss.handler.unit.test.ts index 2fd4591f18..567d13e921 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/compare/lf-uss/LocalfileUss.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/compare/lf-uss/LocalfileUss.handler.unit.test.ts @@ -12,7 +12,7 @@ jest.mock("fs"); import { Get } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { DiffUtils, IDiffOptions } from "@zowe/imperative"; import * as fs from "fs"; diff --git a/packages/cli/__tests__/zosfiles/__unit__/compare/sdd/Spooldd.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/compare/sdd/Spooldd.handler.unit.test.ts index d71b72dd4f..9b71ec2b96 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/compare/sdd/Spooldd.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/compare/sdd/Spooldd.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { DiffUtils, IDiffOptions, ImperativeError } from "@zowe/imperative"; describe("Compare spooldd handler", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/compare/uss/UssFile.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/compare/uss/UssFile.handler.unit.test.ts index de4ac64f24..8117ec2719 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/compare/uss/UssFile.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/compare/uss/UssFile.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Get } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { DiffUtils, IDiffOptions, ImperativeError } from "@zowe/imperative"; describe("Compare data set handler", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/copy/dsclp/TargetProfile.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/copy/dsclp/TargetProfile.handler.unit.test.ts index 4a756e9d0d..9feccd3f0f 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/copy/dsclp/TargetProfile.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/copy/dsclp/TargetProfile.handler.unit.test.ts @@ -12,17 +12,13 @@ import { IHandlerParameters, ImperativeConfig, ImperativeError } from "@zowe/imperative"; import TargetProfileHandler from "../../../../../src/zosfiles/copy/dsclp/TargetProfile.handler"; import { DsclpDefinition } from "../../../../../src/zosfiles/copy/dsclp/Dsclp.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["files", "copy", "data-set-cross-lpar"], - definition: DsclpDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: DsclpDefinition }); describe("TargetProfileHandler", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/binaryPds/BinaryPDS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/binaryPds/BinaryPDS.handler.unit.test.ts index 04231126d3..44c96a8651 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/binaryPds/BinaryPDS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/binaryPds/BinaryPDS.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Create, CreateDataSetTypeEnum } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Create binary PDS data set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/cPds/CPDS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/cPds/CPDS.handler.unit.test.ts index 52ea562e68..56b9800230 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/cPds/CPDS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/cPds/CPDS.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Create, CreateDataSetTypeEnum } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Create C-code PDS data set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/classicPds/ClassicPDS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/classicPds/ClassicPDS.handler.unit.test.ts index 100a1f0269..6bf9932aa7 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/classicPds/ClassicPDS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/classicPds/ClassicPDS.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Create, CreateDataSetTypeEnum } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Create classic PDS data set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/ds/ds.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/ds/ds.handler.unit.test.ts index 1c8ce8705e..998ca33757 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/ds/ds.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/ds/ds.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Create, CreateDataSetTypeEnum } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Create data set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/pds/Pds.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/pds/Pds.handler.unit.test.ts index 2f389193ac..d59d95b08b 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/pds/Pds.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/pds/Pds.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Create, CreateDataSetTypeEnum } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Create PDS data set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/ps/Ps.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/ps/Ps.handler.unit.test.ts index e830b6cf71..0ebd8da55e 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/ps/Ps.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/ps/Ps.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Create, CreateDataSetTypeEnum } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Create PS data set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/ussDir/ussDir.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/ussDir/ussDir.handler.unit.test.ts index 299a0b6d28..8062b8d143 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/ussDir/ussDir.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/ussDir/ussDir.handler.unit.test.ts @@ -11,7 +11,7 @@ import { Create, IZosFilesOptions } from "@zowe/zos-files-for-zowe-sdk"; // import { CreateDataSetTypeEnum } from "../../../../src/api/methods/create/CreateDataSetType.enum"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Create USS Directory", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/ussFile/ussFile.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/ussFile/ussFile.handler.unit.test.ts index 765570d70d..05ebca4e72 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/ussFile/ussFile.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/ussFile/ussFile.handler.unit.test.ts @@ -11,7 +11,7 @@ import { Create, IZosFilesOptions } from "@zowe/zos-files-for-zowe-sdk"; // import { CreateDataSetTypeEnum } from "../../../../src/api/methods/create/CreateDataSetType.enum"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Create USS file", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/vsam/Vsam.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/vsam/Vsam.handler.unit.test.ts index 85a782fde4..cdcdf06c1d 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/vsam/Vsam.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/vsam/Vsam.handler.unit.test.ts @@ -11,7 +11,7 @@ import { Create } from "@zowe/zos-files-for-zowe-sdk"; import { ImperativeError } from "@zowe/imperative"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; const message: string = "Dummy error message"; diff --git a/packages/cli/__tests__/zosfiles/__unit__/create/zfs/zfs.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/create/zfs/zfs.handler.unit.test.ts index 2c789f1fc7..d206a06c20 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/create/zfs/zfs.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/create/zfs/zfs.handler.unit.test.ts @@ -11,7 +11,7 @@ import { Create } from "@zowe/zos-files-for-zowe-sdk"; import { ImperativeError } from "@zowe/imperative"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; const message: string = "Dummy error message"; diff --git a/packages/cli/__tests__/zosfiles/__unit__/download/am/AllMembers.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/download/am/AllMembers.handler.unit.test.ts index f838bc33a1..42a1e5352b 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/download/am/AllMembers.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/download/am/AllMembers.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Download } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Download AllMembers handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/download/ds/Dataset.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/download/ds/Dataset.handler.unit.test.ts index 372231a04e..0bc6a28354 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/download/ds/Dataset.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/download/ds/Dataset.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Download } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Download data set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/download/dsm/DataSetMatching.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/download/dsm/DataSetMatching.handler.unit.test.ts index 3f8b8c87ca..ce1ae9cb95 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/download/dsm/DataSetMatching.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/download/dsm/DataSetMatching.handler.unit.test.ts @@ -13,14 +13,13 @@ import { IHandlerParameters, Session } from "@zowe/imperative"; import { Download, IDownloadOptions, IDsmListOptions, List } from "@zowe/zos-files-for-zowe-sdk"; import * as DataSetMatchingDefinition from "../../../../../src/zosfiles/download/dsm/DataSetMatching.definition"; import * as DataSetMatchingHandler from "../../../../../src/zosfiles/download/dsm/DataSetMatching.handler"; -import { UNIT_TEST_ZOSMF_PROF_OPTS, UNIT_TEST_PROFILES_ZOSMF } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "download", "output"], - definition: DataSetMatchingDefinition.DataSetMatchingDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: DataSetMatchingDefinition.DataSetMatchingDefinition }); const fakeListOptions: IDsmListOptions = { diff --git a/packages/cli/__tests__/zosfiles/__unit__/download/uss/UssFile.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/download/uss/UssFile.handler.unit.test.ts index e99676bec2..55afdf6edf 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/download/uss/UssFile.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/download/uss/UssFile.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Download } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Download uss file handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/download/ussdir/UssDir.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/download/ussdir/UssDir.handler.unit.test.ts index 64857d28ba..9619831883 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/download/ussdir/UssDir.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/download/ussdir/UssDir.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Download, IDownloadOptions, IUSSListOptions } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; const defaultListObj: IUSSListOptions = { name: "*", diff --git a/packages/cli/__tests__/zosfiles/__unit__/edit/Edit.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/edit/Edit.handler.unit.test.ts index e60b145612..7a30a79836 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/edit/Edit.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/edit/Edit.handler.unit.test.ts @@ -15,7 +15,7 @@ import {ILocalFile, import { mockHandlerParameters } from "@zowe/cli-test-utils"; import { EditDefinition } from "../../../../src/zosfiles/edit/Edit.definition"; import EditHandler from "../../../../src/zosfiles/edit/Edit.handler"; -import { UNIT_TEST_PROFILES_ZOSMF, UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../__tests__/__src__/TestConstants"; import stripAnsi = require("strip-ansi"); describe("Files Edit Group Handler", () => { @@ -27,8 +27,7 @@ describe("Files Edit Group Handler", () => { const commandParameters: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-files", "edit", "ds"], - definition: EditDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: EditDefinition }); const localFile: ILocalFile = { diff --git a/packages/cli/__tests__/zosfiles/__unit__/edit/Edit.utils.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/edit/Edit.utils.unit.test.ts index ade6752d11..a68cb87fa2 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/edit/Edit.utils.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/edit/Edit.utils.unit.test.ts @@ -11,7 +11,7 @@ import { mockHandlerParameters } from "@zowe/cli-test-utils"; import { AbstractSession, CliUtils, GuiResult, IHandlerParameters, ImperativeError, ProcessUtils } from "@zowe/imperative"; -import { UNIT_TEST_ZOSMF_PROF_OPTS, UNIT_TEST_PROFILES_ZOSMF } from "../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../__tests__/__src__/TestConstants"; import { EditDefinition } from "../../../../src/zosfiles/edit/Edit.definition"; import { EditUtilities, ILocalFile, Prompt } from "../../../../src/zosfiles/edit/Edit.utils"; import { cloneDeep } from "lodash"; @@ -26,15 +26,13 @@ describe("Files Edit Utilities", () => { const commandParametersDs: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-files", "edit", "ds"], - definition: EditDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: EditDefinition }); const commandParametersUss: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-files", "edit", "uss"], - definition: EditDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: EditDefinition }); commandParametersDs.arguments["dataSetName"] = commandParametersUss.arguments["file"] = 'fake'; diff --git a/packages/cli/__tests__/zosfiles/__unit__/invoke/amsFile/AmsFile.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/invoke/amsFile/AmsFile.handler.unit.test.ts index 5d84602ce3..f915990226 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/invoke/amsFile/AmsFile.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/invoke/amsFile/AmsFile.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Invoke, IZosFilesOptions } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Invoke AMS files handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/invoke/amsStatements/AmsStatements.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/invoke/amsStatements/AmsStatements.handler.unit.test.ts index df59cc5cff..4b3773a186 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/invoke/amsStatements/AmsStatements.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/invoke/amsStatements/AmsStatements.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Invoke } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Invoke AMS statements handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/list/am/AllMembers.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/list/am/AllMembers.handler.unit.test.ts index 55871bc2ab..cf11e3a249 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/list/am/AllMembers.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/list/am/AllMembers.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { List } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { IHandlerParameters } from "@zowe/imperative"; describe("List AllMembers handler", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/list/ds/Dataset.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/list/ds/Dataset.handler.unit.test.ts index e87a31e6d2..75f217a634 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/list/ds/Dataset.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/list/ds/Dataset.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { List } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("List Dataset handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/list/fs/Fs.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/list/fs/Fs.handler.unit.test.ts index 53e27e5c44..a052f68a63 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/list/fs/Fs.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/list/fs/Fs.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { List } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("fs handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/list/uss/Uss.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/list/uss/Uss.handler.unit.test.ts index 20ab8f4c07..54f0eba9de 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/list/uss/Uss.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/list/uss/Uss.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { List } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("USS file handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/mount/fs/fs.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/mount/fs/fs.handler.unit.test.ts index 5340676739..2a4fdee14a 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/mount/fs/fs.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/mount/fs/fs.handler.unit.test.ts @@ -11,7 +11,7 @@ import { Mount } from "@zowe/zos-files-for-zowe-sdk"; import { ImperativeError } from "@zowe/imperative"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; const message: string = "Dummy error message"; diff --git a/packages/cli/__tests__/zosfiles/__unit__/search/ds/Datasets.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/search/ds/Datasets.handler.unit.test.ts index 521d47f2d4..d3ed3f18c0 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/search/ds/Datasets.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/search/ds/Datasets.handler.unit.test.ts @@ -11,7 +11,7 @@ import { Search } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { TaskStage } from "@zowe/imperative"; describe("Search Datasets handler", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts index aba9173262..a544f56b6c 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtp/DirToPds.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Upload dir-to-pds handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/DirToUSS.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/DirToUSS.handler.unit.test.ts index a90a269155..f1965a7d8d 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/DirToUSS.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/dtu/DirToUSS.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Upload, ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import * as fs from "fs"; describe("Upload dir-to-uss handler", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts index cddbc54373..c71ada1d52 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/ftds/FileToDataSet.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Upload file-to-data-set handler", () => { describe("process method", () => { 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 9e027cd02c..c4eedd2bd4 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 @@ -10,7 +10,7 @@ */ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Upload file-to-uss handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/upload/stds/StdinToDataSet.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/upload/stds/StdinToDataSet.handler.unit.test.ts index 51b8e92c49..fbd3bdd65f 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/upload/stds/StdinToDataSet.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/upload/stds/StdinToDataSet.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Upload } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("Upload stdin-to-data-set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/view/ds/Dataset.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/view/ds/Dataset.handler.unit.test.ts index 828246841e..a2b544a611 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/view/ds/Dataset.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/view/ds/Dataset.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Get } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("View data set handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosfiles/__unit__/view/uss/USSFiles.handler.unit.test.ts b/packages/cli/__tests__/zosfiles/__unit__/view/uss/USSFiles.handler.unit.test.ts index cdb40f7868..a3069f959c 100644 --- a/packages/cli/__tests__/zosfiles/__unit__/view/uss/USSFiles.handler.unit.test.ts +++ b/packages/cli/__tests__/zosfiles/__unit__/view/uss/USSFiles.handler.unit.test.ts @@ -10,7 +10,7 @@ */ import { Get } from "@zowe/zos-files-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; describe("View USS file handler", () => { describe("process method", () => { diff --git a/packages/cli/__tests__/zosjobs/__unit__/cancel/job/Job.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/cancel/job/Job.handler.unit.test.ts index df8c2da150..4c6a80e43b 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/cancel/job/Job.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/cancel/job/Job.handler.unit.test.ts @@ -15,10 +15,7 @@ import { GetJobs, CancelJobs, IJobFeedback } from "@zowe/zos-jobs-for-zowe-sdk"; import { GetJobsData } from "../../../__resources__/GetJobsData"; import * as JobHandler from "../../../../../src/zosjobs/cancel/job/Job.handler"; import * as JobDefinition from "../../../../../src/zosjobs/cancel/job/Job.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -26,8 +23,7 @@ process.env.FORCE_COLOR = "0"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "cancel", "job"], - definition: JobDefinition.JobDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: JobDefinition.JobDefinition }); const DEFAULT_RESPONSE_FEEDBACK: IJobFeedback = { diff --git a/packages/cli/__tests__/zosjobs/__unit__/delete/job/Job.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/delete/job/Job.handler.unit.test.ts index 4ac9c09ec3..d1945ef98f 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/delete/job/Job.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/delete/job/Job.handler.unit.test.ts @@ -15,10 +15,7 @@ import { GetJobs, DeleteJobs, IJobFeedback } from "@zowe/zos-jobs-for-zowe-sdk"; import { GetJobsData } from "../../../__resources__/GetJobsData"; import * as JobHandler from "../../../../../src/zosjobs/delete/job/Job.handler"; import * as JobDefinition from "../../../../../src/zosjobs/delete/job/Job.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -26,8 +23,7 @@ process.env.FORCE_COLOR = "0"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "delete", "job"], - definition: JobDefinition.JobDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: JobDefinition.JobDefinition }); const DEFAULT_RESPONSE_FEEDBACK: IJobFeedback = { diff --git a/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/OldJobs.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/OldJobs.handler.unit.test.ts index bc43ad6499..608efa2c0d 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/OldJobs.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/delete/old-jobs/OldJobs.handler.unit.test.ts @@ -15,10 +15,7 @@ import { GetJobs, DeleteJobs } from "@zowe/zos-jobs-for-zowe-sdk"; import { GetJobsData } from "../../../__resources__/GetJobsData"; import * as OldJobsHandler from "../../../../../src/zosjobs/delete/old-jobs/OldJobs.handler"; import * as OldJobsDefinition from "../../../../../src/zosjobs/delete/old-jobs/OldJobs.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -26,8 +23,7 @@ process.env.FORCE_COLOR = "0"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "delete", "old-jobs"], - definition: OldJobsDefinition.OldJobsDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: OldJobsDefinition.OldJobsDefinition }); describe("delete old-jobs handler tests", () => { diff --git a/packages/cli/__tests__/zosjobs/__unit__/download/download-output/Output.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/download/download-output/Output.handler.unit.test.ts index ea7378a4ff..b2bc1e02a9 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/download/download-output/Output.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/download/download-output/Output.handler.unit.test.ts @@ -16,10 +16,7 @@ jest.mock("@zowe/zos-jobs-for-zowe-sdk"); import { IHandlerParameters, ImperativeError, Session } from "@zowe/imperative"; import * as OutputHandler from "../../../../../src/zosjobs/download/download-output/Output.handler"; import * as OutputDefinition from "../../../../../src/zosjobs/download/download-output/Output.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -27,8 +24,7 @@ process.env.FORCE_COLOR = "0"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "download", "output"], - definition: OutputDefinition.OutputDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: OutputDefinition.OutputDefinition }); describe("download output handler tests", () => { diff --git a/packages/cli/__tests__/zosjobs/__unit__/list/jobs/Jobs.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/list/jobs/Jobs.handler.unit.test.ts index 1dbca8370e..edad84edbc 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/list/jobs/Jobs.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/list/jobs/Jobs.handler.unit.test.ts @@ -16,10 +16,7 @@ jest.mock("@zowe/zos-jobs-for-zowe-sdk"); import { IHandlerParameters, ImperativeError, Session } from "@zowe/imperative"; import * as JobsHandler from "../../../../../src/zosjobs/list/jobs/Jobs.handler"; import * as JobsDefinition from "../../../../../src/zosjobs/list/jobs/Jobs.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -27,8 +24,7 @@ process.env.FORCE_COLOR = "0"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "view", "job"], - definition: JobsDefinition.JobsDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: JobsDefinition.JobsDefinition }); describe("list jobs handler tests", () => { diff --git a/packages/cli/__tests__/zosjobs/__unit__/list/spool-files-by-jobid/SpoolFilesByJobid.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/list/spool-files-by-jobid/SpoolFilesByJobid.handler.unit.test.ts index 18e8e481d1..88f1d40a60 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/list/spool-files-by-jobid/SpoolFilesByJobid.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/list/spool-files-by-jobid/SpoolFilesByJobid.handler.unit.test.ts @@ -15,10 +15,7 @@ import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; import { GetJobsData } from "../../../__resources__/GetJobsData"; import { SpoolFilesByJobidDefinition } from "../../../../../src/zosjobs/list/spool-files-by-jobid/SpoolFilesByJobid.definition"; import * as SpoolFilesHandler from "../../../../../src/zosjobs/list/spool-files-by-jobid/SpoolFilesByJobid.handler"; -import { - UNIT_TEST_PROFILES_ZOSMF, - UNIT_TEST_ZOSMF_PROF_OPTS -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; // Disable coloring for the snapshots @@ -27,8 +24,7 @@ process.env.FORCE_COLOR = "0"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "list", "spool-files"], - definition: SpoolFilesByJobidDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: SpoolFilesByJobidDefinition }); describe("zos-jobs list spool-files-by-jobid handler", () => { 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 fc0b1a4d2a..b703740e85 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 @@ -14,10 +14,7 @@ import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import { GetJobs, IJob, IJobFeedback, ModifyJobs } from "@zowe/zos-jobs-for-zowe-sdk"; import * as ModifyDefintion from "../../../../../src/zosjobs/modify/job/Job.definition"; import * as ModifyHandler from "../../../../../src/zosjobs/modify/job/Job.handler"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -25,8 +22,7 @@ process.env.FORCE_COLOR = "0"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "modify", "job"], - definition: ModifyDefintion.JobDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: ModifyDefintion.JobDefinition }); const SAMPLE_COMPLETE_JOB: IJob= { diff --git a/packages/cli/__tests__/zosjobs/__unit__/search/job/JobSearch.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/search/job/JobSearch.handler.unit.test.ts index 1d9a126d96..9b426a8201 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/search/job/JobSearch.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/search/job/JobSearch.handler.unit.test.ts @@ -14,10 +14,7 @@ import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import { SearchJobs } from "@zowe/zos-jobs-for-zowe-sdk"; import * as JobHandler from "../../../../../src/zosjobs/search/job/Job.handler"; import * as JobDefinition from "../../../../../src/zosjobs/search/job/Job.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -28,8 +25,7 @@ const mockSearchData: string = "This job contains RC=0000"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "search", "job"], - definition: JobDefinition.JobDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: JobDefinition.JobDefinition }); describe("search job handler tests", () => { diff --git a/packages/cli/__tests__/zosjobs/__unit__/submit/Submit.shared.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/submit/Submit.shared.handler.unit.test.ts index dc0135c776..a6ec8b0933 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/submit/Submit.shared.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/submit/Submit.shared.handler.unit.test.ts @@ -13,10 +13,7 @@ jest.mock("@zowe/zos-jobs-for-zowe-sdk"); import { MonitorJobs, SubmitJobs, ISubmitJobUSSParms, ISubmitJobParms } from "@zowe/zos-jobs-for-zowe-sdk"; import { IHandlerParameters, ImperativeError, IO } from "@zowe/imperative"; import * as SubmitDefinition from "../../../../src/zosjobs/submit/Submit.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -29,22 +26,19 @@ describe("submit shared handler", () => { DEFAULT_PARAMETERS = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "submit", "data-set"], - definition: SubmitDefinition.SubmitDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: SubmitDefinition.SubmitDefinition }); USSFILE_PARAMETERS = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "submit", "uss-file"], - definition: SubmitDefinition.SubmitDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: SubmitDefinition.SubmitDefinition }); LOCALFILE_PARAMETERS = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "submit", "local-file"], - definition: SubmitDefinition.SubmitDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: SubmitDefinition.SubmitDefinition }); }); diff --git a/packages/cli/__tests__/zosjobs/__unit__/view/all-spool-content/AllSpoolContent.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/view/all-spool-content/AllSpoolContent.handler.unit.test.ts index c7cb2b4b33..432c0b22dd 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/view/all-spool-content/AllSpoolContent.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/view/all-spool-content/AllSpoolContent.handler.unit.test.ts @@ -16,7 +16,7 @@ import { GetJobsData } from "../../../__resources__/GetJobsData"; import { AllSpoolContentDefinition } from "../../../../../src/zosjobs/view/all-spool-content/AllSpoolContent.definition"; import * as fs from "fs"; import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS, UNIT_TEST_PROFILES_ZOSMF } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; import * as AllSpoolContentHandler from "../../../../../src/zosjobs/view/all-spool-content/AllSpoolContent.handler"; @@ -27,8 +27,7 @@ const TEST_RESOURCES_DIR = __dirname + "/../../../__resources__"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "view", "spool-file-by-id"], - definition: AllSpoolContentDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF, + definition: AllSpoolContentDefinition }); describe("zos-jobs view all-spool-content handler", () => { diff --git a/packages/cli/__tests__/zosjobs/__unit__/view/job/JobStatusByJobid.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/view/job/JobStatusByJobid.handler.unit.test.ts index 6e23fc4557..305b21e1ae 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/view/job/JobStatusByJobid.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/view/job/JobStatusByJobid.handler.unit.test.ts @@ -15,10 +15,7 @@ import { GetJobs } from "@zowe/zos-jobs-for-zowe-sdk"; import { GetJobsData } from "../../../__resources__/GetJobsData"; import * as JobStatusByJobidHandler from "../../../../../src/zosjobs/view/job-status-by-jobid/JobStatusByJobid.handler"; import * as JobStatusByJobidDefinition from "../../../../../src/zosjobs/view/job-status-by-jobid/JobStatusByJobid.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -27,8 +24,7 @@ process.env.FORCE_COLOR = "0"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "view", "job"], - definition: JobStatusByJobidDefinition.JobStatusByJobidDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: JobStatusByJobidDefinition.JobStatusByJobidDefinition }); describe("view job-status-by-jobid handler tests", () => { diff --git a/packages/cli/__tests__/zosjobs/__unit__/view/spool-file-by-id/SpoolFileById.handler.unit.test.ts b/packages/cli/__tests__/zosjobs/__unit__/view/spool-file-by-id/SpoolFileById.handler.unit.test.ts index 094cc6e9ed..6d6582727f 100644 --- a/packages/cli/__tests__/zosjobs/__unit__/view/spool-file-by-id/SpoolFileById.handler.unit.test.ts +++ b/packages/cli/__tests__/zosjobs/__unit__/view/spool-file-by-id/SpoolFileById.handler.unit.test.ts @@ -17,7 +17,7 @@ import { SpoolFilesByJobidDefinition } from "../../../../../src/zosjobs/list/spo import * as SpoolFileByIdHandler from "../../../../../src/zosjobs/view/spool-file-by-id/SpoolFileById.handler"; import * as fs from "fs"; import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk"; -import { UNIT_TEST_ZOSMF_PROF_OPTS, UNIT_TEST_PROFILES_ZOSMF } from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; import { cloneDeep } from "lodash"; @@ -28,8 +28,7 @@ const TEST_RESOURCES_DIR = __dirname + "/../../../__resources__"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-jobs", "view", "spool-file-by-id"], - definition: SpoolFilesByJobidDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: SpoolFilesByJobidDefinition }); describe("zos-jobs view spool-file-by-id handler", () => { diff --git a/packages/cli/__tests__/zoslogs/__unit__/list/logs/Logs.handler.unit.test.ts b/packages/cli/__tests__/zoslogs/__unit__/list/logs/Logs.handler.unit.test.ts index f262d4d8ce..5fb4912fc3 100644 --- a/packages/cli/__tests__/zoslogs/__unit__/list/logs/Logs.handler.unit.test.ts +++ b/packages/cli/__tests__/zoslogs/__unit__/list/logs/Logs.handler.unit.test.ts @@ -15,10 +15,7 @@ import { IHandlerParameters, ImperativeError, Session, Imperative } from "@zowe/ import * as LogsHandler from "../../../../../src/zoslogs/list/logs/Logs.handler"; import * as LogsDefinition from "../../../../../src/zoslogs/list/logs/Logs.definition"; import { GetZosLog, IZosLogParms } from "@zowe/zos-logs-for-zowe-sdk"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; process.env.FORCE_COLOR = "0"; @@ -29,8 +26,7 @@ const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ ...UNIT_TEST_ZOSMF_PROF_OPTS }, positionals: ["zos-logs", "list", "logs"], - definition: LogsDefinition.LogsDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: LogsDefinition.LogsDefinition }); describe("get logs handler tests", () => { diff --git a/packages/cli/__tests__/zosmf/__unit__/check/status/Status.handler.unit.test.ts b/packages/cli/__tests__/zosmf/__unit__/check/status/Status.handler.unit.test.ts index 6741cf64ca..e3800ce919 100644 --- a/packages/cli/__tests__/zosmf/__unit__/check/status/Status.handler.unit.test.ts +++ b/packages/cli/__tests__/zosmf/__unit__/check/status/Status.handler.unit.test.ts @@ -14,17 +14,13 @@ import { CheckStatus } from "@zowe/zosmf-for-zowe-sdk"; import { ICommandHandler, IHandlerParameters } from "@zowe/imperative"; import CmdHandler from "../../../../../src/zosmf/check/status/Status.handler"; import * as cmdDef from "../../../../../src/zosmf/check/status/Status.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const goodCmdParms: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zosmf", "check", "status"], - definition: cmdDef.StatusDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: cmdDef.StatusDefinition }); let checkStatHandler: ICommandHandler = null; diff --git a/packages/cli/__tests__/zosmf/__unit__/list/systems/Systems.handler.unit.test.ts b/packages/cli/__tests__/zosmf/__unit__/list/systems/Systems.handler.unit.test.ts index c25c6c7280..fa2c8e5a32 100644 --- a/packages/cli/__tests__/zosmf/__unit__/list/systems/Systems.handler.unit.test.ts +++ b/packages/cli/__tests__/zosmf/__unit__/list/systems/Systems.handler.unit.test.ts @@ -15,17 +15,13 @@ import { ListDefinedSystems } from "@zowe/zosmf-for-zowe-sdk"; import { ICommandHandler, IHandlerParameters } from "@zowe/imperative"; import CmdHandler from "../../../../../src/zosmf/list/systems/Systems.handler"; import * as cmdDef from "../../../../../src/zosmf/list/systems/Systems.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const goodCmdParms: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zosmf", "check", "status"], - definition: cmdDef.SystemsDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: cmdDef.SystemsDefinition }); let listSystemsHandler: ICommandHandler = null; diff --git a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts index 6bf449c70d..7d82689383 100644 --- a/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/issue/command/Command.handler.unit.test.ts @@ -15,11 +15,7 @@ import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import * as Command from "../../../../../src/zostso/issue/command/Command.handler"; import { CommandDefinition } from "../../../../../src/zostso/issue/command/Command.definition"; import { StartTsoData } from "../../../__resources__/StartTsoData"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF_TSO, - UNIT_TEST_TSO_PROF_OPTS -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS, UNIT_TEST_TSO_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ @@ -28,8 +24,7 @@ const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ ...UNIT_TEST_TSO_PROF_OPTS }, positionals: ["zos-tso", "issue", "address-space"], - definition: CommandDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF_TSO + definition: CommandDefinition }); describe("issue command handler tests", () => { diff --git a/packages/cli/__tests__/zostso/__unit__/ping/address-space/AddressSpace.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/ping/address-space/AddressSpace.handler.unit.test.ts index d8a0b0aa38..1c63e55c73 100644 --- a/packages/cli/__tests__/zostso/__unit__/ping/address-space/AddressSpace.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/ping/address-space/AddressSpace.handler.unit.test.ts @@ -16,17 +16,13 @@ import { PingTso } from "@zowe/zos-tso-for-zowe-sdk"; import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import * as PingAddressSpaceHandler from "../../../../../src/zostso/ping/address_space/PingAddressSpace.handler"; import { PingAddressSpaceCommandDefinition } from "../../../../../src/zostso/ping/address_space/PingAddressSpace.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-tso", "ping", "address-space"], - definition: PingAddressSpaceCommandDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: PingAddressSpaceCommandDefinition }); describe("ping address-space handler tests", () => { diff --git a/packages/cli/__tests__/zostso/__unit__/send/address-space/AddressSpace.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/send/address-space/AddressSpace.handler.unit.test.ts index c439ca7aee..584e3ab655 100644 --- a/packages/cli/__tests__/zostso/__unit__/send/address-space/AddressSpace.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/send/address-space/AddressSpace.handler.unit.test.ts @@ -16,17 +16,13 @@ import { SendTso } from "@zowe/zos-tso-for-zowe-sdk"; import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import * as SendToAddressSpace from "../../../../../src/zostso/send/address_space/SendToAddressSpace.handler"; import { SendToAddressSpaceCommandDefinition } from "../../../../../src/zostso/send/address_space/SendToAddressSpace.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-tso", "send", "address-space"], - definition: SendToAddressSpaceCommandDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: SendToAddressSpaceCommandDefinition }); describe("send address-space handler tests", () => { diff --git a/packages/cli/__tests__/zostso/__unit__/start/address-space/AddressSpace.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/start/address-space/AddressSpace.handler.unit.test.ts index 5bd864a64f..3b9411ee08 100644 --- a/packages/cli/__tests__/zostso/__unit__/start/address-space/AddressSpace.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/start/address-space/AddressSpace.handler.unit.test.ts @@ -11,23 +11,12 @@ import { StartTso } from "@zowe/zos-tso-for-zowe-sdk"; import { StartTsoData } from "../../../__resources__/StartTsoData"; -import { CommandProfiles, IHandlerParameters, ImperativeError, IProfile } from "@zowe/imperative"; +import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import * as AddressSpaceHandler from "../../../../../src/zostso/start/address-space/AddressSpace.handler"; import * as AddressSpaceDefinition from "../../../../../src/zostso/start/address-space/AddressSpace.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; -const PROFILE_MAP = new Map(); -PROFILE_MAP.set( - "zosmf", [{ - name: "zosmf", - type: "zosmf", - ...UNIT_TEST_ZOSMF_PROF_OPTS - }] -); - const TSO_PROF_OPTS = { logonProcedure: "IZUFPROC", characterSet: "697", @@ -38,21 +27,10 @@ const TSO_PROF_OPTS = { account: "DEFAULT" }; -PROFILE_MAP.set( - "tso", [{ - name: "tso", - type: "tso", - ...TSO_PROF_OPTS - }] -); - -const PROFILES: CommandProfiles = new CommandProfiles(PROFILE_MAP); - const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-tso", "start", "address-space"], - definition: AddressSpaceDefinition.AddressSpaceDefinition, - profiles: PROFILES + definition: AddressSpaceDefinition.AddressSpaceDefinition }); describe("start address-space handler tests", () => { diff --git a/packages/cli/__tests__/zostso/__unit__/stop/address-space/AddressSpace.handler.unit.test.ts b/packages/cli/__tests__/zostso/__unit__/stop/address-space/AddressSpace.handler.unit.test.ts index 978f739e01..80c78c1acf 100644 --- a/packages/cli/__tests__/zostso/__unit__/stop/address-space/AddressSpace.handler.unit.test.ts +++ b/packages/cli/__tests__/zostso/__unit__/stop/address-space/AddressSpace.handler.unit.test.ts @@ -15,17 +15,13 @@ import { StopTsoData } from "../../../__resources__/StopTsoData"; import { IHandlerParameters, ImperativeError } from "@zowe/imperative"; import * as AddressSpaceHandler from "../../../../../src/zostso/stop/address-space/AddressSpace.handler"; import * as AddressSpaceDefinition from "../../../../../src/zostso/stop/address-space/AddressSpace.definition"; -import { - UNIT_TEST_ZOSMF_PROF_OPTS, - UNIT_TEST_PROFILES_ZOSMF -} from "../../../../../../../__tests__/__src__/mocks/ZosmfProfileMock"; +import { UNIT_TEST_ZOSMF_PROF_OPTS } from "../../../../../../../__tests__/__src__/TestConstants"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_ZOSMF_PROF_OPTS, positionals: ["zos-tso", "stop", "address-space"], - definition: AddressSpaceDefinition.AddressSpaceDefinition, - profiles: UNIT_TEST_PROFILES_ZOSMF + definition: AddressSpaceDefinition.AddressSpaceDefinition }); describe("stop address-space handler tests", () => { diff --git a/packages/cli/__tests__/zosuss/__unit__/issue/ssh/Ssh.handler.unit.test.ts b/packages/cli/__tests__/zosuss/__unit__/issue/ssh/Ssh.handler.unit.test.ts index 58c1fedba0..c7bdc2efab 100644 --- a/packages/cli/__tests__/zosuss/__unit__/issue/ssh/Ssh.handler.unit.test.ts +++ b/packages/cli/__tests__/zosuss/__unit__/issue/ssh/Ssh.handler.unit.test.ts @@ -11,7 +11,7 @@ jest.mock("../../../../../../zosuss/lib/Shell"); -import { IHandlerParameters, IProfile, CommandProfiles, ConnectionPropsForSessCfg } from "@zowe/imperative"; +import { IHandlerParameters, ConnectionPropsForSessCfg } from "@zowe/imperative"; import SshHandler from "../../../../../src/zosuss/issue/ssh/Ssh.handler"; import * as SshDefinition from "../../../../../src/zosuss/issue/ssh/Ssh.definition"; import { Shell } from "@zowe/zos-uss-for-zowe-sdk"; @@ -47,73 +47,28 @@ const UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER = { keyPassPhrase: "dummyPassPhrase123" }; - -// A mocked profile map with ssh profile -const UNIT_TEST_PROFILE_MAP = new Map(); -UNIT_TEST_PROFILE_MAP.set( - "ssh", [{ - name: "ssh", - type: "ssh", - ...UNIT_TEST_SSH_PROF_OPTS - }] -); -const UNIT_TEST_PROFILES_SSH = new CommandProfiles(UNIT_TEST_PROFILE_MAP); - -const UNIT_TEST_PROFILE_MAP_PRIVATE_KEY = new Map(); -UNIT_TEST_PROFILE_MAP_PRIVATE_KEY.set( - "ssh", [{ - name: "ssh", - type: "ssh", - ...UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY - }] -); -const UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE = new Map(); -UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE.set( - "ssh", [{ - name: "ssh", - type: "ssh", - ...UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE - }] -); -const UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER = new Map(); -UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE.set( - "ssh", [{ - name: "ssh", - type: "ssh", - ...UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER - }] -); - -const UNIT_TEST_PROFILES_SSH_PRIVATE_KEY = new CommandProfiles(UNIT_TEST_PROFILE_MAP_PRIVATE_KEY); -const UNIT_TEST_PROFILES_SSH_PRIVATE_KEY_WITH_PASSPHRASE = new CommandProfiles(UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE); -const UNIT_TEST_PROFILES_SSH_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER = new CommandProfiles(UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER); - // Mocked parameters for the unit tests const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_SSH_PROF_OPTS, positionals: ["zos-uss", "issue", "ssh"], - definition: SshDefinition.SshDefinition, - profiles: UNIT_TEST_PROFILES_SSH + definition: SshDefinition.SshDefinition }); const DEFAULT_PARAMETERS_PRIVATE_KEY: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY, positionals: ["zos-uss", "issue", "ssh"], - definition: SshDefinition.SshDefinition, - profiles: UNIT_TEST_PROFILES_SSH_PRIVATE_KEY + definition: SshDefinition.SshDefinition }); const DEFAULT_PARAMETERS_KEY_PASSPHRASE: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE, positionals: ["zos-uss", "issue", "ssh"], - definition: SshDefinition.SshDefinition, - profiles: UNIT_TEST_PROFILES_SSH_PRIVATE_KEY_WITH_PASSPHRASE, + definition: SshDefinition.SshDefinition }); const DEFAULT_PARAMETERS_KEY_PASSPHRASE_NO_USER: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER, positionals: ["zos-uss", "issue", "ssh"], - definition: SshDefinition.SshDefinition, - profiles: UNIT_TEST_PROFILES_SSH_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER, + definition: SshDefinition.SshDefinition }); const testOutput = "TEST OUTPUT"; diff --git a/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/invalid/Cmd.cli.invalid.profile-spec.integration.test.ts b/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/invalid/Cmd.cli.invalid.profile-spec.integration.test.ts deleted file mode 100644 index fb1f2c2c38..0000000000 --- a/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/invalid/Cmd.cli.invalid.profile-spec.integration.test.ts +++ /dev/null @@ -1,40 +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 { ITestEnvironment } from "../../../../../../__src__/environment/doc/response/ITestEnvironment"; -import { SetupTestEnvironment } from "../../../../../../__src__/environment/SetupTestEnvironment"; -import { runCliScript } from "../../../../../../src/TestUtil"; - - -let TEST_ENVIRONMENT: ITestEnvironment; - -describe("cmd-cli invalid profile-spec", () => { - // Create the unique test environment - beforeAll(async () => { - TEST_ENVIRONMENT = await SetupTestEnvironment.createTestEnv({ - cliHomeEnvVar: "CMD_CLI_CLI_HOME", - testName: "cmd_cli_invalid_profile_spec" - }); - }); - - it("should fail the command if the profile property is not supplied and the handler requests a profile", () => { - const response = runCliScript(__dirname + "/__scripts__/profile-spec.sh", TEST_ENVIRONMENT.workingDir); - expect(response.stdout.toString()).toBe(''); - expect(response.stderr.toString()).toContain('Internal Error: No profiles of type "blah" were loaded for this command.'); - expect(response.status).toBe(1); - expect(response.stderr.toString()).toContain('This error can occur for one of two reasons:'); - expect(response.stderr.toString()).toContain('- The "profile" property on the command definition document ' + - 'does NOT specify the requested profile type'); - expect(response.stderr.toString()).toContain('- The profile type is marked "optional", ' + - 'no profiles of type "blah" have been created, ' + - 'and the command handler requested a profile of type "blah" with "failNotFound=true"'); - }); -}); diff --git a/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/invalid/__scripts__/profile-spec.sh b/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/invalid/__scripts__/profile-spec.sh deleted file mode 100644 index 1879d239cd..0000000000 --- a/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/invalid/__scripts__/profile-spec.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -cmd-cli invalid profile-spec -exit $? \ No newline at end of file diff --git a/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/root/__snapshots__/Cmd.cli.root.integration.test.ts.snap b/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/root/__snapshots__/Cmd.cli.root.integration.test.ts.snap index 8606fe3568..0a4eb0e99b 100644 --- a/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/root/__snapshots__/Cmd.cli.root.integration.test.ts.snap +++ b/packages/imperative/__tests__/__integration__/cmd/__tests__/integration/cli/root/__snapshots__/Cmd.cli.root.integration.test.ts.snap @@ -196,11 +196,6 @@ cmd-cli invalid no-handler This will never get invoked. No handler specified on this definition. -cmd-cli invalid profile-spec - - Command handler attempts to load a profile that wasn't specified on the command - definition - cmd-cli invoke exit-143 Test handler that exits with status code 143 @@ -260,10 +255,6 @@ cmd-cli profile mapping-positional Tests Imperative's profile to CLI mapping capabilities. -cmd-cli read profile - - Read some profiles - cmd-cli respond with-data-array Formulates a string array object to pass back when response format JSON is diff --git a/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/Invalid.definition.ts b/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/Invalid.definition.ts index d6ca7fef31..6c0fa036ba 100644 --- a/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/Invalid.definition.ts +++ b/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/Invalid.definition.ts @@ -12,15 +12,13 @@ import { ICommandDefinition } from "../../../../../../lib/index"; import { NoHandlerDefinition } from "./no-handler/NoHandler.definition"; import { InvalidHandlerDefinition } from "./invalid-handler/InvalidHandler.definition"; -import { ProfileSpecDefinition } from "./profile-spec/ProfileSpec.definition"; export const definition: ICommandDefinition = { name: "invalid", description: "Attempt to invoke commands that have poorly coded definitions.", summary: "Invalid definitions", type: "group", - children: [NoHandlerDefinition, InvalidHandlerDefinition, - ProfileSpecDefinition] + children: [NoHandlerDefinition, InvalidHandlerDefinition] }; module.exports = definition; diff --git a/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/profile-spec/ProfileSpec.definition.ts b/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/profile-spec/ProfileSpec.definition.ts deleted file mode 100644 index a14f67bb4c..0000000000 --- a/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/profile-spec/ProfileSpec.definition.ts +++ /dev/null @@ -1,21 +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 { ICommandDefinition } from "../../../../../../../lib"; - - -export const ProfileSpecDefinition: ICommandDefinition = { - name: "profile-spec", - aliases: ["ao"], - description: "Command handler attempts to load a profile that wasn't specified on the command definition", - type: "command", - handler: __dirname + "/ProfileSpec.handler" -}; diff --git a/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/profile-spec/ProfileSpec.handler.ts b/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/profile-spec/ProfileSpec.handler.ts deleted file mode 100644 index 750248d6c4..0000000000 --- a/packages/imperative/__tests__/__integration__/cmd/src/cli/invalid/profile-spec/ProfileSpec.handler.ts +++ /dev/null @@ -1,19 +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 { ICommandHandler, IHandlerParameters } from "../../../../../../../lib"; - -export default class ProfileSpecHandler implements ICommandHandler { - public async process(params: IHandlerParameters): Promise { - // eslint-disable-next-line deprecation/deprecation - params.profiles.get("blah"); - } -} diff --git a/packages/imperative/__tests__/__integration__/cmd/src/cli/read/Read.definition.ts b/packages/imperative/__tests__/__integration__/cmd/src/cli/read/Read.definition.ts deleted file mode 100644 index d10a2b8121..0000000000 --- a/packages/imperative/__tests__/__integration__/cmd/src/cli/read/Read.definition.ts +++ /dev/null @@ -1,23 +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 { ICommandDefinition } from "../../../../../../lib"; -import { ProfileCommand } from "./profile/Profile.definition"; - -export const definition: ICommandDefinition = { - name: "read", - description: "Read some profiles", - summary: "Read some profiles", - type: "group", - children: [ProfileCommand], -}; - -module.exports = definition; diff --git a/packages/imperative/__tests__/__integration__/cmd/src/cli/read/profile/Profile.definition.ts b/packages/imperative/__tests__/__integration__/cmd/src/cli/read/profile/Profile.definition.ts deleted file mode 100644 index f8a0337eef..0000000000 --- a/packages/imperative/__tests__/__integration__/cmd/src/cli/read/profile/Profile.definition.ts +++ /dev/null @@ -1,23 +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 { ICommandDefinition } from "../../../../../../../lib"; - -export const ProfileCommand: ICommandDefinition = { - name: "profile", - description: "Read some profiles", - summary: "Read some profiles", - type: "command", - handler: __dirname + "/Profile.handler", - profile: { - required: ["insecure"] - } -}; diff --git a/packages/imperative/__tests__/__integration__/cmd/src/cli/read/profile/Profile.handler.ts b/packages/imperative/__tests__/__integration__/cmd/src/cli/read/profile/Profile.handler.ts deleted file mode 100644 index 18da0fe758..0000000000 --- a/packages/imperative/__tests__/__integration__/cmd/src/cli/read/profile/Profile.handler.ts +++ /dev/null @@ -1,20 +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 { IHandlerParameters, ICommandHandler, TextUtils } from "../../../../../../../lib/index"; - -export default class FirstGroupCommandOneHandler implements ICommandHandler { - public async process(params: IHandlerParameters): Promise { - // eslint-disable-next-line deprecation/deprecation - const prof = params.profiles.get("insecure"); - params.response.console.log(TextUtils.prettyJson(prof)); - } -} diff --git a/packages/imperative/__tests__/src/packages/cmd/__integration__/CliProfileManager.integration.test.ts b/packages/imperative/__tests__/src/packages/cmd/__integration__/CliProfileManager.integration.test.ts index 22ebad1b72..4f5ce662af 100644 --- a/packages/imperative/__tests__/src/packages/cmd/__integration__/CliProfileManager.integration.test.ts +++ b/packages/imperative/__tests__/src/packages/cmd/__integration__/CliProfileManager.integration.test.ts @@ -9,6 +9,8 @@ * */ +/* eslint-disable deprecation/deprecation */ + import * as TestUtil from "../../../TestUtil"; import { TestLogger } from "../../../../src/TestLogger"; import { CliProfileManager } from "../../../../../src/cmd/src/profiles/CliProfileManager"; diff --git a/packages/imperative/src/cmd/__tests__/CommandProcessor.unit.test.ts b/packages/imperative/src/cmd/__tests__/CommandProcessor.unit.test.ts index be3f7bfe2a..a333af0ebf 100644 --- a/packages/imperative/src/cmd/__tests__/CommandProcessor.unit.test.ts +++ b/packages/imperative/src/cmd/__tests__/CommandProcessor.unit.test.ts @@ -18,7 +18,6 @@ import { IHelpGenerator } from "../src/help/doc/IHelpGenerator"; import { ImperativeError } from "../../error"; import { ICommandValidatorResponse } from "../src/doc/response/response/ICommandValidatorResponse"; import { SharedOptions } from "../src/utils/SharedOptions"; -import { CommandProfileLoader } from "../src/profiles/CommandProfileLoader"; import { CliUtils } from "../../utilities/src/CliUtils"; import { WebHelpManager } from "../src/help/WebHelpManager"; import { ImperativeConfig } from "../../utilities/src/ImperativeConfig"; @@ -789,43 +788,6 @@ describe("Command Processor", () => { expect(logOutput).toContain("--user **** --password **** --token-value **** --cert-file-passphrase **** --cert-key-file ****"); }); - it("should handle an error thrown from the profile loader", async () => { - // Allocate the command processor - const processor: CommandProcessor = new CommandProcessor({ - envVariablePrefix: ENV_VAR_PREFIX, - fullDefinition: SAMPLE_COMPLEX_COMMAND, - definition: SAMPLE_COMMAND_REAL_HANDLER, - helpGenerator: FAKE_HELP_GENERATOR, - rootCommandName: SAMPLE_ROOT_COMMAND, - commandLine: "", - promptPhrase: "dummydummy" - }); - - // Mock read stdin - (SharedOptions.readStdinIfRequested as any) = jest.fn((args, response, type) => { - // Nothing to do - }); - - // Mock the profile loader - CommandProfileLoader.loader = jest.fn((args) => { - throw new ImperativeError({ msg: "Profile loading failed!" }); - }); - - const parms: any = { - arguments: { _: ["check", "for", "banana"], $0: "", valid: true }, - responseFormat: "json", silent: true - }; - const commandResponse: ICommandResponse = await processor.invoke(parms); - - expect(commandResponse).toBeDefined(); - const stderrText = (commandResponse.stderr as Buffer).toString(); - expect(stderrText).toContain("Command Preparation Failed:"); - expect(stderrText).toContain("Profile loading failed!"); - expect(commandResponse.message).toEqual("Profile loading failed!"); - expect(commandResponse.error?.msg).toEqual("Profile loading failed!"); - expect(commandResponse.error?.additionalDetails).not.toBeDefined(); - }); - it("should handle not being able to instantiate the handler", async () => { // Allocate the command processor const processor: CommandProcessor = new CommandProcessor({ @@ -843,15 +805,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -897,15 +850,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -948,15 +892,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1008,15 +943,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1050,15 +976,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1100,15 +1017,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1150,15 +1058,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1200,15 +1099,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1253,15 +1143,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1301,15 +1182,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1342,15 +1214,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1484,15 +1347,6 @@ describe("Command Processor", () => { config: ImperativeConfig.instance.config }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - return; - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1595,15 +1449,6 @@ describe("Command Processor", () => { config: ImperativeConfig.instance.config }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - return; - } - }; - }); - const parms: any = { arguments: { _: ["check", "for", "banana"], @@ -1667,19 +1512,8 @@ describe("Command Processor", () => { config: ImperativeConfig.instance.config }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - return; - } - }; - }); - // return the "fake" args object with values from profile - CliUtils.getOptValueFromProfiles = jest.fn((cmdProfiles, profileDef, allOpts) => { - return {}; - }); + CliUtils.getOptValuesFromConfig = jest.fn().mockReturnValue({}); const parms: any = { arguments: { @@ -1767,15 +1601,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - jest.spyOn(process, "chdir"); const mockConfigReload = jest.fn(); jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ @@ -1833,15 +1658,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - jest.spyOn(process, "chdir"); const mockConfigReload = jest.fn(); jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({ @@ -1886,7 +1702,8 @@ describe("Command Processor", () => { helpGenerator: FAKE_HELP_GENERATOR, rootCommandName: SAMPLE_ROOT_COMMAND, commandLine: "", - promptPhrase: "dummydummy" + promptPhrase: "dummydummy", + config: ImperativeConfig.instance.config }); // Mock read stdin @@ -1894,21 +1711,8 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - return; - } - }; - }); - // return the "fake" args object with values from profile - CliUtils.getOptValueFromProfiles = jest.fn((cmdProfiles, profileDef, allOpts) => { - return { - color: "yellow" - }; - }); + CliUtils.getOptValuesFromConfig = jest.fn().mockReturnValue({ color: "yellow" }); const parms: any = { arguments: { @@ -1920,7 +1724,7 @@ describe("Command Processor", () => { }; const commandResponse: ICommandResponse = await processor.invoke(parms); - expect(CliUtils.getOptValueFromProfiles).toHaveBeenCalledTimes(1); + expect(CliUtils.getOptValuesFromConfig).toHaveBeenCalledTimes(1); expect(commandResponse.stdout.toString()).toMatchSnapshot(); expect(commandResponse).toBeDefined(); expect(commandResponse).toMatchSnapshot(); @@ -1942,19 +1746,8 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - return; - } - }; - }); - // return the "fake" args object with values from profile - CliUtils.getOptValueFromProfiles = jest.fn((cmdProfiles, profileDef, allOpts) => { - return {}; - }); + CliUtils.getOptValuesFromConfig = jest.fn().mockReturnValue({}); const parms: any = { arguments: { @@ -1979,7 +1772,8 @@ describe("Command Processor", () => { helpGenerator: FAKE_HELP_GENERATOR, rootCommandName: SAMPLE_ROOT_COMMAND, commandLine: "", - promptPhrase: "dummydummy" + promptPhrase: "dummydummy", + config: ImperativeConfig.instance.config }); // Mock read stdin @@ -1987,21 +1781,8 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - return; - } - }; - }); - // return the "fake" args object with values from profile - CliUtils.getOptValueFromProfiles = jest.fn((cmdProfiles, profileDef, allOpts) => { - return { - color: "yellow" - }; - }); + CliUtils.getOptValuesFromConfig = jest.fn().mockReturnValue({ color: "yellow" }); const parms: any = { arguments: { @@ -2013,7 +1794,7 @@ describe("Command Processor", () => { }; const commandResponse: ICommandResponse = await processor.invoke(parms); - expect(CliUtils.getOptValueFromProfiles).toHaveBeenCalledTimes(1); + expect(CliUtils.getOptValuesFromConfig).toHaveBeenCalledTimes(1); expect(commandResponse.stdout.toString()).toMatchSnapshot(); expect(commandResponse).toBeDefined(); expect(commandResponse).toMatchSnapshot(); @@ -2027,7 +1808,8 @@ describe("Command Processor", () => { helpGenerator: FAKE_HELP_GENERATOR, rootCommandName: SAMPLE_ROOT_COMMAND, commandLine: "", - promptPhrase: "dummydummy" + promptPhrase: "dummydummy", + config: ImperativeConfig.instance.config }); // Mock read stdin @@ -2035,21 +1817,8 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - return; - } - }; - }); - // return the "fake" args object with values from profile - CliUtils.getOptValueFromProfiles = jest.fn((cmdProfiles, profileDef, allOpts) => { - return { - color: "yellow" - }; - }); + CliUtils.getOptValuesFromConfig = jest.fn().mockReturnValue({ color: "yellow" }); const parms: any = { arguments: { @@ -2062,7 +1831,7 @@ describe("Command Processor", () => { }; const commandResponse: ICommandResponse = await processor.invoke(parms); - expect(CliUtils.getOptValueFromProfiles).toHaveBeenCalledTimes(1); + expect(CliUtils.getOptValuesFromConfig).toHaveBeenCalledTimes(1); expect(commandResponse.stdout.toString()).toMatchSnapshot(); expect(commandResponse).toBeDefined(); expect(commandResponse).toMatchSnapshot(); @@ -2076,7 +1845,8 @@ describe("Command Processor", () => { helpGenerator: FAKE_HELP_GENERATOR, rootCommandName: SAMPLE_ROOT_COMMAND, commandLine: "", - promptPhrase: "dummydummy" + promptPhrase: "dummydummy", + config: ImperativeConfig.instance.config }); // Mock read stdin @@ -2084,21 +1854,8 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - return; - } - }; - }); - // return the "fake" args object with values from profile - CliUtils.getOptValueFromProfiles = jest.fn((cmdProfiles, profileDef, allOpts) => { - return { - color: "yellow" - }; - }); + CliUtils.getOptValuesFromConfig = jest.fn().mockReturnValue({ color: "yellow" }); const parms: any = { arguments: { @@ -2111,7 +1868,7 @@ describe("Command Processor", () => { }; const commandResponse: ICommandResponse = await processor.invoke(parms); - expect(CliUtils.getOptValueFromProfiles).toHaveBeenCalledTimes(1); + expect(CliUtils.getOptValuesFromConfig).toHaveBeenCalledTimes(1); expect(commandResponse.stdout.toString()).toMatchSnapshot(); expect(commandResponse).toBeDefined(); expect(commandResponse).toMatchSnapshot(); @@ -2171,15 +1928,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: [], @@ -2215,15 +1963,6 @@ describe("Command Processor", () => { // Nothing to do }); - // Mock the profile loader - (CommandProfileLoader.loader as any) = jest.fn((args) => { - return { - loadProfiles: (profArgs: any) => { - // Nothing to do - } - }; - }); - const parms: any = { arguments: { _: [], @@ -2419,22 +2158,22 @@ describe("Command Processor", () => { }); it("should find profile that matches name specified in arguments", async () => { - const commandPrepared = await (processor as any).prepare(null, { + const preparedArgs = await (processor as any).prepare(null, { "banana-profile": "ripe" }); - expect(commandPrepared.args.color).toBe("yellow"); + expect(preparedArgs.color).toBe("yellow"); }); it("should find profile with type prefix that matches name specified in arguments", async () => { - const commandPrepared = await (processor as any).prepare(null, { + const preparedArgs = await (processor as any).prepare(null, { "banana-profile": "old" }); - expect(commandPrepared.args.color).toBe("brown"); + expect(preparedArgs.color).toBe("brown"); }); it("should find default profile that matches type", async () => { - const commandPrepared = await (processor as any).prepare(null, {}); - expect(commandPrepared.args.color).toBe("green"); + const preparedArgs = await (processor as any).prepare(null, {}); + expect(preparedArgs.color).toBe("green"); }); }); }); diff --git a/packages/imperative/src/cmd/__tests__/profiles/CliProfileManager.unit.test.ts b/packages/imperative/src/cmd/__tests__/profiles/CliProfileManager.unit.test.ts index 8985e6b2a0..714dfc7d44 100644 --- a/packages/imperative/src/cmd/__tests__/profiles/CliProfileManager.unit.test.ts +++ b/packages/imperative/src/cmd/__tests__/profiles/CliProfileManager.unit.test.ts @@ -9,6 +9,8 @@ * */ +/* eslint-disable deprecation/deprecation */ + import { ImperativeError } from "../../../error"; import { TestLogger } from "../../../../__tests__/src/TestLogger"; import { APPLE_PROFILE_TYPE, ONLY_APPLE } from "./TestConstants"; diff --git a/packages/imperative/src/cmd/__tests__/profiles/CommandProfileLoader.unit.test.ts b/packages/imperative/src/cmd/__tests__/profiles/CommandProfileLoader.unit.test.ts index 0f5cea376b..a23e844942 100644 --- a/packages/imperative/src/cmd/__tests__/profiles/CommandProfileLoader.unit.test.ts +++ b/packages/imperative/src/cmd/__tests__/profiles/CommandProfileLoader.unit.test.ts @@ -9,6 +9,8 @@ * */ +/* eslint-disable deprecation/deprecation */ + import { CommandProfileLoader } from "../../src/profiles/CommandProfileLoader"; import { ICommandDefinition } from "../../src/doc/ICommandDefinition"; import { TestLogger } from "../../../../__tests__/src/TestLogger"; diff --git a/packages/imperative/src/cmd/__tests__/profiles/CommandProfiles.unit.test.ts b/packages/imperative/src/cmd/__tests__/profiles/CommandProfiles.unit.test.ts index 48352581fc..a8d2397c8a 100644 --- a/packages/imperative/src/cmd/__tests__/profiles/CommandProfiles.unit.test.ts +++ b/packages/imperative/src/cmd/__tests__/profiles/CommandProfiles.unit.test.ts @@ -9,6 +9,8 @@ * */ +/* eslint-disable deprecation/deprecation */ + import { IProfile, IProfileLoaded } from "../../../profiles"; import { CommandProfiles } from "../../src/profiles/CommandProfiles"; import { ImperativeError } from "../../../error"; diff --git a/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/AddTwoNumbersHandler.ts b/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/AddTwoNumbersHandler.ts deleted file mode 100644 index 0f3db4eef3..0000000000 --- a/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/AddTwoNumbersHandler.ts +++ /dev/null @@ -1,20 +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 { ICommandHandler, IHandlerParameters } from "../../../"; - -export default class AddTwoNumbersHandler implements ICommandHandler { - public async process(params: IHandlerParameters): Promise { - const sum = params.arguments.a + params.arguments.b; - params.response.console.log("updated sum to: " + sum); - params.response.data.setObj({sum}); - } -} diff --git a/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/DoNothingHandler.ts b/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/DoNothingHandler.ts deleted file mode 100644 index ab19d2da81..0000000000 --- a/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/DoNothingHandler.ts +++ /dev/null @@ -1,19 +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 { ICommandHandler, IHandlerParameters } from "../../../"; - -export default class DoNothingHandler implements ICommandHandler { - public async process(params: IHandlerParameters): Promise { - params.response.console.log("Doing nothing "); - params.response.data.setObj({}); - } -} diff --git a/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/ThrowErrorHandler.ts b/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/ThrowErrorHandler.ts deleted file mode 100644 index 021b5f32d2..0000000000 --- a/packages/imperative/src/cmd/__tests__/profiles/profileHandlers/ThrowErrorHandler.ts +++ /dev/null @@ -1,18 +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 { ICommandHandler, IHandlerParameters } from "../../../"; - -export default class ThrowErrorHandler implements ICommandHandler { - public async process(params: IHandlerParameters): Promise { - throw new Error("threw an error"); - } -} diff --git a/packages/imperative/src/cmd/src/CommandProcessor.ts b/packages/imperative/src/cmd/src/CommandProcessor.ts index 5adfe0ad0e..bdb78ee99d 100644 --- a/packages/imperative/src/cmd/src/CommandProcessor.ts +++ b/packages/imperative/src/cmd/src/CommandProcessor.ts @@ -17,11 +17,8 @@ import { ICommandHandler } from "./doc/handler/ICommandHandler"; import { couldNotInstantiateCommandHandler, unexpectedCommandError } from "../../messages"; import { SharedOptions } from "./utils/SharedOptions"; import { IImperativeError, ImperativeError } from "../../error"; -import { ProfileUtils } from "../../profiles"; import { SyntaxValidator } from "./syntax/SyntaxValidator"; -import { CommandProfileLoader } from "./profiles/CommandProfileLoader"; import { IHelpGenerator } from "./help/doc/IHelpGenerator"; -import { ICommandPrepared } from "./doc/response/response/ICommandPrepared"; import { CommandResponse } from "./response/CommandResponse"; import { ICommandResponse } from "./doc/response/response/ICommandResponse"; import { Logger } from "../../logger"; @@ -40,7 +37,6 @@ import { Constants } from "../../constants"; import { ICommandArguments } from "./doc/args/ICommandArguments"; import { CliUtils } from "../../utilities/src/CliUtils"; import { WebHelpManager } from "./help/WebHelpManager"; -import { ICommandProfile } from "./doc/profiles/definition/ICommandProfile"; import { Config } from "../../config/src/Config"; import { ConfigUtils } from "../../config/src/ConfigUtils"; import { ConfigConstants } from "../../config/src/ConfigConstants"; @@ -409,7 +405,7 @@ export class CommandProcessor { prepareResponse.succeeded(); // Prepare for command processing - load profiles, stdin, etc. - let prepared: ICommandPrepared; + let preparedArgs: ICommandArguments; try { // Build the response object, base args object, and the entire array of options for this command // Assume that the command succeed, it will be marked otherwise under the appropriate failure conditions @@ -442,7 +438,7 @@ export class CommandProcessor { } this.log.info(`Preparing (loading profiles, reading stdin, etc.) execution of "${this.definition.name}" command...`); - prepared = await this.prepare(prepareResponse, params.arguments); + preparedArgs = await this.prepare(prepareResponse, params.arguments); } catch (prepareErr) { // Indicate that the command has failed @@ -475,7 +471,7 @@ export class CommandProcessor { } // Recreate the response object with the update params from prepare. - params.arguments = prepared.args; + params.arguments = preparedArgs; const response = this.constructResponseObject(params); response.succeeded(); @@ -488,36 +484,36 @@ export class CommandProcessor { // convert if positional is an array designated by "..." const positionalName = positional.name.replace("...", ""); // check if value provided - if (prepared.args[positionalName] != null) { + if (preparedArgs[positionalName] != null) { // string processing - if (typeof prepared.args[positionalName] === "string" && - prepared.args[positionalName].toUpperCase() === this.promptPhrase.toUpperCase()) { + if (typeof preparedArgs[positionalName] === "string" && + preparedArgs[positionalName].toUpperCase() === this.promptPhrase.toUpperCase()) { // prompt has been requested for a positional this.log.debug("Prompting for positional %s which was requested by passing the value %s", positionalName, this.promptPhrase); - prepared.args[positionalName] = + preparedArgs[positionalName] = await response.console.prompt(`"${positionalName}" Description: ` + `${positional.description}\nPlease enter "${positionalName}":`, { hideText: true, secToWait: 0 }); } // array processing else { - if (prepared.args[positionalName] != null && - Array.isArray(prepared.args[positionalName]) && - prepared.args[positionalName][0] != null && - typeof prepared.args[positionalName][0] === "string" && - prepared.args[positionalName][0].toUpperCase() === this.promptPhrase.toUpperCase()) { + if (preparedArgs[positionalName] != null && + Array.isArray(preparedArgs[positionalName]) && + preparedArgs[positionalName][0] != null && + typeof preparedArgs[positionalName][0] === "string" && + preparedArgs[positionalName][0].toUpperCase() === this.promptPhrase.toUpperCase()) { // prompt has been requested for a positional this.log.debug("Prompting for positional %s which was requested by passing the value %s", - prepared.args[positionalName][0], this.promptPhrase); - prepared.args[positionalName][0] = + preparedArgs[positionalName][0], this.promptPhrase); + preparedArgs[positionalName][0] = await response.console.prompt(`"${positionalName}" Description: ` + `${positional.description}\nPlease enter "${positionalName}":`, { hideText: true, secToWait: 0 }); // prompting enters as string but need to place it in array - const array = prepared.args[positionalName][0].split(" "); - prepared.args[positionalName] = array; + const array = preparedArgs[positionalName][0].split(" "); + preparedArgs[positionalName] = array; } } } @@ -527,48 +523,48 @@ export class CommandProcessor { if (this.definition.options != null && this.definition.options.length > 0) { for (const option of this.definition.options) { // check if value provided - if (prepared.args[option.name] != null) { + if (preparedArgs[option.name] != null) { // string processing - if (typeof prepared.args[option.name] === "string" && - prepared.args[option.name].toUpperCase() === this.promptPhrase.toUpperCase()) { + if (typeof preparedArgs[option.name] === "string" && + preparedArgs[option.name].toUpperCase() === this.promptPhrase.toUpperCase()) { // prompt has been requested for an --option this.log.debug("Prompting for option %s which was requested by passing the value %s", option.name, this.promptPhrase); - prepared.args[option.name] = + preparedArgs[option.name] = await response.console.prompt(`"${option.name}" Description: ` + `${option.description}\nPlease enter "${option.name}":`, { hideText: true, secToWait: 0 }); const camelCase = CliUtils.getOptionFormat(option.name).camelCase; - prepared.args[camelCase] = prepared.args[option.name]; + preparedArgs[camelCase] = preparedArgs[option.name]; if (option.aliases != null) { for (const alias of option.aliases) { // set each alias of the args object as well - prepared.args[alias] = prepared.args[option.name]; + preparedArgs[alias] = preparedArgs[option.name]; } } } // array processing else { - if (Array.isArray(prepared.args[option.name]) && - prepared.args[option.name][0] != null && - typeof prepared.args[option.name][0] === "string" && - prepared.args[option.name][0].toUpperCase() === this.promptPhrase.toUpperCase()) { + if (Array.isArray(preparedArgs[option.name]) && + preparedArgs[option.name][0] != null && + typeof preparedArgs[option.name][0] === "string" && + preparedArgs[option.name][0].toUpperCase() === this.promptPhrase.toUpperCase()) { // prompt has been requested for an --option this.log.debug("Prompting for option %s which was requested by passing the value %s", option.name, this.promptPhrase); - prepared.args[option.name][0] = + preparedArgs[option.name][0] = await response.console.prompt(`"${option.name}" Description: ` + `${option.description}\nPlease enter "${option.name}":`, { hideText: true, secToWait: 0 }); - const array = prepared.args[option.name][0].split(" "); - prepared.args[option.name] = array; + const array = preparedArgs[option.name][0].split(" "); + preparedArgs[option.name] = array; const camelCase = CliUtils.getOptionFormat(option.name).camelCase; - prepared.args[camelCase] = prepared.args[option.name]; + preparedArgs[camelCase] = preparedArgs[option.name]; if (option.aliases != null) { for (const alias of option.aliases) { // set each alias of the args object as well - prepared.args[alias] = prepared.args[option.name]; + preparedArgs[alias] = preparedArgs[option.name]; } } } @@ -595,7 +591,7 @@ export class CommandProcessor { // Validate that the syntax is correct for the command let validator: ICommandValidatorResponse; try { - validator = await this.validate(prepared.args, response); + validator = await this.validate(preparedArgs, response); } catch (e) { const errMsg: string = `Unexpected syntax validation error`; const errReason: string = errMsg + ": " + e.message; @@ -630,9 +626,8 @@ export class CommandProcessor { const handlerParms: IHandlerParameters = { response, - profiles: prepared.profiles, - arguments: prepared.args, - positionals: prepared.args._, + arguments: preparedArgs, + positionals: preparedArgs._, definition: this.definition, fullDefinition: this.fullDefinition, stdin: this.getStdinStream() @@ -696,16 +691,15 @@ export class CommandProcessor { try { await handler.process({ response: chainedResponse, - profiles: prepared.profiles, arguments: ChainedHandlerService.getArguments( this.mCommandRootName, this.definition.chainedHandlers, chainedHandlerIndex, chainedResponses, - prepared.args, + preparedArgs, this.log ), - positionals: prepared.args._, + positionals: preparedArgs._, definition: this.definition, fullDefinition: this.fullDefinition, stdin: this.getStdinStream(), @@ -882,9 +876,9 @@ export class CommandProcessor { * the command handler is invoked. * @param {CommandResponse} response: The response object for command messaging. * @param {yargs.Arguments} commandArguments: The arguments specified on the command line. - * @return {Promise}: Promise to fulfill when complete. + * @return {Promise}: Promise to fulfill when complete. */ - private async prepare(response: CommandResponse, commandArguments: Arguments): Promise { + private async prepare(response: CommandResponse, commandArguments: Arguments): Promise { // Construct the imperative arguments - replacement/wrapper for Yargs to insulate handlers against any // changes made to Yargs let args: ICommandArguments = CliUtils.buildBaseArgs(commandArguments); @@ -905,100 +899,11 @@ export class CommandProcessor { this.log.trace(`Reading stdin for "${this.definition.name}" command...`); await SharedOptions.readStdinIfRequested(commandArguments, response, this.definition.type); - // Build a list of all profile types - this will help us search the CLI - // options for profiles specified by the user - let allTypes: string[] = []; - if (this.definition.profile != null) { - if (this.definition.profile.required != null) - allTypes = allTypes.concat(this.definition.profile.required); - if (this.definition.profile.optional != null) - allTypes = allTypes.concat(this.definition.profile.optional); - } - // Build an object that contains all the options loaded from config - const fulfilled: string[] = []; - let fromCnfg: any = {}; if (this.mConfig != null) { - for (const profileType of allTypes) { - const opt = ProfileUtils.getProfileOptionAndAlias(profileType)[0]; - // If the config contains the requested profiles, then "remember" - // that this type has been fulfilled - so that we do NOT load from - // the traditional profile location - const profileTypePrefix = profileType + "_"; - let p: any = {}; - if (args[opt] != null && this.mConfig.api.profiles.exists(args[opt])) { - fulfilled.push(profileType); - p = this.mConfig.api.profiles.get(args[opt]); - } else if (args[opt] != null && !args[opt].startsWith(profileTypePrefix) && - this.mConfig.api.profiles.exists(profileTypePrefix + args[opt])) { - fulfilled.push(profileType); - p = this.mConfig.api.profiles.get(profileTypePrefix + args[opt]); - } else if (args[opt] == null && - this.mConfig.properties.defaults[profileType] != null && - this.mConfig.api.profiles.exists(this.mConfig.properties.defaults[profileType])) { - fulfilled.push(profileType); - p = this.mConfig.api.profiles.defaultGet(profileType); - } - fromCnfg = { ...p, ...fromCnfg }; - } - } - - // Convert each property extracted from the config to the correct yargs - // style cases for the command handler (kebab and camel) - allOpts.forEach((opt) => { - const cases = CliUtils.getOptionFormat(opt.name); - const profileKebab = fromCnfg[cases.kebabCase]; - const profileCamel = fromCnfg[cases.camelCase]; - - if ((profileCamel !== undefined || profileKebab !== undefined) && - (!Object.prototype.hasOwnProperty.call(args, cases.kebabCase) && - !Object.prototype.hasOwnProperty.call(args, cases.camelCase))) { - - // If both case properties are present in the profile, use the one that matches - // the option name explicitly - const value = profileKebab !== undefined && profileCamel !== undefined ? - opt.name === cases.kebabCase ? profileKebab : profileCamel : - profileKebab !== undefined ? profileKebab : profileCamel; - const keys = CliUtils.setOptionValue(opt.name, - "aliases" in opt ? opt.aliases : [], - value - ); - fromCnfg = { ...fromCnfg, ...keys }; - } - }); - - // Merge the arguments from the config into the CLI args - this.log.trace(`Arguments extracted from the config:\n${inspect(fromCnfg)}`); - args = CliUtils.mergeArguments(fromCnfg, args); - - // Load all profiles for the command - this.log.trace(`Loading profiles for "${this.definition.name}" command. ` + - `Profile definitions: ${inspect(this.definition.profile, { depth: null })}`); - - const profiles = await CommandProfileLoader.loader({ - commandDefinition: this.definition - }).loadProfiles(args); - this.log.trace(`Profiles loaded for "${this.definition.name}" command:\n${inspect(profiles, { depth: null })}`); - - // If we have profiles listed on the command definition (the would be loaded already) - // we can extract values from them for options arguments - if (this.definition.profile != null) { - - // "fake out" the cli util to only populate options for profiles - // that have not been fulfilled by the config - const p: ICommandProfile = { - required: [], - optional: [], - suppressOptions: this.definition.profile.suppressOptions - }; - - if (this.definition.profile.required) - p.required = this.definition.profile.required.filter(type => fulfilled.indexOf(type) < 0); - if (this.definition.profile.optional) - p.optional = this.definition.profile.optional.filter(type => fulfilled.indexOf(type) < 0); - - const profArgs = CliUtils.getOptValueFromProfiles(profiles, p, allOpts); - this.log.trace(`Arguments extract from the profile:\n${inspect(profArgs)}`); + // Merge the arguments from the config into the CLI args + const profArgs = CliUtils.getOptValuesFromConfig(this.mConfig, this.definition, args, allOpts); + this.log.trace(`Arguments extracted from the config:\n${inspect(profArgs)}`); args = CliUtils.mergeArguments(profArgs, args); } @@ -1020,7 +925,7 @@ export class CommandProcessor { // Log for debugging this.log.trace(`Full argument object constructed:\n${inspect(args)}`); - return { profiles, args }; + return args; } /** diff --git a/packages/imperative/src/cmd/src/doc/handler/IHandlerParameters.ts b/packages/imperative/src/cmd/src/doc/handler/IHandlerParameters.ts index 247b68bcde..d2c960091f 100644 --- a/packages/imperative/src/cmd/src/doc/handler/IHandlerParameters.ts +++ b/packages/imperative/src/cmd/src/doc/handler/IHandlerParameters.ts @@ -11,7 +11,6 @@ import * as stream from "stream"; import { ICommandDefinition } from "../ICommandDefinition"; -import { CommandProfiles } from "../../profiles/CommandProfiles"; import { IHandlerResponseApi } from "../../doc/response/api/handler/IHandlerResponseApi"; import { ICommandArguments } from "../args/ICommandArguments"; @@ -52,15 +51,6 @@ export interface IHandlerParameters { */ positionals: (string | number)[]; - /** - * The set of profiles loaded for this command handler - the map is built with the key being the type and it - * returns the set of profiles loaded of that type. Multiple profiles can be loaded of the same type - depending - * on the request and the 0th entry is the first loaded. - * @type {Map} - * @memberof IHandlerParameters - */ - profiles: CommandProfiles; - /** * The command definition node that defines the command being issued. * @type {ICommandDefinition} diff --git a/packages/imperative/src/cmd/src/doc/response/response/ICommandPrepared.ts b/packages/imperative/src/cmd/src/doc/response/response/ICommandPrepared.ts deleted file mode 100644 index 636e0fbc58..0000000000 --- a/packages/imperative/src/cmd/src/doc/response/response/ICommandPrepared.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* This program and the accompanying materials are made available under the terms of the -* Eclipse Public License v2.0 which accompanies this distribution, and is available at -* https://www.eclipse.org/legal/epl-v20.html -* -* SPDX-License-Identifier: EPL-2.0 -* -* Copyright Contributors to the Zowe Project. -* -*/ - -import { CommandProfiles } from "../../../../src/profiles/CommandProfiles"; -import { ICommandArguments } from "../../../../src/doc/args/ICommandArguments"; -/** - * Command Processor prepare response. - * @export - * @interface ICommandPrepared - */ -export interface ICommandPrepared { - /** - * The profile map object for all profiles loaded for commands. - * @type {CommandProfiles} - * @memberof ICommandPrepared - */ - profiles: CommandProfiles; - /** - * Imperative arguments object. Starts with arguments passed parsed by - * Yargs as a base and fills in the rest from ENV/profile/defaults. - * Eventually passed to handlers. - * @type {ICommandArguments} - */ - args: ICommandArguments; -} diff --git a/packages/imperative/src/cmd/src/profiles/CliProfileManager.ts b/packages/imperative/src/cmd/src/profiles/CliProfileManager.ts index f71896074e..0989f2435c 100644 --- a/packages/imperative/src/cmd/src/profiles/CliProfileManager.ts +++ b/packages/imperative/src/cmd/src/profiles/CliProfileManager.ts @@ -27,6 +27,7 @@ import { * * The Profile Manager no longer reads V1 profile from disk. It only processes profile information from a * command's definition. The Config class now handles reading profiles from disk stored in a zowe.config.json file. + * @deprecated Use the `V1ProfileRead` class if you still need to read V1 profiles */ export class CliProfileManager { /** diff --git a/packages/imperative/src/cmd/src/profiles/CommandProfileLoader.ts b/packages/imperative/src/cmd/src/profiles/CommandProfileLoader.ts index 516b688a9f..2db7b75422 100644 --- a/packages/imperative/src/cmd/src/profiles/CommandProfileLoader.ts +++ b/packages/imperative/src/cmd/src/profiles/CommandProfileLoader.ts @@ -24,6 +24,7 @@ import { ImperativeExpect } from "../../../expect"; * command handlers usage). * @internal * @class CommandProfileLoader + * @deprecated Use the `V1ProfileRead` class if you still need to read V1 profiles */ export class CommandProfileLoader { /** @@ -34,6 +35,7 @@ export class CommandProfileLoader { * @memberof CommandProfileLoader */ public static loader(parms: ICommandProfileLoaderParms) { + // eslint-disable-next-line deprecation/deprecation return new CommandProfileLoader(parms.commandDefinition, parms.logger || Logger.getImperativeLogger()); } @@ -76,6 +78,7 @@ export class CommandProfileLoader { * Imperative error * @memberof CommandProfileLoader */ + // eslint-disable-next-line deprecation/deprecation public async loadProfiles(commandArguments: Arguments): Promise { // Validate parms ImperativeExpect.toNotBeNullOrUndefined(commandArguments, `Could not load profiles. No command arguments supplied.`); @@ -89,6 +92,7 @@ export class CommandProfileLoader { const profileMetaMap: Map = new Map(); // We no longer read V1 profile files, so just return empty maps + // eslint-disable-next-line deprecation/deprecation return new CommandProfiles(profileMap, profileMetaMap); } diff --git a/packages/imperative/src/cmd/src/profiles/CommandProfiles.ts b/packages/imperative/src/cmd/src/profiles/CommandProfiles.ts index 919d384350..e57a267d41 100644 --- a/packages/imperative/src/cmd/src/profiles/CommandProfiles.ts +++ b/packages/imperative/src/cmd/src/profiles/CommandProfiles.ts @@ -17,6 +17,7 @@ import { ImperativeExpect } from "../../../expect"; * Profiles map created by the command profile loader and passed to the handler via parameters. Handlers can * retrieve loaded profiles from the map via the profile type. * @class CommandProfiles + * @deprecated Use the `V1ProfileRead` class if you still need to read V1 profiles */ export class CommandProfiles { /** diff --git a/packages/imperative/src/imperative/__tests__/handlers/DefaultRootCommandHandler.unit.test.ts b/packages/imperative/src/imperative/__tests__/handlers/DefaultRootCommandHandler.unit.test.ts index f9f931687d..f61dbf32f5 100644 --- a/packages/imperative/src/imperative/__tests__/handlers/DefaultRootCommandHandler.unit.test.ts +++ b/packages/imperative/src/imperative/__tests__/handlers/DefaultRootCommandHandler.unit.test.ts @@ -116,7 +116,6 @@ describe("Default Root Command Handler", () => { arguments: {_: [], $0: ""}, definition: prepared.children?.[0].children?.[0] as any, fullDefinition: prepared, - profiles: undefined as any, positionals: [], stdin: process.stdin }); @@ -136,7 +135,6 @@ describe("Default Root Command Handler", () => { arguments: {_: [], $0: "", availableCommands: true}, definition: MULTIPLE_GROUPS, fullDefinition: MULTIPLE_GROUPS, - profiles: undefined as any, positionals: [], stdin: process.stdin }); @@ -159,7 +157,6 @@ describe("Default Root Command Handler", () => { arguments: {_: [], $0: "", version: true}, definition: MULTIPLE_GROUPS.children?.[0].children?.[0] as any, fullDefinition: MULTIPLE_GROUPS, - profiles: undefined as any, positionals: [], stdin: process.stdin }); diff --git a/packages/imperative/src/imperative/src/api/ImperativeApi.ts b/packages/imperative/src/imperative/src/api/ImperativeApi.ts index 358cbec56a..3fb75a82d9 100644 --- a/packages/imperative/src/imperative/src/api/ImperativeApi.ts +++ b/packages/imperative/src/imperative/src/api/ImperativeApi.ts @@ -12,7 +12,6 @@ import { IImperativeConfig } from "../doc/IImperativeConfig"; import { IImperativeApi } from "./doc/IImperativeApi"; import { Logger } from "../../../logger"; -import { CliProfileManager } from "../../../cmd"; export class ImperativeApi { /** @@ -63,18 +62,4 @@ export class ImperativeApi { public addAdditionalLogger(name: string, logger: Logger): void { this.mCustomLoggerMap[name] = logger; } - - /** - * Return an instance of a profile manager for a given profile type - * See ProfileManager.ts for more details - * @internal - */ - public profileManager(type: string): CliProfileManager { - return new CliProfileManager({ - type, - typeConfigurations: this.mConfig.profiles, - logger: this.imperativeLogger, - productDisplayName: this.mConfig.productDisplayName - }); - } } diff --git a/packages/imperative/src/utilities/__tests__/CliUtils.unit.test.ts b/packages/imperative/src/utilities/__tests__/CliUtils.unit.test.ts index ea94d6435c..b53c83c35c 100644 --- a/packages/imperative/src/utilities/__tests__/CliUtils.unit.test.ts +++ b/packages/imperative/src/utilities/__tests__/CliUtils.unit.test.ts @@ -294,6 +294,7 @@ describe("CliUtils", () => { let error; try { const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(new Map()), { required: ["banana"] }, FAKE_OPTS); @@ -307,6 +308,7 @@ describe("CliUtils", () => { it("should return nothing if a profile was optional and not loaded", () => { const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(new Map()), { optional: ["banana"] }, FAKE_OPTS); @@ -317,6 +319,7 @@ describe("CliUtils", () => { const map = new Map(); map.set("banana", [{ type: "banana", name: "fakebanana", nohyphen: "specified in profile" }]); const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(map), { optional: ["banana"] }, FAKE_OPTS); @@ -332,6 +335,7 @@ describe("CliUtils", () => { "could-be-either": "should not be me" }]); const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(map), { optional: ["banana"] }, FAKE_OPTS); @@ -347,6 +351,7 @@ describe("CliUtils", () => { "fake-string-opt": "should be me" }]); const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(map), { optional: ["banana"] }, FAKE_OPTS); @@ -361,6 +366,7 @@ describe("CliUtils", () => { "could-be-either": "should be me" }]); const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(map), { optional: ["banana"] }, FAKE_OPTS); @@ -375,6 +381,7 @@ describe("CliUtils", () => { fakeStringOpt: "should be me" }]); const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(map), { optional: ["banana"] }, FAKE_OPTS); @@ -389,6 +396,7 @@ describe("CliUtils", () => { withAlias: "should have 'w' on args object too" }]); const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(map), { optional: ["banana"] }, FAKE_OPTS); @@ -403,6 +411,7 @@ describe("CliUtils", () => { username: "fake" }]); const args = CliUtils.getOptValueFromProfiles( + // eslint-disable-next-line deprecation/deprecation new CommandProfiles(map), { optional: ["banana"] }, FAKE_OPTS); diff --git a/packages/imperative/src/utilities/src/CliUtils.ts b/packages/imperative/src/utilities/src/CliUtils.ts index 8b2612f7da..460d025750 100644 --- a/packages/imperative/src/utilities/src/CliUtils.ts +++ b/packages/imperative/src/utilities/src/CliUtils.ts @@ -18,10 +18,13 @@ import { CommandProfiles, ICommandOptionDefinition, ICommandPositionalDefinition ICommandProfile, IHandlerParameters } from "../../cmd"; import { ICommandArguments } from "../../cmd/src/doc/args/ICommandArguments"; -import { IProfile } from "../../profiles"; +import { IProfile } from "../../profiles/src/doc/definition/IProfile"; +import { ProfileUtils } from "../../profiles/src/utils/ProfileUtils"; import { IPromptOptions } from "../../cmd/src/doc/response/api/handler/IPromptOptions"; import { read } from "read"; import { ICommandDefinition } from "../../cmd"; +import { Config } from "../../config"; + /** * Cli Utils contains a set of static methods/helpers that are CLI related (forming options, censoring args, etc.) * @export @@ -117,6 +120,7 @@ export class CliUtils { * * @memberof CliUtils */ + // eslint-disable-next-line deprecation/deprecation public static getOptValueFromProfiles(profiles: CommandProfiles, definitions: ICommandProfile, options: Array): any { let args: any = {}; @@ -185,6 +189,82 @@ export class CliUtils { return args; } + /** + * Searches properties in team configuration and attempts to match the option names supplied with profile keys. + * @param {Config} config - Team config API + * @param {ICommandDefinition} definition - Definition of invoked command + * @param {ICommandArguments} args - Arguments from command line and environment + * @param {(Array)} allOpts - the full set of command options + * for the command being processed + * + * @returns {*} + * + * @memberof CliUtils + */ + public static getOptValuesFromConfig(config: Config, definition: ICommandDefinition, args: ICommandArguments, + allOpts: Array): any { + // Build a list of all profile types - this will help us search the CLI + // options for profiles specified by the user + let allTypes: string[] = []; + if (definition.profile != null) { + if (definition.profile.required != null) + allTypes = allTypes.concat(definition.profile.required); + if (definition.profile.optional != null) + allTypes = allTypes.concat(definition.profile.optional); + } + + // Build an object that contains all the options loaded from config + const fulfilled: string[] = []; + let fromCnfg: any = {}; + for (const profileType of allTypes) { + const opt = ProfileUtils.getProfileOptionAndAlias(profileType)[0]; + // If the config contains the requested profiles, then "remember" + // that this type has been fulfilled - so that we do NOT load from + // the traditional profile location + const profileTypePrefix = profileType + "_"; + let p: any = {}; + if (args[opt] != null && config.api.profiles.exists(args[opt])) { + fulfilled.push(profileType); + p = config.api.profiles.get(args[opt]); + } else if (args[opt] != null && !args[opt].startsWith(profileTypePrefix) && + config.api.profiles.exists(profileTypePrefix + args[opt])) { + fulfilled.push(profileType); + p = config.api.profiles.get(profileTypePrefix + args[opt]); + } else if (args[opt] == null && + config.properties.defaults[profileType] != null && + config.api.profiles.exists(config.properties.defaults[profileType])) { + fulfilled.push(profileType); + p = config.api.profiles.defaultGet(profileType); + } + fromCnfg = { ...p, ...fromCnfg }; + } + + // Convert each property extracted from the config to the correct yargs + // style cases for the command handler (kebab and camel) + allOpts.forEach((opt) => { + const cases = CliUtils.getOptionFormat(opt.name); + const profileKebab = fromCnfg[cases.kebabCase]; + const profileCamel = fromCnfg[cases.camelCase]; + + if ((profileCamel !== undefined || profileKebab !== undefined) && + (!Object.prototype.hasOwnProperty.call(args, cases.kebabCase) && + !Object.prototype.hasOwnProperty.call(args, cases.camelCase))) { + + // If both case properties are present in the profile, use the one that matches + // the option name explicitly + const value = profileKebab !== undefined && profileCamel !== undefined ? + opt.name === cases.kebabCase ? profileKebab : profileCamel : + profileKebab !== undefined ? profileKebab : profileCamel; + const keys = CliUtils.setOptionValue(opt.name, + "aliases" in opt ? opt.aliases : [], + value + ); + fromCnfg = { ...fromCnfg, ...keys }; + } + }); + return fromCnfg; + } + /** * Using Object.assign(), merges objects in the order they appear in call. Object.assign() copies and overwrites * existing properties in the target object, meaning property precedence is least to most (left to right). diff --git a/packages/zosuss/__tests__/__unit__/SshBaseHandler.unit.test.ts b/packages/zosuss/__tests__/__unit__/SshBaseHandler.unit.test.ts index 5e9365250a..3f8ee619f4 100644 --- a/packages/zosuss/__tests__/__unit__/SshBaseHandler.unit.test.ts +++ b/packages/zosuss/__tests__/__unit__/SshBaseHandler.unit.test.ts @@ -9,7 +9,7 @@ * */ -import { IHandlerParameters, IProfile, CommandProfiles, ConnectionPropsForSessCfg } from "@zowe/imperative"; +import { IHandlerParameters, ConnectionPropsForSessCfg } from "@zowe/imperative"; import { mockHandlerParameters } from "@zowe/cli-test-utils"; import { join, normalize } from "path"; import { Shell } from "../../src/Shell"; @@ -45,73 +45,28 @@ const UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER = { keyPassPhrase: "dummyPassPhrase123" }; - -// A mocked profile map with ssh profile -const UNIT_TEST_PROFILE_MAP = new Map(); -UNIT_TEST_PROFILE_MAP.set( - "ssh", [{ - name: "ssh", - type: "ssh", - ...UNIT_TEST_SSH_PROF_OPTS - }] -); -const UNIT_TEST_PROFILES_SSH = new CommandProfiles(UNIT_TEST_PROFILE_MAP); - -const UNIT_TEST_PROFILE_MAP_PRIVATE_KEY = new Map(); -UNIT_TEST_PROFILE_MAP_PRIVATE_KEY.set( - "ssh", [{ - name: "ssh", - type: "ssh", - ...UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY - }] -); -const UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE = new Map(); -UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE.set( - "ssh", [{ - name: "ssh", - type: "ssh", - ...UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE - }] -); -const UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER = new Map(); -UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE.set( - "ssh", [{ - name: "ssh", - type: "ssh", - ...UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER - }] -); - -const UNIT_TEST_PROFILES_SSH_PRIVATE_KEY = new CommandProfiles(UNIT_TEST_PROFILE_MAP_PRIVATE_KEY); -const UNIT_TEST_PROFILES_SSH_PRIVATE_KEY_WITH_PASSPHRASE = new CommandProfiles(UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE); -const UNIT_TEST_PROFILES_SSH_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER = new CommandProfiles(UNIT_TEST_PROFILE_MAP_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER); - // Mocked parameters for the unit tests const DEFAULT_PARAMETERS: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_SSH_PROF_OPTS, positionals: ["zos-uss", "issue", "ssh"], - definition: {} as any, - profiles: UNIT_TEST_PROFILES_SSH + definition: {} as any }); const DEFAULT_PARAMETERS_PRIVATE_KEY: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY, positionals: ["zos-uss", "issue", "ssh"], - definition: {} as any, - profiles: UNIT_TEST_PROFILES_SSH_PRIVATE_KEY + definition: {} as any }); const DEFAULT_PARAMETERS_KEY_PASSPHRASE: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE, positionals: ["zos-uss", "issue", "ssh"], - definition: {} as any, - profiles: UNIT_TEST_PROFILES_SSH_PRIVATE_KEY_WITH_PASSPHRASE, + definition: {} as any }); const DEFAULT_PARAMETERS_KEY_PASSPHRASE_NO_USER: IHandlerParameters = mockHandlerParameters({ arguments: UNIT_TEST_SSH_PROF_OPTS_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER, positionals: ["zos-uss", "issue", "ssh"], - definition: {} as any, - profiles: UNIT_TEST_PROFILES_SSH_PRIVATE_KEY_WITH_PASSPHRASE_NO_USER, + definition: {} as any }); class myHandler extends SshBaseHandler {