Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix-dataset-copy
Browse files Browse the repository at this point in the history
  • Loading branch information
awharn committed Jan 3, 2025
2 parents 520ecaa + e8939d8 commit 2e8a27a
Show file tree
Hide file tree
Showing 7 changed files with 487 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/imperative/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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

## Recent Changes

- BugFix: Resolved an issue where extraneous base profiles were created in project configurations when a nested profile property was updated. [#2400](https://github.com/zowe/zowe-cli/pull/2400)

## `8.10.1`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ describe("TeamConfig ProfileInfo tests", () => {
const teamHomeProjDir = path.join(testDir, testAppNm + "_home_team_config_proj");
const largeTeamProjDir = path.join(testDir, testAppNm + "_large_team_config_proj");
const nestedTeamProjDir = path.join(testDir, testAppNm + "_nested_team_config_proj");
const nestedTeamProjDirEmptyBase = path.join(testDir, testAppNm + "_proj_nested_global_empty");
const nestedTeamProjDirEmptyBaseProj = path.join(testDir, testAppNm + "_proj_nested_global_empty_proj");
let origDir: string;

const envHost = testEnvPrefix + "_OPT_HOST";
Expand Down Expand Up @@ -1348,6 +1350,26 @@ describe("TeamConfig ProfileInfo tests", () => {
propsToStore: ["areBirdsReal"], sessCfg: { "areBirdsReal": true }, setSecure: undefined,
});
});
it("should not add new base to nested project config profile when updating secure creds", async () => {
process.env[testEnvPrefix + "_CLI_HOME"] = nestedTeamProjDirEmptyBase;
const profInfo = createNewProfInfo(nestedTeamProjDirEmptyBase);
await profInfo.readProfilesFromDisk({ projectDir: nestedTeamProjDirEmptyBaseProj});
const upd = { profileName: "lpar1.zosmf", profileType: "zosmf" };

let caughtError;
try {
await profInfo.updateProperty({ ...upd, property: "user", value: "testxyz", setSecure: true });
await profInfo.updateProperty({ ...upd, property: "password", value: "testabc", setSecure: true });
} catch (error) {
caughtError = error;
}
const profiles = profInfo.getAllProfiles();
const targetProfile = profiles.find(p => p.profName === "base1234567");
expect(caughtError).toBeUndefined();
expect(targetProfile).toBeDefined();
expect(targetProfile?.profLoc?.osLoc?.[0]).toEqual(path.join(testDir,"/ProfInfoApp_proj_nested_global_empty/ProfInfoApp.config.json"));
expect(targetProfile?.profLoc?.osLoc?.[0]).not.toEqual(path.join(testDir,"/ProfInfoApp_proj_nested_global_empty_proj/ProfInfoApp.config.json"));
});
});

describe("updateKnownProperty", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "./ProfInfoApp.schema.json",
"profiles": {
"base1234567": {
"type": "base",
"properties": {},
"secure": [
"password",
"user"
]
}
},
"defaults": {
"base": "base1234567"
},
"autoStore": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$version": "1.0",
"type": "object",
"description": "Zowe configuration",
"properties": {
"profiles": {
"type": "object",
"description": "Mapping of profile types to default profile names",
"patternProperties": {
"^\\S*$": {
"type": "object",
"description": "Profile configuration object",
"properties": {
"type": {
"description": "Profile type",
"type": "string",
"enum": [
"zosmf",
"base"
]
},
"properties": {
"description": "Profile properties object",
"type": "object"
},
"profiles": {
"description": "Optional subprofile configurations",
"type": "object",
"$ref": "#/properties/profiles"
},
"secure": {
"description": "Secure property names",
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
}
},
"allOf": [
{
"if": {
"properties": {
"type": false
}
},
"then": {
"properties": {
"properties": {
"title": "Missing profile type"
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "zosmf"
}
}
},
"then": {
"properties": {
"properties": {
"type": "object",
"title": "z/OSMF Profile",
"description": "z/OSMF Profile",
"properties": {
"host": {
"type": "string",
"description": "The z/OSMF server host name."
},
"port": {
"type": "number",
"description": "The z/OSMF server port.",
"default": 443
},
"user": {
"type": "string",
"description": "Mainframe (z/OSMF) user name, which can be the same as your TSO login."
},
"password": {
"type": "string",
"description": "Mainframe (z/OSMF) password, which can be the same as your TSO password."
},
"rejectUnauthorized": {
"type": "boolean",
"description": "Reject self-signed certificates.",
"default": true
},
"basePath": {
"type": "string",
"description": "The base path for your API mediation layer instance. Specify this option to prepend the base path to all z/OSMF resources when making REST requests. Do not specify this option if you are not using an API mediation layer."
},
"protocol": {
"type": "string",
"description": "The protocol used (HTTP or HTTPS)",
"default": "https",
"enum": [
"http",
"https"
]
},
"encoding": {
"type": "number",
"description": "The encoding for download and upload of z/OS data set and USS files. The default encoding if not specified is 1047."
},
"responseTimeout": {
"type": "number",
"description": "The maximum amount of time in seconds the z/OSMF Files TSO servlet should run before returning a response. Any request exceeding this amount of time will be terminated and return an error. Allowed values: 5 - 600"
}
},
"required": []
},
"secure": {
"items": {
"enum": [
"user",
"password"
]
}
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "base"
}
}
},
"then": {
"properties": {
"properties": {
"type": "object",
"title": "Base Profile",
"description": "Base profile that stores values shared by multiple service profiles",
"properties": {
"host": {
"type": "string",
"description": "Host name of service on the mainframe."
},
"port": {
"type": "number",
"description": "Port number of service on the mainframe."
},
"user": {
"type": "string",
"description": "User name to authenticate to service on the mainframe."
},
"password": {
"type": "string",
"description": "Password to authenticate to service on the mainframe."
},
"rejectUnauthorized": {
"type": "boolean",
"description": "Reject self-signed certificates.",
"default": true
},
"tokenType": {
"type": "string",
"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'."
},
"tokenValue": {
"type": "string",
"description": "The value of the token to pass to the API."
}
},
"required": []
},
"secure": {
"items": {
"enum": [
"user",
"password",
"tokenValue"
]
}
}
}
}
}
]
}
}
},
"defaults": {
"type": "object",
"description": "Mapping of profile types to default profile names",
"properties": {
"zosmf": {
"description": "Default zosmf profile",
"type": "string"
},
"base": {
"description": "Default base profile",
"type": "string"
}
}
},
"autoStore": {
"type": "boolean",
"description": "If true, values you enter when prompted are stored for future use"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "./ProfInfoApp.schema.json",
"profiles": {
"lpar1": {
"profiles": {
"zosmf": {
"type": "zosmf",
"properties": {
"port": 1234
},
"secure": [
]
}
}
}
},
"defaults": {
"zosmf": "zosmf"
},
"autoStore": true
}
Loading

0 comments on commit 2e8a27a

Please sign in to comment.