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
DigestAuth as middleware - No nonce count #332
DigestAuth as middleware - No nonce count #332
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, I left some comments inline. :)
response = client.get(url, auth=auth) | ||
|
||
assert response.status_code == 200 | ||
assert response.json() == {"auth": None} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a test case where only 1 of the 2 conditions are met like 200+WWW-Authenticate or 401 without the header?
assert digest_data["algorithm"] == "SHA-256" | ||
|
||
|
||
def test_digest_auth_qop_including_spaces_and_auth_returns_auth(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we parametrize this with: (current input), "auth-int,auth", and "unknown, auth"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Thanks @yeraydiazdiaz :) |
Split from #305
This PR introduces a
DigestAuth
middleware that can be used as anauth
parameter toClient
and the request methods.This works for the synchronous Client situations, for example:
Prints:
But fails on concurrent AsyncClient such as:
Printing inconsistent results with only some of the requests succeeding:
There's already a fair bit of code in the PR so I opted not to include the discussed solution in the previous PR (having a per request instance of the middleware) until I get feedback.