Skip to content

Commit

Permalink
Use pre-existing profile files not v1 profile cmds
Browse files Browse the repository at this point in the history
Signed-off-by: Gene Johnston <[email protected]>
  • Loading branch information
gejohnston committed Dec 15, 2023
1 parent 1210730 commit acbb5ef
Show file tree
Hide file tree
Showing 12 changed files with 592 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ describe("ProfileUtils", () => {
testName: "core_utils_get_default_profile",
skipProperties: true
});

// We need the meta YAML files for the ProfileManager to initialize, so create dummy profiles to supply them
runCliScript(__dirname + "/__scripts__/create_profile.sh", TEST_ENVIRONMENT,
["zosmf", "fakeServiceProfile", "--host fake --dd"]);
runCliScript(__dirname + "/__scripts__/create_profile.sh", TEST_ENVIRONMENT,
["base", "fakeBaseProfile", "--host fake --dd"]);
process.env.ZOWE_CLI_HOME = TEST_ENVIRONMENT.workingDir;

// copy existing profiles into test directory
const response = runCliScript(__dirname + "/__scripts__/copy_profiles.sh", TEST_ENVIRONMENT);
expect(response.stderr.toString()).toBe("");
expect(response.status).toBe(0);
});

beforeEach(() => {
jest.resetAllMocks();

Expand All @@ -67,11 +67,12 @@ describe("ProfileUtils", () => {
})
});
});

afterAll(async () => {
runCliScript(__dirname + "/__scripts__/delete_profile.sh", TEST_ENVIRONMENT, ["zosmf", "fakeServiceProfile"]);
runCliScript(__dirname + "/__scripts__/delete_profile.sh", TEST_ENVIRONMENT, ["base", "fakeBaseProfile"]);
await TestEnvironment.cleanUp(TEST_ENVIRONMENT);
});


it("Should return a service profile", async() => {
const profileManagerSpy = jest.spyOn(imperative.CliProfileManager.prototype, "load")
.mockResolvedValueOnce({ profile: fakeServiceProfile } as any);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
defaultProfile: fakeBaseProfile
configuration:
type: base
schema:
type: object
title: 'Base Profile'
description: 'Base profile that stores values shared by multiple service profiles'
properties:
host:
type: string
optionDefinition:
name: host
aliases:
- H
description: 'Host name of service on the mainframe.'
type: string
group: 'Base Connection Options'
includeInTemplate: true
port:
type: number
optionDefinition:
name: port
aliases:
- P
description: 'Port number of service on the mainframe.'
type: number
group: 'Base Connection Options'
user:
type: string
secure: true
optionDefinition:
name: user
aliases:
- u
description: 'User name to authenticate to service on the mainframe.'
type: string
group: 'Base Connection Options'
includeInTemplate: true
password:
type: string
secure: true
optionDefinition:
name: password
aliases:
- pass
- pw
description: 'Password to authenticate to service on the mainframe.'
type: string
group: 'Base Connection Options'
includeInTemplate: true
rejectUnauthorized:
type: boolean
optionDefinition:
name: reject-unauthorized
aliases:
- ru
description: 'Reject self-signed certificates.'
type: boolean
defaultValue: true
group: 'Base Connection Options'
includeInTemplate: true
tokenType:
type: string
optionDefinition:
name: token-type
aliases:
- tt
description: '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''.'
type: string
group: 'Base Connection Options'
tokenValue:
type: string
secure: true
optionDefinition:
name: token-value
aliases:
- tv
description: 'The value of the token to pass to the API.'
type: string
group: 'Base Connection Options'
certFile:
type: string
optionDefinition:
name: cert-file
description: 'The file path to a certificate file to use for authentication'
type: existingLocalFile
group: 'Base Connection Options'
aliases: []
certKeyFile:
type: string
optionDefinition:
name: cert-key-file
description: 'The file path to a certificate key file to use for authentication'
type: existingLocalFile
group: 'Base Connection Options'
aliases: []
required: []
createProfileExamples:
-
options: 'base1 --host example.com --port 443 --user admin --password 123456'
description: 'Create a profile called ''base1'' to connect to host example.com and port 443'
-
options: 'base2 --host example.com --user admin --password 123456 --reject-unauthorized false'
description: 'Create a profile called ''base2'' to connect to host example.com (default port - 443) and allow self-signed certificates'
-
options: 'base3 --host example.com --port 1443'
description: 'Create a profile called ''base3'' to connect to host example.com and port 1443, not specifying a username or password so they are not stored on disk; these will need to be specified on every command'
-
options: 'base4 --reject-unauthorized false'
description: 'Create a zosmf profile called ''base4'' to connect to default port 443 and allow self-signed certificates, not specifying a username, password, or host so they are not stored on disk; these will need to be specified on every command'
updateProfileExamples:
-
options: 'base1 --user newuser --password newp4ss'
description: 'Update a base profile named ''base1'' with a new username and password'
authConfig:
-
serviceName: apiml
handler: /home/stduser/repos/zowe-cli/packages/cli/lib/auth/ApimlAuthHandler
login:
summary: 'Log in to API ML authentication service'
description: "Log in to Zowe API Mediation Layer authentication service and obtain or update a token.\n\nThe token provides authentication to services that support the API ML SSO (Single Sign-On) capability. When you log in, the token is stored in your default base profile until it expires. Base profiles store connection information shared by multiple services (e.g., z/OSMF), and are used if you do not supply connection information in a service profile. To take advantage of the API ML SSO capability, you should omit username and password in service profiles so that the token in the base profile is used."
examples:
-
description: 'Log in to an API ML instance to obtain or update the token stored in your base profile'
options: ""
-
description: 'Log in to an API ML instance to obtain a token without storing it in a profile'
options: '--show-token'
options:
-
name: host
aliases:
- H
description: 'Host name of service on the mainframe.'
type: string
group: 'Base Connection Options'
-
name: port
aliases:
- P
description: 'Port number of service on the mainframe.'
type: number
group: 'Base Connection Options'
-
name: user
aliases:
- u
description: 'User name to authenticate to service on the mainframe.'
type: string
group: 'Base Connection Options'
-
name: password
aliases:
- pass
- pw
description: 'Password to authenticate to service on the mainframe.'
type: string
group: 'Base Connection Options'
-
name: reject-unauthorized
aliases:
- ru
description: 'Reject self-signed certificates.'
type: boolean
defaultValue: true
group: 'Base Connection Options'
-
name: cert-file
description: 'The file path to a certificate file to use for authentication'
type: existingLocalFile
group: 'Base Connection Options'
aliases: []
-
name: cert-key-file
description: 'The file path to a certificate key file to use for authentication'
type: existingLocalFile
group: 'Base Connection Options'
aliases: []
logout:
summary: 'Log out of API ML authentication service'
description: 'Log out of the Zowe API Mediation Layer authentication service and revoke the token so it can no longer authenticate. Also remove the token from the default base profile, if it is stored on disk.'
examples:
-
description: 'Log out of an API ML instance to revoke the token that was in use and remove it from your base profile'
options: ""
-
description: 'Log out of an API ML instance to revoke a token that was not stored in a profile'
options: '--token-value <token>'
options:
-
name: host
aliases:
- H
description: 'Host name of service on the mainframe.'
type: string
group: 'Base Connection Options'
-
name: port
aliases:
- P
description: 'Port number of service on the mainframe.'
type: number
group: 'Base Connection Options'
-
name: token-type
aliases:
- tt
description: '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''.'
type: string
group: 'Base Connection Options'
allowableValues:
values:
- '^apimlAuthenticationToken.*'
- jwtToken
- LtpaToken2
-
name: token-value
aliases:
- tv
description: 'The value of the token to pass to the API.'
type: string
group: 'Base Connection Options'
-
name: reject-unauthorized
aliases:
- ru
description: 'Reject self-signed certificates.'
type: boolean
defaultValue: true
group: 'Base Connection Options'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
host: fake
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
defaultProfile: null
configuration:
type: ssh
schema:
type: object
title: 'z/OS SSH Profile'
description: 'z/OS SSH Profile'
properties:
host:
type: string
optionDefinition:
name: host
aliases:
- H
description: 'The z/OS SSH server host name.'
type: string
required: false
group: 'z/OS Ssh Connection Options'
port:
type: number
optionDefinition:
name: port
aliases:
- P
description: 'The z/OS SSH server port.'
type: number
defaultValue: 22
group: 'z/OS Ssh Connection Options'
includeInTemplate: true
user:
type: string
secure: true
optionDefinition:
name: user
aliases:
- u
description: 'Mainframe user name, which can be the same as your TSO login.'
type: string
required: false
group: 'z/OS Ssh Connection Options'
password:
type: string
secure: true
optionDefinition:
name: password
aliases:
- pass
- pw
description: 'Mainframe password, which can be the same as your TSO password.'
type: string
group: 'z/OS Ssh Connection Options'
privateKey:
type: string
optionDefinition:
name: privateKey
aliases:
- key
- pk
description: 'Path to a file containing your private key, that must match a public key stored in the server for authentication'
type: string
group: 'z/OS Ssh Connection Options'
keyPassphrase:
type: string
secure: true
optionDefinition:
name: keyPassphrase
aliases:
- passphrase
- kp
description: 'Private key passphrase, which unlocks the private key.'
type: string
group: 'z/OS Ssh Connection Options'
handshakeTimeout:
type: number
optionDefinition:
name: handshakeTimeout
aliases:
- timeout
- to
description: 'How long in milliseconds to wait for the SSH handshake to complete.'
type: number
group: 'z/OS Ssh Connection Options'
required: []
createProfileExamples:
-
options: 'ssh111 --host sshhost --user ibmuser --password myp4ss'
description: 'Create a ssh profile called ''ssh111'' to connect to z/OS SSH server at host ''zos123'' and default port 22'
-
options: 'ssh222 --host sshhost --port 13022 --user ibmuser --password myp4ss'
description: 'Create a ssh profile called ''ssh222'' to connect to z/OS SSH server at host ''zos123'' and port 13022'
-
options: 'ssh333 --host sshhost --user ibmuser --privateKey /path/to/privatekey --keyPassphrase privateKeyPassphrase'
description: 'Create a ssh profile called ''ssh333'' to connect to z/OS SSH server at host ''zos123'' using a privatekey ''/path/to/privatekey'' and its decryption passphrase ''privateKeyPassphrase'' for privatekey authentication'
-
options: 'ssh444 --privateKey /path/to/privatekey'
description: 'Create a ssh profile called ''ssh444'' to connect to z/OS SSH server on default port 22, without specifying username, host, or password, preventing those values from being stored on disk'
Loading

0 comments on commit acbb5ef

Please sign in to comment.