-
Notifications
You must be signed in to change notification settings - Fork 49
WIP - aiohttp: support for auth from ClientSession #167
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import aiohttp | ||
| import pytest | ||
| from aiohttp import BasicAuth | ||
|
|
||
| import pook | ||
| from tests.unit.fixtures import BINARY_FILE | ||
|
|
@@ -97,6 +98,21 @@ async def test_client_headers_merged(local_responder): | |
| assert await res.read() == b"hello from pook" | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| 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" | ||
|
Comment on lines
+102
to
+113
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth adding a basic auth test to the standard interceptor tests 🤔
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there actually is already, the problem here is that |
||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_client_headers_both_session_and_request(local_responder): | ||
| """Headers should be matchable from both the session and request in the same matcher""" | ||
|
|
||
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.
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.
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.
Let's see how this goes....