From 12362fb986c7d0a637548e3bbf2f4eb4d526da86 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Tue, 18 Jul 2023 16:51:07 +0000 Subject: [PATCH 1/7] ProfileInfo: Add offSchema property to known and missing args Signed-off-by: Amber Torrise Co-authored-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> Signed-off-by: Amber Torrise --- packages/config/src/ProfileInfo.ts | 9 +++++++-- packages/config/src/doc/IProfArgAttrs.ts | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/config/src/ProfileInfo.ts b/packages/config/src/ProfileInfo.ts index f663b512b..5b31b37d3 100644 --- a/packages/config/src/ProfileInfo.ts +++ b/packages/config/src/ProfileInfo.ts @@ -623,7 +623,8 @@ export class ProfileInfo { dataType: this.argDataType(typeof propVal), // TODO Is using `typeof` bad for "null" values that may be int or bool? argValue: propVal, argLoc, - secure + secure, + offSchema: true }); } } @@ -654,7 +655,8 @@ export class ProfileInfo { dataType: this.argDataType(typeof propVal), argValue: propVal, argLoc, - secure + secure, + offSchema: true }); } } @@ -746,6 +748,7 @@ export class ProfileInfo { dataType: this.argDataType(propInfoInSchema.type), argValue: (propInfoInSchema as ICommandProfileProperty).optionDefinition?.defaultValue, argLoc, + offSchema: false, // See https://github.com/zowe/imperative/issues/739 secure: foundInSecureArray || propInfoInSchema.secure }; @@ -760,6 +763,7 @@ export class ProfileInfo { if (!argFound) { mergedArgs.missingArgs.push({ argName: propName, + offSchema: false, dataType: this.argDataType(propInfoInSchema.type), argValue: (propInfoInSchema as ICommandProfileProperty).optionDefinition?.defaultValue, argLoc: { locType: ProfLocType.DEFAULT }, @@ -767,6 +771,7 @@ export class ProfileInfo { }); } } else { + knownArg.offSchema = false; knownArg.secure = knownArg.secure ?? propInfoInSchema.secure; if (knownArg.secure) { delete knownArg.argValue; diff --git a/packages/config/src/doc/IProfArgAttrs.ts b/packages/config/src/doc/IProfArgAttrs.ts index f227b2bed..370dda3d4 100644 --- a/packages/config/src/doc/IProfArgAttrs.ts +++ b/packages/config/src/doc/IProfArgAttrs.ts @@ -35,4 +35,7 @@ export interface IProfArgAttrs { /** Whether the argument value is stored securely */ secure?: boolean; + + /** Whether the argument value is defined in the schema file */ + offSchema?: boolean; } From 15aa180135cf4e928699ee7c11f49b57f3b4c9bf Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Tue, 18 Jul 2023 16:13:59 -0400 Subject: [PATCH 2/7] creating test for detecting correct offSchema values Signed-off-by: Amber Torrise Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> Signed-off-by: Amber Torrise --- .../__tests__/ProfileInfo.TeamConfig.test.ts | 22 +++++++++++++++++++ .../ProfInfoApp.config.json | 9 ++++++++ 2 files changed, 31 insertions(+) diff --git a/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts b/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts index bbb33f7b5..fd6acca1a 100644 --- a/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts +++ b/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts @@ -753,6 +753,28 @@ describe("TeamConfig ProfileInfo tests", () => { } }); + it("should find correct offSchema args", async () => { + const profInfo = createNewProfInfo(teamProjDir); + await profInfo.readProfilesFromDisk(); + const profAttrs = profInfo.getAllProfiles()[7] as IProfAttrs; + const mergedArgs = profInfo.mergeArgsForProfile(profAttrs); + + const expectedArgs = [ + { argName: "host", offSchema: false }, + { argName: "port", offSchema: false }, + { argName: "responseFormatHeader", offSchema: true }, + { argName: "fakeOffSchemaArg", offSchema: true }, + { argName: "user", offSchema: false }, + { argName: "password", offSchema: false }, + { argName: "rejectUnauthorized", offSchema: false }, + ]; + + expect(mergedArgs.knownArgs.length).toBe(expectedArgs.length); + for (const [idx, arg] of mergedArgs.knownArgs.entries()) { + expect(arg.offSchema).toEqual(expectedArgs[idx].offSchema); + } + }); + it("should throw if schema fails to load", async () => { const profInfo = createNewProfInfo(teamProjDir); await profInfo.readProfilesFromDisk(); diff --git a/packages/config/__tests__/__resources__/ProfInfoApp_team_config_proj/ProfInfoApp.config.json b/packages/config/__tests__/__resources__/ProfInfoApp_team_config_proj/ProfInfoApp.config.json index 9d85bf752..9eea51ef1 100644 --- a/packages/config/__tests__/__resources__/ProfInfoApp_team_config_proj/ProfInfoApp.config.json +++ b/packages/config/__tests__/__resources__/ProfInfoApp_team_config_proj/ProfInfoApp.config.json @@ -60,6 +60,15 @@ "host": "LPAR4.your.domain.net", "responseFormatHeader": true } + }, + "LPAR5": { + "type": "zosmf", + "properties": { + "host": "LPAR4.your.domain.net", + "port": 1234, + "responseFormatHeader": true, + "fakeOffSchemaArg": "fakeArg" + } } }, "defaults": { From 57d330aa9868caa713be8d9c552276dd46d4713c Mon Sep 17 00:00:00 2001 From: Amber Torrise Date: Wed, 19 Jul 2023 10:10:30 -0400 Subject: [PATCH 3/7] changelog Signed-off-by: Amber Torrise --- .vscode/zowe-cli | 1 + CHANGELOG.md | 3 +++ 2 files changed, 4 insertions(+) create mode 160000 .vscode/zowe-cli diff --git a/.vscode/zowe-cli b/.vscode/zowe-cli new file mode 160000 index 000000000..ae4ad3359 --- /dev/null +++ b/.vscode/zowe-cli @@ -0,0 +1 @@ +Subproject commit ae4ad335934ff72888a650ab5796f21ca57166f5 diff --git a/CHANGELOG.md b/CHANGELOG.md index 37ee13edd..98f03b31f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to the Imperative package will be documented in this file. +## Recent Changes +- Enhancement: Added `offSchema` property for ProfileInfo to indicate if argument is a known schema argument [#899](https://github.com/zowe/imperative/issues/899) + ## `5.15.1` - BugFix: Enabled NextVerFeatures.useV3ErrFormat() to form the right environment variable name even if Imperative.init() has not been called. From 61aadc27a46917bf692407185ac7a8edbc37a088 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:01:53 +0000 Subject: [PATCH 4/7] fix unit tests Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- packages/config/__tests__/ProfileInfo.TeamConfig.test.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts b/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts index fd6acca1a..aa7a5ddbb 100644 --- a/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts +++ b/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts @@ -308,20 +308,19 @@ describe("TeamConfig ProfileInfo tests", () => { describe("getAllProfiles", () => { it("should return all profiles if no type is specified", async () => { - const length = 7; const expectedDefaultProfiles = 4; const expectedDefaultProfileNameZosmf = "LPAR1"; const expectedDefaultProfileNameTso = "LPAR1.tsoProfName"; const expectedDefaultProfileNameBase = "base_glob"; const expectedDefaultProfileNameDummy = "LPAR4"; let actualDefaultProfiles = 0; - let expectedProfileNames = ["LPAR1", "LPAR2", "LPAR3", "LPAR1.tsoProfName", "LPAR1.tsoProfName.tsoSubProfName", "base_glob", "LPAR4"]; + let expectedProfileNames = ["LPAR1", "LPAR2", "LPAR3", "LPAR1.tsoProfName", "LPAR1.tsoProfName.tsoSubProfName", "base_glob", "LPAR4", "LPAR5"]; const profInfo = createNewProfInfo(teamProjDir); await profInfo.readProfilesFromDisk(); const profAttrs = profInfo.getAllProfiles(); - expect(profAttrs.length).toEqual(length); + expect(profAttrs.length).toEqual(expectedProfileNames.length); for (const prof of profAttrs) { if (prof.isDefaultProfile) { let expectedName = ""; @@ -355,7 +354,7 @@ describe("TeamConfig ProfileInfo tests", () => { const desiredProfType = "zosmf"; const expectedName = "LPAR1"; const expectedDefaultProfiles = 1; - let expectedProfileNames = ["LPAR1", "LPAR2", "LPAR3", "LPAR2_home"]; + let expectedProfileNames = ["LPAR1", "LPAR2", "LPAR3", "LPAR2_home", "LPAR5"]; let actualDefaultProfiles = 0; const profInfo = createNewProfInfo(teamProjDir); @@ -389,7 +388,7 @@ describe("TeamConfig ProfileInfo tests", () => { const desiredProfType = "zosmf"; const expectedName = "LPAR1"; const expectedDefaultProfiles = 1; - let expectedProfileNames = ["LPAR1", "LPAR2", "LPAR3"]; + let expectedProfileNames = ["LPAR1", "LPAR2", "LPAR3", "LPAR5"]; let actualDefaultProfiles = 0; const profInfo = createNewProfInfo(teamProjDir); From 5c351d92f7d91e0967fbba7d297a20e6a1fdd47d Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Wed, 26 Jul 2023 16:43:34 +0000 Subject: [PATCH 5/7] remove zowe-cli submodule Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- .vscode/zowe-cli | 1 - 1 file changed, 1 deletion(-) delete mode 160000 .vscode/zowe-cli diff --git a/.vscode/zowe-cli b/.vscode/zowe-cli deleted file mode 160000 index ae4ad3359..000000000 --- a/.vscode/zowe-cli +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ae4ad335934ff72888a650ab5796f21ca57166f5 From 0de219e67f9518586b6e6453086b68448ccc3532 Mon Sep 17 00:00:00 2001 From: Amber Torrise <112635587+ATorrise@users.noreply.github.com> Date: Wed, 26 Jul 2023 15:44:27 -0400 Subject: [PATCH 6/7] fixing line length Signed-off-by: Amber Torrise <112635587+ATorrise@users.noreply.github.com> --- packages/config/__tests__/ProfileInfo.TeamConfig.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts b/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts index aa7a5ddbb..109bdd26b 100644 --- a/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts +++ b/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts @@ -314,7 +314,8 @@ describe("TeamConfig ProfileInfo tests", () => { const expectedDefaultProfileNameBase = "base_glob"; const expectedDefaultProfileNameDummy = "LPAR4"; let actualDefaultProfiles = 0; - let expectedProfileNames = ["LPAR1", "LPAR2", "LPAR3", "LPAR1.tsoProfName", "LPAR1.tsoProfName.tsoSubProfName", "base_glob", "LPAR4", "LPAR5"]; + let expectedProfileNames = ["LPAR1", "LPAR2", "LPAR3", "LPAR1.tsoProfName", "LPAR1.tsoProfName.tsoSubProfName", + "base_glob", "LPAR4", "LPAR5"]; const profInfo = createNewProfInfo(teamProjDir); await profInfo.readProfilesFromDisk(); From 55ed1923f75f5ff4aac498eb80447048f3d14e66 Mon Sep 17 00:00:00 2001 From: Amber Torrise <112635587+ATorrise@users.noreply.github.com> Date: Mon, 31 Jul 2023 17:00:52 +0000 Subject: [PATCH 7/7] changing property name offSchema to inSchema Signed-off-by: Amber Torrise <112635587+ATorrise@users.noreply.github.com> --- CHANGELOG.md | 2 +- .../__tests__/ProfileInfo.TeamConfig.test.ts | 18 +++++++++--------- packages/config/src/ProfileInfo.ts | 10 +++++----- packages/config/src/doc/IProfArgAttrs.ts | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9649ff42..39e90632e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to the Imperative package will be documented in this file. ## Recent Changes -- Enhancement: Added `offSchema` property for ProfileInfo to indicate if argument is a known schema argument [#899](https://github.com/zowe/imperative/issues/899) +- Enhancement: Added `inSchema` property for ProfileInfo to indicate if argument is a known schema argument [#899](https://github.com/zowe/imperative/issues/899) ## `5.16.0` diff --git a/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts b/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts index 109bdd26b..cd05cc12a 100644 --- a/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts +++ b/packages/config/__tests__/ProfileInfo.TeamConfig.test.ts @@ -753,25 +753,25 @@ describe("TeamConfig ProfileInfo tests", () => { } }); - it("should find correct offSchema args", async () => { + it("should find correct inSchema args", async () => { const profInfo = createNewProfInfo(teamProjDir); await profInfo.readProfilesFromDisk(); const profAttrs = profInfo.getAllProfiles()[7] as IProfAttrs; const mergedArgs = profInfo.mergeArgsForProfile(profAttrs); const expectedArgs = [ - { argName: "host", offSchema: false }, - { argName: "port", offSchema: false }, - { argName: "responseFormatHeader", offSchema: true }, - { argName: "fakeOffSchemaArg", offSchema: true }, - { argName: "user", offSchema: false }, - { argName: "password", offSchema: false }, - { argName: "rejectUnauthorized", offSchema: false }, + { argName: "host", inSchema: true }, + { argName: "port", inSchema: true }, + { argName: "responseFormatHeader", inSchema: false }, + { argName: "fakeOffSchemaArg", inSchema: false }, + { argName: "user", inSchema: true }, + { argName: "password", inSchema: true }, + { argName: "rejectUnauthorized", inSchema: true }, ]; expect(mergedArgs.knownArgs.length).toBe(expectedArgs.length); for (const [idx, arg] of mergedArgs.knownArgs.entries()) { - expect(arg.offSchema).toEqual(expectedArgs[idx].offSchema); + expect(arg.inSchema).toEqual(expectedArgs[idx].inSchema); } }); diff --git a/packages/config/src/ProfileInfo.ts b/packages/config/src/ProfileInfo.ts index d38781b0f..0e1f3a197 100644 --- a/packages/config/src/ProfileInfo.ts +++ b/packages/config/src/ProfileInfo.ts @@ -624,7 +624,7 @@ export class ProfileInfo { argValue: propVal, argLoc, secure, - offSchema: true + inSchema: false }); } } @@ -656,7 +656,7 @@ export class ProfileInfo { argValue: propVal, argLoc, secure, - offSchema: true + inSchema: false }); } } @@ -748,7 +748,7 @@ export class ProfileInfo { dataType: this.argDataType(propInfoInSchema.type), argValue: (propInfoInSchema as ICommandProfileProperty).optionDefinition?.defaultValue, argLoc, - offSchema: false, + inSchema: true, // See https://github.com/zowe/imperative/issues/739 secure: foundInSecureArray || propInfoInSchema.secure }; @@ -763,7 +763,7 @@ export class ProfileInfo { if (!argFound) { mergedArgs.missingArgs.push({ argName: propName, - offSchema: false, + inSchema: true, dataType: this.argDataType(propInfoInSchema.type), argValue: (propInfoInSchema as ICommandProfileProperty).optionDefinition?.defaultValue, argLoc: { locType: ProfLocType.DEFAULT }, @@ -771,7 +771,7 @@ export class ProfileInfo { }); } } else { - knownArg.offSchema = false; + knownArg.inSchema = true; knownArg.secure = knownArg.secure ?? propInfoInSchema.secure; if (knownArg.secure) { delete knownArg.argValue; diff --git a/packages/config/src/doc/IProfArgAttrs.ts b/packages/config/src/doc/IProfArgAttrs.ts index 370dda3d4..70c80512a 100644 --- a/packages/config/src/doc/IProfArgAttrs.ts +++ b/packages/config/src/doc/IProfArgAttrs.ts @@ -37,5 +37,5 @@ export interface IProfArgAttrs { secure?: boolean; /** Whether the argument value is defined in the schema file */ - offSchema?: boolean; + inSchema?: boolean; }