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 for: Incorrect username/password gives misleading error #5659

Merged
merged 4 commits into from
Oct 16, 2018

Conversation

patter001
Copy link

No description provided.

@patter001
Copy link
Author

This CI failure is unrelated to the change...i'm not sure of why the build has timed out.

@patter001
Copy link
Author

CI checks are passing...can I get this merged?

@pradyunsg pradyunsg added the S: needs triage Issues/PRs that need to be triaged label Aug 16, 2018
@pradyunsg
Copy link
Member

I won't be able to take a look at this since there's quite a bit happening offline for me currently. Perhaps some other maintainer is able to find time to look at this before I come around to it. :)

Thanks and sorry for the wait.

Copy link
Member

@pfmoore pfmoore left a comment

Choose a reason for hiding this comment

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

While it might not be easy to do, if it's possible to add a test for this, that would be useful. But I can imagine it might need a lot more infrastructure set up than is reasonable, so I won't reject this for lack of a test.

logger.warning('401 Error, Credentials not correct for %s',
resp.request.url)
return resp

Copy link
Member

Choose a reason for hiding this comment

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

If I'm reading the Requests documentation correctly, you only need to return a value if you're retruning something different. So

if resp.status_code == 410:
    logger.warning(...)

should be all you need (and it looks cleaner).

@@ -199,13 +199,23 @@ def handle_401(self, resp, **kwargs):

# Add our new username and password to the request
req = HTTPBasicAuth(username or "", password or "")(resp.request)
req.register_hook("response", self.handle_401_again)
Copy link
Member

Choose a reason for hiding this comment

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

Minor naming nit: we're not actually handling the 401, and definitely not doing so "again". Maybe warn_on_401?

@pradyunsg pradyunsg added type: enhancement Improvements to functionality and removed S: needs triage Issues/PRs that need to be triaged labels Aug 17, 2018
if resp.status_code == 401:
logger.warning('401 Error, Credentials not correct for %s',
resp.request.url)
return resp
Copy link
Member

Choose a reason for hiding this comment

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

This return isn't needed.

@patter001
Copy link
Author

ah, thanks, removed the return and fixed the function name to be the recommended "warn_on_401"

@patter001
Copy link
Author

I did not seen any existing 401 tests to leverage from. Is that required for the merge? Any other opens I need to take care of before this would be qualified to get merged in?

@patter001
Copy link
Author

Since this is approved, can someone merge this so that it makes it to the next release?

@xavfernandez xavfernandez merged commit 7f3b2c1 into pypa:master Oct 16, 2018
@xavfernandez
Copy link
Member

@patter001 thanks for the PR 👍

@patter001
Copy link
Author

very cool. glad to provide some small help to an awesome tool. Thanks for the merge!

@pradyunsg pradyunsg added this to the 19.0 milestone Jan 3, 2019
@lock
Copy link

lock bot commented May 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 31, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants