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

Fix error using session with auth type "none" #2218

Merged
merged 3 commits into from
Aug 8, 2024

Conversation

t1m0thyj
Copy link
Member

@t1m0thyj t1m0thyj commented Aug 6, 2024

What It Does

Fixes #2219

How to Test

Try issuing a REST request with no credentials on the session object:

const { RestClient, Session } = require("@zowe/imperative");
const mySession = new Session({
    hostname: "example.com",
    port: 443,
    type: "none"
});
const restClient = new RestClient(mySession);
restClient.request({ resource: "/", request: "GET" }).then(console.log);

Review Checklist
I certify that I have:

Additional Comments

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

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.15%. Comparing base (de6aacc) to head (0c05bcc).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2218      +/-   ##
==========================================
- Coverage   91.16%   91.15%   -0.01%     
==========================================
  Files         638      638              
  Lines       19103    19103              
  Branches     3927     3974      +47     
==========================================
- Hits        17415    17414       -1     
- Misses       1687     1688       +1     
  Partials        1        1              

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

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.

The change makes sense to me conceptually speaking.
I may need some help understanding it a bit better. 🙏🏽

LGTM though 😋

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.

Changes look good to me, thanks Timothy for the quick fix

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

@anaxceron anaxceron left a comment

Choose a reason for hiding this comment

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

amazing!

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.

Had a bit more time to test.
Thanks @t1m0thyj for helping! 🙏🏽

LGTM! 😋

Tested in 7.24.0 and this PR and they work as expected (no errors thrown).

Tested with 7.24.1 - a couple of versions in between - 7.28.2, and the latest vNext version and we get the error 😋

Also did some testing with varios Zowe bundles
2.9 - 2.15 (versions before CLI-7.24.1) and they all worked 😋
Then, 2.16 started to fail (as expected)

@t1m0thyj t1m0thyj marked this pull request as ready for review August 7, 2024 20:01
Copy link
Member

@gejohnston gejohnston left a comment

Choose a reason for hiding this comment

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

I agree with the implementation using AUTH_TYPE_NONE. AUTH_TYPE_NONE does not fall into our order-of-precedence. Its presence is an indicator that the items in our order-of-precedence do not even apply to the action.

I suppose AUTH_TYPE_NONE could be tested earlier and we could skip many of the credential checks, but then we would still have to set the headers and flags at the end of the function. Placing the test for AUTH_TYPE_NONE on an existing test (as you have done) minimizes the changes that have to be made, and may even make the logic easier for a human to follow.

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

sonarcloud bot commented Aug 8, 2024

@t1m0thyj t1m0thyj merged commit d846437 into master Aug 8, 2024
44 checks passed
@t1m0thyj t1m0thyj deleted the fix/error-auth-type-none branch August 8, 2024 16:33
@t1m0thyj t1m0thyj added the release-patch Indicates a patch to existing code has been applied label Aug 8, 2024
Copy link

github-actions bot commented Aug 8, 2024

Release succeeded for the master branch. 🎉

The following packages have been published:

  • npm: @zowe/imperative@5.26.2
  • npm: @zowe/cli-test-utils@7.28.3
  • npm: @zowe/core-for-zowe-sdk@7.28.3
  • npm: @zowe/zos-uss-for-zowe-sdk@7.28.3
  • npm: @zowe/provisioning-for-zowe-sdk@7.28.3
  • npm: @zowe/zos-console-for-zowe-sdk@7.28.3
  • npm: @zowe/zos-files-for-zowe-sdk@7.28.3
  • npm: @zowe/zos-logs-for-zowe-sdk@7.28.3
  • npm: @zowe/zosmf-for-zowe-sdk@7.28.3
  • npm: @zowe/zos-workflows-for-zowe-sdk@7.28.3
  • npm: @zowe/zos-jobs-for-zowe-sdk@7.28.3
  • npm: @zowe/zos-tso-for-zowe-sdk@7.28.3
  • npm: @zowe/cli@7.28.3

Powered by Octorelease 🚀

@t1m0thyj t1m0thyj mentioned this pull request Aug 9, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-patch Indicates a patch to existing code has been applied released
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

RestClient.buildOptions doesn't support session with AUTH_TYPE_NONE
6 participants