Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Tokens #412

Merged
merged 179 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from 175 commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
bf18ff1
parse token and add type to cookier
dkelosky Oct 30, 2019
fb7941b
Fix #37
dkelosky Oct 30, 2019
e504317
remove token from basic auth check
dkelosky Oct 30, 2019
a138f5e
pass IProfileLoaded to commands
dkelosky Oct 30, 2019
2c0e7ae
get base64 credentials
dkelosky Oct 30, 2019
f8e0292
fix #316
dkelosky Oct 31, 2019
d25531e
typo
dkelosky Oct 31, 2019
694882c
correctly obtain token value
dkelosky Nov 1, 2019
2fd92c7
use new typings
dkelosky Nov 1, 2019
f69f024
pipeline updates for branch
dkelosky Nov 1, 2019
63a3dc4
update api method name
dkelosky Nov 1, 2019
a3829ff
node 12 typings
dkelosky Nov 1, 2019
577bf5e
revert loader change
dkelosky Nov 1, 2019
652682f
add a note for CLI users
dkelosky Nov 1, 2019
4aafa31
stage in next branch
dkelosky Nov 1, 2019
3d47c18
eliminate unused function
dkelosky Nov 1, 2019
f7e43b3
lint fix
dkelosky Nov 1, 2019
b581ab4
here i go again
dkelosky Nov 1, 2019
7e793b9
Updating dependencies [ci skip]
zowe-robot Nov 1, 2019
76cd7db
Bump version to 5.0.0-next.201911011856 [ci skip]
zowe-robot Nov 1, 2019
51f77ac
Switch to SonarCloud
jackjia-ibm Nov 27, 2019
37b9417
rename stage
jackjia-ibm Dec 2, 2019
a54eee8
Merge pull request #331 from zowe/users/jack/sonarcloud-next
zFernand0 Dec 2, 2019
fe6bd53
Update to Zowe artifactory and get building with Node 12
t1m0thyj Jan 14, 2020
5e335d4
Merge branch 'master' into fix-next
t1m0thyj Jan 15, 2020
65788e7
Merge pull request #351 from zowe/fix-next
zFernand0 Jan 15, 2020
83091d8
Updating dependencies [ci skip]
zowe-robot Jan 15, 2020
4762405
Bump version to 5.0.0-next.202001151750 [ci skip]
zowe-robot Jan 15, 2020
100f224
Update next with changes from master branch (#378)
t1m0thyj Mar 26, 2020
fb579b9
Bump version to 5.0.0-next.202003262002 [ci skip]
zowe-robot Mar 26, 2020
b1a0fad
Add token support.
gejohnston Mar 31, 2020
e99e179
4.6.0-tokens-01
gejohnston Apr 3, 2020
840f81a
Merge remote-tracking branch 'origin/master' into tokens
gejohnston Apr 3, 2020
6e2a8b8
Merge remote-tracking branch 'origin/next' into tokens
gejohnston Apr 3, 2020
fdfac26
Merge remote-tracking branch 'origin/master' into tokens
gejohnston Apr 6, 2020
6bfeb55
Add a 'Recent Changes' section.
gejohnston Apr 6, 2020
20c5081
Restore 'next' as protected branch.
gejohnston Apr 6, 2020
ba85471
Try the "prepare" for installing from Git.
gejohnston Apr 6, 2020
1f29a84
Add reminder to remove temp changes before publishing.
gejohnston Apr 6, 2020
3eba289
Add promptWithTimeout and sleep functions.
gejohnston Apr 21, 2020
db7c400
Add the APIML token type.
gejohnston Apr 23, 2020
b929665
Merge remote-tracking branch 'origin/master' into tokens
gejohnston Apr 28, 2020
68ecfad
Add and use SessCconstants.
gejohnston May 6, 2020
e96112f
Add PromptingSession class.
gejohnston May 6, 2020
6ec403d
Fix lint complaints.
gejohnston May 6, 2020
dd71da9
Merge remote-tracking branch 'origin/master' into tokens
gejohnston May 6, 2020
5ec9bed
Merge remote-tracking branch 'origin/master' into tokens
gejohnston May 6, 2020
29a4f8f
Exclude packages/rest/index.ts from tslint.
gejohnston May 6, 2020
8a14d68
Replace PromptingSession with CredsForSessCfg.
gejohnston May 8, 2020
6465207
Give user name precedence over token.
gejohnston May 11, 2020
6d52df5
Fix garbled display when backspace in hidden password.
gejohnston May 11, 2020
676c5a6
Fix lower-case typo in CredsForSessCfg.
gejohnston May 11, 2020
424e36d
Add tests for CredsForSessCfg.
gejohnston May 11, 2020
8c02bb4
Add an options argument to addCredsOrPrompt.
gejohnston May 11, 2020
78ef3db
Add test to ask for no prompting.
gejohnston May 11, 2020
da905eb
Add a jest timeout longer than our prompt timeout.
gejohnston May 12, 2020
eb09fd9
Enhance documentation of addCredsOrPrompt().
gejohnston May 12, 2020
fa477f3
Enhance recent changes doc in the CHANGELOG.
gejohnston May 12, 2020
a7fdd7e
Remove the build hacks that were necessary before
gejohnston May 12, 2020
88d7f46
add metaMap to constructor
dkelosky May 13, 2020
9569fd1
directly return the new object
dkelosky May 13, 2020
1e27c7c
adjust lint rule and remove meaningless todo
dkelosky May 14, 2020
909e5f4
Restore the build hacks to build when installed.
gejohnston May 14, 2020
19976a6
Merge branch 'tokens' of https://github.com/zowe/imperative into tokens
gejohnston May 14, 2020
daee634
revert export as
dkelosky May 14, 2020
9aa4e4f
Merge branch 'tokens' of https://github.com/zowe/imperative into tokens
dkelosky May 14, 2020
ac431c1
remove zowe cli reference
dkelosky May 14, 2020
fa715a8
revert lint
dkelosky May 14, 2020
54f719a
Remove "next" from protectedBranches.
gejohnston May 14, 2020
19c7106
Mock our sleep function so that we do not wait 30 seconds in our time…
gejohnston May 14, 2020
f14ef37
increase session coverage - totally legit
dkelosky May 15, 2020
1aba9d1
Restructure for base64 creds. Then decided not use base64 creds.
gejohnston May 15, 2020
93b1172
Merge branch 'tokens' of https://github.com/zowe/imperative into tokens
gejohnston May 15, 2020
2aaea80
Do not display * for newline in hidden test prompt.
gejohnston May 15, 2020
bfd8d66
add test for getMeta
dkelosky May 18, 2020
a43145d
Merge branch 'tokens' of https://github.com/zowe/imperative into tokens
dkelosky May 18, 2020
7ba80e2
test getMeta without name
dkelosky May 18, 2020
623599e
extra getMeta test cases
dkelosky May 18, 2020
310d366
Add tests for sleep and promptWithTimeout.
gejohnston May 18, 2020
dfb09cb
Ensure writeToOutputOrig is defined before using it.
gejohnston May 18, 2020
fad322c
Add mock-stdin.
gejohnston May 18, 2020
9c3b4f5
Merge branch 'tokens' of https://github.com/zowe/imperative into tokens
gejohnston May 18, 2020
9e7fe36
Only move assignment of writeToOutputOrig early.
gejohnston May 19, 2020
6f25746
Add base profile to command definitions containing other profile types
t1m0thyj May 14, 2020
4212b90
Fix profile fields set to null when they should be undefined
t1m0thyj May 14, 2020
72d6e95
Add base profile to command definitions containing other profile types
t1m0thyj May 14, 2020
4728348
Don't add base profile if none is defined in Imperative config
t1m0thyj May 15, 2020
c0214f0
Add integration test for fields defined in base profile
t1m0thyj May 15, 2020
50269fa
Add unit test for base profiles in getProfileGroup
t1m0thyj May 15, 2020
06144cc
Add unit test and fix snapshots
t1m0thyj May 15, 2020
bd2f866
Update changelog
t1m0thyj May 18, 2020
37c4d6e
Add initial implementation.
awharn May 15, 2020
2319aca
Make specific to create profile command
awharn May 15, 2020
9818069
Add initial implementation.
awharn May 15, 2020
f03cd00
Make specific to create profile command
awharn May 15, 2020
4da62d7
Rebase off of add-base-profile
awharn May 15, 2020
eb1257a
Update unit test snapshots
awharn May 15, 2020
7b68ffb
Add initial implementation.
awharn May 15, 2020
bc7119a
Make specific to create profile command
awharn May 15, 2020
9d6e4f6
Add initial implementation.
awharn May 15, 2020
3a4de10
Make specific to create profile command
awharn May 15, 2020
48af221
Update test snapshots
awharn May 18, 2020
ac006ac
Update Changelog
awharn May 18, 2020
71668bb
Remove mock-stdin which fails in pipeline.
gejohnston May 20, 2020
a45d4e9
Add tests for prompted user and password.
gejohnston May 20, 2020
fe76c1a
Merge remote-tracking branch 'origin/tokens' into fix-prompt-tests
gejohnston May 20, 2020
f3ff2c6
Update changelog.
gejohnston May 20, 2020
195f1a9
Merge pull request #404 from zowe/fix-prompt-tests
gejohnston May 20, 2020
e6e5357
Automatically generate auth command group
t1m0thyj May 19, 2020
22855fd
Support multiple auth configs per single profile
t1m0thyj May 19, 2020
2bbebb6
Temporarily use CLI handlers for auth commands
t1m0thyj May 20, 2020
bfbaf47
Push for testing on another machine.
awharn May 20, 2020
78cfb0b
Replace null with undefined when loading/saving secure profile values
t1m0thyj May 20, 2020
8884e7f
Automatically add base profile options to commands missing them
t1m0thyj May 21, 2020
e34c0c6
Remove unneeded import
t1m0thyj May 21, 2020
bc26f4f
Update object for integration test
awharn May 21, 2020
f59d617
Update Tests
awharn May 22, 2020
2842f14
Push the collaboration work
awharn May 22, 2020
4326f86
Fix import and add todos
t1m0thyj May 26, 2020
e504d1d
Fix circular dependency
t1m0thyj May 26, 2020
2f21f0f
Add abstract properties to auth handler
t1m0thyj May 26, 2020
995d2ef
Fix lint error
t1m0thyj May 26, 2020
e61ca9e
Fix integration test not compiling
t1m0thyj May 27, 2020
7b799ec
Add logout command.
awharn May 27, 2020
9823efb
Rewrite auth login integration test
t1m0thyj May 27, 2020
bf23557
Merge branch 'auto-auth-commands' of https://github.com/zowe/imperati…
t1m0thyj May 27, 2020
24de4e4
Add test for Imperative.addAutoGeneratedCommands
t1m0thyj May 27, 2020
5f93441
Add integration test for logout.
awharn May 27, 2020
ed83c40
Add unit tests for auth group builder
t1m0thyj May 27, 2020
190707f
Merge branch 'auto-auth-commands' of https://github.com/zowe/imperati…
t1m0thyj May 27, 2020
08bf740
Add tests for base auth handler
t1m0thyj May 28, 2020
bf06e79
Fix integration tests
t1m0thyj May 28, 2020
0123c67
Add checks for required parameters, only update profile if token matc…
awharn May 28, 2020
d825a48
Fix the broken test
awharn May 28, 2020
37e83b4
Replace CredsForSessCfg.addCredsOrPrompt with ConnectionPropsForSessC…
gejohnston May 29, 2020
d43f137
Replace CredsForSessCfg.addCredsOrPrompt with ConnectionPropsForSessC…
gejohnston May 29, 2020
a29dd54
Merge branch 'auto-auth-commands' of https://github.com/zowe/imperati…
gejohnston May 29, 2020
c91a746
Add and fix tests
awharn May 29, 2020
9586f50
Add check to verify loadedProfile not null or undefined before save
awharn May 29, 2020
f6372ec
Add profile creation logic
awharn May 29, 2020
2609d7c
Update snapshot
awharn May 29, 2020
afa77a3
Update login command to do profile creation
awharn Jun 1, 2020
ef4e107
Remove unused imports
awharn Jun 1, 2020
4b24a4f
Add token information to --rfj login option
awharn Jun 2, 2020
b4d3b4f
Merge remote-tracking branch 'origin/master' into tokens-test-branch
awharn Jun 2, 2020
81147fe
Merge branch 'tokens-test-branch' into auto-auth-commands
awharn Jun 2, 2020
3c8a6ee
Do not change what we return.
awharn Jun 2, 2020
a2c4f77
Update changelog
awharn Jun 2, 2020
738b156
Make requested changes.
awharn Jun 4, 2020
59cc550
Make more requested changes.
awharn Jun 4, 2020
54e7826
Fix broken test.
awharn Jun 4, 2020
a284341
Clean up code smells.
awharn Jun 4, 2020
e9816ed
Update script name
awharn Jun 4, 2020
6dd5381
Fix one more code smell
awharn Jun 4, 2020
8b37136
Make suggested change.
awharn Jun 5, 2020
08be35b
Merge pull request #409 from zowe/auto-auth-commands
awharn Jun 5, 2020
9bc5c1b
Update help text for auth commands
t1m0thyj Jun 9, 2020
db19091
Fix login successful message not showing when base profile already ex…
t1m0thyj Jun 9, 2020
4bfcbd2
Don't require token type on logout, and fix unit test
t1m0thyj Jun 9, 2020
b25b20b
Fix tests
awharn Jun 9, 2020
bdb4d27
Update tests and snapshots
awharn Jun 10, 2020
42f66ec
Fix code smell
t1m0thyj Jun 10, 2020
b2a1e31
very minor grammar
BrandonJenkins14 Jun 10, 2020
14405c8
Update failing test
awharn Jun 10, 2020
3689d5a
More test fixes
awharn Jun 10, 2020
3cf5a48
Another wording update.
awharn Jun 10, 2020
ba444df
Remove word per Brandon's suggestion
t1m0thyj Jun 10, 2020
54ba7f5
Merge branch 'token-help-text' of https://github.com/zowe/imperative …
t1m0thyj Jun 10, 2020
b61c8c4
Update text again to fix tests.
awharn Jun 10, 2020
3b23252
Merge pull request #410 from zowe/token-help-text
awharn Jun 11, 2020
656e113
Remove temporary build modifications
gejohnston Jun 11, 2020
0bf1f9d
Update changelog.
gejohnston Jun 11, 2020
552166d
Doc new ConnectionPropsForSessCfg.addPropsOrPrompt
gejohnston Jun 11, 2020
e2b3716
Merge pull request #411 from zowe/remove_build_hacks
gejohnston Jun 11, 2020
4fd13f1
Remove commented code
t1m0thyj Jun 12, 2020
f6eee40
Fix Imperative unit test
t1m0thyj Jun 12, 2020
617fb90
Added comments to changelog for various feature changes.
gejohnston Jun 12, 2020
808f12d
Add IPartialCommandDefinition interface
t1m0thyj Jun 12, 2020
23ed18f
Merge branch 'tokens' of https://github.com/zowe/imperative into tokens
t1m0thyj Jun 12, 2020
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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

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

## Recent Changes

- Fix tests for interactive prompting.
zFernand0 marked this conversation as resolved.
Show resolved Hide resolved
- Add the --dd flag to profile creation to allow the profile to be created without the default values specified for that profile.
zFernand0 marked this conversation as resolved.
Show resolved Hide resolved
- Use a token for authentication if a token is present in the underlying REST session object.
- Add a new ConnectionPropsForSessCfg.addPropsOrPrompt function that places credentials (including a possible token) into a session configuration object.
- Credentials are obtained from the command line, environment variables, or a profile.
- If no credentials are available, it will prompt for a user name and password.
zFernand0 marked this conversation as resolved.
Show resolved Hide resolved
- Any prompt will timeout after 30 seconds so that it will not hang an automated script.
- Add base profiles, a new type of profile which can store values shared between profiles of other types.
- To use base profiles in an Imperative-based CLI, define a `baseProfile` schema on your Imperative configuration object.
- If the `baseProfile` schema is defined, base profile support will be added to any command that uses profiles.
- Add login and logout commands to get and delete/invalidate tokens
- Add showToken flag to display token only, and not save it to the user profile
- Add ability to create a user profile on login if no profile of that type existed previously

## `4.6.4`

- Fix optional secure fields not deleted when overwriting a profile
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
* 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 { runCliScript } from "../../../../../../src/TestUtil";
import { ITestEnvironment } from "../../../../../../__src__/environment/doc/response/ITestEnvironment";
import { SetupTestEnvironment } from "../../../../../../__src__/environment/SetupTestEnvironment";
import { join } from "path";

// Test Environment populated in the beforeAll();
let TEST_ENVIRONMENT: ITestEnvironment;
describe("cmd-cli auth login", () => {
// Create the unique test environment
beforeAll(async () => {
TEST_ENVIRONMENT = await SetupTestEnvironment.createTestEnv({
cliHomeEnvVar: "CMD_CLI_CLI_HOME",
testName: "cmd_auth_login"
});
});

afterEach(() => {
// delete profiles between tests so that they can be recreated
require("rimraf").sync(join(TEST_ENVIRONMENT.workingDir, "profiles"));
});

it("should load values from base profile and store token in it", () => {
const response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login.sh",
TEST_ENVIRONMENT.workingDir, ["fakeUser", "fakePass"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// the output of the command should include token value
expect(response.stdout.toString()).toContain("user: fakeUser");
expect(response.stdout.toString()).toContain("password: fakePass");
expect(response.stdout.toString()).toContain("tokenType: jwtToken");
expect(response.stdout.toString()).toContain("tokenValue: fakeUser:fakePass@fakeToken");
});

it("should load values from base profile and show token only", () => {
let response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_show_token.sh",
TEST_ENVIRONMENT.workingDir, ["fakeUser", "fakePass"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// the output of the command should include token value
expect(response.stdout.toString()).toContain("fakeUser:fakePass@fakeToken");

response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_show_profiles.sh", TEST_ENVIRONMENT.workingDir);

// the output of the command should not include token value
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).not.toContain("tokenType:");
expect(response.stdout.toString()).not.toContain("tokenValue:");
});

it("should load values from base profile and show token in rfj", () => {
let response = runCliScript(__dirname + "/__scripts__/base_profile_create.sh",
TEST_ENVIRONMENT.workingDir, ["fakeUser", "fakePass"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// the output of the command should include token value
response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_show_token_rfj.sh",
TEST_ENVIRONMENT.workingDir);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(JSON.parse(response.stdout.toString()).data).toMatchObject({tokenType: "jwtToken", tokenValue: "fakeUser:fakePass@fakeToken"});

// the output of the command should not include token value
response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_show_profiles.sh", TEST_ENVIRONMENT.workingDir);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).not.toContain("tokenType:");
expect(response.stdout.toString()).not.toContain("tokenValue:");
});

it("should create a profile, if requested 1", () => {
let response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_create_profile.sh",
TEST_ENVIRONMENT.workingDir, ["y", "fakeUser", "fakePass"]);
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");

response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_show_profiles.sh", TEST_ENVIRONMENT.workingDir);

expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("host: fakeHost");
expect(response.stdout.toString()).toContain("port: 3000");
expect(response.stdout.toString()).toContain("tokenType: jwtToken");
expect(response.stdout.toString()).toContain("tokenValue: fakeUser:fakePass@fakeToken");
expect(response.stdout.toString()).not.toContain("user:");
expect(response.stdout.toString()).not.toContain("password:");
});

it("should create a profile, if requested 2", () => {
let response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_create_profile.sh",
TEST_ENVIRONMENT.workingDir, ["yes", "fakeUser", "fakePass"]);
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");

response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_show_profiles.sh", TEST_ENVIRONMENT.workingDir);

expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("host: fakeHost");
expect(response.stdout.toString()).toContain("port: 3000");
expect(response.stdout.toString()).toContain("tokenType: jwtToken");
expect(response.stdout.toString()).toContain("tokenValue: fakeUser:fakePass@fakeToken");
expect(response.stdout.toString()).not.toContain("user:");
expect(response.stdout.toString()).not.toContain("password:");
});

it("should not create a profile, if requested", () => {
let response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_create_profile.sh",
TEST_ENVIRONMENT.workingDir, ["n", "fakeUser", "fakePass"]);
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Login successful.");
expect(response.stdout.toString()).toContain("will not be stored in your profile");
expect(response.stdout.toString()).toContain("fakeUser:fakePass@fakeToken");

response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_show_profiles.sh", TEST_ENVIRONMENT.workingDir);

expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).not.toContain("user:");
expect(response.stdout.toString()).not.toContain("password:");
expect(response.stdout.toString()).not.toContain("host:");
expect(response.stdout.toString()).not.toContain("port:");
expect(response.stdout.toString()).not.toContain("tokenType:");
expect(response.stdout.toString()).not.toContain("tokenValue:");
});

it("should not create a profile, if it times out", () => {
let response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_create_profile_timeout.sh",
TEST_ENVIRONMENT.workingDir, ["fakeUser", "fakePass"]);
expect(response.status).toBe(0);
expect(response.stdout.toString()).toContain("Login successful.");
expect(response.stdout.toString()).toContain("will not be stored in your profile");
expect(response.stdout.toString()).toContain("fakeUser:fakePass@fakeToken");

response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login_show_profiles.sh", TEST_ENVIRONMENT.workingDir);

expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
expect(response.stdout.toString()).not.toContain("user:");
expect(response.stdout.toString()).not.toContain("password:");
expect(response.stdout.toString()).not.toContain("host:");
expect(response.stdout.toString()).not.toContain("port:");
expect(response.stdout.toString()).not.toContain("tokenType:");
expect(response.stdout.toString()).not.toContain("tokenValue:");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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 { runCliScript } from "../../../../../../src/TestUtil";
import { ITestEnvironment } from "../../../../../../__src__/environment/doc/response/ITestEnvironment";
import { SetupTestEnvironment } from "../../../../../../__src__/environment/SetupTestEnvironment";
import { join } from "path";

// Test Environment populated in the beforeAll();
let TEST_ENVIRONMENT: ITestEnvironment;
describe("cmd-cli auth logout", () => {
// Create the unique test environment
beforeAll(async () => {
TEST_ENVIRONMENT = await SetupTestEnvironment.createTestEnv({
cliHomeEnvVar: "CMD_CLI_CLI_HOME",
testName: "cmd_auth_logout"
});
});

afterEach(() => {
// delete profiles between tests so that they can be recreated
require("rimraf").sync(join(TEST_ENVIRONMENT.workingDir, "profiles"));
});

it("should have auth logout command that loads values from base profile and removes the token", () => {
let response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login.sh",
TEST_ENVIRONMENT.workingDir, ["fakeUser", "fakePass"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// the output of the command should include token value
expect(response.stdout.toString()).toContain("tokenType: jwtToken");
expect(response.stdout.toString()).toContain("tokenValue: fakeUser:fakePass@fakeToken");

response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_logout.sh",
TEST_ENVIRONMENT.workingDir);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// the output of the command should include token value
expect(response.stdout.toString()).not.toContain("tokenType:");
expect(response.stdout.toString()).not.toContain("tokenValue:");
});

it("should have auth logout command that invalidates another token", () => {
let response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_login.sh",
TEST_ENVIRONMENT.workingDir, ["fakeUser", "fakePass"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// the output of the command should include token value
expect(response.stdout.toString()).toContain("tokenType: jwtToken");
expect(response.stdout.toString()).toContain("tokenValue: fakeUser:fakePass@fakeToken");

response = runCliScript(__dirname + "/__scripts__/base_profile_and_auth_logout_specify_token.sh",
TEST_ENVIRONMENT.workingDir, ["fakeToken:fakeToken@fakeToken"]);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);

// the output of the command should include token value
expect(response.stdout.toString()).toContain("tokenType: jwtToken");
expect(response.stdout.toString()).toContain("tokenValue: fakeUser:fakePass@fakeToken");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

baseUser=$1
basePass=$2

# First create a base profile
cmd-cli profiles create base-profile "test_base" --user "$baseUser" --password "$basePass"
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Creating a test_base profile of type base failed!" 1>&2
exit $CMDRC
fi

# Next login to fruit auth
cmd-cli auth login fruit
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Logging into auth of type fruit failed!" 1>&2
exit $CMDRC
fi

# Now show contents of base profile
cmd-cli profiles list base-profiles --sc
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Listing profiles of type base failed!" 1>&2
exit $CMDRC
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

echoVal=$1
baseUser=$2
basePass=$3

echo $echoVal | cmd-cli auth login fruit --user "$baseUser" --password "$basePass"
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Logging into auth of type fruit failed!" 1>&2
exit $CMDRC
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

baseUser=$1
basePass=$2

cmd-cli auth login fruit --user "$baseUser" --password "$basePass"
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Logging into auth of type fruit failed!" 1>&2
exit $CMDRC
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Now show contents of base profile
cmd-cli profiles list base-profiles --sc
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Listing profiles of type base failed!" 1>&2
exit $CMDRC
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

baseUser=$1
basePass=$2

# First create a base profile
cmd-cli profiles create base-profile "test_base" --user "$baseUser" --password "$basePass"
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Creating a test_base profile of type base failed!" 1>&2
exit $CMDRC
fi

# Next login to fruit auth
cmd-cli auth login fruit --show-token
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Logging into auth of type fruit failed!" 1>&2
exit $CMDRC
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Next login to fruit auth
cmd-cli auth login fruit --st --rfj
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Logging into auth of type fruit failed!" 1>&2
exit $CMDRC
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Next logout of fruit auth
cmd-cli auth logout fruit
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Logging out of auth of type fruit failed!" 1>&2
exit $CMDRC
fi

# Now show contents of base profile
cmd-cli profiles list base-profiles --sc
CMDRC=$?
if [ $CMDRC -gt 0 ]
then
echo "Listing profiles of type base failed!" 1>&2
exit $CMDRC
fi
Loading