Skip to content

Add ca_certs argument for oauth and dropbox client #385

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

Merged
merged 3 commits into from
Jun 30, 2022

Conversation

stanislau-arkhipenka
Copy link
Contributor

@stanislau-arkhipenka stanislau-arkhipenka commented Sep 14, 2021

This change adds ca_certs str argument for oauth and dropbox client classes. It may be used with applications that packed into executable archives (like python par or py2exe). It also may be useful with some security related scenarios.

Checklist

General Contributing

  • Have you read the Code of Conduct and signed the CLA?

Is This a Code Change?

  • Non-code related change (markdown/git settings etc)
  • SDK Code Change
  • Example/Test Code Change

Validation

  • Does tox pass?
  • Do the tests pass? (no integration tests)

@greg-db
Copy link
Contributor

greg-db commented Sep 15, 2021

Thanks for putting this together! I'll ask the team to review this, though I can't promise when that would be.

@stanislau-arkhipenka
Copy link
Contributor Author

Hey @greg-db , thanks for reply. May be you have any updates?

@greg-db
Copy link
Contributor

greg-db commented Oct 4, 2021

@stanislau-arkhipenka This is still open with the team, but I don't have an update on it.

@codecov
Copy link

codecov bot commented Oct 4, 2021

Codecov Report

Merging #385 (f862c4b) into main (3fa08e5) will decrease coverage by 0.57%.
The diff coverage is 73.33%.

@@            Coverage Diff             @@
##             main     #385      +/-   ##
==========================================
- Coverage   64.25%   63.67%   -0.58%     
==========================================
  Files          30       30              
  Lines       51974    51982       +8     
  Branches     5780     5781       +1     
==========================================
- Hits        33394    33098     -296     
- Misses      18420    18849     +429     
+ Partials      160       35     -125     
Flag Coverage Δ
integration ?
unit 63.67% <73.33%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
dropbox/session.py 88.23% <63.63%> (-11.77%) ⬇️
dropbox/dropbox_client.py 38.43% <100.00%> (-34.36%) ⬇️
dropbox/oauth.py 55.04% <100.00%> (ø)
dropbox/stone_serializers.py 0.00% <0.00%> (-100.00%) ⬇️
dropbox/exceptions.py 61.22% <0.00%> (-16.33%) ⬇️
dropbox/check.py 77.77% <0.00%> (-8.34%) ⬇️
dropbox/common.py 72.44% <0.00%> (-5.52%) ⬇️
dropbox/users.py 62.93% <0.00%> (-4.08%) ⬇️
dropbox/team_common.py 72.99% <0.00%> (-3.65%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3fa08e5...f862c4b. Read the comment docs.

@rogebrd
Copy link
Contributor

rogebrd commented Oct 4, 2021

Hello @stanislau-arkhipenka, I took at look at the PR and code wise, it looks good to me. I want to get a better understanding for your use case before we make the decision to merge this. Could you help me understand why this is needed?

def __init__(self, *args, **kwargs):
self._ca_certs = kwargs.pop("ca_certs", None) or _TRUSTED_CERT_FILE
if not self._ca_certs:
raise FileNotFoundError("CA certificate not found")
Copy link

Choose a reason for hiding this comment

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

This error is a bit misleading - it's not checking for the presence of a readable file (although maybe it should be?) - it's simply checking to see if ca_certs or _TRUSTED_CERT_FILE is set.

@stanislau-arkhipenka
Copy link
Contributor Author

Hello @rogebrd ,
Sorry for quite a long delay.
There are two possible scenarios when this code may be useful:

  1. In a secure environment with https reverse proxy (effectively corporate term for "man in the middle"). This diff will allows to use custom certificate issued by company.
  2. (my case) For cases when developed application is packed into executable archive like par or py2exe (issues mentioned here and here).

@CLAassistant
Copy link

CLAassistant commented Apr 16, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 3 committers have signed the CLA.

✅ stanislau-arkhipenka
❌ Stanislau Arkhipenka
❌ Brent1LT


Stanislau Arkhipenka seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@stanislau-arkhipenka
Copy link
Contributor Author

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
Stanislau Arkhipenka seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Signed it

@stanislau-arkhipenka
Copy link
Contributor Author

Hey guys, any updates? I've signed CLA. Do you need anything else on my side?
Thanks!

@greg-db
Copy link
Contributor

greg-db commented Jun 13, 2022

Thanks for checking in. This is open with the team, but I don't have an update or timeline on it right now.

@Brent1LT
Copy link
Contributor

Everything looks good to me but it looks like there are some integration tests that are failing before it can get merged in.

New error better represents actual problem (CA not set)
And also compatible with python2.7
@stanislau-arkhipenka
Copy link
Contributor Author

Everything looks good to me but it looks like there are some integration tests that are failing before it can get merged in.

Everything looks good to me but it looks like there are some integration tests that are failing before it can get merged in.

Hey @Brent1LT , thanks for reply!
Indeed there was a problem with FileNotFoundError (it doesn't supported in python2.7) - FIXED.
With regards to integration tests: I believe it is not related to this particular PR, as it seems persists across other open PRs.
Based on error message my best guess is that some environmental variables on CI side are not populated correctly. I'm not sure, but it may be related to rename of envs from DROPBOX_* to SCOPED_* (btw same problem exists if you try to run tox -e test_integration )

@stanislau-arkhipenka
Copy link
Contributor Author

Yep,
credentials for integration tests are not populated.
If you open failed Integration test -> Run Integration Tests -> Run pytest test/integration/test_dropbox.py you will see that credentials are not set. Here is an example https://paste.pics/99b08a30383cb84552645493745caa22

@stanislau-arkhipenka
Copy link
Contributor Author

@rogebrd , @april , @Brent1LT
How do you think can this PR be merged to upstream?
The Integration tests are failing because of missed environmental variables, and it doesn't relate to PR

@sderickson
Copy link
Contributor

@rogebrd , @april , @Brent1LT How do you think can this PR be merged to upstream? The Integration tests are failing because of missed environmental variables, and it doesn't relate to PR

Those are because only Dropboxers can run those tests with those sensitive variables. Hence why they aren't required. Moving forward with merging - thanks for doing this!

@dennissiemensma
Copy link
Contributor

I've added a minor follow-up for this PR in #440 to prevent pickle from breaking.

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.

8 participants