Conversation
|
|
||
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/oauth2/service_account.py
Outdated
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/oauth2/service_account.py
Outdated
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/oauth2/test_service_account.py
Outdated
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/oauth2/test_service_account.py
Outdated
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tests/oauth2/test_service_account.py
Outdated
| 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| # 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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @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.
This comment was marked as spam.
Sorry, something went wrong.
|
LGTM after |
No description provided.