diff --git a/docs/reference/google.auth.transport.aiohttp_requests.rst b/docs/reference/google.auth.transport.aiohttp_requests.rst index bc3e74381..44fc4e577 100644 --- a/docs/reference/google.auth.transport.aiohttp_requests.rst +++ b/docs/reference/google.auth.transport.aiohttp_requests.rst @@ -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: diff --git a/docs/reference/google.auth.transport.rst b/docs/reference/google.auth.transport.rst index eba29d037..f1d198855 100644 --- a/docs/reference/google.auth.transport.rst +++ b/docs/reference/google.auth.transport.rst @@ -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 diff --git a/google/auth/jwt_async.py b/google/auth/_jwt_async.py similarity index 98% rename from google/auth/jwt_async.py rename to google/auth/_jwt_async.py index daa5e3ee9..9d39fcf14 100644 --- a/google/auth/jwt_async.py +++ b/google/auth/_jwt_async.py @@ -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 diff --git a/google/auth/transport/aiohttp_requests.py b/google/auth/transport/_aiohttp_requests.py similarity index 98% rename from google/auth/transport/aiohttp_requests.py rename to google/auth/transport/_aiohttp_requests.py index 8fe0434f3..b90cdcde9 100644 --- a/google/auth/transport/aiohttp_requests.py +++ b/google/auth/transport/_aiohttp_requests.py @@ -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 @@ -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( diff --git a/system_tests/system_tests_async/conftest.py b/system_tests/system_tests_async/conftest.py index 2477f3f82..af2a70517 100644 --- a/system_tests/system_tests_async/conftest.py +++ b/system_tests/system_tests_async/conftest.py @@ -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() @@ -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): diff --git a/tests_async/oauth2/test__client_async.py b/tests_async/oauth2/test__client_async.py index 87982807f..458937ac1 100644 --- a/tests_async/oauth2/test__client_async.py +++ b/tests_async/oauth2/test__client_async.py @@ -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 diff --git a/tests_async/test_jwt_async.py b/tests_async/test_jwt_async.py index b5a499027..ba7044532 100644 --- a/tests_async/test_jwt_async.py +++ b/tests_async/test_jwt_async.py @@ -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 diff --git a/tests_async/transport/test_aiohttp_requests.py b/tests_async/transport/test_aiohttp_requests.py index 4c3d9717b..875a24e67 100644 --- a/tests_async/transport/test_aiohttp_requests.py +++ b/tests_async/transport/test_aiohttp_requests.py @@ -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 @@ -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) @@ -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 ) @@ -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 @@ -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