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

reuse the digest auth state to avoid unnecessary requests #2463

Merged
merged 9 commits into from Nov 29, 2022

Conversation

rettier
Copy link
Contributor

@rettier rettier commented Nov 25, 2022

this implements digest authentication state reuse as discussed in #1467.

Contrary to the comment i am not skipping most of the authentication flow if a previous challenge exists. Otherwise a failed authentication (401) would not result in a retry with the new server challenge (test_digest_auth_resets_nonce_count_after_401 would fail).

@pytest.mark.asyncio
async def test_digest_auth_reuses_challenge() -> None:
url = "https://example.org/"
auth = DigestAuth(username="tomchristie", password="password123")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
auth = DigestAuth(username="tomchristie", password="password123")
auth = DigestAuth(username="user", password="password123")

@pytest.mark.asyncio
async def test_digest_auth_resets_nonce_count_after_401() -> None:
url = "https://example.org/"
auth = DigestAuth(username="tomchristie", password="password123")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
auth = DigestAuth(username="tomchristie", password="password123")
auth = DigestAuth(username="user", password="password123")

Copy link
Member

@tomchristie tomchristie left a comment

Choose a reason for hiding this comment

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

Great stuff - thanks!
A few minor suggestions here.

@rettier
Copy link
Contributor Author

rettier commented Nov 27, 2022

I have refactored some code in view of your suggestions.
Since you removed your username from the test-data i have also removed it from the existing basic auth test cases.

Regarding the failing test pipeline i assume this is not an issue with my branch, as other pipelines seem to fail with the same error message?

@tomchristie
Copy link
Member

Regarding the failing test pipeline i assume this is not an issue with my branch, as other pipelines seem to fail with the same error message?

Yup. See #2465

@tomchristie tomchristie merged commit 8327e13 into encode:master Nov 29, 2022
@tomchristie
Copy link
Member

Good work, thanks!

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.

None yet

2 participants