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 service account credentials #25

Merged
merged 5 commits into from
Oct 17, 2016
Merged

Conversation

theacodes
Copy link
Contributor

No description provided.

@theacodes theacodes added this to the 1.0.0 milestone Oct 14, 2016

from google.auth import _helpers
from google.auth import crypt
from google.auth import credentials

This comment was marked as spam.

This comment was marked as spam.


def __init__(self, signer, service_account_email, token_uri, scopes=None,
subject=None, additional_claims=None):
"""

This comment was marked as spam.

This comment was marked as spam.

self._service_account_email = service_account_email
self._subject = subject
self._token_uri = token_uri
self._additional_claims = additional_claims or {}

This comment was marked as spam.

This comment was marked as spam.

email = info['client_email']
key_id = info['private_key_id']
private_key = info['private_key']
token_uri = info['token_uri']

This comment was marked as spam.

This comment was marked as spam.


Args:
filename (str): The path to the service account json file.
kwargs: Additional arguments to pass to the constructor.

This comment was marked as spam.

This comment was marked as spam.

assert credentials._additional_claims['meta'] == 'data'

def test_from_service_account_bad_key(self):
info = dict(SERVICE_ACCOUNT_INFO)

This comment was marked as spam.

This comment was marked as spam.

with pytest.raises(ValueError) as excinfo:
service_account.Credentials.from_service_account_info(info)

assert excinfo.match(r'No key could be detected')

This comment was marked as spam.

This comment was marked as spam.

info = {}

with pytest.raises(KeyError):
service_account.Credentials.from_service_account_info(info)

This comment was marked as spam.

This comment was marked as spam.

def test_sign_bytes(self):
to_sign = b'123'
signature = self.credentials.sign_bytes(to_sign)
crypt.verify_signature(to_sign, signature, PUBLIC_CERT_BYTES)

This comment was marked as spam.

This comment was marked as spam.


# Check jwt grant call.
assert jwt_grant_mock.called
request, token_uri, assertion = jwt_grant_mock.call_args[0]

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@pytest.fixture(autouse=True)
def credentials(self, signer):
self.credentials = service_account.Credentials(
signer, self.SERVICE_ACCOUNT_EMAIL, self.TOKEN_URI)

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented Oct 16, 2016

LGTM after def credentials rename?

This was referenced Oct 16, 2016
@theacodes theacodes merged commit ab9eba3 into master Oct 17, 2016
@theacodes theacodes deleted the service-account-credentials branch October 17, 2016 17:50
@theacodes theacodes mentioned this pull request Oct 21, 2016
12 tasks
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