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

Add transport #2

Closed
wants to merge 5 commits into from
Closed

Add transport #2

wants to merge 5 commits into from

Conversation

theacodes
Copy link
Contributor

Proof-of-concept for #1.

(Not fully implemented, tests will not pass).

I validated this with:

import logging

from google.auth import service_account
import google.auth.transport.urllib3
import urllib3

logging.basicConfig(level=logging.DEBUG)

http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED')

request = google.auth.transport.urllib3.Request(http)

sa_credentials = service_account.Credentials.from_service_account_file(
    'service_account.json',
    scopes=['https://www.googleapis.com/auth/cloud-platform'])

sa_credentials.refresh(request)

print(sa_credentials.token)

@theacodes
Copy link
Contributor Author

Also by happy accident I forgot to implement transport.urllib3.Response, but the urllib3 Response class interface is a superset of transport.Response, so everything still works.

@theacodes
Copy link
Contributor Author

@dhermes I know I promised to unplug, but I had a hunch about the tests. It seems like a good indication that this allows me to reduce the usage of mock.patch in the tests. :)

@@ -112,7 +112,9 @@ def _get_gae_credentials():


def _get_gce_credentials():
if _metadata.ping():
# TODO: Ping now requires a request argument. Figure out how to deal with

This comment was marked as spam.

This comment was marked as spam.

@@ -20,6 +20,11 @@ class GoogleAuthError(Exception):
pass


class TransportError(Exception):
"""Used to indicate an error occurred during an HTTP request."""
pass

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,82 @@
# Copyright 2016 Google Inc. All rights reserved.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"""
# pylint: disable=redundant-returns-doc, missing-raises-doc
# (pylint doesn't play well with abstract docstrings.)
raise NotImplementedError('__call__ must be implemented.')

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


def __call__(self, url, method='GET', body=None, headers=None,
timeout=None, **kwargs):
"""

This comment was marked as spam.

This comment was marked as spam.

@theacodes theacodes closed this Sep 29, 2016
@theacodes theacodes deleted the transport branch October 3, 2016 20:22
arithmetic1728 added a commit that referenced this pull request May 5, 2020
# This is the 1st commit message:
feat: encrypted mtls private key support

(1) support encrypted private key decryption
(2) support reading encrypted key and passphrase from cert provider
command

# The commit message #2 will be skipped:

#	password

# The commit message #3 will be skipped:

#	tmp
anibadde added a commit to anibadde/google-auth-library-python that referenced this pull request Jul 28, 2020
crwilcox pushed a commit that referenced this pull request Jul 31, 2020
…on types (service accounts, default... etc) (#573)

* feat: asyncio http request logic and asynchronous credentials log c

* feat: all asynchronous credentials types implemented and with tests

* feat: added the private scope for Response class

* feat: added docstring for Auth Session request method

* fix: Changed initialization of client session to within an async context manager

* changed aiohttp_requests abbreviation for the async authorized session class

* fix: changed abbrevation of the aiohttp_requests file

* fix: comments on PR regarding shared data between requests and aiohttp_requests

* fix: fixed noxfile test dependency sharing

* fix: fixed the noxfile dependencies between sync and async unit tests

* fix: cover async dependency

* fix: merge conflict issue with credentials

* fix: merge conflict #2

* fix: changed duplicated constants for sync-->async inheritance relationship

* fix: async docstring

* refactoring

* fix: refactoring

* fix: first round of comments, refactoring and test duplication changes

* fix: removed duplication in _default_async

* fix: removed oauth2 client
crwilcox pushed a commit that referenced this pull request Jul 31, 2020
…ken credentials (#574)

* feat: asyncio http request logic and asynchronous credentials log c

* feat: all asynchronous credentials types implemented and with tests

* included system tests for the asynchronous auth library

* feat: added the private scope for Response class

* feat: added docstring for Auth Session request method

* fix: Changed initialization of client session to within an async context manager

* changed aiohttp_requests abbreviation for the async authorized session class

* fix: changed abbrevation of the aiohttp_requests file

* fix: comments on PR regarding shared data between requests and aiohttp_requests

* fix: fixed noxfile test dependency sharing

* fix: fixed the noxfile dependencies between sync and async unit tests

* fix: cover async dependency

* fix: merge conflict issue with credentials

* fix: merge conflict #2

* fix: changed duplicated constants for sync-->async inheritance relationship

* fix: async docstring

* refactoring

* fix: refactoring

* fix: first round of comments, refactoring and test duplication changes

* fix: removed duplication in _default_async

* compute engine and metadata changes

* fix: removed oauth2 client

* added further system tests and refactored

* modified aiohttp request docstring

* refactoring and fixing comments

* refactored system tests and re-wrote nox file

* metadata typo

* fix: nox file tests added

* fix: directory path in app_engine
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