WIP - aiohttp: support for auth from ClientSession#167
Closed
cjw296 wants to merge 1 commit intoh2non:masterfrom
Closed
WIP - aiohttp: support for auth from ClientSession#167cjw296 wants to merge 1 commit intoh2non:masterfrom
cjw296 wants to merge 1 commit intoh2non:masterfrom
Conversation
| if "Content-Type" not in req.headers: | ||
| req.headers["Content-Type"] = "application/json" | ||
|
|
||
| # Lifted from the ClientSession._request method we're mocking: |
Collaborator
There was a problem hiding this comment.
aiohttp is licenced under Apache 2.0. It is probably best to put this portion of code into a separate directory with its own LICENSE file (and heading) to clarify that this code is not MIT licenced with the rest of pook.
Comment on lines
+102
to
+113
| async def test_client_auth_merged(local_responder): | ||
| """Auth headers set on the client should be matched""" | ||
| pook \ | ||
| .get(local_responder + "/status/404") \ | ||
| .header("Authorization", "Basic dXNlcjpwYXNzd29yZA==") \ | ||
| .reply(200).body("hello from pook") | ||
| async with aiohttp.ClientSession(auth=BasicAuth('user', 'password')) as session: | ||
| res = await session.get( | ||
| local_responder + "/status/404", headers={"x-pook-secondary": "xyz"} | ||
| ) | ||
| assert res.status == 200 | ||
| assert await res.read() == b"hello from pook" |
Collaborator
There was a problem hiding this comment.
Might be worth adding a basic auth test to the standard interceptor tests 🤔
Author
There was a problem hiding this comment.
I think there actually is already, the problem here is that aiohttp.ClientSession(auth=BasicAuth('user', 'password')) is an aiohttp-specific way of setting session-wide basic auth, and pook's interceptor currently doesn't handle that.
1 task
2 tasks
Collaborator
|
Closing in favour of #170 which fixes the issue without needing to further into aiohttp's guts 😁 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(not ready yet, just pushing up to see what CI looks like)
Description
PR Checklist