Skip to content

Commit

Permalink
Merge pull request #1734 from zowe/imp-979
Browse files Browse the repository at this point in the history
Handle new APIML unique cookie identifier
  • Loading branch information
traeok authored Aug 4, 2023
2 parents 3d81e91 + 4a9056f commit bc9b85c
Show file tree
Hide file tree
Showing 27 changed files with 193 additions and 65 deletions.
7 changes: 6 additions & 1 deletion packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ All notable changes to the Zowe CLI package will be documented in this file.
## Recent Changes

- Enhancement: Updated daemon on MacOS to use universal binary which adds support for Apple Silicon.
- BugFix: Fixed an issue in the Daemon server which prevents users on Windows with uppercase letters in their username from using the Daemon
- Enhancement: Added support for mutliple `zowe auth login apiml` operations on a single `zowe config secure` call. [#1734](https://github.com/zowe/zowe-cli/pull/1734)
- Enhancement: Replaced use of `node-keytar` with the `keyring` module from `@zowe/secrets-for-zowe-sdk`.
- Enhancement: Updated the Imperative Framework to add support for unique cookie identifiers from API ML. [#1734](https://github.com/zowe/zowe-cli/pull/1734)
- BugFix: Fixed an issue in the Daemon server which prevents users on Windows with uppercase letters in their username from using the Daemon
- BugFix: Add check for invalid block size when creating a sequential dataset. [#1439](https://github.com/zowe/zowe-cli/issues/1439)
- BugFix: Allowed `logout` operations with invalid and/or expired tokens. [#1734](https://github.com/zowe/zowe-cli/pull/1734)
- BugFix: Prevented misleading `basePath error` when credentials are invalid. [#1734](https://github.com/zowe/zowe-cli/pull/1734)

## `7.17.0`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ exports[`auth login/logout apiml help should display the logout help 1`] = `
The type of token to get and use for the API. Omit this option to use the
default token type, which is provided by 'zowe auth login'.
Allowed values: apimlAuthenticationToken, jwtToken, LtpaToken2
Allowed values: ^apimlAuthenticationToken.*, jwtToken, LtpaToken2
--token-value | --tv (string)
Expand Down Expand Up @@ -206,8 +206,8 @@ exports[`auth login/logout apiml help should display the logout help 1`] = `
\\"success\\": true,
\\"exitCode\\": 0,
\\"message\\": \\"The help was constructed for command: apiml.\\",
\\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n apiml\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Log out of the Zowe API Mediation Layer authentication service and revoke the\\\\n token so it can no longer authenticate. Also remove the token from the default\\\\n base profile, if it is stored on disk.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe auth logout apiml [options]\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n Host name of service on the mainframe.\\\\n\\\\n --port | -P (number)\\\\n\\\\n Port number of service on the mainframe.\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n Allowed values: apimlAuthenticationToken, jwtToken, LtpaToken2\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Log out of an API ML instance to revoke the token that was\\\\n in use and remove it from your base profile:\\\\n\\\\n $ zowe auth logout apiml\\\\n\\\\n - Log out of an API ML instance to revoke a token that was\\\\n not stored in a profile:\\\\n\\\\n $ zowe auth logout apiml --token-value <token>\\\\n\\\\n\\",
\\"stdout\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n apiml\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Log out of the Zowe API Mediation Layer authentication service and revoke the\\\\n token so it can no longer authenticate. Also remove the token from the default\\\\n base profile, if it is stored on disk.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe auth logout apiml [options]\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n Host name of service on the mainframe.\\\\n\\\\n --port | -P (number)\\\\n\\\\n Port number of service on the mainframe.\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n Allowed values: ^apimlAuthenticationToken.*, jwtToken, LtpaToken2\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Log out of an API ML instance to revoke the token that was\\\\n in use and remove it from your base profile:\\\\n\\\\n $ zowe auth logout apiml\\\\n\\\\n - Log out of an API ML instance to revoke a token that was\\\\n not stored in a profile:\\\\n\\\\n $ zowe auth logout apiml --token-value <token>\\\\n\\\\n\\",
\\"stderr\\": \\"\\",
\\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n apiml\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Log out of the Zowe API Mediation Layer authentication service and revoke the\\\\n token so it can no longer authenticate. Also remove the token from the default\\\\n base profile, if it is stored on disk.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe auth logout apiml [options]\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n Host name of service on the mainframe.\\\\n\\\\n --port | -P (number)\\\\n\\\\n Port number of service on the mainframe.\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n Allowed values: apimlAuthenticationToken, jwtToken, LtpaToken2\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Log out of an API ML instance to revoke the token that was\\\\n in use and remove it from your base profile:\\\\n\\\\n $ zowe auth logout apiml\\\\n\\\\n - Log out of an API ML instance to revoke a token that was\\\\n not stored in a profile:\\\\n\\\\n $ zowe auth logout apiml --token-value <token>\\\\n\\\\n\\"
\\"data\\": \\"\\\\n COMMAND NAME\\\\n ------------\\\\n\\\\n apiml\\\\n\\\\n DESCRIPTION\\\\n -----------\\\\n\\\\n Log out of the Zowe API Mediation Layer authentication service and revoke the\\\\n token so it can no longer authenticate. Also remove the token from the default\\\\n base profile, if it is stored on disk.\\\\n\\\\n USAGE\\\\n -----\\\\n\\\\n zowe auth logout apiml [options]\\\\n\\\\n BASE CONNECTION OPTIONS\\\\n -----------------------\\\\n\\\\n --host | -H (string)\\\\n\\\\n Host name of service on the mainframe.\\\\n\\\\n --port | -P (number)\\\\n\\\\n Port number of service on the mainframe.\\\\n\\\\n --token-type | --tt (string)\\\\n\\\\n The type of token to get and use for the API. Omit this option to use the\\\\n default token type, which is provided by 'zowe auth login'.\\\\n\\\\n Allowed values: ^apimlAuthenticationToken.*, jwtToken, LtpaToken2\\\\n\\\\n --token-value | --tv (string)\\\\n\\\\n The value of the token to pass to the API.\\\\n\\\\n --reject-unauthorized | --ru (boolean)\\\\n\\\\n Reject self-signed certificates.\\\\n\\\\n Default value: true\\\\n\\\\n PROFILE OPTIONS\\\\n ---------------\\\\n\\\\n --base-profile | --base-p (string)\\\\n\\\\n The name of a (base) profile to load for this command execution.\\\\n\\\\n GLOBAL OPTIONS\\\\n --------------\\\\n\\\\n --show-inputs-only (boolean)\\\\n\\\\n Show command inputs and do not run the command\\\\n\\\\n --response-format-json | --rfj (boolean)\\\\n\\\\n Produce JSON formatted data from a command\\\\n\\\\n --help | -h (boolean)\\\\n\\\\n Display help text\\\\n\\\\n --help-web | --hw (boolean)\\\\n\\\\n Display HTML help in browser\\\\n\\\\n EXAMPLES\\\\n --------\\\\n\\\\n - Log out of an API ML instance to revoke the token that was\\\\n in use and remove it from your base profile:\\\\n\\\\n $ zowe auth logout apiml\\\\n\\\\n - Log out of an API ML instance to revoke a token that was\\\\n not stored in a profile:\\\\n\\\\n $ zowe auth logout apiml --token-value <token>\\\\n\\\\n\\"
}"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ describe("auth login/logout apiml with profile", () => {
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Logout successful.");
expect(response.stdout.toString()).toContain("The authentication token has been revoked and removed");
expect(response.stdout.toString()).toContain("The authentication token has been revoked");
expect(response.stdout.toString()).toContain("Token was removed from your"); // ${name} base profile
});
});

Expand Down Expand Up @@ -153,15 +154,16 @@ describe("auth login/logout apiml create profile", () => {
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Login successful.");
expect(response.stdout.toString()).toContain("The authentication token is stored in the 'default' base profile");
expect(response.stdout.toString()).toContain("The authentication token is stored in the"); // ${name} base profile
});

it("should successfully issue the logout command with a created profile", () => {
const response = runCliScript(__dirname + "/__scripts__/auth_logout_apiml.sh",
TEST_ENVIRONMENT_CREATE_PROF);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Logout successful. The authentication token has been revoked and removed");
expect(response.stdout.toString()).toContain("Logout successful. The authentication token has been revoked");
expect(response.stdout.toString()).toContain("Token was removed from your"); // ${name} base profile
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

import ApimlAutoInitHandler from "../../../../src/config/auto-init/ApimlAutoInitHandler";
import { SessConstants, RestClientError, IRestClientError, ImperativeConfig, IConfig } from "@zowe/imperative";
import { SessConstants, RestClientError, IRestClientError, ImperativeConfig, IConfig, ConfigUtils } from "@zowe/imperative";
import { ZosmfSession } from "@zowe/zosmf-for-zowe-sdk";
import { IApimlProfileInfo, IProfileRpt, Login, Services } from "@zowe/core-for-zowe-sdk";
import * as lodash from "lodash";
Expand All @@ -27,7 +27,8 @@ function mockConfigApi(properties: IConfig | undefined): any {
})
},
profiles: {
expandPath: (name: string) => `profiles.${name}`
getProfilePathFromName: (name: string) => `profiles.${name}`,
get: jest.fn()
}
},
exists: true,
Expand Down Expand Up @@ -191,10 +192,12 @@ describe("ApimlAutoInitHandler", () => {
});

it("should not have changed - user & password with existing base profile", async () => {
// NOTE: Token type and token value will be stored, but user and password will still be present in the base profile
const mockCreateZosmfSession = jest.fn();
const mockGetPluginApimlConfigs = jest.fn().mockReturnValue([]);
const mockGetServicesByConfig = jest.fn().mockResolvedValue([]);
const mockConvertApimlProfileInfoToProfileConfig = jest.fn().mockReturnValue({
jest.spyOn(ConfigUtils, "getActiveProfileName").mockReturnValueOnce("base");
const mockConfigValue: any = {
defaults: { base: "base"},
profiles: {
"base": {
Expand All @@ -207,9 +210,10 @@ describe("ApimlAutoInitHandler", () => {
}
},
plugins: []
});
};
const mockConvertApimlProfileInfoToProfileConfig = jest.fn().mockReturnValue(mockConfigValue);
const mockLogin = jest.fn().mockResolvedValue("fakeToken");
jest.spyOn(ImperativeConfig.instance, "config", "get").mockReturnValue(mockConfigApi(undefined));
jest.spyOn(ImperativeConfig.instance, "config", "get").mockReturnValue(mockConfigApi(mockConfigValue));

ZosmfSession.createSessCfgFromArgs = mockCreateZosmfSession;
Services.getPluginApimlConfigs = mockGetPluginApimlConfigs;
Expand Down Expand Up @@ -243,9 +247,9 @@ describe("ApimlAutoInitHandler", () => {
expect(mockGetServicesByConfig).toHaveBeenCalledTimes(1);
expect(mockConvertApimlProfileInfoToProfileConfig).toHaveBeenCalledTimes(1);
expect(mockLogin).toHaveBeenCalledTimes(1);
expect(response.profiles.base.secure).not.toContain("tokenValue");
expect(response.profiles.base.properties.tokenType).not.toBeDefined();
expect(response.profiles.base.properties.tokenValue).not.toBeDefined();
expect(response.profiles.base.secure).toContain("tokenValue");
expect(response.profiles.base.properties.tokenType).toBeDefined();
expect(response.profiles.base.properties.tokenValue).toBeDefined();
});

it("should not have changed - rejectUnauthorized flag true", async () => {
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit bc9b85c

Please sign in to comment.