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

Fix merging of profile properties in ProfileInfo.createSession #1010

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

t1m0thyj
Copy link
Member

@t1m0thyj t1m0thyj commented Aug 28, 2023

What It Does
Fixes #1008 so that user and password takes precedence over tokenValue when both are defined in profile properties.

How to Test

  1. Create a team config file that has both user/password and tokenValue defined (such as the example provided in the linked issue).
  2. Call ProfileInfo.createSession (using a test script like the one below) and verify that only user/password are present in the session.
const { ProfileInfo } = require("@zowe/imperative");
(async () => {
    // Load connection info from default z/OSMF profile
    const profInfo = new ProfileInfo("zowe");
    await profInfo.readProfilesFromDisk();
    const zosmfProfAttrs = profInfo.getDefaultProfile("zosmf");
    const zosmfMergedArgs = profInfo.mergeArgsForProfile(zosmfProfAttrs, { getSecureVals: true });
    const session = ProfileInfo.createSession(zosmfMergedArgs.knownArgs);
    console.dir(session.ISession);
})();

Review Checklist
I certify that I have:

Additional Comments
There is logic in ConnectionPropsForSessCfg.resolveSessCfgProps to conditionally add either user/password or tokenValue to the session. But this logic only runs when user, password, and tokenValue are passed in cmdArgs instead of the sessCfg object. The fix implemented in this PR is consistent with how Zowe CLI command handlers resolve the properties - for example the ZosFilesBaseHandler.

Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

Comparison is base (267ffe8) 89.77% compared to head (22b55e1) 89.76%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1010      +/-   ##
==========================================
- Coverage   89.77%   89.76%   -0.01%     
==========================================
  Files         211      211              
  Lines       11536    11538       +2     
  Branches     2586     2587       +1     
==========================================
+ Hits        10356    10357       +1     
- Misses       1180     1181       +1     
Files Changed Coverage Δ
packages/config/src/ProfileInfo.ts 97.36% <100.00%> (-0.18%) ⬇️

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

@sonarcloud
Copy link

sonarcloud bot commented Aug 28, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell B 3 Code Smells

87.5% 87.5% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

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.

Tested and LGTM, thanks @t1m0thyj

Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

changes LGTM! 😋

@t1m0thyj t1m0thyj merged commit 8fe9d28 into master Aug 29, 2023
18 of 20 checks passed
@t1m0thyj t1m0thyj deleted the fix/profinfo-create-session-precedence branch August 29, 2023 17:42
@t1m0thyj t1m0thyj added the release-patch Indicates a patch to existing code has been applied label Aug 29, 2023
@github-actions
Copy link

Release succeeded for the master branch. 🎉

The following packages have been published:

  • npm: @zowe/imperative@5.18.1

Powered by Octorelease 🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-patch Indicates a patch to existing code has been applied released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Presence of tokenValue in profile should take precedence over user and password
5 participants