-
Notifications
You must be signed in to change notification settings - Fork 244
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
~/.netrc #246
~/.netrc #246
Conversation
Codecov Report
@@ Coverage Diff @@
## master #246 +/- ##
==========================================
+ Coverage 95.79% 95.85% +0.05%
==========================================
Files 3 3
Lines 571 579 +8
Branches 123 125 +2
==========================================
+ Hits 547 555 +8
Misses 15 15
Partials 9 9
Continue to review full report at Codecov.
|
The test success is a bit deceptive. Since we with VCR make requests work even if no or wrong credentials are given, the netrc test succeeds as well. But maybe that is actually OK, since this is what we do for all tests. |
👍 Maybe instead of trying to access a .netrc file in the home directory in tests we can get by with just mocking the netrc file access as is done in the unit tests of |
Good thinking, @valgur. Mocking I could follow the same logic and monkey-patch the |
Before I do anything - do you support my choice of doing the parsing in the CLI to avoid confusion deeper down (also @Fernerkundung)? My concern is that if we allow omitting
|
I think adding the .netrc support to the Python API by using it when both user and pass are set to Regarding the implementation, I suggest replacing the custom |
👍
In that case how would a user know whether the API takes the envvar or the .netrc file? From a design perspective I would favour it if setting user/pass to Do you think we should also include a way to explicitly set the path to a |
Good idea. Done. I don't think we can drop the tests, though, and they work fine as they are. So maybe we are good?
I agree. Actually, this already works: SentinelAPI(None, None).query(uuid='eaa093dd-46a6-49b5-a1bd-7625c2956029') So all we need is to add this to the docs.
No, let us not do that. The So we actually support |
This is just a stab at adding netrc support, fixing #90, as discussed there. I still think that netrc support is relevant and it is relatively easy to implement.
So here I add a little function in the CLI that tries to read
~/.netrc
, if neither command-line parameters are given nor environment variables set.I know we could also just let
requests
handle it, probably simply by allowing no authentication to go through the API. But in case of missing auth or malformatted~/.netrc
, that would give an error deep in the API code that is harder to communicate to the CLI user.So I suggest to just add this in the CLI and let API users add their own
netrc
magic if they need it, since it it is very simple.One obstacle: Testing this gets a bit dirty because I need to mess with the system environment. Also, a proper success test is only possible if I do get valid credentials from somewhere, which we currently do not have on Travis. Although maybe there is a way around the latter, just testing whether the cli fails in the right way...