Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the 'zowe profiles' command command handlers & APIs #2073

Merged
merged 80 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
1bc9229
Remove profile cmd definition builders, handlers, unit tests
gejohnston Jan 11, 2024
30dd3aa
Remove obsolete unused profile constants
gejohnston Jan 11, 2024
652b1aa
Remove obsolete unused profile constants - 2
gejohnston Jan 11, 2024
4356787
Merge remote-tracking branch 'origin/no-v1-profiles' into rm-profile-…
gejohnston Jan 18, 2024
90e7ad1
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Jan 19, 2024
a71d465
Remove getMeta. Related to V1 profiles
gejohnston Jan 22, 2024
576f7ec
Remove calls to commandParameters.profiles.get & getMeta
gejohnston Jan 22, 2024
1a0300a
Remove logic to login/logout with V1 profiles
gejohnston Jan 22, 2024
2bda169
Replace test logic that relied on V1 profile APIs.
gejohnston Jan 22, 2024
2b1e387
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Jan 22, 2024
ce31224
Remove CommandProfiles.get()
gejohnston Jan 23, 2024
d2b5875
Fix typo on profile name.
gejohnston Jan 23, 2024
66d95ca
Restore CommandProfiles.get(). Remove getAll()
gejohnston Jan 31, 2024
358a6a3
Restore the use of params.profiles.get() in tests
gejohnston Feb 1, 2024
44f33c1
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 2, 2024
3a18010
Remove xxxProfileManager.saveProfile and updateProfile
gejohnston Feb 5, 2024
68ac43c
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 6, 2024
4a9e2c5
Remove unused imports
gejohnston Feb 6, 2024
53fb480
Remove xxxProfileManager.deleteProfile
gejohnston Feb 6, 2024
0aab0ec
Put @internal annotation on loadAll()
gejohnston Feb 6, 2024
dd0bebe
Mark classes internal. Remove unused ProfileUtils.
gejohnston Feb 7, 2024
b303e0b
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 8, 2024
8058f99
Remove createProfileFromArgumentsHandler, createProfileExamples, setD…
gejohnston Feb 8, 2024
5b47af0
Remove more createProfileExamples and createProfileFromArgumentsHandler
gejohnston Feb 8, 2024
0d0f1eb
Change references from V2 Config to Team Config
gejohnston Feb 8, 2024
a7ba019
Remove unused imports.
gejohnston Feb 8, 2024
fa037d4
Add issue numbers to CHANGELOG.
gejohnston Feb 8, 2024
17e16e1
Mark ImperativeApi.profileManager as internal
gejohnston Feb 8, 2024
723f8f9
Add onlyV1ProfilesExist. Use it to display message before prompting
gejohnston Feb 12, 2024
9bbb458
Remove v1 profile operations and usingTeamConfig
gejohnston Feb 12, 2024
58e4d15
Add tests for onlyV1ProfilesExist
gejohnston Feb 13, 2024
ffdc0bb
Remove tests for V1 profiles and usingTeamConfig
gejohnston Feb 13, 2024
e70f9ae
Add try-catch around ImperativeConfig.instance.cliHome
gejohnston Feb 13, 2024
523b351
Add guard around connOpts?.parms?.response?.console?.log
gejohnston Feb 13, 2024
d741cc9
Fix snapshots for 'no config' message - round 1
gejohnston Feb 13, 2024
db652f6
Remove new message before prompting for values
gejohnston Feb 14, 2024
aaf8cc7
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 14, 2024
e1a7a00
removing profileVersion from returned array
ATorrise Feb 15, 2024
1cde362
removing the same type of unecessary output from EnvQuery
ATorrise Feb 15, 2024
da98a07
adding to changelog and removing from test files
ATorrise Feb 15, 2024
965605f
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 15, 2024
e9b04de
Fix CHANGELOG release label broken by a merge
gejohnston Feb 16, 2024
ec22412
Remove V1 profile I/O from AbstractProfileManager.load
gejohnston Feb 16, 2024
b45f0e0
int test update
ATorrise Feb 20, 2024
7d17143
removing profile: v1 tests
ATorrise Feb 20, 2024
9aaa0a6
removing team config vs v1 specific tests and leaving generic tests b…
ATorrise Feb 20, 2024
0a8b311
fix unit tests
ATorrise Feb 20, 2024
a5164e8
fixing tests - putting back in right test, taking out wrong test - th…
ATorrise Feb 20, 2024
64c18f8
Consolidate AbstractProfileManager and BasicProfileManager into CliPr…
gejohnston Feb 20, 2024
c76c93b
fixing failing test examining secure parms
ATorrise Feb 22, 2024
395acb1
Alphabetize changelog entries
gejohnston Feb 22, 2024
a58990a
Remove ProfileManagerFactory from CommandProcessor.unit.test
gejohnston Feb 22, 2024
1d04772
Remove BasicProfileManager & Factory from CommandProfileLoader.unit.t…
gejohnston Feb 22, 2024
b77dbc4
Removed BasicProfileManager unit tests.
gejohnston Feb 22, 2024
e5e59f1
Merge branch 'rm-profile-handlers' into show-inputs-only
ATorrise Feb 22, 2024
38e78bd
removing unused import
ATorrise Feb 22, 2024
29d7d59
adding back describe profiles
ATorrise Feb 22, 2024
ac29e75
adding back parens
ATorrise Feb 22, 2024
13dcdc7
Remove obsolete Cmd.cli.read.profile.integration.tests
gejohnston Feb 22, 2024
50c1f92
Update integration tests for CliProfileManager
gejohnston Feb 22, 2024
52913b7
Remove profileManagerFactory from ProfileCommandExample.integration.test
gejohnston Feb 22, 2024
123318e
Remove integration tests for BasicProfileManager and CliProfileManage…
gejohnston Feb 22, 2024
2ca8661
Remove CliProfileManager.credentials test from imperative.secure.inte…
gejohnston Feb 22, 2024
3fcffd1
Example CLI integration tests no longer expect values to be read from…
gejohnston Feb 23, 2024
ff4fbd4
Merge branch 'rm-profile-handlers' into show-inputs-only
ATorrise Feb 23, 2024
ae06f7f
hopefully fixes failing unit test
ATorrise Feb 23, 2024
d7813e2
Merge pull request #2053 from zowe/show-inputs-only
gejohnston Feb 23, 2024
f394e83
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 23, 2024
e97a0c8
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 26, 2024
67c2c8a
Merge remote-tracking branch 'origin/next' into rm-profile-handlers a…
gejohnston Feb 26, 2024
7899b15
report-env no longer reports V1 profiles & handles having no config a…
gejohnston Feb 27, 2024
e5c30c9
Changlog entry for removal of ProfileUtils.ts
gejohnston Feb 27, 2024
6cfc699
Changelog entries for zosmf, zos-tso, and zos-uss
gejohnston Feb 27, 2024
dc1eac7
Remove unused variables
gejohnston Feb 27, 2024
f95d0d4
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 27, 2024
86559e1
Restore getZoweDir( ) into ProfileInfo
gejohnston Feb 28, 2024
77ae643
Merge remote-tracking branch 'origin/next' into rm-profile-handlers
gejohnston Feb 28, 2024
c4f89c1
node engine shrinkwrap update
gejohnston Feb 28, 2024
2c94e07
Remove test file that has no tests.
gejohnston Feb 28, 2024
a38c22d
Remove unused profileVersion property.
gejohnston Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
/* eslint-disable max-len */

describe("Imperative Secure Tests", () => {
require("./../../packages/imperative/__tests__/src/packages/profiles/__integration__/CliProfileManager.credentials.integration.subtest");
require("./../../packages/imperative/__tests__/src/packages/imperative/__integration__/PluginManagementFacility.integration.subtest");
require("./../../packages/imperative/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/init/cli.imperative-test-cli.config.init.integration.subtest");
require("./../../packages/imperative/__tests__/__integration__/imperative/__tests__/__integration__/cli/config/auto-init/imperative.test.cli.config.auto-init.fruit.integration.subtest");
Expand Down
11 changes: 0 additions & 11 deletions __tests__/__packages__/cli-test-utils/src/TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,6 @@ export function runCliScript(scriptPath: string, testEnvironment: ITestEnvironme
}
}

/**
* Strip v1 profile deprecation messages from stderr output.
*/
export function stripProfileDeprecationMessages(stderr: Buffer | string): string {
return stderr.toString()
.replace(/Warning: The command 'profiles [a-z]+' is deprecated\./g, "")
.replace(/Recommended replacement: The 'config [a-z]+' command/g, "")
.replace(/Recommended replacement: Edit your Zowe V2 configuration\s+zowe\.config\.json/g, "")
.trim();
}

/**
* Type for handler data used to build mock IHandlerParameters object.
* The type inherits from IHandlerParameters but is different:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
import * as fs from "fs";

import { v4 as uuidv4 } from "uuid";
import { Config, ImperativeError, IO } from "@zowe/imperative";
import { Config } from "@zowe/imperative";

import { ITestEnvironment } from "./doc/response/ITestEnvironment";
import { runCliScript, stripProfileDeprecationMessages } from "../TestUtils";

/**
* Utilities for creating and cleaning up temporary profiles for tests
Expand Down Expand Up @@ -53,12 +52,6 @@ export class TempTestProfiles {
`installed or linked globally so that '${TempTestProfiles.BINARY_NAME}' can be issued to create profiles and ` +
`issue other commands.`;

/**
* Override for the ZOWE_CLI_TEST_OLD_PROFILES environment variable. If
* set to true, old-school profiles will be created instead of team config.
*/
public static forceOldProfiles: boolean = false;

/**
* Create profiles for tests from data in the properties yaml file
* @param {ITestEnvironment} testEnvironment - with working directory and test properties loaded
Expand All @@ -73,11 +66,7 @@ export class TempTestProfiles {
const profileNames: { [key: string]: string[] } = {};
this.log(testEnvironment, "Creating the following profileTypes: " + profileTypes);
for (const profileType of profileTypes) {
if (this.usingTeamConfig) {
profileNames[profileType] = [await this.createV2Profile(testEnvironment, profileType)];
} else {
profileNames[profileType] = [await this.createV1Profile(testEnvironment, profileType)];
}
profileNames[profileType] = [await this.createV2Profile(testEnvironment, profileType)];
}
return profileNames;
}
Expand All @@ -94,11 +83,7 @@ export class TempTestProfiles {
this.log(testEnvironment, "Deleting the following profiles:\n" + JSON.stringify(profiles));
for (const profileType of Object.keys(profiles)) {
for (const profileName of profiles[profileType]) {
if (this.usingTeamConfig) {
await this.deleteV2Profile(testEnvironment, profileType, profileName);
} else {
await this.deleteV1Profile(testEnvironment, profileType, profileName);
}
await this.deleteV2Profile(testEnvironment, profileType, profileName);
}
}
}
Expand All @@ -111,44 +96,6 @@ export class TempTestProfiles {
*/
private static readonly MAX_UUID_LENGTH = 20;

/**
* Whether new team config profiles should be used instead of old school
* profiles.
*/
private static get usingTeamConfig(): boolean {
if (this.forceOldProfiles) return false;
const envOldProfiles = process.env.ZOWE_CLI_TEST_OLD_PROFILES;
return envOldProfiles !== "1" && envOldProfiles?.toLowerCase() !== "true";
}

/**
* Helper to create a temporary old school profile from test properties
* @param {ITestEnvironment} testEnvironment - the test environment with env and working directory to use for output
* @returns {Promise<string>} promise that resolves to the name of the created profile on success
* @throws errors if the profile creation fails
*/
private static async createV1Profile(testEnvironment: ITestEnvironment<any>, profileType: string): Promise<string> {
const profileName: string = uuidv4().substring(0, TempTestProfiles.MAX_UUID_LENGTH) + "_tmp_" + profileType;
let createProfileScript = this.SHEBANG +
`${this.BINARY_NAME} profiles create ${profileType} ${profileName}`;
for (const [k, v] of Object.entries(testEnvironment.systemTestProperties[profileType])) {
createProfileScript += ` ${(k.length > 1) ? "--" : "-"}${k} ${v}`;
}
const scriptPath = testEnvironment.workingDir + "_create_profile_" + profileName;
await IO.writeFileAsync(scriptPath, createProfileScript);
const output = runCliScript(scriptPath, testEnvironment, []);
if (output.status !== 0 || stripProfileDeprecationMessages(output.stderr).length > 0) {
throw new ImperativeError({
msg: `Creation of ${profileType} profile '${profileName}' failed! You should delete the script: ` +
`'${scriptPath}' after reviewing it to check for possible errors. Stderr of the profile create ` +
`command:\n` + output.stderr.toString() + TempTestProfiles.GLOBAL_INSTALL_NOTE
});
}
IO.deleteFile(scriptPath);
this.log(testEnvironment, `Created ${profileType} V1 profile '${profileName}'. Stdout from creation:\n${output.stdout.toString()}`);
return profileName;
}

/**
* Helper to create a temporary team config profile from test properties
* @internal
Expand Down Expand Up @@ -176,31 +123,6 @@ export class TempTestProfiles {
return profileName;
}

/**
* Helper to delete a temporary old school profile
* @param {ITestEnvironment} testEnvironment - the test environment with env and working directory to use for output
* @param {string} profileType - the type of profile e.g. zosmf to
* @param {string} profileName - the name of the profile to delete
* @returns {Promise<string>} promise that resolves to the name of the created profile on success
* @throws errors if the profile delete fails
*/
private static async deleteV1Profile(testEnvironment: ITestEnvironment<any>, profileType: string, profileName: string): Promise<string> {
const deleteProfileScript = this.SHEBANG + `${this.BINARY_NAME} profiles delete ${profileType} ${profileName} --force`;
const scriptPath = testEnvironment.workingDir + "_delete_profile_" + profileName;
await IO.writeFileAsync(scriptPath, deleteProfileScript);
const output = runCliScript(scriptPath, testEnvironment, []);
if (output.status !== 0 || stripProfileDeprecationMessages(output.stderr).length > 0) {
throw new ImperativeError({
msg: "Deletion of " + profileType + " profile '" + profileName + "' failed! You should delete the script: '" + scriptPath + "' " +
"after reviewing it to check for possible errors. Stderr of the profile create command:\n" + output.stderr.toString()
+ TempTestProfiles.GLOBAL_INSTALL_NOTE
});
}
this.log(testEnvironment, `Deleted ${profileType} V1 profile '${profileName}'. Stdout from deletion:\n${output.stdout.toString()}`);
IO.deleteFile(scriptPath);
return profileName;
}

/**
* Helper to delete a temporary team config profile
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ export class TestEnvironment {
}

// the result of the test environment setup so far is used to create profiles
TempTestProfiles.forceOldProfiles = params.createOldProfiles ?? false;
if (TempTestProfiles.forceOldProfiles || (params.tempProfileTypes?.length ?? 0 > 0)) {
if (params.tempProfileTypes?.length ?? 0 > 0) {
result.tempProfiles = await TempTestProfiles.createProfiles(result, params.tempProfileTypes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,4 @@ export interface ISetupEnvironmentParms {
* you are trying to execute plugin commands installed into Zowe CLI.
*/
installPlugin?: boolean;

/**
* Should old-school profiles be created instead of team config?
* Default: false
*/
createOldProfiles?: boolean;
}
7 changes: 6 additions & 1 deletion packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to the Zowe CLI package will be documented in this file.

## Recent Changes

- BugFix: Eliminated a Node Version Manager (NVM) GUI popup dialog which NVM now displays during the `zowe config report-env` command by removing the NVM version number from our report.
- Enhancement: Replaced the term "Team configuration" with "Zowe client configuration" in the `zowe config report-env` command.

## `8.0.0-next.202402261705`

- BugFix: Updated additional dependencies for technical currency. [#2061](https://github.com/zowe/zowe-cli/pull/2061)
Expand Down Expand Up @@ -37,7 +42,7 @@ LTS Breaking: Removed the following previously deprecated items: [#1981](https:/
- SSH_OPTION_HOST_PROFILE use SSH_OPTION_HOST
- Removed zosmfProfile from `ZosFilesBase.handler.ts`
- Removed statCmdFlag as an export from Shell.ts


## `8.0.0-next.202401262128`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,47 +79,6 @@ describe("TargetProfileHandler", () => {
});
});

it("should merge properties from v1 profiles and command arguments", async () => {
const commandParameters = {
...DEFAULT_PARAMETERS,
arguments: {
...DEFAULT_PARAMETERS.arguments,
host: "example1.com",
user: "user1",
password: "password1",
targetUser: "user2",
targetPassword: "password3",
targetZosmfProfile: "target_zosmf"
}
};

commandParameters.response.data.setObj = jest.fn();
const getProfileMock = jest.fn().mockReturnValue({
password: "password2",
port: 123
});
commandParameters.profiles.get = getProfileMock;
jest.spyOn(ImperativeConfig, "instance", "get").mockReturnValue({
config: { exists: false }
} as any);

const handler = new TargetProfileHandler();
await handler.process(commandParameters);

expect(getProfileMock).toHaveBeenCalledTimes(1);
expect(commandParameters.response.data.setObj).toHaveBeenCalledWith({
apiResponse: {
sessCfg: expect.objectContaining({
hostname: "example1.com",
port: 123,
user: "user2",
password: "password3"
})
},
success: true
});
});

it("should handle error loading target z/OSMF profile", async () => {
const commandParameters = {
...DEFAULT_PARAMETERS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("submit shared handler", () => {

expect(error).toBeDefined();
expect(error instanceof ImperativeError).toBe(true);
expect(error.message).toMatchSnapshot();
expect(error.message).toContain("Unable to determine the JCL source. Please contact support");
});

it("should not transform an error thrown by the submit JCL API", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`submit shared handler error handling should detect if the JCL source type (data set, etc.) could not be determined 1`] = `"Internal submit error: Unable to determine the JCL source. Please contact support."`;

exports[`submit shared handler process method should submit JCL contained within a data-set if requested 1`] = `
Object {
"fields": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ export default class TargetProfileHandler extends ZosFilesBaseHandler {

try {
if (targetProfileName != null) {
if (ImperativeConfig.instance.config?.exists) {
targetCmdArgs = ImperativeConfig.instance.config.api.profiles.get(targetProfileName);
} else {
targetCmdArgs = params.profiles.get("zosmf", false, targetProfileName);
}
targetCmdArgs = ImperativeConfig.instance.config.api.profiles.get(targetProfileName);
}

const targetPrefix = "target";
Expand Down
6 changes: 6 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to the Zowe core SDK package will be documented in this file.

## Recent Changes

- LTS Breaking: Removed the file ProfileUtils.ts which contains the following obsolete V1 profile functions:
- getDefaultProfile
- getZoweDir

## `8.0.0-next.202402261705`

- BugFix: Updated additional dependencies for technical currency. [#2061](https://github.com/zowe/zowe-cli/pull/2061)
Expand Down
Loading
Loading