Skip to content

fix: move async to internal surface until stabilized #611

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

Merged
merged 3 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference/google.auth.transport.aiohttp_requests.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
google.auth.transport.aiohttp\_requests module
==============================================

.. automodule:: google.auth.transport.aiohttp_requests
.. automodule:: google.auth.transport._aiohttp_requests
:members:
:inherited-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/reference/google.auth.transport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Submodules
.. toctree::
:maxdepth: 4

google.auth.transport.aiohttp_requests
google.auth.transport._aiohttp_requests
google.auth.transport.grpc
google.auth.transport.mtls
google.auth.transport.requests
Expand Down
3 changes: 3 additions & 0 deletions google/auth/jwt_async.py → google/auth/_jwt_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

.. _rfc7519: https://tools.ietf.org/html/rfc7519


NOTE: This async support is experimental and marked internal. This surface may
change in minor releases.
"""

import google.auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Transport adapter for Async HTTP (aiohttp)."""
"""Transport adapter for Async HTTP (aiohttp).

NOTE: This async support is experimental and marked internal. This surface may
change in minor releases.
"""

from __future__ import absolute_import

Expand Down Expand Up @@ -197,7 +201,7 @@ class AuthorizedSession(aiohttp.ClientSession):
This class is used to perform requests to API endpoints that require
authorization::

import google.auth.transport.aiohttp_requests
from google.auth.transport import aiohttp_requests

async with aiohttp_requests.AuthorizedSession(credentials) as authed_session:
response = await authed_session.request(
Expand Down
4 changes: 2 additions & 2 deletions system_tests/system_tests_async/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import urllib3

import aiohttp
import google.auth.transport.aiohttp_requests
from google.auth.transport import _aiohttp_requests as aiohttp_requests
from system_tests import conftest as sync_conftest

ASYNC_REQUESTS_SESSION = aiohttp.ClientSession()
Expand Down Expand Up @@ -52,7 +52,7 @@ def authorized_user_file():
@pytest.fixture(params=["aiohttp"])
async def http_request(request):
"""A transport.request object."""
yield google.auth.transport.aiohttp_requests.Request(ASYNC_REQUESTS_SESSION)
yield aiohttp_requests.Request(ASYNC_REQUESTS_SESSION)

@pytest.fixture
async def token_info(http_request):
Expand Down
2 changes: 1 addition & 1 deletion tests_async/oauth2/test__client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from six.moves import urllib

from google.auth import _helpers
from google.auth import _jwt_async as jwt
from google.auth import exceptions
from google.auth import jwt_async as jwt
from google.oauth2 import _client as sync_client
from google.oauth2 import _client_async as _client
from tests.oauth2 import test__client as test_client
Expand Down
2 changes: 1 addition & 1 deletion tests_async/test_jwt_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from google.auth import crypt
from google.auth import exceptions
from google.auth import jwt_async
from google.auth import _jwt_async as jwt_async
from tests import test_jwt


Expand Down
20 changes: 7 additions & 13 deletions tests_async/transport/test_aiohttp_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from tests_async.transport import async_compliance

import google.auth.credentials_async
from google.auth.transport import aiohttp_requests
from google.auth.transport import _aiohttp_requests as aiohttp_requests
import google.auth.transport._mtls_helper


Expand All @@ -33,7 +33,7 @@ def make_with_parameter_request(self):

def test_timeout(self):
http = mock.create_autospec(aiohttp.ClientSession, instance=True)
request = google.auth.transport.aiohttp_requests.Request(http)
request = aiohttp_requests.Request(http)
request(url="http://example.com", method="GET", timeout=5)


Expand All @@ -54,16 +54,14 @@ class TestAuthorizedSession(object):
method = "GET"

def test_constructor(self):
authed_session = google.auth.transport.aiohttp_requests.AuthorizedSession(
mock.sentinel.credentials
)
authed_session = aiohttp_requests.AuthorizedSession(mock.sentinel.credentials)
assert authed_session.credentials == mock.sentinel.credentials

def test_constructor_with_auth_request(self):
http = mock.create_autospec(aiohttp.ClientSession)
auth_request = google.auth.transport.aiohttp_requests.Request(http)
auth_request = aiohttp_requests.Request(http)

authed_session = google.auth.transport.aiohttp_requests.AuthorizedSession(
authed_session = aiohttp_requests.AuthorizedSession(
mock.sentinel.credentials, auth_request=auth_request
)

Expand Down Expand Up @@ -137,9 +135,7 @@ async def test_request_no_refresh(self):
credentials = mock.Mock(wraps=CredentialsStub())
with aioresponses() as mocked:
mocked.get("http://example.com", status=200)
authed_session = google.auth.transport.aiohttp_requests.AuthorizedSession(
credentials
)
authed_session = aiohttp_requests.AuthorizedSession(credentials)
response = await authed_session.request("GET", "http://example.com")
assert response.status == 200
assert credentials.before_request.called
Expand All @@ -153,9 +149,7 @@ async def test_request_refresh(self):
with aioresponses() as mocked:
mocked.get("http://example.com", status=401)
mocked.get("http://example.com", status=200)
authed_session = google.auth.transport.aiohttp_requests.AuthorizedSession(
credentials
)
authed_session = aiohttp_requests.AuthorizedSession(credentials)
response = await authed_session.request("GET", "http://example.com")
assert credentials.refresh.called
assert response.status == 200
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy