Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add secureFieldsWithDetails 😋 #2241

Merged
merged 12 commits into from
Aug 29, 2024
Merged

feat: add secureFieldsWithDetails 😋 #2241

merged 12 commits into from
Aug 29, 2024

Conversation

zFernand0
Copy link
Member

@zFernand0 zFernand0 commented Aug 23, 2024

What It Does

How to Test

Review Checklist
I certify that I have:

Additional Comments

// using config.api.secure.secureFields()
[
  'profiles.lpar1.profiles.zosmf.properties.user',
  'profiles.lpar1.profiles.zosmf.properties.test0', // unknown property (boolean)
  'profiles.lpar1.profiles.zosmf.properties.test1', // unknown property (number)
  'profiles.lpar1.profiles.zosmf.properties.test2', // unknown property (missing)
  'profiles.lpar1.properties.tokenValue', // let's assume that lpar1 is a typeless profile
  'profiles.base.properties.tokenValue', 
]

Here is what the output will look like in case we would like to reuse the same IProfArgAttrs interface.

[
  {
    "argName": "user",
    "dataType": "string",
    "argValue": "fernando",
    "argLoc": {
      "locType": 1,
      "osLoc": [
        "/Users/fernando/.zowe/zowe.config.json"
      ],
      "jsonLoc": "profiles.lpar1.profiles.zosmf.properties.user"
    }
  },
  {
    "argName": "test0",
    "dataType": "boolean",
    "argValue": false,
    "argLoc": {
      "locType": 1,
      "osLoc": [
        "/Users/fernando/.zowe/zowe.config.json"
      ],
      "jsonLoc": "profiles.lpar1.profiles.zosmf.properties.test0"
    }
  },
  {
    "argName": "test1",
    "dataType": "number",
    "argValue": 1234,
    "argLoc": {
      "locType": 1,
      "osLoc": [
        "/Users/fernando/.zowe/zowe.config.json"
      ],
      "jsonLoc": "profiles.lpar1.profiles.zosmf.properties.test1"
    }
  },
  {
    "argName": "test2",
    "dataType": null,
    "argValue": undefined,
    "argLoc": {
      "locType": 1,
      "osLoc": [
        "/Users/fernando/.zowe/zowe.config.json"
      ],
      "jsonLoc": "profiles.lpar1.profiles.zosmf.properties.test2"
    }
  },
  {
    "argName": "tokenValue",
    "dataType": null, // This is `null` because the lpar1 profile does not have a type
    "argValue": undefined,
    "argLoc": {
      "locType": 1,
      "osLoc": [
        "/Users/fernando/.zowe/zowe.config.json"
      ],
      "jsonLoc": "profiles.lpar1.properties.tokenValue"
    },
  {
    "argName": "tokenValue",
    "dataType": "string",
    "argValue": undefined,
    "argLoc": {
      "locType": 1,
      "osLoc": [
        "/Users/fernando/.zowe/zowe.config.json"
      ],
      "jsonLoc": "profiles.base.properties.tokenValue"
    }
  }
]

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.30%. Comparing base (35b9d47) to head (dc945c7).
Report is 3 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2241   +/-   ##
=======================================
  Coverage   91.30%   91.30%           
=======================================
  Files         632      632           
  Lines       18147    18147           
  Branches     3888     3849   -39     
=======================================
  Hits        16570    16570           
  Misses       1576     1576           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zFernand0 zFernand0 marked this pull request as ready for review August 26, 2024 18:46
Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Fernando! I left a suggestion for the opts parameter, but the implementation LGTM.

Copy link

Copy link
Member

@awharn awharn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just have two little questions that don't need to be resolved.

config.mSecure = secureConfigs;
expect(config.api.secure.secureFieldsForLayer(projectConfigPath)).toEqual({ [securePropPath]: "area51" });
expect(config.api.secure.secureFieldsForLayer(projectUserConfigPath)).toEqual(null);
config.mSecure = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is being a little picky, but is this line necessary for the locally scoped config variable?

getPropAttr("rejectUnauthorized", undefined, "boolean"),
]);

profInfo.getTeamConfig().mSecure = {};
Copy link
Member

@awharn awharn Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, is this necessary for the locally scoped profInfo?

* @param layerPath Path of the layer to get secure properties for
* @returns the secure properties for the given layer, or null if not found
*/
public secureFieldsForLayer(layerPath: string): IConfigSecureProperties {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is adding this method necessary? I'm probably being dumb but it seems like the secureFields method has a layer parameter which can be used to filter the secure fields returned for only a specific layer.

@traeok traeok merged commit fa7bcd4 into next Aug 29, 2024
46 checks passed
@traeok traeok deleted the fix/ze-2982 branch August 29, 2024 15:08
@traeok traeok added the release-current Indicates that there is no new functionality being delivered label Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-current Indicates that there is no new functionality being delivered
Projects
Status: Closed
5 participants