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

Support AUTH_TYPE_CERT_PEM and AUTH_TYPE_NONE #305

Merged
merged 9 commits into from
Jul 12, 2024
Merged

Support AUTH_TYPE_CERT_PEM and AUTH_TYPE_NONE #305

merged 9 commits into from
Jul 12, 2024

Conversation

pem70
Copy link
Collaborator

@pem70 pem70 commented Jul 5, 2024

What It Does
Supports for AUTH_TYPE_CERT_PEM and AUTH_TYPE_NONE in session addressed in [#291] and [#296]

How to Test

Review Checklist
I certify that I have:

Additional Comments

pem70 added 3 commits July 3, 2024 15:09
Signed-off-by: pem70 <[email protected]>
Signed-off-by: pem70 <[email protected]>
Signed-off-by: pem70 <[email protected]>
@pem70 pem70 requested review from t1m0thyj and zFernand0 July 5, 2024 14:08
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.90%. Comparing base (af53e8f) to head (8fdf3b3).
Report is 156 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #305      +/-   ##
==========================================
+ Coverage   89.82%   89.90%   +0.07%     
==========================================
  Files          53       53              
  Lines        2694     2713      +19     
==========================================
+ Hits         2420     2439      +19     
  Misses        274      274              
Flag Coverage Δ
unittests 89.90% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@pem70 pem70 marked this pull request as ready for review July 5, 2024 14:10
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.

TL;DR: Changes LGTM! 😋


After testing the AUTH_TYPE_NONE, I'm wondering if we should update the sample SDK. I was able to use some of that code to test this functionality and it works! 🥳

from zowe.core_for_zowe_sdk.sdk_api import SdkApi

sample = SdkApi({"host": "jsonplaceholder.typicode.com"}, "/")
custom_args = sample._create_custom_request_arguments()
custom_args["json"] = {"title": "foo", "body": "bar", "userId": 10}
custom_args["url"] = f"{sample._request_endpoint}/posts"
response_json = sample.request_handler.perform_request("POST", custom_args, expected_code=[201])
print(response_json)

Tested with a local instance of the APIML (using this instructions) and...

I can't seems to be able to use certificates as a valid authentication mechanism.
😢

While trying to resolve this, I found a few other places where we may need to make changes in order to pass certs properly to the requests.Session() object.
And keep in mind that we would also want to make sure not to validate certs if rejectUnauthorized is False. 😋


Here are some pointers that may help in resolving the certificate support issue:

  • The sdk_api needs to handle the authType cert-pem (same as with the other auth types)
  • The format of how certs should be passed is kind of specific (tuple instead of multiple params)
    • See requests#sessions.py#request() for more details
      • :param cert: (optional) if String, path to ssl client cert file (.pem).
        If Tuple, ('cert', 'key') pair.

src/core/zowe/core_for_zowe_sdk/session.py Outdated Show resolved Hide resolved
@JTonda JTonda requested a review from zFernand0 July 10, 2024 15:08
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.

Left a small comment, but otherwise, the functionality LGTM! 😋

src/core/zowe/core_for_zowe_sdk/session.py Outdated Show resolved Hide resolved
Co-authored-by: Fernando Rijo Cedeno <[email protected]>
Signed-off-by: Peizhao Mei <[email protected]>
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.

LGTM! 😋

@zFernand0 zFernand0 merged commit 19297ff into main Jul 12, 2024
21 checks passed
@zFernand0 zFernand0 deleted the Auth_Type branch July 12, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Session should support AUTH_TYPE_CERT [core] Session should support AUTH_TYPE_NONE
2 participants